php-llm / llm-chain
一个围绕大型语言模型(LLMs)的精简PHP组件。
0.1
2024-09-22 21:07 UTC
Requires
- php: >=8.2
- phpdocumentor/reflection-docblock: ^5.4
- psr/cache: ^3.0
- psr/log: ^3.0
- symfony/http-client: ^6.4 || ^7.1
- symfony/property-access: ^6.4 || ^7.1
- symfony/property-info: ^6.4 || ^7.1
- symfony/serializer: ^6.4 || ^7.1
- symfony/type-info: ^6.4 || ^7.1
- symfony/uid: ^6.4 || ^7.1
Requires (Dev)
- codewithkyrian/chromadb-php: ^0.2.1
- php-cs-fixer/shim: ^3.64
- phpstan/phpstan: ^1.12
- phpunit/phpunit: ^11.3
- probots-io/pinecone-php: ^1.0
- rector/rector: ^1.2
- symfony/clock: ^6.4 || ^7.1
- symfony/console: ^6.4 || ^7.1
- symfony/css-selector: ^6.4 || ^7.1
- symfony/dom-crawler: ^6.4 || ^7.1
- symfony/var-dumper: ^6.4 || ^7.1
Suggests
- codewithkyrian/chromadb-php: For using the ChromaDB as retrieval vector store.
- probots-io/pinecone-php: For using the Pinecone as retrieval vector store.
- symfony/clock: For using the clock tool.
- symfony/css-selector: For using the YouTube transcription tool.
- symfony/dom-crawler: For using the YouTube transcription tool.
This package is auto-updated.
Last update: 2024-09-23 22:54:41 UTC
README
构建LLM链的简单PHP工具包。
这还不是稳定或生产就绪的,它只是我用来实验LLMs的游乐场。抽象、概念和接口都不太好,肯定会改变。
要求
- PHP 8.2或更高版本
安装
安装LlmChain的推荐方法是使用Composer
composer require php-llm/llm-chain
支持模型和运行时
当前支持的模型和运行时
计划中的模型和运行时(尚未实现)
支持存储
当前支持的存储
- Chroma DB
- Azure AI Search
- Pinecone
提供的工具
- 时钟
- SerpApi
- 相似度搜索(基本)
- 维基百科
- 天气
- YouTube转录器
使用示例
查看示例以运行使用此库的示例实现。根据需要,您可能需要导出所需的API密钥或部署配置的环境变量
聊天示例
-
聊天示例:OpenAI的GPT
export OPENAI_API_KEY=sk-... php examples/chat-gpt-openai.php
-
聊天示例:带有Azure的OpenAI的GPT
export AZURE_OPENAI_BASEURL=... // e.g. your-resource.openai.azure.com export AZURE_OPENAI_DEPLOYMENT=... export AZURE_OPENAI_VERSION=... // e.g. 2023-03-15-preview export AZURE_OPENAI_KEY=... php examples/chat-gpt-azure.php
-
聊天示例:Anthropic的Claude
export ANTHROPIC_API_KEY=sk-... php examples/chat-claude-anthropic.php
工具链示例
-
简单的时钟工具
export OPENAI_API_KEY=sk-... php examples/toolbox-clock.php
-
维基百科工具
export OPENAI_API_KEY=sk-... php examples/toolbox-wikipedia.php
-
SerpAPI工具
export OPENAI_API_KEY=sk-... export SERPAPI_API_KEY=... php examples/toolbox-serpapi.php
-
天气工具
export OPENAI_API_KEY=sk-... php examples/toolbox-weather.php
-
YouTube转录器工具
export OPENAI_API_KEY=sk-... php examples/toolbox-youtube.php
结构化输出
- 结构化输出示例:OpenAI的GPT
export OPENAI_API_KEY=sk-... php examples/structured-output-math.php