Spaces:
Runtime error
Runtime error
Sushil Thapa
commited on
Commit
·
82566ad
1
Parent(s):
9570ac3
setup gemini code
Browse files- .gitignore +51 -0
- .python-version +1 -0
- app.py +14 -5
- main.py +6 -0
- pyproject.toml +16 -0
- retriever.py +1 -4
- tools.py +1 -1
- uv.lock +0 -0
.gitignore
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Byte-compiled / optimized / DLL files
|
| 2 |
+
__pycache__/
|
| 3 |
+
*.py[cod]
|
| 4 |
+
*$py.class
|
| 5 |
+
|
| 6 |
+
# C extensions
|
| 7 |
+
*.so
|
| 8 |
+
|
| 9 |
+
# Distribution / packaging
|
| 10 |
+
build/
|
| 11 |
+
dist/
|
| 12 |
+
*.egg-info/
|
| 13 |
+
.eggs/
|
| 14 |
+
|
| 15 |
+
# Virtual environments
|
| 16 |
+
.venv/
|
| 17 |
+
venv/
|
| 18 |
+
env/
|
| 19 |
+
ENV/
|
| 20 |
+
env.bak/
|
| 21 |
+
venv.bak/
|
| 22 |
+
|
| 23 |
+
# uv environment files
|
| 24 |
+
.uv/
|
| 25 |
+
|
| 26 |
+
# IDE/editor folders
|
| 27 |
+
.vscode/
|
| 28 |
+
.idea/
|
| 29 |
+
*.sublime-project
|
| 30 |
+
*.sublime-workspace
|
| 31 |
+
|
| 32 |
+
# Jupyter Notebook checkpoints
|
| 33 |
+
.ipynb_checkpoints/
|
| 34 |
+
|
| 35 |
+
# macOS files
|
| 36 |
+
.DS_Store
|
| 37 |
+
|
| 38 |
+
# Logs and local data
|
| 39 |
+
*.log
|
| 40 |
+
*.sqlite3
|
| 41 |
+
*.db
|
| 42 |
+
|
| 43 |
+
# Environment variables
|
| 44 |
+
.env
|
| 45 |
+
.env.*
|
| 46 |
+
.local.env
|
| 47 |
+
|
| 48 |
+
# GRPC plugin artifacts
|
| 49 |
+
*.proto.ts
|
| 50 |
+
|
| 51 |
+
.gradio/
|
.python-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
3.12
|
app.py
CHANGED
|
@@ -1,13 +1,22 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import random
|
| 3 |
-
|
|
|
|
| 4 |
|
| 5 |
# Import our custom tools from their modules
|
| 6 |
from tools import DuckDuckGoSearchTool, WeatherInfoTool, HubStatsTool
|
| 7 |
from retriever import load_guest_dataset
|
| 8 |
|
| 9 |
# Initialize the Hugging Face model
|
| 10 |
-
model = HfApiModel()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
# Initialize the web search tool
|
| 13 |
search_tool = DuckDuckGoSearchTool()
|
|
@@ -21,12 +30,12 @@ hub_stats_tool = HubStatsTool()
|
|
| 21 |
# Load the guest dataset and initialize the guest info tool
|
| 22 |
guest_info_tool = load_guest_dataset()
|
| 23 |
|
| 24 |
-
# Create Alfred with
|
| 25 |
alfred = CodeAgent(
|
| 26 |
tools=[guest_info_tool, weather_info_tool, hub_stats_tool, search_tool],
|
| 27 |
model=model,
|
| 28 |
-
add_base_tools=True, #
|
| 29 |
-
planning_interval=3 #
|
| 30 |
)
|
| 31 |
|
| 32 |
if __name__ == "__main__":
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import random
|
| 3 |
+
import os
|
| 4 |
+
from smolagents import GradioUI, CodeAgent, HfApiModel, LiteLLMModel, ApiModel
|
| 5 |
|
| 6 |
# Import our custom tools from their modules
|
| 7 |
from tools import DuckDuckGoSearchTool, WeatherInfoTool, HubStatsTool
|
| 8 |
from retriever import load_guest_dataset
|
| 9 |
|
| 10 |
# Initialize the Hugging Face model
|
| 11 |
+
#model = HfApiModel(model_id="Qwen/Qwen2.5-Coder-32B-Instruct")
|
| 12 |
+
# model = LiteLLMModel(model_id="gpt-4")
|
| 13 |
+
|
| 14 |
+
# Use Gemini 1.5 Flash - Long context (1M tokens) and cheap
|
| 15 |
+
model = LiteLLMModel(
|
| 16 |
+
model_id="gemini/gemini-1.5-flash",
|
| 17 |
+
api_key=os.getenv("GEMINI_API_KEY"),
|
| 18 |
+
max_tokens=2000 # Can be higher due to long context window
|
| 19 |
+
)
|
| 20 |
|
| 21 |
# Initialize the web search tool
|
| 22 |
search_tool = DuckDuckGoSearchTool()
|
|
|
|
| 30 |
# Load the guest dataset and initialize the guest info tool
|
| 31 |
guest_info_tool = load_guest_dataset()
|
| 32 |
|
| 33 |
+
# Create Alfred with full configuration - Gemini can handle more tokens
|
| 34 |
alfred = CodeAgent(
|
| 35 |
tools=[guest_info_tool, weather_info_tool, hub_stats_tool, search_tool],
|
| 36 |
model=model,
|
| 37 |
+
add_base_tools=True, # Re-enable base tools
|
| 38 |
+
planning_interval=3 # Re-enable planning with shorter interval
|
| 39 |
)
|
| 40 |
|
| 41 |
if __name__ == "__main__":
|
main.py
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
def main():
|
| 2 |
+
print("Hello from agentic-rag!")
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
if __name__ == "__main__":
|
| 6 |
+
main()
|
pyproject.toml
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[project]
|
| 2 |
+
name = "agentic-rag"
|
| 3 |
+
version = "0.1.0"
|
| 4 |
+
description = "Add your description here"
|
| 5 |
+
readme = "README.md"
|
| 6 |
+
requires-python = ">=3.12"
|
| 7 |
+
dependencies = [
|
| 8 |
+
"datasets>=3.6.0",
|
| 9 |
+
"duckduckgo-search>=8.0.4",
|
| 10 |
+
"gradio>=5.35.0",
|
| 11 |
+
"langchain-community>=0.3.26",
|
| 12 |
+
"openai>=1.93.0",
|
| 13 |
+
"rank-bm25>=0.2.2",
|
| 14 |
+
"smolagents[litellm]==1.18.0",
|
| 15 |
+
"together>=1.5.17",
|
| 16 |
+
]
|
retriever.py
CHANGED
|
@@ -47,7 +47,4 @@ def load_guest_dataset():
|
|
| 47 |
]
|
| 48 |
|
| 49 |
# Return the tool
|
| 50 |
-
return GuestInfoRetrieverTool(docs)
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
|
|
|
| 47 |
]
|
| 48 |
|
| 49 |
# Return the tool
|
| 50 |
+
return GuestInfoRetrieverTool(docs)
|
|
|
|
|
|
|
|
|
tools.py
CHANGED
|
@@ -5,7 +5,7 @@ from huggingface_hub import list_models
|
|
| 5 |
|
| 6 |
|
| 7 |
# Initialize the DuckDuckGo search tool
|
| 8 |
-
|
| 9 |
|
| 10 |
|
| 11 |
class WeatherInfoTool(Tool):
|
|
|
|
| 5 |
|
| 6 |
|
| 7 |
# Initialize the DuckDuckGo search tool
|
| 8 |
+
search_tool = DuckDuckGoSearchTool()
|
| 9 |
|
| 10 |
|
| 11 |
class WeatherInfoTool(Tool):
|
uv.lock
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|