microsoft / autogen

A programming framework for agentic AI 🤖
https://microsoft.github.io/autogen/
Creative Commons Attribution 4.0 International
32.37k stars 4.72k forks source link

Is it possible to inject previous history? #837

Closed tyler-suard-parker closed 10 months ago

tyler-suard-parker commented 11 months ago

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 commented 11 months ago

@tyler-suard-parker ,

Yes, you can update the history of agents.

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 commented 10 months ago

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

easontsai commented 9 months ago

how about groupchat? how to handle the chat history?

annusrcm commented 7 months ago

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