Skip to content

Conversation

@Guikingone
Copy link
Contributor

@Guikingone Guikingone commented Dec 12, 2025

Q A
Bug fix? no
New feature? yes
Docs? yes
Issues Discussed with @TimoBakx on Slack
License MIT

This platform was a POC that I launched a few weeks ago locally (mostly for Ollama and OpenAI as a backup in a context of another POC -more on the other one if I find time to finish the tests-), not totally convinced by the current implementation but debates can lead to improvements so here it is 😅

PS: No configuration for now as the options.php must be improved on my side to handle the platforms.

@Guikingone Guikingone changed the title [Platform] Add Failover platform [Platform] Add FailoverPlatform Dec 12, 2025
@Guikingone Guikingone force-pushed the platform/fallback branch 5 times, most recently from 03b2077 to 2216da4 Compare December 15, 2025 18:48
@Guikingone Guikingone marked this pull request as ready for review December 15, 2025 18:50
@carsonbot carsonbot added Feature New feature Platform Issues & PRs about the AI Platform component Status: Needs Review labels Dec 15, 2025
@Guikingone
Copy link
Contributor Author

Well, that's a weird one, no changes on my side and the class is not found by the bundle, what the funk is this behavior? 🤔

@OskarStark
Copy link
Contributor

Please rebase

Comment on lines +22 to +33
$ollamaPlatform = OllamaPlatformFactory::create(env('OLLAMA_HOST_URL'), http_client());
$openAiPlatform = OpenAiPlatformFactory::create(env('OPENAI_API_KEY'), http_client());

$platform = new FailoverPlatform([
$ollamaPlatform, // # Ollama will fail as 'gpt-4o' is not available in the catalog
$openAiPlatform,
], new RateLimiterFactory([
'policy' => 'sliding_window',
'id' => 'failover',
'interval' => '3 seconds',
'limit' => 1,
], new InMemoryStorage()));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$ollamaPlatform = OllamaPlatformFactory::create(env('OLLAMA_HOST_URL'), http_client());
$openAiPlatform = OpenAiPlatformFactory::create(env('OPENAI_API_KEY'), http_client());
$platform = new FailoverPlatform([
$ollamaPlatform, // # Ollama will fail as 'gpt-4o' is not available in the catalog
$openAiPlatform,
], new RateLimiterFactory([
'policy' => 'sliding_window',
'id' => 'failover',
'interval' => '3 seconds',
'limit' => 1,
], new InMemoryStorage()));
$rateLimiter = new RateLimiterFactory([
'policy' => 'sliding_window',
'id' => 'failover',
'interval' => '3 seconds',
'limit' => 1,
], new InMemoryStorage()));
// Ollama will fail as 'gpt-4o' is not available in the catalog
$platform = new FailoverPlatform([
OllamaPlatformFactory::create(env('OLLAMA_HOST_URL', http_client()),
OpenAiPlatformFactory::create(env('OPENAI_API_KEY'), http_client()),
], $rateLimiter);

Message::ofUser('Tina has one brother and one sister. How many sisters do Tina\'s siblings have?'),
));

echo $result->asText().\PHP_EOL;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how can we "assert"/be sure that openAi platform was used in the end?

@OskarStark
Copy link
Contributor

Please rebase

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature New feature Platform Issues & PRs about the AI Platform component Status: Needs Review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants