Skip to content

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

Closed
@amzker

Description

@amzker

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

Metadata

Metadata

Assignees

Labels

0.2Issues which are related to the pre 0.4 codebaseneeds-triagestreamingStreaming output to websocket

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions