from langroid.language_models.openai_gpt import OpenAIGPTConfig
from langroid.agent.chat_agent import ChatAgent, ChatAgentConfig
TRUEFOUNDRY_PAT = "your-truefoundry-api-key" # Your TrueFoundry Personal Access Token
TRUEFOUNDRY_BASE_URL = "your-truefoundry-base-url" # Your TrueFoundry unified endpoint
# Configure different agents with different models through TrueFoundry
researcher_config = OpenAIGPTConfig(
chat_model="anthropic-main/claude-3-5-sonnet-20241022",
api_key=TRUEFOUNDRY_PAT,
api_base=TRUEFOUNDRY_BASE_URL
)
writer_config = OpenAIGPTConfig(
chat_model="openai-main/gpt-4o",
api_key=TRUEFOUNDRY_PAT,
api_base=TRUEFOUNDRY_BASE_URL
)
# Create specialized agents
researcher = ChatAgent(ChatAgentConfig(llm=researcher_config))
writer = ChatAgent(ChatAgentConfig(llm=writer_config))
# Agents collaborate on a task
research_data = researcher.llm_response("Research the latest trends in AI for 2024")
final_report = writer.llm_response(f"Write a comprehensive summary based on: {research_data.content}")
print("Research:", research_data.content)
print("\nFinal Report:", final_report.content)