Simple PHP toolkit for building LLM chains.
This is not stable nor production ready, it's just a playground for me to experiment with LLMs. Abstractions, concepts and interfaces are not good at all and will definitely change.
- PHP 8.2 or higher
The recommended way to install LlmChain is through Composer:
composer require php-llm/llm-chain
Currently supported models and runtimes:
Vendor | Model | Runtime |
---|---|---|
OpenAI | - GPT - Embeddings |
- OpenAI - Azure |
Anthropic | - Claude | - Anthropic |
Planned Models & Runtimes (not implemented yet):
Vendor | Model | Runtime |
---|---|---|
Anthropic | - Voyage | - GPC - AWS |
- Gemini - Gemma |
- GPC | |
Meta | - Llama | - Meta AI - GPC - Ollama |
Mistral AI | - Mistral - Codestral |
- Mistral - GPT - Ollama |
Currently supported stores:
- Chroma DB
- Azure AI Search
- Pinecone
- Clock
- SerpApi
- Similarity Search (Basic)
- Wikipedia
- Weather
- YouTube Transcriber
See examples to run example implementations using this library. Depending on the example you need to export needed environment variables for API keys or deployment configurations:
-
Chat Example: OpenAI's GPT
export OPENAI_API_KEY=sk-... php examples/chat-gpt-openai.php
-
Chat Example: OpenAI's GPT With Azure
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
-
Chat Example: Anthropic's Claude
export ANTHROPIC_API_KEY=sk-... php examples/chat-claude-anthropic.php
-
Simple Clock Tool
export OPENAI_API_KEY=sk-... php examples/toolbox-clock.php
-
Wikipedia Tool
export OPENAI_API_KEY=sk-... php examples/toolbox-wikipedia.php
-
SerpAPI Tool
export OPENAI_API_KEY=sk-... export SERPAPI_API_KEY=... php examples/toolbox-serpapi.php
-
Weather Tool
export OPENAI_API_KEY=sk-... php examples/toolbox-weather.php
-
YouTube Transcriber Tool
export OPENAI_API_KEY=sk-... php examples/toolbox-youtube.php
- Structured Output Example: OpenAI's GPT
export OPENAI_API_KEY=sk-... php examples/structured-output-math.php