afourney af5dcc7fdf
Significant updates to agbench. (#5313)
- Updated HumanEval template to use AgentChat
- Update templates to use config.yaml for model and other configuration
- Read environment from ENV.yaml (ENV.json still supported but
deprecated)
- Temporarily removed WebArena and AssistantBench. Neither had viable
Templates after `autogen_magentic_one` was removed. Templates need to be
update to AgentChat (in a future PR, but this PR is getting big enough
already)
2025-02-07 18:01:44 +00:00

55 lines
1.6 KiB
Python

import asyncio
import os
import yaml
from autogen_ext.agents.magentic_one import MagenticOneCoderAgent
from autogen_agentchat.teams import RoundRobinGroupChat
from autogen_agentchat.ui import Console
from autogen_core.models import ModelFamily
from autogen_ext.code_executors.local import LocalCommandLineCodeExecutor
from autogen_agentchat.conditions import TextMentionTermination
from custom_code_executor import CustomCodeExecutorAgent
from autogen_core.models import ChatCompletionClient
async def main() -> None:
# Load model configuration and create the model client.
with open("config.yaml", "r") as f:
config = yaml.safe_load(f)
model_client = ChatCompletionClient.load_component(config["model_config"])
# Coder
coder_agent = MagenticOneCoderAgent(
name="coder",
model_client=model_client,
)
# Executor
executor = CustomCodeExecutorAgent(
name="executor",
code_executor=LocalCommandLineCodeExecutor(),
sources=["coder"],
)
# Termination condition
termination = TextMentionTermination(text="TERMINATE", sources=["executor"])
# Define a team
agent_team = RoundRobinGroupChat([coder_agent, executor], max_turns=12, termination_condition=termination)
prompt = ""
with open("prompt.txt", "rt") as fh:
prompt = fh.read()
task = f"""Complete the following python function. Format your output as Markdown python code block containing the entire function definition:
```python
{prompt}
```
"""
# Run the team and stream messages to the console.
stream = agent_team.run_stream(task=task)
await Console(stream)
asyncio.run(main())