Spaces:
Runtime error
Runtime error
from smolagents import ( | |
CodeAgent, | |
DuckDuckGoSearchTool, | |
HfApiModel, | |
LiteLLMModel, | |
OpenAIServerModel, | |
PythonInterpreterTool, | |
tool, | |
InferenceClientModel | |
) | |
from typing import List, Dict, Any, Optional | |
import os | |
import tempfile | |
import re | |
import json | |
import requests | |
from urllib.parse import urlparse | |
class GAIAAgent: | |
def __init__( | |
self, | |
model_type: str = "HfApiModel", | |
model_id: Optional[str] = None, | |
api_key: Optional[str] = None, | |
api_base: Optional[str] = None, | |
temperature: float = 0.2, | |
executor_type: str = "local", # Changed from use_e2b to executor_type | |
additional_imports: List[str] = None, | |
additional_tools: List[Any] = None, | |
system_prompt: Optional[str] = None, # We'll still accept this parameter but not use it directly | |
verbose: bool = False, | |
provider: Optional[str] = None, # Add provider for InferenceClientModel | |
timeout: Optional[int] = None # Add timeout for InferenceClientModel | |
): | |
""" | |
Initialize a GAIAAgent with specified configuration | |
Args: | |
model_type: Type of model to use (HfApiModel, LiteLLMModel, OpenAIServerModel, InferenceClientModel) | |
model_id: ID of the model to use | |
api_key: API key for the model provider | |
api_base: Base URL for API calls | |
temperature: Temperature for text generation | |
executor_type: Type of executor for code execution ('local' or 'e2b') | |
additional_imports: Additional Python modules to allow importing | |
additional_tools: Additional tools to provide to the agent | |
system_prompt: Custom system prompt to use (not directly used, kept for backward compatibility) | |
verbose: Enable verbose logging | |
provider: Provider for InferenceClientModel (e.g., "hf-inference") | |
timeout: Timeout in seconds for API calls | |
""" | |