Conversation
aflament
left a comment
There was a problem hiding this comment.
Thank you very much for your contribution to AlphaSwarm.
Adding the ability to configure default models is much better than the hard coded ones.
Please address comments and we will be glad to merge your PR.
alphaswarm/config.py
Outdated
| logger.warning(f"Required environment variable {env_var} not found in .env file") | ||
| return "" |
There was a problem hiding this comment.
To be reverted, the config part will be drastically revisited later.
We are aware that the current behavior is not so friendly, forcing users to define all environment variables.
alphaswarm/config.py
Outdated
| def get_llm_config(self) -> LLMConfig: | ||
| """Determine LLM provider and model based on available API keys""" | ||
| if os.getenv("OPENAI_API_KEY"): | ||
| return LLMConfig( | ||
| provider="openai", | ||
| model_id=os.getenv("DEFAULT_OPENAI_MODEL", "gpt-4o-mini") | ||
| ) | ||
| elif os.getenv("ANTHROPIC_API_KEY"): | ||
| return LLMConfig( | ||
| provider="anthropic", | ||
| model_id=os.getenv("DEFAULT_ANTHROPIC_MODEL", "claude-3-sonnet-20240229") | ||
| ) | ||
| else: | ||
| raise ValueError("No LLM API keys found in environment variables") |
There was a problem hiding this comment.
This implementation is prioritizing OpenAI over Anthropic when both are configured.
We do not want this behavior.
To move forward, either:
- let's return a valid list of
Dict[provider, LLMConfig] - or (better for now) change signature to
get_default_llm_config(self, provider)and raise a ValueError if API key not configured for the required provider.
|
|
||
|
|
||
| class QuoteResult(Generic[TQuote], BaseModel): | ||
| class QuoteResult(BaseModel, Generic[TQuote]): |
There was a problem hiding this comment.
Good catch 👍 , but unrelated to this PR.
Core team will fix it. Please revert.
alphaswarm/config.py
Outdated
| elif os.getenv("ANTHROPIC_API_KEY"): | ||
| return LLMConfig( | ||
| provider="anthropic", | ||
| model_id=os.getenv("DEFAULT_ANTHROPIC_MODEL", "claude-3-sonnet-20240229") |
There was a problem hiding this comment.
We want to keep claude-3-5-sonnet-20241022 as the default model for Anthopic
| model_id=os.getenv("DEFAULT_ANTHROPIC_MODEL", "claude-3-sonnet-20240229") | |
| model_id=os.getenv("DEFAULT_ANTHROPIC_MODEL", "claude-3-5-sonnet-20241022") |
alphaswarm/config.py
Outdated
| values = self._config["trading_venues"]["jupiter"]["settings"] | ||
| return JupiterSettings(**values) | ||
|
|
||
| def get_llm_config(self) -> LLMConfig: |
There was a problem hiding this comment.
change the mame to get_default_llm_config
examples/basic/02_swap.py
Outdated
| hints = "Here are token addresses: \n" + yaml.dump(token_addresses) # So agent knows addresses to query | ||
| agent = AlphaSwarmAgent(tools=tools, model_id="anthropic/claude-3-5-sonnet-20241022", hints=hints) | ||
|
|
||
| llm_config = config.get_llm_config() |
There was a problem hiding this comment.
after requested changes, this must look like: get_default_llm_config("anthropic") or get_default_llm_config("open_ai")
examples/basic/03_strategy.py
Outdated
| hints = "Here are token addresses: \n" + yaml.dump(token_addresses) # So agent knows addresses to query | ||
| agent = AlphaSwarmAgent(tools=tools, model_id="anthropic/claude-3-5-sonnet-20241022", hints=hints) | ||
|
|
||
| llm_config = config.get_llm_config() |
There was a problem hiding this comment.
after requested changes, this must look like: get_default_llm_config("anthropic") or get_default_llm_config("open_ai")
examples/interaction/cron.py
Outdated
| # Initialize the AlphaSwarm agent with the price tools | ||
| agent = AlphaSwarmAgent(tools=tools, model_id="anthropic/claude-3-5-sonnet-20241022") | ||
|
|
||
| llm_config = config.get_llm_config() |
There was a problem hiding this comment.
after requested changes, this must look like: get_default_llm_config("anthropic") or get_default_llm_config("open_ai")
examples/interaction/telegram_bot.py
Outdated
| ] # Add your tools here | ||
|
|
||
| agent = AlphaSwarmAgent(tools=tools, model_id="anthropic/claude-3-5-sonnet-20241022") | ||
| llm_config = config.get_llm_config() |
There was a problem hiding this comment.
after requested changes, this must look like: get_default_llm_config("anthropic") or get_default_llm_config("open_ai")
examples/interaction/terminal.py
Outdated
| tools=tools, model_id="anthropic/claude-3-5-sonnet-20241022", system_prompt=system_prompt, hints=hints | ||
| ) | ||
|
|
||
| llm_config = config.get_llm_config() |
There was a problem hiding this comment.
after requested changes, this must look like: get_default_llm_config("anthropic") or get_default_llm_config("open_ai")
|
tyvm @lausuarez02 |
Improve the starter environment
Add two new variables
DEFAULT_OPENAI_MODEL=gpt-4o-mini
DEFAULT_ANTHROPIC_MODEL=claude-3-sonnet-20240229
Add at the config a new function to get those new variables
Update examples
Update the error handler to avoid Raise an error when unused missed variable