AgentNaser commited on
Commit
c926290
·
verified ·
1 Parent(s): 0bbfd20

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -38
app.py CHANGED
@@ -1,5 +1,3 @@
1
- from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel, load_tool, tool
2
- import datetime
3
  import requests
4
  import pytz
5
  import yaml
@@ -21,13 +19,6 @@ def summarize_text(text: str, max_length: int = 130) -> str:
21
  data = {
22
  "inputs": text,
23
  "parameters": {"max_length": max_length}
24
- }
25
- response = requests.post(API_URL, headers=headers, json=data)
26
- response.raise_for_status()
27
- summary = response.json()[0]['summary_text']
28
- return f"الملخص: {summary}"
29
- except Exception as e:
30
- return f"خطأ في التلخيص: {str(e)}"
31
 
32
  @tool
33
  def get_current_time_in_timezone(timezone: str) -> str:
@@ -39,26 +30,6 @@ def get_current_time_in_timezone(timezone: str) -> str:
39
  try:
40
  tz = pytz.timezone(timezone)
41
  local_time = datetime.datetime.now(tz).strftime("%Y-%m-%d %H:%M:%S")
42
- return f"The current local time in {timezone} is: {local_time}"
43
- except Exception as e:
44
- return f"Error fetching time for timezone '{timezone}': {str(e)}"
45
-
46
- final_answer = FinalAnswerTool()
47
- model = HfApiModel(
48
- max_tokens=2096,
49
- temperature=0.5,
50
- model_id='Qwen/Qwen2.5-Coder-32B-Instruct',
51
- custom_role_conversions=None,
52
- )
53
-
54
- image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
55
-
56
- with open("prompts.yaml", 'r') as stream:
57
- prompt_templates = yaml.safe_load(stream)
58
-
59
- agent = CodeAgent(
60
- model=model,
61
- tools=[
62
  final_answer,
63
  DuckDuckGoSearchTool(),
64
  image_generation_tool,
@@ -66,12 +37,4 @@ agent = CodeAgent(
66
  get_current_time_in_timezone # تأكد من إضافتها هنا
67
  ],
68
  max_steps=6,
69
- verbosity_level=1,
70
- grammar=None,
71
- planning_interval=None,
72
- name=None,
73
- description=None,
74
- prompt_templates=prompt_templates
75
- )
76
-
77
- GradioUI(agent).launch()
 
 
 
1
  import requests
2
  import pytz
3
  import yaml
 
19
  data = {
20
  "inputs": text,
21
  "parameters": {"max_length": max_length}
 
 
 
 
 
 
 
22
 
23
  @tool
24
  def get_current_time_in_timezone(timezone: str) -> str:
 
30
  try:
31
  tz = pytz.timezone(timezone)
32
  local_time = datetime.datetime.now(tz).strftime("%Y-%m-%d %H:%M:%S")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  final_answer,
34
  DuckDuckGoSearchTool(),
35
  image_generation_tool,
 
37
  get_current_time_in_timezone # تأكد من إضافتها هنا
38
  ],
39
  max_steps=6,
40
+ verbosity_level=1,