-
Notifications
You must be signed in to change notification settings - Fork 192
OpenAI Swarm #248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OpenAI Swarm #248
Conversation
Codecov ReportAttention: Patch coverage is
📢 Thoughts on this report? Let us know! |
|
Tasks get placed before Agents and prefix the context. There's no real way to define delegation; if you add an agent as a tool of another agent, it will delegate, but then what? the
Limitations of the framework more than anything. Read the source, it's like 200 lines. from swarm import Swarm, Agent
import agentstack
class FoobarStack:
def _handoff(self, agent_name: str):
"""Tool for handing off to another agent."""
agent = getattr(self, agent_name)
def func(context_variables: list[str]):
return agent(context_variables)
return func
def _get_first_task(self):
"""Get the first task."""
task_name = agentstack.get_all_task_names()[0]
return getattr(self, task_name)()
@agentstack.agent
def alex(self, messages: list[str] = []):
agent_config = agentstack.get_agent('alex')
return Agent(
name=agent_config.name,
model=agent_config.model,
instructions="\n".join([agent_config.prompt, *messages, ]),
functions=[*agentstack.tools['file_read'], ],
)
@agentstack.task
def hello_world(self):
task_config = agentstack.get_task('hello_world')
messages = [
task_config.prompt,
]
agent = getattr(self, task_config.agent)
return agent(messages)
def run(self, inputs: list[str]):
app = Swarm()
response = app.run(
agent=self._get_first_task(),
messages=[],
context_variables=inputs,
debug=agentstack.conf.DEBUG,
)
for message in response.messages:
agentstack.log.info(message['content']) |
Typo in comment.
i think just a typo, i can fix |
|
it doesnt look like we're automatically ending the agentops session after the swarm finishes we might look for callback functionality for async. For sync, just run |
also removed customization section
bboynton97
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
incredible. iterating through tasks was smart. waiting for tests to pass then good to merge
This addresses #244.
TODO