Skip to content

Commit 4180fd8

Browse files
committed
feature #577 [Platform] Remove default model names from constructor parameters (OskarStark)
This PR was squashed before being merged into the main branch. Discussion ---------- [Platform] Remove default model names from constructor parameters | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | Docs? | no | Issues | -- | License | MIT Removes default model names from all Model class constructors to prevent breaking changes when default models are changed. Model names must now be explicitly provided when instantiating model classes. Commits ------- a5c7bc0 [Platform] Remove default model names from constructor parameters
2 parents c8e0630 + a5c7bc0 commit 4180fd8

File tree

77 files changed

+133
-124
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+133
-124
lines changed

demo/src/Blog/Command/QueryCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function __invoke(SymfonyStyle $io): int
4444
$io->comment(\sprintf('Converting "%s" to vector & searching in Chroma DB ...', $search));
4545
$io->comment('Results are limited to 4 most similar documents.');
4646

47-
$platformResponse = $this->platform->invoke(new Embeddings(), $search);
47+
$platformResponse = $this->platform->invoke(new Embeddings(Embeddings::TEXT_3_SMALL), $search);
4848
$queryResponse = $collection->query(
4949
queryEmbeddings: [$platformResponse->asVectors()[0]->getData()],
5050
nResults: 4,

examples/azure/audio-transcript.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
env('AZURE_OPENAI_KEY'),
2323
http_client(),
2424
);
25-
$model = new Whisper();
25+
$model = new Whisper(Whisper::WHISPER_1);
2626
$file = Audio::fromFile(dirname(__DIR__, 2).'/fixtures/audio.mp3');
2727

2828
$result = $platform->invoke($model, $file);

examples/azure/embeddings.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
env('AZURE_OPENAI_KEY'),
2222
http_client(),
2323
);
24-
$embeddings = new Embeddings();
24+
$embeddings = new Embeddings(Embeddings::TEXT_3_SMALL);
2525

2626
$result = $platform->invoke($embeddings, <<<TEXT
2727
Once upon a time, there was a country called Japan. It was a beautiful country with a lot of mountains and rivers.

examples/cerebras/chat.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@
2222
Message::forSystem('You are a helpful assistant.'),
2323
Message::ofUser('How is the weather in Tokyo today?'),
2424
);
25-
$result = $platform->invoke(new Model(), $messages);
25+
$result = $platform->invoke(new Model(Model::LLAMA3_1_8B), $messages);
2626

2727
echo $result->getResult()->getContent().\PHP_EOL;

examples/cerebras/stream.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
Message::ofUser('What are the top three destinations in France?'),
2424
);
2525

26-
$result = $platform->invoke(new Model(), $messages, [
26+
$result = $platform->invoke(new Model(Model::LLAMA3_1_8B), $messages, [
2727
'stream' => true,
2828
]);
2929

examples/gemini/embeddings.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
require_once dirname(__DIR__).'/bootstrap.php';
1616

1717
$platform = PlatformFactory::create(env('GEMINI_API_KEY'), http_client());
18-
$embeddings = new Embeddings();
18+
$embeddings = new Embeddings(Embeddings::GEMINI_EMBEDDING_EXP_03_07);
1919

2020
$result = $platform->invoke($embeddings, <<<TEXT
2121
Once upon a time, there was a country called Japan. It was a beautiful country with a lot of mountains and rivers.

examples/memory/mariadb.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959

6060
// create embeddings for documents as preparation of the chain memory
6161
$platform = PlatformFactory::create(env('OPENAI_API_KEY'), http_client());
62-
$vectorizer = new Vectorizer($platform, $embeddings = new Embeddings());
62+
$vectorizer = new Vectorizer($platform, $embeddings = new Embeddings(Embeddings::TEXT_3_SMALL));
6363
$indexer = new Indexer(new InMemoryLoader($documents), $vectorizer, $store, logger: logger());
6464
$indexer->index($documents);
6565

examples/mistral/embeddings.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
require_once dirname(__DIR__).'/bootstrap.php';
1616

1717
$platform = PlatformFactory::create(env('MISTRAL_API_KEY'), http_client());
18-
$model = new Embeddings();
18+
$model = new Embeddings(Embeddings::MISTRAL_EMBED);
1919

2020
$result = $platform->invoke($model, <<<TEXT
2121
In the middle of the 20th century, food scientists began to understand the importance of vitamins and minerals in

examples/ollama/stream.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
require_once dirname(__DIR__).'/bootstrap.php';
1818

1919
$platform = PlatformFactory::create(env('OLLAMA_HOST_URL'), http_client());
20-
$model = new Ollama();
20+
$model = new Ollama(Ollama::LLAMA_3_2);
2121

2222
$messages = new MessageBag(
2323
Message::forSystem('You are a helpful assistant.'),

examples/ollama/structured-output-math.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
require_once dirname(__DIR__).'/bootstrap.php';
2121

2222
$platform = PlatformFactory::create(env('OLLAMA_HOST_URL'), http_client());
23-
$model = new Ollama();
23+
$model = new Ollama(Ollama::LLAMA_3_2);
2424

2525
$processor = new AgentProcessor();
2626
$agent = new Agent($platform, $model, [$processor], [$processor], logger: logger());

0 commit comments

Comments
 (0)