sayed99 commited on
Commit
8c01e97
·
verified ·
1 Parent(s): 0e67eaf

Upload tool

Browse files
Files changed (3) hide show
  1. app.py +6 -0
  2. requirements.txt +1 -0
  3. tool.py +30 -0
app.py ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ from smolagents import launch_gradio_demo
2
+ from tool import SimpleTool
3
+
4
+ tool = SimpleTool()
5
+
6
+ launch_gradio_demo(tool)
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ smolagents
tool.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from smolagents import Tool
2
+ from typing import Any, Optional
3
+
4
+ class SimpleTool(Tool):
5
+ name = "get_user_background"
6
+ description = "Retrieves a user's background information based on their name, \nproviding a personalized experience."
7
+ inputs = {"name":{"type":"string","description":"The name of the person to look up."}}
8
+ output_type = "string"
9
+
10
+ def forward(self, name: str) -> str:
11
+ """
12
+ Retrieves a user's background information based on their name,
13
+ providing a personalized experience.
14
+
15
+ Args:
16
+ name: The name of the person to look up.
17
+
18
+ Returns:
19
+ str: A brief description of the user's background and interests,
20
+ or a default message if the user is not found.
21
+ """
22
+ database = {
23
+ "sayed": "Sayed is a data scientist in his final year of engineering. He is not a dog person. He is eager to learn about AI agents, LLMs, Azure Cloud, and computer vision topics like tracking.",
24
+ "sara": "Sara is a medical student specializing in neurology. She is passionate about brain-computer interfaces, neuroimaging, and understanding cognitive disorders. She loves cats.",
25
+ "ahmed": "Ahmed is an economist focusing on financial markets and behavioral economics. He enjoys analyzing stock trends, economic policies, and market predictions using data-driven methods."
26
+ }
27
+
28
+
29
+ name_lower = name.lower()
30
+ return database.get(name_lower, f"Hello, {name.title()}! I don't have details about you yet, but I'd love to learn more.")