autogen icon indicating copy to clipboard operation
autogen copied to clipboard

Need Guidance on Incorporating Conversation History in Group Chat API Requests

Open maslybs opened this issue 2 years ago • 6 comments

Hello I'm relatively new to Python, but I think I've figured out this framework. I'm currently working on a chat app that uses a group agent. My challenge is to incorporate previous conversation history for each user into new API requests. While I have managed to get it working in terminal mode with human_input_mode="ALWAYS",it work well, but each new POST request to my API seems to initiate a new conversation, disregarding history.

Questions:

  1. Is it possible to automatically include the history of past conversations in each new API request?
  2. Should I use List[Dict] ? If so, could someone clarify how to make use of it in this issue context?

I'll look forward to your reply. Thanks

maslybs avatar Oct 13 '23 14:10 maslybs

@gagb @victordibia @afourney might have an answer.

sonichi avatar Oct 13 '23 14:10 sonichi

I've used the following implementation before

  1. save the history somewhere (e.g., a db or file)
  2. upon a new request, first populate the agents with the relevant history:
    • read history from db; use the send() function to populate history
  3. initiate_chat between the agents with the new request

Lmk if this helps!

gagb avatar Oct 13 '23 23:10 gagb

Thank you, @gagb I was also considering implementing it this way. I'm currently saving data in local storage of browser, but I had hoped we could use the cache and "seed" for this purpose. In any case, this solution works and is sufficient for now. Thanks. My implementation in group manager:

     if history:
        for msg_obj in history:
            content = msg_obj.get("content", "")

            if content:
                userProxy.send(message=content, recipient=manager,request_reply=False, silent=True)
    

    userProxy.initiate_chat(
        manager,
        silent=False,
        clear_history=False,
        message=user_message
    ) 

maslybs avatar Oct 14 '23 23:10 maslybs

could you provide a groupchat example that save history and the reload it on a new chat?

camico63 avatar Nov 10 '23 08:11 camico63

@camico63 Did you got any success on your implementation, I'm looking for the similar one.

gauravt avatar Nov 22 '23 10:11 gauravt

could you provide a groupchat example that save history and the reload it on a new chat?

You can save the history, for instance in a file and once the chat resumes, you read the history from file and broadcast the meesages to all the agents. It will be like having a previous conversation continue. Please refer to the following link for more info: https://clintgoodman27.medium.com/a-practical-guide-for-using-autogen-in-software-applications-8799185d27ee

https://github.com/microsoft/autogen/issues/837

annusrcm avatar Mar 22 '24 04:03 annusrcm

lots of relevant examples in new 0.4. closing. please reopen with a more specific question/details if you object.

rysweet avatar Oct 12 '24 02:10 rysweet