MCPcopy Create free account
hub / github.com/Paper2Poster/Paper2Poster / step

Method step

camel/agents/chat_agent.py:550–617  ·  view source on GitHub ↗

r"""Executes a single step in the chat session, generating a response to the input message. Args: input_message (Union[BaseMessage, str]): The input message for the agent. If provided as a BaseMessage, the `role` is adjusted to `user` to i

(
        self,
        input_message: Union[BaseMessage, str],
        response_format: Optional[Type[BaseModel]] = None,
    )

Source from the content-addressed store, hash-verified

548 self.update_memory(message, OpenAIBackendRole.ASSISTANT)
549
550 def step(
551 self,
552 input_message: Union[BaseMessage, str],
553 response_format: Optional[Type[BaseModel]] = None,
554 ) -> ChatAgentResponse:
555 r"""Executes a single step in the chat session, generating a response
556 to the input message.
557
558 Args:
559 input_message (Union[BaseMessage, str]): The input message for the
560 agent. If provided as a BaseMessage, the `role` is adjusted to
561 `user` to indicate an external message.
562 response_format (Optional[Type[BaseModel]], optional): A Pydantic
563 model defining the expected structure of the response. Used to
564 generate a structured response if provided. (default:
565 :obj:`None`)
566
567 Returns:
568 ChatAgentResponse: Contains output messages, a termination status
569 flag, and session information.
570 """
571
572 if (
573 self.model_backend.model_config_dict.get("response_format")
574 and response_format
575 ):
576 raise ValueError(
577 "The `response_format` parameter cannot be set both in "
578 "the model configuration and in the ChatAgent step."
579 )
580
581 self.original_model_dict = self.model_backend.model_config_dict
582 model_response_format_modified = False
583 if (
584 response_format
585 and self.model_type.support_native_structured_output
586 ):
587 self.model_backend.model_config_dict = (
588 self.original_model_dict.copy()
589 )
590 self.model_backend.model_config_dict["response_format"] = (
591 response_format
592 )
593 model_response_format_modified = True
594
595 # Convert input message to BaseMessage if necessary
596 if isinstance(input_message, str):
597 input_message = BaseMessage.make_user_message(
598 role_name='User', content=input_message
599 )
600
601 # Handle tool prompt injection if needed
602 if (
603 self.is_tools_added()
604 and not self.model_type.support_native_tool_calling
605 and not self.tool_prompt_added
606 ):
607 self._inject_tool_prompt()

Callers 15

eval_qa_get_answerFunction · 0.95
gen_eval_markdownFunction · 0.95
get_questionsFunction · 0.95
eval_vlm_as_judge_aspectFunction · 0.95
no_tree_get_layoutFunction · 0.95
generate_docstringFunction · 0.95
text_to_personaMethod · 0.95
persona_to_personaMethod · 0.95
gen_poster_title_contentFunction · 0.95
_process_sectionFunction · 0.95
filter_image_tableFunction · 0.95

Calls 6

is_tools_addedMethod · 0.95
_inject_tool_promptMethod · 0.95
update_memoryMethod · 0.95
_handle_stepMethod · 0.95
copyMethod · 0.45
make_user_messageMethod · 0.45

Tested by

no test coverage detected