(self, model: Llm, prompt_messages: List[ChatCompletionMessageParam])
| 252 | raise Exception("Agent exceeded max tool turns") |
| 253 | |
| 254 | async def run(self, model: Llm, prompt_messages: List[ChatCompletionMessageParam]) -> str: |
| 255 | self.tool_runtime.input_images = self._extract_input_images(prompt_messages) |
| 256 | seed_file_state_from_messages(self.file_state, prompt_messages) |
| 257 | |
| 258 | session = create_provider_session( |
| 259 | model=model, |
| 260 | prompt_messages=prompt_messages, |
| 261 | should_generate_images=self.should_generate_images, |
| 262 | openai_api_key=self.openai_api_key, |
| 263 | openai_base_url=self.openai_base_url, |
| 264 | anthropic_api_key=self.anthropic_api_key, |
| 265 | gemini_api_key=self.gemini_api_key, |
| 266 | replicate_api_key=self.replicate_api_key, |
| 267 | ) |
| 268 | try: |
| 269 | return await self._run_with_session(session) |
| 270 | finally: |
| 271 | await session.close() |
| 272 | |
| 273 | async def _finalize_response(self, assistant_text: str) -> str: |
| 274 | if self.file_state.content: |
no test coverage detected