Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,13 +1,14 @@
|
|
| 1 |
-
from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
|
| 2 |
import datetime
|
| 3 |
import requests
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
|
|
|
| 7 |
|
| 8 |
from Gradio_UI import GradioUI
|
| 9 |
|
| 10 |
-
# Below is an example of a tool that does nothing. Amaze us with your creativity
|
| 11 |
@tool
|
| 12 |
def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
|
| 13 |
#Keep this format for the description / args / args description but feel free to modify the tool
|
|
@@ -16,7 +17,7 @@ def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return
|
|
| 16 |
arg1: the first argument
|
| 17 |
arg2: the second argument
|
| 18 |
"""
|
| 19 |
-
return "What magic will you build
|
| 20 |
|
| 21 |
@tool
|
| 22 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
@@ -36,17 +37,19 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
| 36 |
|
| 37 |
final_answer = FinalAnswerTool()
|
| 38 |
|
| 39 |
-
#
|
| 40 |
-
# model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
|
| 41 |
|
|
|
|
|
|
|
|
|
|
| 42 |
model = HfApiModel(
|
| 43 |
-
max_tokens=2096,
|
| 44 |
-
temperature=0.5,
|
| 45 |
-
model_id='meta-llama/Llama-3.3-70B-Instruct'
|
| 46 |
-
custom_role_conversions=None,
|
|
|
|
| 47 |
)
|
| 48 |
|
| 49 |
-
|
| 50 |
# Import tool from Hub
|
| 51 |
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
| 52 |
|
|
@@ -66,4 +69,4 @@ agent = CodeAgent(
|
|
| 66 |
)
|
| 67 |
|
| 68 |
|
| 69 |
-
GradioUI(agent).launch()
|
|
|
|
| 1 |
+
from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel, load_tool, tool
|
| 2 |
import datetime
|
| 3 |
import requests
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
| 7 |
+
import os
|
| 8 |
|
| 9 |
from Gradio_UI import GradioUI
|
| 10 |
|
| 11 |
+
# Below is an example of a tool that does nothing. Amaze us with your creativity!
|
| 12 |
@tool
|
| 13 |
def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
|
| 14 |
#Keep this format for the description / args / args description but feel free to modify the tool
|
|
|
|
| 17 |
arg1: the first argument
|
| 18 |
arg2: the second argument
|
| 19 |
"""
|
| 20 |
+
return "What magic will you build?"
|
| 21 |
|
| 22 |
@tool
|
| 23 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 37 |
|
| 38 |
final_answer = FinalAnswerTool()
|
| 39 |
|
| 40 |
+
# Load Hugging Face Token from environment variable
|
|
|
|
| 41 |
|
| 42 |
+
HF_TOKEN = os.getenv("superSecretKey")
|
| 43 |
+
|
| 44 |
+
# Initialize HfApiModel with token
|
| 45 |
model = HfApiModel(
|
| 46 |
+
max_tokens=2096,
|
| 47 |
+
temperature=0.5,
|
| 48 |
+
model_id='meta-llama/Llama-3.3-70B-Instruct',
|
| 49 |
+
custom_role_conversions=None,
|
| 50 |
+
huggingface_token=HF_TOKEN, # Pass the token
|
| 51 |
)
|
| 52 |
|
|
|
|
| 53 |
# Import tool from Hub
|
| 54 |
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
| 55 |
|
|
|
|
| 69 |
)
|
| 70 |
|
| 71 |
|
| 72 |
+
GradioUI(agent).launch()
|