Skip to content
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

Update AgentChat State Docs (Saving to Disc) #4730

Merged
merged 3 commits into from
Dec 17, 2024
Merged

Conversation

victordibia
Copy link
Collaborator

Why are these changes needed?

Provides explicit example on how to save state to a dict on disc and load it back.

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)

Related issue number

Closes #4327

Checks

@victordibia victordibia requested a review from ekzhu December 17, 2024 04:39
@victordibia victordibia merged commit 03f57e9 into main Dec 17, 2024
48 checks passed
@victordibia victordibia deleted the persist_state_vd branch December 17, 2024 05:55
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.

What is the current way to export an thread and preload a chat with a team in v0.4
2 participants