ADDED: multi-LLM support via LLMFactory (fully backward compatible) and OptoPrimeMulti multi_llm option#7
Merged
chinganc merged 4 commits intoAgentOpt:experimentalfrom Jun 24, 2025
Conversation
…nd implementation demonstration in OptoPrimeMulti and associated test
Member
|
Can you change this PR to merge into |
Member
|
What is the expected way to call |
Contributor
Author
Correct Usage# Register new profiles
LLMFactory.register_profile("custom_openai", "LiteLLM", model="gpt-4o", temperature=0.7, max_tokens=2000)
LLMFactory.register_profile("custom_claude", "LiteLLM", model="claude-3-5-sonnet-latest", temperature=0.3)
LLMFactory.register_profile("local_llama", "CustomLLM", model="llama-3.1-70b")
# Use the registered profiles
llm_1 = LLM(profile="custom_openai")
llm_2 = LLM(profile="custom_claude")
llm_3 = LLM(profile="local_llama")Pre-defined Profiles AvailableThe code comes with these built-in profiles: llm_default = LLM(profile="default") # gpt-4o-mini
llm_premium = LLM(profile="premium") # gpt-4
llm_cheap = LLM(profile="cheap") # gpt-4o-mini
llm_fast = LLM(profile="fast") # gpt-3.5-turbo-mini
llm_reasoning = LLM(profile="reasoning") # o1-miniYou can override those built-in profiles: LLMFactory.register_profile("default", "LiteLLM", model="gpt-4o", temperature=0.5)
LLMFactory.register_profile("premium", "LiteLLM", model="o1-preview", max_tokens=8000)
LLMFactory.register_profile("cheap", "LiteLLM", model="gpt-3.5-turbo", temperature=0.9)
LLMFactory.register_profile("fast", "LiteLLM", model="gpt-3.5-turbo", max_tokens=500)
LLMFactory.register_profile("reasoning", "LiteLLM", model="o1-preview")Examples with Different Backends# Register custom profiles for different use cases
LLMFactory.register_profile("advanced_reasoning", "LiteLLM", model="o1-preview", max_tokens=4000)
LLMFactory.register_profile("claude_sonnet", "LiteLLM", model="claude-3-5-sonnet-latest", temperature=0.3)
LLMFactory.register_profile("custom_server", "CustomLLM", model="llama-3.1-8b")
# Use in different contexts
reasoning_llm = LLM(profile="advanced_reasoning") # For complex reasoning
claude_llm = LLM(profile="claude_sonnet") # For Claude responses
local_llm = LLM(profile="custom_server") # For local deployment
# Single LLM optimizer with custom profile
optimizer1 = OptoPrime(parameters, llm=LLM(profile="advanced_reasoning"))
# Multi-LLM optimizer with multiple profiles
optimizer2 = OptoPrimeMulti(parameters, llm_profiles=["cheap", "premium", "claude_sonnet"], generation_technique="multi_llm") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ADDED: multi-LLM support via LLMFactory (fully backward compatible) and implementation demonstration in OptoPrimeMulti and associated test