mause123 commited on
Commit
6795e79
Β·
1 Parent(s): 32d2dd2

FORCE Groq provider only - completely avoid Google API rate limits

Browse files
Files changed (1) hide show
  1. simple_app.py +15 -14
simple_app.py CHANGED
@@ -29,19 +29,15 @@ class SimpleAgent:
29
  except Exception as e:
30
  return f"❌ Error processing question: {str(e)}\n\nPlease check that your API keys are properly configured in the Space settings."
31
 
32
- # Check which provider to use based on available API keys
33
  def get_available_provider():
34
- """Check which LLM provider is available based on environment variables"""
35
- if os.getenv("GROQ_API_KEY"):
36
- return "groq"
37
- elif os.getenv("GOOGLE_API_KEY"):
38
- return "google"
39
- else:
40
- return "groq" # Default, will show error if no key
41
 
42
- # Initialize agent with available provider
43
  provider = get_available_provider()
44
  print(f"πŸ€– Initializing RobotPai with {provider} provider...")
 
45
  agent = SimpleAgent(provider=provider)
46
 
47
  def chat_with_agent(message, history):
@@ -97,17 +93,22 @@ with gr.Blocks(title="RobotPai - AI Agent", theme=gr.themes.Soft()) as demo:
97
  gr.Markdown("""
98
  ---
99
  ### πŸ”§ Configuration Notes:
100
- - **LLM Provider**: Using {provider} (based on available API keys)
101
  - **Tools Available**: Math operations, AI reasoning
102
  - **Search Tools**: Available when API keys are configured
103
-
104
  ### πŸ”‘ API Keys Required:
105
  Add these to Space settings for full functionality:
106
- - `GOOGLE_API_KEY` or `GROQ_API_KEY` (for AI responses)
107
  - `TAVILY_API_KEY` (for web search)
108
-
 
 
 
 
 
109
  Built with [LangGraph](https://langchain-ai.github.io/langgraph/) and [Gradio](https://gradio.app)
110
- """.format(provider=provider.title()))
111
 
112
  if __name__ == "__main__":
113
  print("\n" + "="*60)
 
29
  except Exception as e:
30
  return f"❌ Error processing question: {str(e)}\n\nPlease check that your API keys are properly configured in the Space settings."
31
 
32
+ # Force Groq provider to avoid Google rate limits
33
  def get_available_provider():
34
+ """Force Groq provider to avoid Google API rate limits"""
35
+ return "groq" # Always use Groq to avoid Google rate limits
 
 
 
 
 
36
 
37
+ # Initialize agent with Groq provider
38
  provider = get_available_provider()
39
  print(f"πŸ€– Initializing RobotPai with {provider} provider...")
40
+ print("πŸ“ Note: Using Groq to avoid Google API rate limits")
41
  agent = SimpleAgent(provider=provider)
42
 
43
  def chat_with_agent(message, history):
 
93
  gr.Markdown("""
94
  ---
95
  ### πŸ”§ Configuration Notes:
96
+ - **LLM Provider**: Using Groq (optimized for performance and rate limits)
97
  - **Tools Available**: Math operations, AI reasoning
98
  - **Search Tools**: Available when API keys are configured
99
+
100
  ### πŸ”‘ API Keys Required:
101
  Add these to Space settings for full functionality:
102
+ - `GROQ_API_KEY` (for AI responses - recommended)
103
  - `TAVILY_API_KEY` (for web search)
104
+
105
+ ### ⚑ Why Groq?
106
+ - **Higher rate limits** than Google free tier
107
+ - **Faster responses** with optimized inference
108
+ - **More reliable** for frequent testing
109
+
110
  Built with [LangGraph](https://langchain-ai.github.io/langgraph/) and [Gradio](https://gradio.app)
111
+ """)
112
 
113
  if __name__ == "__main__":
114
  print("\n" + "="*60)