Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Is it possible to inject previous history? #837

Closed
tyler-suard-parker opened this issue Dec 1, 2023 · 4 comments
Closed

Is it possible to inject previous history? #837

tyler-suard-parker opened this issue Dec 1, 2023 · 4 comments

Comments

@tyler-suard-parker
Copy link
Contributor

Hello. My frontend returns the last 4 exchanges with a chatbot. I was wondering if there is a way to initialize an agent using that prior history.

@victordibia
Copy link
Collaborator

victordibia commented Dec 2, 2023

@tyler-suard-parker ,

Yes, you can update the history of agents.

  • loop through the history object
  • call agent.send(message, receiver, request_reply=False) . This adds the particular message to the agent history without triggering a reply.
  • finally, when you call initiate_chat, ensure you set clear_history=False ... initiate_chat(clear_history=False)

Some pseudo code below

user_proxy = autogen.UserProxyAgent ..
assistant = autogen.AssistantAgent ...

for message in history:
    user_proxy.send(message, assistant, request_reply=False) 
    # you can also send from assistant to user_proxy depending on your use case

user_proxy.initiate_chat(assistant, message=message, clear_history=False)

@tyler-suard-parker
Copy link
Contributor Author

@victordibia Dr. Dibia, this is SO helpful, thank you!

@easontsai
Copy link

how about groupchat? how to handle the chat history?

@annusrcm
Copy link

annusrcm commented Mar 18, 2024

how about groupchat? how to handle the chat history?

Try this:
https://clintgoodman27.medium.com/a-practical-guide-for-using-autogen-in-software-applications-8799185d27ee
but with one change : await user_proxy.a_initiate_chat(manager, message=message, clear_history=False)
ensure clear_history is set to False
I have tried, it works for me

@microsoft microsoft locked and limited conversation to collaborators Mar 18, 2024
@ekzhu ekzhu converted this issue into discussion #2049 Mar 18, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants