Minimal Module that proxies inference to the tool-calling agent.
| 122 | |
| 123 | |
| 124 | class ToolCallingAgentLLM(Module): |
| 125 | """Minimal Module that proxies inference to the tool-calling agent.""" |
| 126 | |
| 127 | def __init__(self, runner: ToolCallingAgentRunner, system_prompt: Variable): |
| 128 | self.runner = runner |
| 129 | self.system_prompt = system_prompt |
| 130 | |
| 131 | def parameters(self) -> List[Variable]: |
| 132 | return [self.system_prompt] if self.system_prompt else [] |
| 133 | |
| 134 | def forward(self, x: Variable) -> Variable: |
| 135 | system_prompt_value = self.system_prompt.value if self.system_prompt else "" |
| 136 | response_text = self.runner(system_prompt_value, x.value) |
| 137 | return Variable( |
| 138 | value=response_text, |
| 139 | requires_grad=False, |
| 140 | role_description="tool_calling_agent_response", |
| 141 | ) |
| 142 | |
| 143 | |
| 144 | async def _async_prepare_tool_agent( |