Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -8,58 +8,58 @@ from tools.final_answer import FinalAnswerTool
|
|
8 |
from Gradio_UI import GradioUI
|
9 |
|
10 |
|
11 |
-
import os
|
12 |
-
from huggingface_hub import InferenceClient
|
13 |
-
|
14 |
-
HF_API_KEY = os.getenv("HF_API_KEY")
|
15 |
-
if not HF_API_KEY:
|
16 |
-
|
17 |
-
|
18 |
-
client = InferenceClient(token=HF_API_KEY)
|
19 |
-
|
20 |
-
response = client.text_generation("Hello!", model="Qwen/Qwen2.5-Coder-32B-Instruct")
|
21 |
-
print("HF_API_KEY", HF_API_KEY)
|
22 |
-
print(response)
|
23 |
-
|
24 |
-
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
25 |
-
@tool
|
26 |
-
def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
@tool
|
36 |
-
def get_current_time_in_timezone(timezone: str) -> str:
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
final_answer = FinalAnswerTool()
|
52 |
|
53 |
# If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
|
54 |
model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
|
55 |
|
56 |
model = HfApiModel(
|
57 |
-
max_tokens=2096,
|
58 |
-
temperature=0.5,
|
59 |
#model_id='Qwen/Qwen2.5-Coder-32B-Instruct',# it is possible that this model may be overloaded
|
60 |
#model_id='moonshotai/Moonlight-16B-A3B-Instruct',
|
61 |
model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud',
|
62 |
-
custom_role_conversions=None,
|
63 |
)
|
64 |
|
65 |
|
@@ -69,17 +69,19 @@ image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_co
|
|
69 |
with open("prompts.yaml", 'r') as stream:
|
70 |
prompt_templates = yaml.safe_load(stream)
|
71 |
|
72 |
-
agent = CodeAgent(
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
)
|
83 |
-
|
84 |
-
|
85 |
-
|
|
|
|
|
|
8 |
from Gradio_UI import GradioUI
|
9 |
|
10 |
|
11 |
+
# import os
|
12 |
+
# from huggingface_hub import InferenceClient
|
13 |
+
|
14 |
+
# HF_API_KEY = os.getenv("HF_API_KEY")
|
15 |
+
# if not HF_API_KEY:
|
16 |
+
# raise ValueError("HF_API_KEY is not set. Please add it as a secret in your Hugging Face Space settings.")
|
17 |
+
|
18 |
+
# client = InferenceClient(token=HF_API_KEY)
|
19 |
+
|
20 |
+
# response = client.text_generation("Hello!", model="Qwen/Qwen2.5-Coder-32B-Instruct")
|
21 |
+
# print("HF_API_KEY", HF_API_KEY)
|
22 |
+
# print(response)
|
23 |
+
|
24 |
+
# # Below is an example of a tool that does nothing. Amaze us with your creativity !
|
25 |
+
# @tool
|
26 |
+
# def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
|
27 |
+
# #Keep this format for the description / args / args description but feel free to modify the tool
|
28 |
+
# """A tool that does nothing yet
|
29 |
+
# Args:
|
30 |
+
# arg1: the first argument
|
31 |
+
# arg2: the second argument
|
32 |
+
# """
|
33 |
+
# return "What magic will you build ?"
|
34 |
+
|
35 |
+
# @tool
|
36 |
+
# def get_current_time_in_timezone(timezone: str) -> str:
|
37 |
+
# """A tool that fetches the current local time in a specified timezone.
|
38 |
+
# Args:
|
39 |
+
# timezone: A string representing a valid timezone (e.g., 'America/New_York').
|
40 |
+
# """
|
41 |
+
# try:
|
42 |
+
# # Create timezone object
|
43 |
+
# tz = pytz.timezone(timezone)
|
44 |
+
# # Get current time in that timezone
|
45 |
+
# local_time = datetime.datetime.now(tz).strftime("%Y-%m-%d %H:%M:%S")
|
46 |
+
# return f"The current local time in {timezone} is: {local_time}"
|
47 |
+
# except Exception as e:
|
48 |
+
# return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
49 |
+
|
50 |
+
|
51 |
+
# final_answer = FinalAnswerTool()
|
52 |
|
53 |
# If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
|
54 |
model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
|
55 |
|
56 |
model = HfApiModel(
|
57 |
+
# max_tokens=2096,
|
58 |
+
# temperature=0.5,
|
59 |
#model_id='Qwen/Qwen2.5-Coder-32B-Instruct',# it is possible that this model may be overloaded
|
60 |
#model_id='moonshotai/Moonlight-16B-A3B-Instruct',
|
61 |
model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud',
|
62 |
+
# custom_role_conversions=None,
|
63 |
)
|
64 |
|
65 |
|
|
|
69 |
with open("prompts.yaml", 'r') as stream:
|
70 |
prompt_templates = yaml.safe_load(stream)
|
71 |
|
72 |
+
# agent = CodeAgent(
|
73 |
+
# model=model,
|
74 |
+
# tools=[final_answer], ## add your tools here (don't remove final answer)
|
75 |
+
# max_steps=6,
|
76 |
+
# verbosity_level=1,
|
77 |
+
# grammar=None,
|
78 |
+
# planning_interval=None,
|
79 |
+
# name=None,
|
80 |
+
# description=None,
|
81 |
+
# prompt_templates=prompt_templates
|
82 |
+
# )
|
83 |
+
|
84 |
+
agent2 = CodeAgent(tools=[DuckDuckGoSearchTool()], model=model)
|
85 |
+
|
86 |
+
|
87 |
+
GradioUI(agent2).launch()
|