PHP code example of takaaki-mizuno / llm-json-adapter
1. Go to this page and download the library: Download takaaki-mizuno/llm-json-adapter library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
takaaki-mizuno / llm-json-adapter example snippets
$instance = new LLMJsonAdapter(
providerName: "openai",
attributes: [
"api_key" => "[API-KEY]",
"model" => "gpt-3.5-turbo",
],
maximumRetryCount: 3,
model: "gpt-3.5-turbo",
defaultLanguage: "en"
);
$response = new \TakaakiMizuno\LLMJsonAdapter\Models\Response(
name: "response data name",
description: "response data description",
schema: [JSON SCHEMA]
);
$instance = new LLMJsonAdapter(
providerName: "google",
attributes: [
"api_key" => "[API-KEY]",
"model" => "gemini-1.5-pro-latest",
],
maximumRetryCount: 3,
defaultLanguage: "en"
);
$response = new \TakaakiMizuno\LLMJsonAdapter\Models\Response(
name: "response data name",
description: "response data description",
schema: [JSON SCHEMA]
);
$instance = new LLMJsonAdapter(
providerName: "bedrock",
attributes: [
'accessKeyId' => '[ACCESS-KEY]',
'secretAccessKey' => '[SECRET-KEY]',
'model' => 'anthropic.claude-3-haiku-20240307-v1:0',
],
maximumRetryCount: 3,
defaultLanguage: "en"
);
$response = new \TakaakiMizuno\LLMJsonAdapter\Models\Response(
name: "response data name",
description: "response data description",
schema: [JSON SCHEMA]
);
$instance = new LLMJsonAdapter(
providerName: "ollama",
attributes: [
'url' => "http://localhost:11434",
'model' => 'llama3',
],
maximumRetryCount: 3,
defaultLanguage: "en"
);
$response = new \TakaakiMizuno\LLMJsonAdapter\Models\Response(
name: "response data name",
description: "response data description",
schema: [JSON SCHEMA]
);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.