Call the model using COW's bot infrastructure
(self, request: LLMRequest)
| 137 | return self._bot |
| 138 | |
| 139 | def call(self, request: LLMRequest): |
| 140 | """ |
| 141 | Call the model using COW's bot infrastructure |
| 142 | """ |
| 143 | try: |
| 144 | # For non-streaming calls, we'll use the existing reply method |
| 145 | # This is a simplified implementation |
| 146 | if hasattr(self.bot, 'call_with_tools'): |
| 147 | # Use tool-enabled call if available |
| 148 | kwargs = { |
| 149 | 'messages': request.messages, |
| 150 | 'tools': getattr(request, 'tools', None), |
| 151 | 'stream': False, |
| 152 | 'model': self.model # Pass model parameter |
| 153 | } |
| 154 | # Only pass max_tokens if it's explicitly set |
| 155 | if request.max_tokens is not None: |
| 156 | kwargs['max_tokens'] = request.max_tokens |
| 157 | |
| 158 | # Extract system prompt if present |
| 159 | system_prompt = getattr(request, 'system', None) |
| 160 | if system_prompt: |
| 161 | kwargs['system'] = system_prompt |
| 162 | |
| 163 | # Pass context metadata to bot |
| 164 | channel_type = getattr(self, 'channel_type', None) or '' |
| 165 | if channel_type: |
| 166 | kwargs['channel_type'] = channel_type |
| 167 | session_id = getattr(self, 'session_id', None) |
| 168 | if session_id: |
| 169 | kwargs['session_id'] = session_id |
| 170 | |
| 171 | # Thinking mode is a global toggle independent of the channel. |
| 172 | # IM channels (WeChat/WeCom/DingTalk/Feishu) won't render the |
| 173 | # reasoning trace, but still benefit from the higher answer |
| 174 | # quality the thinking pass produces. |
| 175 | from config import conf |
| 176 | thinking_enabled = bool(conf().get("enable_thinking", False)) |
| 177 | kwargs['thinking'] = ( |
| 178 | {"type": "enabled"} if thinking_enabled |
| 179 | else {"type": "disabled"} |
| 180 | ) |
| 181 | # Reasoning effort is only meaningful when thinking is on. |
| 182 | # Bots that don't understand the kwarg drop it silently. |
| 183 | if thinking_enabled: |
| 184 | effort = conf().get("reasoning_effort", "high") |
| 185 | if effort in ("high", "max"): |
| 186 | kwargs['reasoning_effort'] = effort |
| 187 | |
| 188 | response = self.bot.call_with_tools(**kwargs) |
| 189 | return self._format_response(response) |
| 190 | else: |
| 191 | # Fallback to regular call |
| 192 | # This would need to be implemented based on your specific needs |
| 193 | raise NotImplementedError("Regular call not implemented yet") |
| 194 | |
| 195 | except Exception as e: |
| 196 | logger.error(f"AgentLLMModel call error: {e}") |
nothing calls this directly
no test coverage detected