schoolkithub commited on
Commit
138d320
·
verified ·
1 Parent(s): 9f32246

Update agent.py

Browse files
Files changed (1) hide show
  1. agent.py +3 -3
agent.py CHANGED
@@ -23,7 +23,7 @@ class GAIAAgent:
23
  """Call the xAI Grok API with retry logic and endpoint testing."""
24
  for base_url in self.possible_base_urls:
25
  print(f"Trying base URL: {base_url}")
26
- result = self._try_api_call(base_url, prompt)
27
  if not result.startswith("Error:"):
28
  self.base_url = base_url # Update successful base URL
29
  print(f"Success with URL: {base_url}")
@@ -31,7 +31,7 @@ class GAIAAgent:
31
  print(f"Failed with error: {result}")
32
  return f"Error: All API endpoints failed. Please check API key validity and xAI service status."
33
 
34
- def _try_api_call(self, base_url: str, prompt: str) -> str:
35
  """Try API call with a specific base URL."""
36
  headers = {
37
  "Authorization": f"Bearer {self.xai_api_key}",
@@ -44,7 +44,7 @@ class GAIAAgent:
44
  {"role": "system", "content": "You are Grok, a helpful AI assistant. Provide clear, concise answers. When asked to solve a problem, think step by step and provide your final answer in the format 'FINAL ANSWER: [answer]'"},
45
  {"role": "user", "content": prompt}
46
  ],
47
- "model": "grok-3", # Updated to a supported model
48
  "stream": False,
49
  "temperature": 0.1
50
  }
 
23
  """Call the xAI Grok API with retry logic and endpoint testing."""
24
  for base_url in self.possible_base_urls:
25
  print(f"Trying base URL: {base_url}")
26
+ result = self._try_api_call(base_url, prompt, retries)
27
  if not result.startswith("Error:"):
28
  self.base_url = base_url # Update successful base URL
29
  print(f"Success with URL: {base_url}")
 
31
  print(f"Failed with error: {result}")
32
  return f"Error: All API endpoints failed. Please check API key validity and xAI service status."
33
 
34
+ def _try_api_call(self, base_url: str, prompt: str, retries: int) -> str:
35
  """Try API call with a specific base URL."""
36
  headers = {
37
  "Authorization": f"Bearer {self.xai_api_key}",
 
44
  {"role": "system", "content": "You are Grok, a helpful AI assistant. Provide clear, concise answers. When asked to solve a problem, think step by step and provide your final answer in the format 'FINAL ANSWER: [answer]'"},
45
  {"role": "user", "content": prompt}
46
  ],
47
+ "model": "grok-3",
48
  "stream": False,
49
  "temperature": 0.1
50
  }