-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
What is the current way to export an thread and preload a chat with a team in v0.4 #4327
Comments
Sounds good, thanks for the quick response! |
Hi @bih , We have the PR for loading/saving state merged into main (should be available in the next dev release). Documentation page is here Save state .. # Define a team.
assistant_agent = AssistantAgent(
name="assistant_agent",
system_message="You are a helpful assistant",
model_client=OpenAIChatCompletionClient(
model="gpt-4o-2024-08-06",
),
)
agent_team = RoundRobinGroupChat([assistant_agent], termination_condition=MaxMessageTermination(max_messages=2))
# Run the team and stream messages to the console.
stream = agent_team.run_stream(task="Write a beautiful poem 3-line about lake tangayika")
# Use asyncio.run(...) when running in a script.
await Console(stream)
# Save the state of the agent team.
team_state = await agent_team.save_state() load team state print(team_state)
# Load team state.
await agent_team.load_state(team_state)
stream = agent_team.run_stream(task="What was the last line of the poem you wrote?")
await Console(stream) Let us know if it works for you. |
If load_state work in anther context, how can i get the agent_team instance? In the same context, i don't need get team instance by load_state method |
Does this work for you / answer your question?
In new context
import json
## save state to disk
with open("coding/team_state.json", "w") as f:
json.dump(team_state, f)
## load state from disk
with open("coding/team_state.json", "r") as f:
team_state = json.load(f)
## create team
new_agent_team = RoundRobinGroupChat([assistant_agent], termination_condition=MaxMessageTermination(max_messages=2))
## load state
await new_agent_team.load_state(team_state)
stream = new_agent_team.run_stream(task="What was the last line of the poem you wrote?")
await Console(stream) |
I'm fairly new to the AutoGen project and we're exploring it for our use case, but as I was prototyping it in a notebook I was wondering what is the way for us to be able to export a chat and preload it in a team. For example:
I can do this to get the conversation history
But I would love to be able to export it as JSON
And equally I would love to be able to import the conversation history JSON so anything ran against in
team.run()
Also, is it possible to message the agents with nothing (ideally as a specific flag)? We would love to be able to have agents give a meaningful intro message, but this isn't critical - we can build workarounds for this.
Note that this is for the v0.4 release!
The text was updated successfully, but these errors were encountered: