Spaces:
Sleeping
Sleeping
Update app, requirements, and retriever
Browse files- app.py +12 -2
- requirements.txt +7 -4
- retriever.py +4 -1
app.py
CHANGED
|
@@ -1,13 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import random
|
| 3 |
-
from smolagents import GradioUI, CodeAgent
|
|
|
|
| 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 =
|
| 11 |
|
| 12 |
# Initialize the web search tool
|
| 13 |
search_tool = DuckDuckGoSearchTool()
|
|
|
|
| 1 |
+
# 兼容 ZeroGPU 啟動檢查
|
| 2 |
+
try:
|
| 3 |
+
import spaces
|
| 4 |
+
@spaces.GPU
|
| 5 |
+
def _zero_gpu_init():
|
| 6 |
+
pass
|
| 7 |
+
except ImportError:
|
| 8 |
+
pass
|
| 9 |
+
|
| 10 |
import gradio as gr
|
| 11 |
import random
|
| 12 |
+
from smolagents import GradioUI, CodeAgent
|
| 13 |
+
from smolagents import InferenceClientModel
|
| 14 |
|
| 15 |
# Import our custom tools from their modules
|
| 16 |
from tools import DuckDuckGoSearchTool, WeatherInfoTool, HubStatsTool
|
| 17 |
from retriever import load_guest_dataset
|
| 18 |
|
| 19 |
# Initialize the Hugging Face model
|
| 20 |
+
model = InferenceClientModel(model_id="Qwen/Qwen2.5-Coder-32B-Instruct")
|
| 21 |
|
| 22 |
# Initialize the web search tool
|
| 23 |
search_tool = DuckDuckGoSearchTool()
|
requirements.txt
CHANGED
|
@@ -1,5 +1,8 @@
|
|
| 1 |
-
datasets
|
| 2 |
-
smolagents
|
| 3 |
-
langchain-community
|
|
|
|
| 4 |
rank_bm25
|
| 5 |
-
duckduckgo-search
|
|
|
|
|
|
|
|
|
| 1 |
+
datasets
|
| 2 |
+
smolagents
|
| 3 |
+
langchain-community
|
| 4 |
+
langchain
|
| 5 |
rank_bm25
|
| 6 |
+
duckduckgo-search
|
| 7 |
+
gradio
|
| 8 |
+
ddgs
|
retriever.py
CHANGED
|
@@ -1,6 +1,9 @@
|
|
| 1 |
from smolagents import Tool
|
| 2 |
from langchain_community.retrievers import BM25Retriever
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
| 4 |
import datasets
|
| 5 |
|
| 6 |
|
|
|
|
| 1 |
from smolagents import Tool
|
| 2 |
from langchain_community.retrievers import BM25Retriever
|
| 3 |
+
try:
|
| 4 |
+
from langchain_core.documents import Document
|
| 5 |
+
except ImportError:
|
| 6 |
+
from langchain.docstore.document import Document
|
| 7 |
import datasets
|
| 8 |
|
| 9 |
|