Dodaj przycisk pobierania,Umożliwia łatwe pobieranie określonych GitHub falcówka。
< Opinie na GitHub narzędzie do pobierania folderów
<?php require 'vendor/autoload.php';
use GuzzleHttp\Client; use Dotenv\Dotenv;
$dotenv = Dotenv::createImmutable(DIR); $dotenv->load();
$apiKey = $_ENV['API_KEY'] ?? null;
if (!$apiKey) { echo "Error: Missing API_KEY in .env\n"; exit(1); }
function createChatSession($externalUserId, $apiKey) { $client = new Client(); $url = 'https://api.on-demand.io/chat/v1/sessions'; $headers = [ 'apikey' => $apiKey, 'Content-Type' => 'application/json' ]; $body = [ 'agentIds' => [], 'externalUserId' => $externalUserId ];
try { $response = $client->post($url, [ 'headers' => $headers, 'json' => $body ]); $data = json_decode($response->getBody(), true); return $data['data']['id'] ?? null; } catch (Exception $e) { $message = $e->getMessage(); echo "Session creation failed: $message\n"; throw new Exception("Failed to create session: $message"); }
}
function submitQuery($sessionId, $query, $apiKey) { $client = new Client(); $url = "https://api.on-demand.io/chat/v1/sessions/{$sessionId}/query"; $headers = [ 'apikey' => $apiKey, 'Content-Type' => 'application/json' ]; $body = [ 'endpointId' => 'predefined-openai-gpt4o', 'query' => $query, 'agentIds' => 'agent-1712327325
Zaloguj się, by odpowiedzieć.
<?php require 'vendor/autoload.php';
use GuzzleHttp\Client; use Dotenv\Dotenv;
$dotenv = Dotenv::createImmutable(DIR); $dotenv->load();
$apiKey = $_ENV['API_KEY'] ?? null;
if (!$apiKey) { echo "Error: Missing API_KEY in .env\n"; exit(1); }
function createChatSession($externalUserId, $apiKey) { $client = new Client(); $url = 'https://api.on-demand.io/chat/v1/sessions'; $headers = [ 'apikey' => $apiKey, 'Content-Type' => 'application/json' ]; $body = [ 'agentIds' => [], 'externalUserId' => $externalUserId ];
}
function submitQuery($sessionId, $query, $apiKey) { $client = new Client(); $url = "https://api.on-demand.io/chat/v1/sessions/{$sessionId}/query"; $headers = [ 'apikey' => $apiKey, 'Content-Type' => 'application/json' ]; $body = [ 'endpointId' => 'predefined-openai-gpt4o', 'query' => $query, 'agentIds' => 'agent-1712327325