Skip to content
This repository was archived by the owner on Jul 16, 2025. It is now read-only.

Commit 7ccefbe

Browse files
committed
feat: adopt after release 0.8 & 0.9
1 parent 1a3d710 commit 7ccefbe

20 files changed

+576
-358
lines changed

README.md

Lines changed: 26 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -13,51 +13,39 @@ composer require php-llm/llm-chain-bundle
1313
```yaml
1414
# config/packages/llm_chain.yaml
1515
llm_chain:
16-
platforms:
17-
azure_gpt:
18-
type: 'azure'
16+
platform:
17+
openai:
18+
api_key: '%env(OPENAI_API_KEY)%'
19+
azure:
1920
base_url: '%env(AZURE_OPENAI_BASEURL)%'
2021
deployment: '%env(AZURE_OPENAI_GPT)%'
2122
api_key: '%env(AZURE_OPENAI_KEY)%'
2223
version: '%env(AZURE_OPENAI_VERSION)%'
23-
azure_embeddings:
24-
type: 'azure'
25-
base_url: '%env(AZURE_OPENAI_BASEURL)%'
26-
deployment: '%env(AZURE_OPENAI_EMBEDDINGS)%'
27-
api_key: '%env(AZURE_OPENAI_KEY)%'
28-
version: '%env(AZURE_OPENAI_VERSION)%'
29-
openai:
30-
type: 'openai'
31-
api_key: '%env(OPENAI_API_KEY)%'
32-
llms:
33-
azure_gpt:
34-
platform: 'azure_gpt'
35-
original_gpt:
36-
platform: 'openai'
37-
embeddings:
38-
azure_embeddings:
39-
platform: 'azure_embeddings'
40-
original_embeddings:
41-
platform: 'openai'
42-
stores:
24+
anthropic:
25+
api_key: '%env(ANTHROPIC_API_KEY)%'
26+
chain:
27+
default:
28+
model:
29+
name: 'gpt'
30+
version: 'gpt-3.5-turbo'
31+
options: []
32+
tools:
33+
- 'PhpLlm\LlmChain\Chain\ToolBox\Tool\SimilaritySearch'
34+
store:
4335
azure_search:
44-
engine: 'azure-search'
4536
api_key: '%env(AZURE_SEARCH_KEY)%'
4637
endpoint: '%env(AZURE_SEARCH_ENDPOINT)%'
4738
index_name: '%env(AZURE_SEARCH_INDEX)%'
4839
api_version: '2024-07-01'
4940
chroma_db:
50-
engine: 'chroma-db'
5141
collection_name: '%env(CHROMA_COLLECTION)%'
5242
mongodb:
53-
engine: 'mongodb'
5443
database_name: '%env(MONGODB_DATABASE)%'
5544
collection_name: '%env(MONGODB_COLLECTION)%'
5645
index_name: '%env(MONGODB_INDEX)%'
5746
vector_field_name: 'vector'
5847
bulk_write: false
5948
pinecone:
60-
engine: 'pinecone'
6149
namespace: 'partition'
6250
filter: { 'key' : 'value' }
6351
top_k: 5
@@ -69,12 +57,14 @@ llm_chain:
6957
7058
Use the `Chain` service to leverage GPT:
7159
```php
72-
use PhpLlm\LlmChain\Chat;
60+
use PhpLlm\LlmChain\ChainInterface;
61+
use PhpLlm\LlmChain\Model\Message\Message;
62+
use PhpLlm\LlmChain\Model\Message\MessageBag;
7363
7464
final readonly class MyService
7565
{
7666
public function __construct(
77-
private Chain $chain,
67+
private ChainInterface $chain,
7868
) {
7969
}
8070
@@ -99,18 +89,18 @@ services:
9989
autowire: true
10090
autoconfigure: true
10191
102-
PhpLlm\LlmChain\ToolBox\Tool\Clock: ~
103-
PhpLlm\LlmChain\ToolBox\Tool\OpenMeteo: ~
104-
PhpLlm\LlmChain\ToolBox\Tool\SerpApi:
92+
PhpLlm\LlmChain\Chain\ToolBox\Tool\Clock: ~
93+
PhpLlm\LlmChain\Chain\ToolBox\Tool\OpenMeteo: ~
94+
PhpLlm\LlmChain\Chain\ToolBox\Tool\SerpApi:
10595
$apiKey: '%env(SERP_API_KEY)%'
106-
PhpLlm\LlmChain\ToolBox\Tool\SimilaritySearch: ~
107-
PhpLlm\LlmChain\ToolBox\Tool\Wikipedia: ~
108-
PhpLlm\LlmChain\ToolBox\Tool\YouTubeTranscriber: ~
96+
PhpLlm\LlmChain\Chain\ToolBox\Tool\SimilaritySearch: ~
97+
PhpLlm\LlmChain\Chain\ToolBox\Tool\Wikipedia: ~
98+
PhpLlm\LlmChain\Chain\ToolBox\Tool\YouTubeTranscriber: ~
10999
```
110100

111101
Custom tools can be registered by using the `#[AsTool]` attribute:
112102
```php
113-
use PhpLlm\LlmChain\ToolBox\AsTool;
103+
use PhpLlm\LlmChain\Chain\ToolBox\Attribute\AsTool;
114104
115105
#[AsTool('company_name', 'Provides the name of your company')]
116106
final class CompanyName

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
],
1212
"require": {
1313
"php": ">=8.2",
14-
"php-llm/llm-chain": "0.7.*",
14+
"php-llm/llm-chain": "^0.8.1",
1515
"symfony/config": "^6.4 || ^7.0",
1616
"symfony/dependency-injection": "^6.4 || ^7.0",
1717
"symfony/framework-bundle": "^6.4 || ^7.0"

profiler.png

-23.8 KB
Loading

src/DependencyInjection/Configuration.php

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,38 +16,59 @@ public function getConfigTreeBuilder(): TreeBuilder
1616

1717
$rootNode
1818
->children()
19-
->arrayNode('platforms')
20-
->normalizeKeys(false)
21-
->useAttributeAsKey('name')
22-
->arrayPrototype()
23-
->children()
24-
->enumNode('type')->values(['openai', 'azure'])->isRequired()->end()
25-
->scalarNode('api_key')->isRequired()->end()
26-
->scalarNode('base_url')->end()
27-
->scalarNode('deployment')->end()
28-
->scalarNode('version')->info('The used API version')->end()
19+
->arrayNode('platform')
20+
->children()
21+
->arrayNode('openai')
22+
->children()
23+
->scalarNode('api_key')->isRequired()->end()
24+
->end()
25+
->end()
26+
->arrayNode('azure')
27+
->children()
28+
->scalarNode('api_key')->isRequired()->end()
29+
->scalarNode('base_url')->isRequired()->end()
30+
->scalarNode('deployment')->isRequired()->end()
31+
->scalarNode('version')->info('The used API version')->end()
32+
->end()
2933
->end()
3034
->end()
3135
->end()
32-
->arrayNode('llms')
36+
->arrayNode('chain')
3337
->normalizeKeys(false)
3438
->useAttributeAsKey('name')
3539
->arrayPrototype()
3640
->children()
37-
->scalarNode('platform')->end()
41+
->arrayNode('model')
42+
->children()
43+
->scalarNode('name')->isRequired()->end()
44+
->scalarNode('version')->defaultNull()->end()
45+
->arrayNode('options')
46+
->scalarPrototype()->end()
47+
->end()
48+
->end()
49+
->end()
50+
->arrayNode('tools')
51+
->scalarPrototype()->end()
52+
->end()
3853
->end()
3954
->end()
4055
->end()
41-
->arrayNode('embeddings')
56+
->arrayNode('embedder')
4257
->normalizeKeys(false)
4358
->useAttributeAsKey('name')
4459
->arrayPrototype()
4560
->children()
46-
->scalarNode('platform')->end()
61+
->arrayNode('model')
62+
->children()
63+
->scalarNode('name')->isRequired()->end()
64+
->scalarNode('version')->defaultNull()->end()
65+
->arrayNode('options')->end()
66+
->end()
67+
->end()
4768
->end()
4869
->end()
4970
->end()
50-
->arrayNode('stores')
71+
->arrayNode('store')
5172
->normalizeKeys(false)
5273
->useAttributeAsKey('name')
5374
->arrayPrototype()
@@ -71,6 +92,7 @@ public function getConfigTreeBuilder(): TreeBuilder
7192
->scalarNode('top_k')->end()
7293
->end()
7394
->end()
95+
->end()
7496
->end()
7597
;
7698

0 commit comments

Comments
 (0)