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

Commit 072fa56

Browse files
authored
fix: Allow array arguments in model.options (#103)
Allow array arguments in `model.options`
1 parent dbc374e commit 072fa56

File tree

2 files changed

+144
-2
lines changed

2 files changed

+144
-2
lines changed

src/DependencyInjection/Configuration.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public function getConfigTreeBuilder(): TreeBuilder
7474
->scalarNode('name')->isRequired()->end()
7575
->scalarNode('version')->defaultNull()->end()
7676
->arrayNode('options')
77-
->scalarPrototype()->end()
77+
->variablePrototype()->end()
7878
->end()
7979
->end()
8080
->end()
@@ -200,7 +200,7 @@ public function getConfigTreeBuilder(): TreeBuilder
200200
->scalarNode('name')->isRequired()->end()
201201
->scalarNode('version')->defaultNull()->end()
202202
->arrayNode('options')
203-
->scalarPrototype()->end()
203+
->variablePrototype()->end()
204204
->end()
205205
->end()
206206
->end()
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
<?php
2+
3+
namespace PhpLlm\LlmChainBundle\Tests\DependencyInjection;
4+
5+
use PhpLlm\LlmChainBundle\DependencyInjection\Configuration;
6+
use PhpLlm\LlmChainBundle\DependencyInjection\LlmChainExtension;
7+
use PHPUnit\Framework\Attributes\CoversClass;
8+
use PHPUnit\Framework\Attributes\DoesNotPerformAssertions;
9+
use PHPUnit\Framework\Attributes\UsesClass;
10+
use PHPUnit\Framework\TestCase;
11+
use Symfony\Component\DependencyInjection\ContainerBuilder;
12+
13+
#[CoversClass(Configuration::class)]
14+
#[UsesClass(ContainerBuilder::class)]
15+
#[UsesClass(LlmChainExtension::class)]
16+
class ConfigurationTest extends TestCase
17+
{
18+
#[DoesNotPerformAssertions]
19+
public function testExtensionLoad(): void
20+
{
21+
$container = new ContainerBuilder();
22+
$container->setParameter('kernel.debug', true);
23+
$extension = new LlmChainExtension();
24+
25+
$configs = $this->getFullConfig();
26+
$extension->load($configs, $container);
27+
}
28+
29+
/**
30+
* @return array<string, mixed>
31+
*/
32+
private function getFullConfig(): array
33+
{
34+
return [
35+
'llm_chain' => [
36+
'platform' => [
37+
'anthropic' => [
38+
'api_key' => 'anthropic_key_full',
39+
],
40+
'azure' => [
41+
'my_azure_instance' => [
42+
'api_key' => 'azure_key_full',
43+
'base_url' => 'https://myazure.openai.azure.com/',
44+
'deployment' => 'gpt-35-turbo',
45+
'api_version' => '2024-02-15-preview',
46+
],
47+
'another_azure_instance' => [
48+
'api_key' => 'azure_key_2',
49+
'base_url' => 'https://myazure2.openai.azure.com/',
50+
'deployment' => 'gpt-4',
51+
'api_version' => '2024-02-15-preview',
52+
],
53+
],
54+
'google' => [
55+
'api_key' => 'google_key_full',
56+
],
57+
'openai' => [
58+
'api_key' => 'openai_key_full',
59+
],
60+
'mistral' => [
61+
'api_key' => 'mistral_key_full',
62+
],
63+
'openrouter' => [
64+
'api_key' => 'openrouter_key_full',
65+
],
66+
],
67+
'chain' => [
68+
'my_chat_chain' => [
69+
'platform' => 'openai_platform_service_id',
70+
'model' => [
71+
'name' => 'gpt',
72+
'version' => 'gpt-3.5-turbo',
73+
'options' => [
74+
'temperature' => 0.7,
75+
'max_tokens' => 150,
76+
'nested' => ['options' => ['work' => 'too']],
77+
],
78+
],
79+
'structured_output' => false,
80+
'system_prompt' => 'You are a helpful assistant.',
81+
'include_tools' => true,
82+
'tools' => [
83+
'enabled' => true,
84+
'services' => [
85+
['service' => 'my_tool_service_id', 'name' => 'myTool', 'description' => 'A test tool'],
86+
'another_tool_service_id', // String format
87+
],
88+
],
89+
'fault_tolerant_toolbox' => false,
90+
],
91+
'another_chain' => [
92+
'model' => ['name' => 'claude', 'version' => 'claude-3-opus-20240229'],
93+
'system_prompt' => 'Be concise.',
94+
],
95+
],
96+
'store' => [
97+
'azure_search' => [
98+
'my_azure_search_store' => [
99+
'endpoint' => 'https://mysearch.search.windows.net',
100+
'api_key' => 'azure_search_key',
101+
'index_name' => 'my-documents',
102+
'api_version' => '2023-11-01',
103+
'vector_field' => 'contentVector',
104+
],
105+
],
106+
'chroma_db' => [
107+
'my_chroma_store' => [
108+
'collection' => 'my_collection',
109+
],
110+
],
111+
'mongodb' => [
112+
'my_mongo_store' => [
113+
'database' => 'my_db',
114+
'collection' => 'my_collection',
115+
'index_name' => 'vector_index',
116+
'vector_field' => 'embedding',
117+
'bulk_write' => true,
118+
],
119+
],
120+
'pinecone' => [
121+
'my_pinecone_store' => [
122+
'namespace' => 'my_namespace',
123+
'filter' => ['category' => 'books'],
124+
'top_k' => 10,
125+
],
126+
],
127+
],
128+
'indexer' => [
129+
'my_text_indexer' => [
130+
'store' => 'my_azure_search_store_service_id',
131+
'platform' => 'google_platform_service_id',
132+
'model' => [
133+
'name' => 'embeddings',
134+
'version' => 'text-embedding-004',
135+
'options' => ['dimension' => 768],
136+
],
137+
],
138+
],
139+
],
140+
];
141+
}
142+
}

0 commit comments

Comments
 (0)