Spaces:
Build error
Build error
Chris Ellerson commited on
Commit ·
62fb43b
1
Parent(s): 3f90b63
initial commit of agent with score of 60
Browse filesFiles changed (3)
- README.md+10
- app.py+72-56
- requirements.txt+3-2
120 unmodified lines121122123124125126120 unmodified lines4. For X.AI's API, also set:- `XAI_API_BASE` - The API base URL## Usage120 unmodified lines121122123124125126127128129130131132133134135136120 unmodified lines4. For X.AI's API, also set:- `XAI_API_BASE` - The API base URL5. **Important**: If you're using OpenAIServerModel, ensure the requirements.txt includes:```smolagents[openai]openai```If the space gives an error about OpenAI modules, rebuild the space after updating requirements.txt.6. After adding all secrets, go to the "Factory" tab in the Space settings and click "Rebuild Space" to apply the changes.## Usage
62 unmodified lines6364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914062 unmodified linesprint(f"Agent config - Model Type: {model_type}, Model ID: {model_id}")if xai_key:# Use X.AI API with OpenAIServerModelapi_base = os.environ.get("XAI_API_BASE", "https://api.x.ai/v1")self.gaia_agent = GAIAAgent(model_type="OpenAIServerModel",model_id="grok-3-latest", # X.AI's modelapi_key=xai_key,api_base=api_base,temperature=temperature,executor_type="local",verbose=verbose)print(f"Using OpenAIServerModel with X.AI API at {api_base}")elif model_type == "HfApiModel" and hf_token:# Use Hugging Face APIself.gaia_agent = GAIAAgent(model_type="HfApiModel",model_id=model_id,api_key=hf_token,temperature=temperature,executor_type="local",verbose=verbose)print(f"Using HfApiModel with model_id: {model_id}")elif openai_key:# Default to OpenAI APIapi_base = os.environ.get("AGENT_API_BASE")kwargs = {"model_type": "OpenAIServerModel","model_id": model_id,"api_key": openai_key,"temperature": temperature,"executor_type": "local","verbose": verbose}if api_base:kwargs["api_base"] = api_baseprint(f"Using custom API base: {api_base}")self.gaia_agent = GAIAAgent(**kwargs)print(f"Using OpenAIServerModel with model_id: {model_id}")else:# Fallback to using whatever token we haveprint("WARNING: Using fallback initialization with available token")if hf_token:self.gaia_agent = GAIAAgent(model_type="HfApiModel",model_id="mistralai/Mistral-7B-Instruct-v0.2",api_key=hf_token,temperature=temperature,executor_type="local",verbose=verbose)elif openai_key:self.gaia_agent = GAIAAgent(model_type="OpenAIServerModel",model_id="gpt-3.5-turbo",api_key=openai_key,temperature=temperature,executor_type="local",verbose=verbose)else:self.gaia_agent = GAIAAgent(model_type="OpenAIServerModel",model_id="grok-3-latest",api_key=xai_key,api_base=os.environ.get("XAI_API_BASE", "https://api.x.ai/v1"),temperature=temperature,executor_type="local",verbose=verbose)else:# No API keys available, log the errorprint("ERROR: No API keys found. Please set at least one of these environment variables:")62 unmodified lines6364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515662 unmodified linesprint(f"Agent config - Model Type: {model_type}, Model ID: {model_id}")try:if xai_key:# Use X.AI API with OpenAIServerModelapi_base = os.environ.get("XAI_API_BASE", "https://api.x.ai/v1")self.gaia_agent = GAIAAgent(model_type="OpenAIServerModel",model_id="grok-3-latest", # X.AI's modelapi_key=xai_key,api_base=api_base,temperature=temperature,executor_type="local",verbose=verbose)print(f"Using OpenAIServerModel with X.AI API at {api_base}")elif model_type == "HfApiModel" and hf_token:# Use Hugging Face APIself.gaia_agent = GAIAAgent(model_type="HfApiModel",model_id=model_id,api_key=hf_token,temperature=temperature,executor_type="local",verbose=verbose)print(f"Using HfApiModel with model_id: {model_id}")elif openai_key:# Default to OpenAI APIapi_base = os.environ.get("AGENT_API_BASE")kwargs = {"model_type": "OpenAIServerModel","model_id": model_id,"api_key": openai_key,"temperature": temperature,"executor_type": "local","verbose": verbose}if api_base:kwargs["api_base"] = api_baseprint(f"Using custom API base: {api_base}")self.gaia_agent = GAIAAgent(**kwargs)print(f"Using OpenAIServerModel with model_id: {model_id}")else:# Fallback to using whatever token we haveprint("WARNING: Using fallback initialization with available token")if hf_token:self.gaia_agent = GAIAAgent(model_type="HfApiModel",model_id="mistralai/Mistral-7B-Instruct-v0.2",api_key=hf_token,temperature=temperature,executor_type="local",verbose=verbose)elif openai_key:self.gaia_agent = GAIAAgent(model_type="OpenAIServerModel",model_id="gpt-3.5-turbo",api_key=openai_key,temperature=temperature,executor_type="local",verbose=verbose)else:self.gaia_agent = GAIAAgent(model_type="OpenAIServerModel",model_id="grok-3-latest",api_key=xai_key,api_base=os.environ.get("XAI_API_BASE", "https://api.x.ai/v1"),temperature=temperature,executor_type="local",verbose=verbose)except ImportError as ie:# Handle OpenAI module errors specificallyif "openai" in str(ie).lower() and hf_token:print(f"OpenAI module error: {ie}. Falling back to HfApiModel.")self.gaia_agent = GAIAAgent(model_type="HfApiModel",model_id="mistralai/Mistral-7B-Instruct-v0.2",api_key=hf_token,temperature=temperature,executor_type="local",verbose=verbose)print(f"Using HfApiModel with model_id: mistralai/Mistral-7B-Instruct-v0.2 (fallback)")else:raiseelse:# No API keys available, log the errorprint("ERROR: No API keys found. Please set at least one of these environment variables:")
123456gradiorequestssmolagentspython-dotenvpandasnumpy1234567gradiorequestssmolagents[openai]python-dotenvpandasnumpyopenai
README.md+10
app.py+72-56
requirements.txt+3-2