microsoft / autogen

A programming framework for agentic AI. Discord: https://aka.ms/autogen-dc. Roadmap: https://aka.ms/autogen-roadmap
https://microsoft.github.io/autogen/
Creative Commons Attribution 4.0 International
28.23k stars 4.13k forks source link

Autogen Retrieval User Proxy generate_init_message bug #859

Open mknio opened 7 months ago

mknio commented 7 months ago

I am trying to use the Autogen's RetrievalUserProxy and after i created a userpoxyagent and an assistant agent i wanted to initiate a message by saying user.initiate_chat(assistant, message = passed_prompt). it gave me a TypeError that it is not expecting it because it should have been passed as "problem" not "message" in the retrieval_user_proxy_agent.py at line 414. It is passed as a "problem" not a "message".

def generate_init_message(self, problem: str, n_results: int = 20, search_string: str = ""):
    """Generate an initial message with the given problem and prompt.

    Args:
        problem (str): the problem to be solved.
        n_results (int): the number of results to be retrieved.
        search_string (str): only docs containing this string will be retrieved.

    Returns:
        str: the generated prompt ready to be sent to the assistant agent.
    """
    self._reset()
    self.retrieve_docs(problem, n_results, search_string)
    self.problem = problem
    self.n_results = n_results
    doc_contents = self._get_context(self._results)
    message = self._generate_message(doc_contents, self._task)
    return message

However, in the class ConversableAgent the initiate_chat function is expecting a message argument at the line 529.

def initiate_chat(
    self,
    recipient: "ConversableAgent",
    clear_history: Optional[bool] = True,
    silent: Optional[bool] = False,
    **context,
):
    """Initiate a chat with the recipient agent.

    Reset the consecutive auto reply counter.
    If `clear_history` is True, the chat history with the recipient agent will be cleared.
    `generate_init_message` is called to generate the initial message for the agent.

    Args:
        recipient: the recipient agent.
        clear_history (bool): whether to clear the chat history with the agent.
        silent (bool or None): (Experimental) whether to print the messages for this conversation.
        **context: any context information.
            "message" needs to be provided if the `generate_init_message` method is not overridden.
    """

I believe that the generate_init_message should be also overridden as message and not as problem.

Please clarify this issue.

sonichi commented 7 months ago

@thinkall would you like to make RetrievalUserProxyAgent more general? If the agent is intended for general use, "problem" is probably too narrow a concept. Another question I've been thinking is how to consolidate TeachableAgent, RetrievalUserProxyAgent, EcoAssistant, MemGPT etc. I believe there is value to generalize the lessons learned from these and build a good systems component. cc @rickyloynd-microsoft @JieyuZ2 @cpacker

mknio commented 7 months ago

I have seen some other codes where it uses message and somewhere else it uses "problem" and "message". So the question rises. When do we use "message" and when do we use "problem". the code is from the examples that autogen provided in the agentchat_groupchat_RAG.ipynb. Thank you

JieyuZ2 commented 7 months ago

@thinkall would you like to make RetrievalUserProxyAgent more general? If the agent is intended for general use, "problem" is probably too narrow a concept. Another question I've been thinking is how to consolidate TeachableAgent, RetrievalUserProxyAgent, EcoAssistant, MemGPT etc. I believe there is value to generalize the lessons learned from these and build a good systems component. cc @rickyloynd-microsoft @JieyuZ2 @cpacker

it may require a modularized way to build retrieval-based agents, define store and retrieve function like we define reply function.

thinkall commented 7 months ago

@thinkall would you like to make RetrievalUserProxyAgent more general? If the agent is intended for general use, "problem" is probably too narrow a concept. Another question I've been thinking is how to consolidate TeachableAgent, RetrievalUserProxyAgent, EcoAssistant, MemGPT etc. I believe there is value to generalize the lessons learned from these and build a good systems component. cc @rickyloynd-microsoft @JieyuZ2 @cpacker

it may require a modularized way to build retrieval-based agents, define store and retrieve function like we define reply function.

Yes, looks like it's time to start working on that.

thinkall commented 7 months ago

I have seen some other codes where it uses message and somewhere else it uses "problem" and "message". So the question rises. When do we use "message" and when do we use "problem". the code is from the examples that autogen provided in the agentchat_groupchat_RAG.ipynb. Thank you

Hi @mknio , before we update the code, you'll need to initiate the chat with problem when using a RetrieveUserProxyAgent.

mknio commented 7 months ago

Isnt "message" the better word to use in this instance as it is also dependent on many other factors like the generate_init_message and initiate_chat are all expecting message. Anyways, I will change the code to "problem" once it is updated if that is the most suitable thing to do. Thank you!

thinkall commented 7 months ago

Isnt "message" the better word to use in this instance as it is also dependent on many other factors like the generate_init_message and initiate_chat are all expecting message. Anyways, I will change the code to "problem" once it is updated if that is the most suitable thing to do. Thank you!

Right, we'll unify the interface. Before that, please use "problem" as a workaround. Just to clarify, you need "problem" for the current version of RetrieveUserProxyAgent.