mause123 commited on
Commit Β·
6795e79
1
Parent(s): 32d2dd2
FORCE Groq provider only - completely avoid Google API rate limits
Browse files- 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 |
-
#
|
| 33 |
def get_available_provider():
|
| 34 |
-
"""
|
| 35 |
-
|
| 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
|
| 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
|
| 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 |
-
- `
|
| 107 |
- `TAVILY_API_KEY` (for web search)
|
| 108 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
Built with [LangGraph](https://langchain-ai.github.io/langgraph/) and [Gradio](https://gradio.app)
|
| 110 |
-
"""
|
| 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)
|