-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
[Issue]: ConversableAgent parameter ---chat_messages #2928
Comments
I also struggled to use a short chat history to initialize a ConversableAgent object, as in OpenAI's chat_completion API example, we initialize like:
Now the question is how to inject those short conversation history as a memory into ConversableAgent.chat_messages? Here is a hacky way to do it (although we should have official support for this type of initialization beyond just a plain string):
|
hi @WaelKarkoub Do you have any ideas here? |
Hopefully I understood you correctly, I'm failing to see where the issue is though. Are you trying to report a bug? |
Thanks @WaelKarkoub! I think I have the same question. "chat_messages is used to initialize a convesable_agent" and documentation said "This will allow the agent to resume previous had conversations.". However, the conflict is if this is the first time to initialize the agent, how we get its previous chat history? Even we use the same agent class but they are essentially different objects in python (the agents used to generate the history and the agent which is initialized using the chat_messages.). I am not sure whether I clarify it clear. |
The chat history is empty when you initialize an agent, so you can't really get it. What you can do is store the previous chat history from the "previously" initialized agent in a database and reconstruct it later when you want to use it again. Once you reconstruct it you can pass it to the newly initialized agent. Hope that helped @skzhang1 ! |
@WaelKarkoub Thanks! After getting into the code details. I think I got it point. |
Thanks for explaining. @WaelKarkoub
It would behave more consistently than only specifying |
@yuanzheng319 who is sending those user messages? isn't it another agent as well (e.g. user proxy agent)? You can do what you just showed me using
you can feed this dictionary to the agent's constructor. Just be careful with system messages. From looking at the code, it assumes there's only one system message and it's the beginning of the message list. |
Describe the issue
"chat_messages (dict or None): the previous chat messages that this agent had in the past with other agents.
Can be used to give the agent a memory by providing the chat history. This will allow the agent to
resume previous had conversations. Defaults to an empty chat history."I'm having trouble understanding the meaning of this parameter. Since it doesn't exist before we initialize the object, how can there be a chat history? This has confused me for a long time. I haven't found a correct example of how to use this parameter, and I'm hoping to find the right way to use it
Steps to reproduce
No response
Screenshots and logs
KeyError: <autogen.agentchat.conversable_agent.ConversableAgent object at 0x0000027035619CD0>
Additional Information
No response
The text was updated successfully, but these errors were encountered: