Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions rooms/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,15 @@ def generate_response(self, context_messages: List[Dict[str, str]], override_par
if self.config.max_tokens:
litellm_params["max_tokens"] = self.config.max_tokens

litellm_params["timeout"] = self.config.timeout
litellm_params.update(params)

response = litellm.completion(**litellm_params)
return response.choices[0].message.content.strip()

except litellm.Timeout as e:
logger.error(f"Timeout logic executed for agent '{self.name}' on model '{self.model}': {e}")
return f"[Timeout Error: The model '{self.model}' took too long to respond ({self.config.timeout}s)]"
except Exception as e:
logger.error(f"Error getting response from agent '{self.name}' on model '{self.model}': {e}")
return f"[Error: Could not generate response. Details: {str(e)}]"
Expand Down
1 change: 1 addition & 0 deletions rooms/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class AgentConfig(BaseModel):
model: str = Field(default="ollama/llama3", description="LiteLLM compatible model name or placeholder for custom")
temperature: float = Field(default=0.7, description="Generation temperature")
max_tokens: Optional[int] = Field(default=None, description="Max generated tokens")
timeout: int = Field(default=30, description="Timeout in seconds for model generation")
color: str = Field(default="blue", description="CLI output color for this agent")
custom_function_path: Optional[str] = Field(default=None, description="Path to .py file if model_type is custom_function")
custom_function_name: Optional[str] = Field(default=None, description="Name of the python function to call")
Expand Down
Loading