GitHub preuzimač mapa

Dodajte gumb za preuzimanje,Omogućuje jednostavno preuzimanje određenih GitHub mapa。

< Feedback on GitHub preuzimač mapa

Question/comment

§
Posted: 06.06.2025.

<?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

Post reply

Sign in to post a reply.