Spaces:
Runtime error
Runtime error
File size: 1,985 Bytes
b1c5894 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
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
"""
|