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 lines121122123124125126127128129130131132133134135136120 unmodified lines4. For X.AI's API, also set: - `XAI_API_BASE` - The API base URL
5. **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.

## Usage62 unmodified lines636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091106667686970112113114717273747576777811979808182121122123838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214313013113213314414514614714814915015115215315415515662 unmodified lines print(f"Agent config - Model Type: {model_type}, Model ID: {model_id}") if xai_key: # Use X.AI API with OpenAIServerModel api_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 model api_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 API self.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 API api_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_base print(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 have print("WARNING: Using fallback initialization with available token") if hf_token: try: if xai_key: # Use X.AI API with OpenAIServerModel api_base = os.environ.get("XAI_API_BASE", "https://api.x.ai/v1") self.gaia_agent = GAIAAgent( model_type="HfApiModel", model_id="mistralai/Mistral-7B-Instruct-v0.2", api_key=hf_token, model_type="OpenAIServerModel", model_id="grok-3-latest", # X.AI's model api_key=xai_key, api_base=api_base, temperature=temperature, executor_type="local", verbose=verbose ) elif openai_key: print(f"Using OpenAIServerModel with X.AI API at {api_base}") elif model_type == "HfApiModel" and hf_token: # Use Hugging Face API self.gaia_agent = GAIAAgent( model_type="OpenAIServerModel", model_id="gpt-3.5-turbo", api_key=openai_key, 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 API api_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_base print(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 have print("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 specifically if "openai" in str(ie).lower() and hf_token: print(f"OpenAI module error: {ie}. Falling back to HfApiModel.") 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"), 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: raise else: # No API keys available, log the error print("ERROR: No API keys found. Please set at least one of these environment variables:")123345667gradiorequestssmolagentssmolagents[openai]python-dotenvpandasnumpynumpyopenaiREADME.md+10
app.py+72-56
requirements.txt+3-2