8000 GitHub - OskarStark/llm-chain: A slim PHP component with tooling around LLMs.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

A slim PHP component with tooling around LLMs.

License

Notifications You must be signed in to change notification settings

OskarStark/llm-chain

 
 

Repository files navigation

LLM Chain

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.

Requirements

  • PHP 8.2 or higher

Installation

The recommended way to install LlmChain is through Composer:

composer require php-llm/llm-chain

Supported Models & Runtimes

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
Google - Gemini
- Gemma
- GPC
Meta - Llama - Meta AI
- GPC
- Ollama
Mistral AI - Mistral
- Codestral
- Mistral
- GPT
- Ollama

Supported Stores

Currently supported stores:

  • Chroma DB
  • Azure AI Search
  • Pinecone

Provided Tools

  • Clock
  • SerpApi
  • Similarity Search (Basic)
  • Wikipedia
  • Weather
  • YouTube Transcriber

Usage Examples

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 Examples

  1. Chat Example: OpenAI's GPT

    export OPENAI_API_KEY=sk-...
    php examples/chat-gpt-openai.php
  2. 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
  3. Chat Example: Anthropic's Claude

    export ANTHROPIC_API_KEY=sk-...
    php examples/chat-claude-anthropic.php

ToolChain Examples

  1. Simple Clock Tool

    export OPENAI_API_KEY=sk-...
    php examples/toolbox-clock.php
  2. Wikipedia Tool

    export OPENAI_API_KEY=sk-...
    php examples/toolbox-wikipedia.php
  3. SerpAPI Tool

    export OPENAI_API_KEY=sk-...
    export SERPAPI_API_KEY=...
    php examples/toolbox-serpapi.php
  4. Weather Tool

    export OPENAI_API_KEY=sk-...
    php examples/toolbox-weather.php
  5. YouTube Transcriber Tool

    export OPENAI_API_KEY=sk-...
    php examples/toolbox-youtube.php

Structured Output

  1. Structured Output Example: OpenAI's GPT
    export OPENAI_API_KEY=sk-...
    php examples/structured-output-math.php

About

A slim PHP component with tooling around LLMs.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 99.6%
  • Makefile 0.4%
0