autogen icon indicating copy to clipboard operation
autogen copied to clipboard

[Feature Request]: only get agent message to iostream / websocket output

Open amzker opened this issue 10 months ago • 1 comments

Is your feature request related to a problem? Please describe.

while using autogen websocket chat and setting stream true in llm config , in web socket end we receive everything including.

  • suggested function call
  • executing function
  • please provide feedback to agent etc...

Describe the solution you'd like

i dont know if it already exists but it would be nice to have toggle argument like (stream: true , stream_only = ["agent_final_response","function_calls"]

like only content. no background process currently i need to extend existing class to modify printing to iostream.

Additional context

chatbot interface with user. user really dont need to know what is happening in background , he/she just wants to get answer of query

i did following

  • will it create problem in future? specifically the roles
    def return_only_agent_message(
        self,
        messages: Optional[List[Dict]] = None,
        sender: Optional[Agent] = None,
        config: Optional[Any] = None,
    ) -> Tuple[bool, Union[str, Dict, None]]:
        
        if config is None:
            config = self
        if messages is None:
            messages = self._oai_messages[sender] if sender else []
        message = messages[-1] if messages else {}
        reply = ""
        no_human_input_msg = ""
        sender_name = "the sender" if sender is None else sender.name
        # print(f"current role {message.get('role')}")
        # iostream = IOStream.get_default()
        # iostream.print(content_str(message.get("content")), flush=True)
        
        if message.get("role") == "user":
            iostream = IOStream.get_default()
            iostream.print(content_str(message.get("content")), flush=True)
            print(f"role is user now need to print content {message.get('content')}")
            return False, None #message.get("content")
        else:
            print(f"not getting role so directly returning {message.get('role')}")
            return False, None

i registered this reply to userproxy at last ( in order of registration ) and did silent=True in initiate chat. will this be problamtic or good workaround

amzker avatar May 01 '24 09:05 amzker

@davorrunje has an on-going PR #2030 that add structure to streams, so you can filter on the client side.

@davorrunje do you need help on that PR?

ekzhu avatar May 01 '24 22:05 ekzhu