Spaces:
Build error
Build error
Update core_agent.py
Browse files5 unmodified lines6789101112198 unmodified lines2112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892905 unmodified linesOpenAIServerModel,PythonInterpreterTool,tool,InferenceClientModel)from typing import List, Dict, Any, Optionalimport os198 unmodified linesself.system_prompt = system_prompt # Store for potential future use# Initialize model based on configurationif model_type == "HfApiModel":if api_key is None:api_key = os.getenv("HUGGINGFACEHUB_API_TOKEN")if not api_key:raise ValueError("No Hugging Face token provided. Please set HUGGINGFACEHUB_API_TOKEN environment variable or pass api_key parameter.")if self.verbose:print(f"Using Hugging Face token: {api_key[:5]}...")self.model = HfApiModel(model_id=model_id or "meta-llama/Llama-3-70B-Instruct",token=api_key,temperature=temperature)elif model_type == "InferenceClientModel":if api_key is None:api_key = os.getenv("HUGGINGFACEHUB_API_TOKEN")if not api_key:raise ValueError("No Hugging Face token provided. Please set HUGGINGFACEHUB_API_TOKEN environment variable or pass api_key parameter.")if self.verbose:print(f"Using Hugging Face token: {api_key[:5]}...")self.model = InferenceClientModel(model_id=model_id or "meta-llama/Llama-3-70B-Instruct",provider=provider or "hf-inference",token=api_key,timeout=timeout or 120,temperature=temperature)elif model_type == "LiteLLMModel":from smolagents import LiteLLMModelself.model = LiteLLMModel(model_id=model_id or "gpt-4o",api_key=api_key or os.getenv("OPENAI_API_KEY"),temperature=temperature)elif model_type == "OpenAIServerModel":# Check for xAI API key and base URL firstxai_api_key = os.getenv("XAI_API_KEY")xai_api_base = os.getenv("XAI_API_BASE")# If xAI credentials are available, use themif xai_api_key and api_key is None:api_key = xai_api_keyif self.verbose:print(f"Using xAI API key: {api_key[:5]}...")# If no API key specified, fall back to OPENAI_API_KEYif api_key is None:api_key = os.getenv("OPENAI_API_KEY")if not api_key:raise ValueError("No OpenAI API key provided. Please set OPENAI_API_KEY or XAI_API_KEY environment variable or pass api_key parameter.")# If xAI API base is available and no api_base is provided, use itif xai_api_base and api_base is None:api_base = xai_api_baseif self.verbose:print(f"Using xAI API base URL: {api_base}")# If no API base specified but environment variable available, use itif api_base is None:api_base = os.getenv("AGENT_API_BASE")if api_base and self.verbose:print(f"Using API base from AGENT_API_BASE: {api_base}")self.model = OpenAIServerModel(model_id=model_id or "gpt-4o",api_key=api_key,api_base=api_base,temperature=temperature)else:raise ValueError(f"Unknown model type: {model_type}")if self.verbose:print(f"Initialized model: {model_type} - {model_id}")5 unmodified lines678910111213198 unmodified lines2122132142152162172182192202212222232242252265 unmodified linesOpenAIServerModel,PythonInterpreterTool,tool,InferenceClientModel,LiteLLMModel)from typing import List, Dict, Any, Optionalimport os198 unmodified linesself.system_prompt = system_prompt # Store for potential future use# Initialize model based on configurationmodel_type == "LiteLLMModel":self.model = LiteLLMModel(model_id="gemini/gemini-2.0-flash",api_key=os.getenv("GEMINI_API_KEY"),temperature=temperature)if self.verbose:print(f"Initialized model: {model_type} - {model_id}")
core_agent.py+9-73