MCPcopy
hub / github.com/QwenLM/Qwen-Agent / _call_llm

Method _call_llm

qwen_agent/agent.py:150–176  ·  view source on GitHub ↗

The interface of calling LLM for the agent. We prepend the system_message of this agent to the messages, and call LLM. Args: messages: A list of messages. functions: The list of functions provided to LLM. stream: LLM streaming output or non-strea

(
        self,
        messages: List[Message],
        functions: Optional[List[Dict]] = None,
        stream: bool = True,
        extra_generate_cfg: Optional[dict] = None,
    )

Source from the content-addressed store, hash-verified

148 raise NotImplementedError
149
150 def _call_llm(
151 self,
152 messages: List[Message],
153 functions: Optional[List[Dict]] = None,
154 stream: bool = True,
155 extra_generate_cfg: Optional[dict] = None,
156 ) -> Iterator[List[Message]]:
157 """The interface of calling LLM for the agent.
158
159 We prepend the system_message of this agent to the messages, and call LLM.
160
161 Args:
162 messages: A list of messages.
163 functions: The list of functions provided to LLM.
164 stream: LLM streaming output or non-streaming output.
165 For consistency, we default to using streaming output across all agents.
166
167 Yields:
168 The response generator of LLM.
169 """
170 return self.llm.chat(messages=messages,
171 functions=functions,
172 stream=stream,
173 extra_generate_cfg=merge_generate_cfgs(
174 base_generate_cfg=self.extra_generate_cfg,
175 new_generate_cfg=extra_generate_cfg,
176 ))
177
178 def _call_tool(self, tool_name: str, tool_args: Union[str, dict] = '{}', **kwargs) -> Union[str, List[ContentItem]]:
179 """The interface of calling tools for the agent.

Callers 15

_runMethod · 0.80
_runMethod · 0.80
_runMethod · 0.80
_runMethod · 0.80
_runMethod · 0.80
_runMethod · 0.80
_runMethod · 0.80
_runMethod · 0.80
_runMethod · 0.80
_runMethod · 0.80
_runMethod · 0.80
_runMethod · 0.80

Calls 2

merge_generate_cfgsFunction · 0.90
chatMethod · 0.80

Tested by

no test coverage detected