Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -3,20 +3,21 @@ import datetime
|
|
3 |
import requests
|
4 |
import pytz
|
5 |
import yaml
|
6 |
-
import os
|
7 |
from tools.final_answer import FinalAnswerTool
|
8 |
from Gradio_UI import GradioUI
|
9 |
|
10 |
@tool
|
11 |
def summarize_text(text: str, max_length: int = 130) -> str:
|
12 |
"""تلخيص النصوص باستخدام نموذج BART من Hugging Face
|
|
|
13 |
Args:
|
14 |
text: النص الأصلي المراد تلخيصه
|
15 |
max_length: الحد الأقصى لطول الملخص (افتراضي: 130 كلمة)
|
16 |
"""
|
17 |
try:
|
18 |
API_URL = "https://api-inference.huggingface.co/models/facebook/bart-large-cnn"
|
19 |
-
headers = {"Authorization": f"Bearer {os.environ['HF_TOKEN']}"}
|
20 |
data = {
|
21 |
"inputs": text,
|
22 |
"parameters": {"max_length": max_length}
|
@@ -30,7 +31,11 @@ def summarize_text(text: str, max_length: int = 130) -> str:
|
|
30 |
|
31 |
@tool
|
32 |
def get_current_time_in_timezone(timezone: str) -> str:
|
33 |
-
"""أداة لجلب الوقت الحالي في منطقة زمنية
|
|
|
|
|
|
|
|
|
34 |
try:
|
35 |
tz = pytz.timezone(timezone)
|
36 |
local_time = datetime.datetime.now(tz).strftime("%Y-%m-%d %H:%M:%S")
|
@@ -57,7 +62,8 @@ agent = CodeAgent(
|
|
57 |
final_answer,
|
58 |
DuckDuckGoSearchTool(),
|
59 |
image_generation_tool,
|
60 |
-
summarize_text
|
|
|
61 |
],
|
62 |
max_steps=6,
|
63 |
verbosity_level=1,
|
|
|
3 |
import requests
|
4 |
import pytz
|
5 |
import yaml
|
6 |
+
import os
|
7 |
from tools.final_answer import FinalAnswerTool
|
8 |
from Gradio_UI import GradioUI
|
9 |
|
10 |
@tool
|
11 |
def summarize_text(text: str, max_length: int = 130) -> str:
|
12 |
"""تلخيص النصوص باستخدام نموذج BART من Hugging Face
|
13 |
+
|
14 |
Args:
|
15 |
text: النص الأصلي المراد تلخيصه
|
16 |
max_length: الحد الأقصى لطول الملخص (افتراضي: 130 كلمة)
|
17 |
"""
|
18 |
try:
|
19 |
API_URL = "https://api-inference.huggingface.co/models/facebook/bart-large-cnn"
|
20 |
+
headers = {"Authorization": f"Bearer {os.environ['HF_TOKEN']}"}
|
21 |
data = {
|
22 |
"inputs": text,
|
23 |
"parameters": {"max_length": max_length}
|
|
|
31 |
|
32 |
@tool
|
33 |
def get_current_time_in_timezone(timezone: str) -> str:
|
34 |
+
"""أداة لجلب الوقت الحالي في منطقة زمنية محددة.
|
35 |
+
|
36 |
+
Args:
|
37 |
+
timezone: سلسلة نصية تمثل منطقة زمنية صالحة (مثال: 'America/New_York').
|
38 |
+
"""
|
39 |
try:
|
40 |
tz = pytz.timezone(timezone)
|
41 |
local_time = datetime.datetime.now(tz).strftime("%Y-%m-%d %H:%M:%S")
|
|
|
62 |
final_answer,
|
63 |
DuckDuckGoSearchTool(),
|
64 |
image_generation_tool,
|
65 |
+
summarize_text,
|
66 |
+
get_current_time_in_timezone # تأكد من إضافتها هنا
|
67 |
],
|
68 |
max_steps=6,
|
69 |
verbosity_level=1,
|