Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -8,109 +8,109 @@ import random
|
|
8 |
|
9 |
from Gradio_UI import GradioUI
|
10 |
|
11 |
-
@tool
|
12 |
-
def futuristic_profession_predictor(name: str) -> str:
|
13 |
-
|
14 |
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
34 |
-
@tool
|
35 |
-
def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
@tool
|
46 |
-
def findLoveOfTwoNumbers(arg1:int, arg2:int)-> int:
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
55 |
-
@tool
|
56 |
-
def personIdentifier(arg1:str)-> int: #it's important to specify the return type
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
@tool
|
68 |
-
def get_current_time_in_timezone(timezone: str) -> str:
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
final_answer = FinalAnswerTool()
|
84 |
-
|
85 |
-
# 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:
|
86 |
-
# model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
|
87 |
-
|
88 |
-
model = HfApiModel(
|
89 |
-
max_tokens=2096,
|
90 |
-
temperature=0.5,
|
91 |
-
model_id='Qwen/Qwen2.5-Coder-32B-Instruct',# it is possible that this model may be overloaded
|
92 |
-
custom_role_conversions=None,
|
93 |
-
)
|
94 |
-
|
95 |
-
|
96 |
-
# Import tool from Hub
|
97 |
-
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
98 |
-
|
99 |
-
with open("prompts.yaml", 'r') as stream:
|
100 |
-
|
101 |
|
102 |
-
agent = CodeAgent(
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
)
|
114 |
|
115 |
from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel
|
116 |
|
|
|
8 |
|
9 |
from Gradio_UI import GradioUI
|
10 |
|
11 |
+
# @tool
|
12 |
+
# def futuristic_profession_predictor(name: str) -> str:
|
13 |
+
# """Predicts the person's profession in the year 2050 based on their name.
|
14 |
|
15 |
+
# Args:
|
16 |
+
# name: The name of the person.
|
17 |
+
# """
|
18 |
+
# professions = [
|
19 |
+
# "Quantum Data Alchemist",
|
20 |
+
# "Neural Interface Designer",
|
21 |
+
# "AI-Powered Philosopher",
|
22 |
+
# "Martian Agriculture Specialist",
|
23 |
+
# "Virtual Reality Psychologist",
|
24 |
+
# "Holographic Content Creator",
|
25 |
+
# "Synthetic Biology Engineer",
|
26 |
+
# "Time Travel Consultant",
|
27 |
+
# "Cybersecurity Shaman"
|
28 |
+
# ]
|
29 |
|
30 |
+
# prediction = random.choice(professions)
|
31 |
+
# return f"In the year 2050, {name} will be a {prediction}!"
|
32 |
+
|
33 |
+
# # Below is an example of a tool that does nothing. Amaze us with your creativity !
|
34 |
+
# @tool
|
35 |
+
# def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
|
36 |
+
# #Keep this format for the description / args / args description but feel free to modify the tool
|
37 |
+
# """A tool that does nothing yet
|
38 |
+
# Args:
|
39 |
+
# arg1: the first argument
|
40 |
+
# arg2: the second argument
|
41 |
+
# """
|
42 |
+
# return "What magic will you build ?"
|
43 |
+
|
44 |
+
|
45 |
+
# @tool
|
46 |
+
# def findLoveOfTwoNumbers(arg1:int, arg2:int)-> int:
|
47 |
+
# """ A tool that returns Love of two numbers
|
48 |
+
# Args:
|
49 |
+
# arg1: the first argument
|
50 |
+
# arg2: the second argument
|
51 |
+
# """
|
52 |
+
# return arg1+arg2 - 20
|
53 |
+
|
54 |
+
# # Below is an example of a tool that does nothing. Amaze us with your creativity !
|
55 |
+
# @tool
|
56 |
+
# def personIdentifier(arg1:str)-> int: #it's important to specify the return type
|
57 |
+
# #Keep this format for the description / args / args description but feel free to modify the tool
|
58 |
+
# """A Tool that identifies the person. For example,
|
59 |
+
# Task: Who is Ajit Kumar?
|
60 |
+
# Answer: He is a professor at Shiv Nadar University.
|
61 |
|
62 |
+
# Args:
|
63 |
+
# arg1: the first argument
|
64 |
+
# """
|
65 |
+
# return "He is a professor at Shiv Nadar University"
|
66 |
+
|
67 |
+
# @tool
|
68 |
+
# def get_current_time_in_timezone(timezone: str) -> str:
|
69 |
+
# """A tool that fetches the current local time in a specified timezone.
|
70 |
+
# Args:
|
71 |
+
# timezone: A string representing a valid timezone (e.g., 'America/New_York').
|
72 |
+
# """
|
73 |
+
# try:
|
74 |
+
# # Create timezone object
|
75 |
+
# tz = pytz.timezone(timezone)
|
76 |
+
# # Get current time in that timezone
|
77 |
+
# local_time = datetime.datetime.now(tz).strftime("%Y-%m-%d %H:%M:%S")
|
78 |
+
# return f"The current local time in {timezone} is: {local_time}"
|
79 |
+
# except Exception as e:
|
80 |
+
# return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
81 |
+
|
82 |
+
|
83 |
+
# final_answer = FinalAnswerTool()
|
84 |
+
|
85 |
+
# # 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:
|
86 |
+
# # model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
|
87 |
+
|
88 |
+
# model = HfApiModel(
|
89 |
+
# max_tokens=2096,
|
90 |
+
# temperature=0.5,
|
91 |
+
# model_id='Qwen/Qwen2.5-Coder-32B-Instruct',# it is possible that this model may be overloaded
|
92 |
+
# custom_role_conversions=None,
|
93 |
+
# )
|
94 |
+
|
95 |
+
|
96 |
+
# # Import tool from Hub
|
97 |
+
# image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
98 |
+
|
99 |
+
# with open("prompts.yaml", 'r') as stream:
|
100 |
+
# prompt_templates = yaml.safe_load(stream)
|
101 |
|
102 |
+
# agent = CodeAgent(
|
103 |
+
# model=model,
|
104 |
+
# #tools=[final_answer, image_generation_tool, DuckDuckGoSearchTool()], ## add your tools here (don't remove final answer)
|
105 |
+
# tools = [final_answer, futuristic_profession_predictor, personIdentifier, findLoveOfTwoNumbers],
|
106 |
+
# max_steps=20,
|
107 |
+
# verbosity_level=1,
|
108 |
+
# grammar=None,
|
109 |
+
# planning_interval=None,
|
110 |
+
# name=None,
|
111 |
+
# description=None,
|
112 |
+
# prompt_templates=prompt_templates
|
113 |
+
# )
|
114 |
|
115 |
from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel
|
116 |
|