|
| 1 | +import os |
1 | 2 | from abc import ABC, abstractmethod |
2 | 3 | from typing import TypeVar |
3 | 4 |
|
4 | 5 | from pydantic import BaseModel |
5 | 6 |
|
| 7 | +from beeai_framework.agents import AgentExecutionConfig |
6 | 8 | from beeai_framework.agents.experimental import RequirementAgent, RequirementAgentRunOutput |
7 | 9 | from beeai_framework.template import PromptTemplate, PromptTemplateInput |
8 | 10 |
|
@@ -31,9 +33,18 @@ def _render_prompt(self, input: TInputSchema) -> str: |
31 | 33 | return template.render(input) |
32 | 34 |
|
33 | 35 | async def _run_with_schema(self, input: TInputSchema) -> TOutputSchema: |
| 36 | + max_retries_per_step = int(os.getenv("BEEAI_MAX_RETRIES_PER_STEP", 5)) |
| 37 | + total_max_retries = int(os.getenv("BEEAI_TOTAL_MAX_RETRIES", 10)) |
| 38 | + max_iterations = int(os.getenv("BEEAI_MAX_ITERATIONS", 100)) |
| 39 | + |
34 | 40 | response = await self.run( |
35 | 41 | prompt=self._render_prompt(input), |
36 | 42 | expected_output=self.output_schema, |
| 43 | + execution=AgentExecutionConfig( |
| 44 | + max_retries_per_step=max_retries_per_step, |
| 45 | + total_max_retries=total_max_retries, |
| 46 | + max_iterations=max_iterations, |
| 47 | + ), |
37 | 48 | ) |
38 | 49 | return self.output_schema.model_validate_json(response.result.text) |
39 | 50 |
|
|
0 commit comments