定制 reliant/reliant-php 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

reliant/reliant-php

最新稳定版本:v1.0.0

Composer 安装命令:

composer require reliant/reliant-php

包简介

Official PHP SDK for Reliant — LLM Reliability Layer

README 文档

README

SDK oficial PHP para o Reliant — LLM Reliability Layer.

Instalação

composer require reliant/reliant-php

Início rápido

<?php

require 'vendor/autoload.php';

use Reliant\Reliant;

$client = new Reliant([
    'api_key'  => 'rel_...',   // Dashboard → Configurações
    'user_id'  => 'seu-user-id', // Dashboard → Configurações
    'base_url' => 'https://reliant-production.up.railway.app',
]);

// Executar com validação garantida
$result = $client->execute([
    'prompt'    => 'Extraia os dados: João Silva, joao@email.com',
    'schema_id' => 'id-do-seu-schema',
    'provider'  => 'anthropic',
    'model'     => 'claude-sonnet-4-20250514',
]);

echo $result['output']['name'];  // João Silva
echo $result['output']['email']; // joao@email.com
echo $result['metadata']['attempts']; // 1

Métodos disponíveis

execute(array $params): array

$result = $client->execute([
    'prompt'    => 'seu prompt',
    'schema_id' => 'sch_...',
    'provider'  => 'anthropic', // anthropic | openai | gemini | groq | mistral
    'model'     => 'claude-sonnet-4-20250514',
    'options'   => ['max_retries' => 3],
]);

// $result['success']  → bool
// $result['output']   → array com o output validado
// $result['status']   → 'success' | 'fallback' | 'failed'
// $result['metadata'] → execution_id, attempts, latency_ms, tokens_used

listSchemas(): array

$schemas = $client->listSchemas();
foreach ($schemas['schemas'] as $schema) {
    echo $schema['name'] . '' . $schema['id'];
}

createSchema(array $params): array

$schema = $client->createSchema([
    'name'       => 'Extração de Contato',
    'slug'       => 'contact-extraction',
    'definition' => [
        'type'       => 'object',
        'required'   => ['name', 'email'],
        'properties' => [
            'name'  => ['type' => 'string'],
            'email' => ['type' => 'string'],
        ],
    ],
    'safe_fallback' => ['name' => null, 'email' => null],
]);

listExecutions(array $filters = []): array

$executions = $client->listExecutions([
    'limit'  => 20,
    'status' => 'failed',
]);

getMetrics(int $days = 30): array

$metrics = $client->getMetrics(30);
echo $metrics['success_rate']; // 98.5
echo $metrics['total_executions']; // 1420
echo $metrics['estimated_cost_usd']; // 0.0842

getMetricsBySchema(): array / getMetricsByProvider(): array

$bySchema   = $client->getMetricsBySchema(30);
$byProvider = $client->getMetricsByProvider(30);

Tratamento de erros

use Reliant\ReliantException;

try {
    $result = $client->execute([...]);
} catch (ReliantException $e) {
    echo 'Erro ' . $e->getCode() . ': ' . $e->getMessage();
}

Requisitos

  • PHP >= 7.4
  • Extensões: curl, json

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 8
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-05-08

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固