Skip to content

Feature starter environments#88

Merged
aflament merged 11 commits intochain-ml:mainfrom
lausuarez02:feature-starter-environments
Feb 27, 2025
Merged

Feature starter environments#88
aflament merged 11 commits intochain-ml:mainfrom
lausuarez02:feature-starter-environments

Conversation

@lausuarez02
Copy link
Contributor

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

Copy link
Contributor

@aflament aflament left a comment

Choose a reason for hiding this comment

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

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.

Comment on lines +164 to +165
logger.warning(f"Required environment variable {env_var} not found in .env file")
return ""
Copy link
Contributor

Choose a reason for hiding this comment

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

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.

Comment on lines +313 to +326
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")
Copy link
Contributor

Choose a reason for hiding this comment

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

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]):
Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch 👍 , but unrelated to this PR.
Core team will fix it. Please revert.

elif os.getenv("ANTHROPIC_API_KEY"):
return LLMConfig(
provider="anthropic",
model_id=os.getenv("DEFAULT_ANTHROPIC_MODEL", "claude-3-sonnet-20240229")
Copy link
Contributor

Choose a reason for hiding this comment

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

We want to keep claude-3-5-sonnet-20241022 as the default model for Anthopic

Suggested change
model_id=os.getenv("DEFAULT_ANTHROPIC_MODEL", "claude-3-sonnet-20240229")
model_id=os.getenv("DEFAULT_ANTHROPIC_MODEL", "claude-3-5-sonnet-20241022")

values = self._config["trading_venues"]["jupiter"]["settings"]
return JupiterSettings(**values)

def get_llm_config(self) -> LLMConfig:
Copy link
Contributor

Choose a reason for hiding this comment

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

change the mame to get_default_llm_config

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()
Copy link
Contributor

Choose a reason for hiding this comment

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

after requested changes, this must look like: get_default_llm_config("anthropic") or get_default_llm_config("open_ai")

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()
Copy link
Contributor

Choose a reason for hiding this comment

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

after requested changes, this must look like: get_default_llm_config("anthropic") or get_default_llm_config("open_ai")

# 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()
Copy link
Contributor

Choose a reason for hiding this comment

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

after requested changes, this must look like: get_default_llm_config("anthropic") or get_default_llm_config("open_ai")

] # Add your tools here

agent = AlphaSwarmAgent(tools=tools, model_id="anthropic/claude-3-5-sonnet-20241022")
llm_config = config.get_llm_config()
Copy link
Contributor

Choose a reason for hiding this comment

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

after requested changes, this must look like: get_default_llm_config("anthropic") or get_default_llm_config("open_ai")

tools=tools, model_id="anthropic/claude-3-5-sonnet-20241022", system_prompt=system_prompt, hints=hints
)

llm_config = config.get_llm_config()
Copy link
Contributor

Choose a reason for hiding this comment

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

after requested changes, this must look like: get_default_llm_config("anthropic") or get_default_llm_config("open_ai")

@lausuarez02 lausuarez02 requested a review from aflament February 22, 2025 18:14
@aflament aflament merged commit 5adf6b2 into chain-ml:main Feb 27, 2025
1 of 2 checks passed
@aflament
Copy link
Contributor

tyvm @lausuarez02

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants