Hugaida commited on
Commit
431bed3
·
1 Parent(s): ae7a494

initial commit

Browse files
.gradio/certificate.pem ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIFazCCA1OgAwIBAgIRAIIQz7DSQONZRGPgu2OCiwAwDQYJKoZIhvcNAQELBQAw
3
+ TzELMAkGA1UEBhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2Vh
4
+ cmNoIEdyb3VwMRUwEwYDVQQDEwxJU1JHIFJvb3QgWDEwHhcNMTUwNjA0MTEwNDM4
5
+ WhcNMzUwNjA0MTEwNDM4WjBPMQswCQYDVQQGEwJVUzEpMCcGA1UEChMgSW50ZXJu
6
+ ZXQgU2VjdXJpdHkgUmVzZWFyY2ggR3JvdXAxFTATBgNVBAMTDElTUkcgUm9vdCBY
7
+ MTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAK3oJHP0FDfzm54rVygc
8
+ h77ct984kIxuPOZXoHj3dcKi/vVqbvYATyjb3miGbESTtrFj/RQSa78f0uoxmyF+
9
+ 0TM8ukj13Xnfs7j/EvEhmkvBioZxaUpmZmyPfjxwv60pIgbz5MDmgK7iS4+3mX6U
10
+ A5/TR5d8mUgjU+g4rk8Kb4Mu0UlXjIB0ttov0DiNewNwIRt18jA8+o+u3dpjq+sW
11
+ T8KOEUt+zwvo/7V3LvSye0rgTBIlDHCNAymg4VMk7BPZ7hm/ELNKjD+Jo2FR3qyH
12
+ B5T0Y3HsLuJvW5iB4YlcNHlsdu87kGJ55tukmi8mxdAQ4Q7e2RCOFvu396j3x+UC
13
+ B5iPNgiV5+I3lg02dZ77DnKxHZu8A/lJBdiB3QW0KtZB6awBdpUKD9jf1b0SHzUv
14
+ KBds0pjBqAlkd25HN7rOrFleaJ1/ctaJxQZBKT5ZPt0m9STJEadao0xAH0ahm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KJ4EBs+lVDR3veyJm+kXQ99b21/+jh5Xos1AnX5iItreGCc=
31
+ -----END CERTIFICATE-----
.idea/.gitignore ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ # Default ignored files
2
+ /shelf/
3
+ /workspace.xml
4
+ # Editor-based HTTP Client requests
5
+ /httpRequests/
.idea/First_agent_template.iml ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="WEB_MODULE" version="4">
3
+ <component name="NewModuleRootManager">
4
+ <content url="file://$MODULE_DIR$">
5
+ <excludeFolder url="file://$MODULE_DIR$/.tmp" />
6
+ <excludeFolder url="file://$MODULE_DIR$/temp" />
7
+ <excludeFolder url="file://$MODULE_DIR$/tmp" />
8
+ </content>
9
+ <orderEntry type="jdk" jdkName="smolly" jdkType="Python SDK" />
10
+ <orderEntry type="sourceFolder" forTests="false" />
11
+ </component>
12
+ </module>
.idea/git_toolbox_blame.xml ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="GitToolBoxBlameSettings">
4
+ <option name="version" value="2" />
5
+ </component>
6
+ </project>
.idea/inspectionProfiles/Project_Default.xml ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ <component name="InspectionProjectProfileManager">
2
+ <profile version="1.0">
3
+ <option name="myName" value="Project Default" />
4
+ <inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
5
+ </profile>
6
+ </component>
.idea/jsLinters/eslint.xml ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="EslintConfiguration">
4
+ <option name="fix-on-save" value="true" />
5
+ </component>
6
+ </project>
.idea/misc.xml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="Black">
4
+ <option name="sdkName" value="smolly" />
5
+ </component>
6
+ <component name="ProjectRootManager" version="2" project-jdk-name="smolly" project-jdk-type="Python SDK" />
7
+ </project>
.idea/modules.xml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/First_agent_template.iml" filepath="$PROJECT_DIR$/.idea/First_agent_template.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
.idea/prettier.xml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="PrettierConfiguration">
4
+ <option name="myConfigurationMode" value="AUTOMATIC" />
5
+ <option name="myRunOnSave" value="true" />
6
+ <option name="myRunOnReformat" value="true" />
7
+ </component>
8
+ </project>
.idea/vcs.xml ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="" vcs="Git" />
5
+ </component>
6
+ </project>
__pycache__/Gradio_UI.cpython-312.pyc ADDED
Binary file (12.1 kB). View file
 
app.py CHANGED
@@ -1,22 +1,57 @@
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
14
- """A tool that does nothing yet
15
- Args:
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:
@@ -35,27 +70,28 @@ def get_current_time_in_timezone(timezone: str) -> str:
35
 
36
 
37
  final_answer = FinalAnswerTool()
 
 
38
 
39
  # 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:
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='Qwen/Qwen2.5-Coder-32B-Instruct',# it is possible that this model may be overloaded
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
 
53
  with open("prompts.yaml", 'r') as stream:
54
  prompt_templates = yaml.safe_load(stream)
55
-
56
  agent = CodeAgent(
57
  model=model,
58
- tools=[final_answer], ## add your tools here (don't remove final answer)
59
  max_steps=6,
60
  verbosity_level=1,
61
  grammar=None,
@@ -65,5 +101,4 @@ agent = CodeAgent(
65
  prompt_templates=prompt_templates
66
  )
67
 
68
-
69
- GradioUI(agent).launch()
 
 
1
  import datetime
2
+ import os
3
+
4
  import pytz
5
  import yaml
6
+ from smolagents import CodeAgent, HfApiModel, load_tool, tool
7
 
8
  from Gradio_UI import GradioUI
9
+ from tools.final_answer import FinalAnswerTool
10
+ from tools.visit_webpage import VisitWebpageTool
11
+ from tools.web_search import DuckDuckGoSearchTool
12
+
13
+ print(os.getenv("HF_TOKEN"))
14
 
15
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
16
+ import requests
17
+
18
+
19
  @tool
20
+ def get_my_ip_info() -> dict:
21
+ """Fetches the current user's public IP and provides geolocation info."""
22
+ try:
23
+ # Step 1: Get public IP
24
+ ip_response = requests.get("https://api64.ipify.org?format=json")
25
+ if ip_response.status_code != 200:
26
+ return {"error": "Error fetching public IP."}
27
+
28
+ user_ip = ip_response.json().get("ip", "Unknown IP")
29
+
30
+ # Step 2: Get geolocation details from IP-API
31
+ geo_response = requests.get(f"http://ip-api.com/json/{user_ip}")
32
+ if geo_response.status_code != 200:
33
+ return {"error": "Error fetching IP geolocation."}
34
+
35
+ data = geo_response.json()
36
+ if data.get("status") == "fail":
37
+ return {"error": f"IP lookup failed: {data.get('message', 'Invalid IP')}"}
38
+
39
+ # Step 3: Return formatted response
40
+ return {
41
+ "Public IP": data["query"],
42
+ "Country": f"{data['country']} ({data['countryCode']})",
43
+ "Region": f"{data['regionName']} ({data['region']})",
44
+ "City": data["city"],
45
+ "PROVIDER": data["isp"],
46
+ "PROVIDER_DETAILED": data.get("as", "N/A"),
47
+ "Latitude": data["lat"],
48
+ "Longitude": data["lon"],
49
+ "Timezone": data["timezone"]
50
+ }
51
+
52
+ except Exception as e:
53
+ return {"error": str(e)}
54
+
55
 
56
  @tool
57
  def get_current_time_in_timezone(timezone: str) -> str:
 
70
 
71
 
72
  final_answer = FinalAnswerTool()
73
+ search = DuckDuckGoSearchTool()
74
+ visit_webpage = VisitWebpageTool()
75
 
76
  # 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:
77
  # model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
78
 
79
  model = HfApiModel(
80
+ max_tokens=2096,
81
+ temperature=0.5,
82
+ model_id='Qwen/Qwen2.5-Coder-32B-Instruct', # it is possible that this model may be overloaded
83
+ custom_role_conversions=None,
84
  )
85
 
 
86
  # Import tool from Hub
87
  image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
88
 
89
  with open("prompts.yaml", 'r') as stream:
90
  prompt_templates = yaml.safe_load(stream)
91
+
92
  agent = CodeAgent(
93
  model=model,
94
+ tools=[final_answer, get_my_ip_info, get_current_time_in_timezone, image_generation_tool, search, visit_webpage],
95
  max_steps=6,
96
  verbosity_level=1,
97
  grammar=None,
 
101
  prompt_templates=prompt_templates
102
  )
103
 
104
+ GradioUI(agent).launch()
 
tools/__pycache__/final_answer.cpython-312.pyc ADDED
Binary file (1.04 kB). View file
 
tools/__pycache__/visit_webpage.cpython-312.pyc ADDED
Binary file (2.51 kB). View file
 
tools/__pycache__/web_search.cpython-312.pyc ADDED
Binary file (2.19 kB). View file