Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,4 @@
|
|
| 1 |
from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel, load_tool
|
| 2 |
-
from smolagents.tools import Tool
|
| 3 |
import datetime
|
| 4 |
import requests
|
| 5 |
import pytz
|
|
@@ -15,7 +14,7 @@ from transformers import pipeline
|
|
| 15 |
API_KEY = os.getenv("Weather_Token")
|
| 16 |
|
| 17 |
# -------------------- TOOL 1: Get Weather --------------------
|
| 18 |
-
@
|
| 19 |
def get_current_weather(place: str) -> str:
|
| 20 |
try:
|
| 21 |
url = "https://api.openweathermap.org/data/2.5/weather"
|
|
@@ -48,7 +47,7 @@ def get_current_weather(place: str) -> str:
|
|
| 48 |
|
| 49 |
|
| 50 |
# -------------------- TOOL 2: Get Time --------------------
|
| 51 |
-
@
|
| 52 |
def get_current_time_in_timezone(timezone: str) -> str:
|
| 53 |
try:
|
| 54 |
tz = pytz.timezone(timezone)
|
|
@@ -62,7 +61,7 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
| 62 |
embedding_model = SentenceTransformer("sentence-transformers/all-MiniLM-L6-v2")
|
| 63 |
qa_pipeline = pipeline("text2text-generation", model="google/flan-t5-base")
|
| 64 |
|
| 65 |
-
@
|
| 66 |
def document_qna_tool(pdf_path: str, question: str) -> str:
|
| 67 |
import traceback
|
| 68 |
|
|
|
|
| 1 |
from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel, load_tool
|
|
|
|
| 2 |
import datetime
|
| 3 |
import requests
|
| 4 |
import pytz
|
|
|
|
| 14 |
API_KEY = os.getenv("Weather_Token")
|
| 15 |
|
| 16 |
# -------------------- TOOL 1: Get Weather --------------------
|
| 17 |
+
@tool
|
| 18 |
def get_current_weather(place: str) -> str:
|
| 19 |
try:
|
| 20 |
url = "https://api.openweathermap.org/data/2.5/weather"
|
|
|
|
| 47 |
|
| 48 |
|
| 49 |
# -------------------- TOOL 2: Get Time --------------------
|
| 50 |
+
@tool
|
| 51 |
def get_current_time_in_timezone(timezone: str) -> str:
|
| 52 |
try:
|
| 53 |
tz = pytz.timezone(timezone)
|
|
|
|
| 61 |
embedding_model = SentenceTransformer("sentence-transformers/all-MiniLM-L6-v2")
|
| 62 |
qa_pipeline = pipeline("text2text-generation", model="google/flan-t5-base")
|
| 63 |
|
| 64 |
+
@tool
|
| 65 |
def document_qna_tool(pdf_path: str, question: str) -> str:
|
| 66 |
import traceback
|
| 67 |
|