Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -9,14 +9,32 @@ 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
|
13 |
-
|
14 |
-
|
15 |
Args:
|
16 |
-
|
17 |
-
|
|
|
|
|
18 |
"""
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
@tool
|
22 |
def get_current_time_in_timezone(timezone: str) -> str:
|
@@ -55,7 +73,7 @@ with open("prompts.yaml", 'r') as 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,
|
|
|
9 |
|
10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
11 |
@tool
|
12 |
+
def analyze_text(text: str) -> str:
|
13 |
+
"""A tool that analyzes text for sentiment and provides a simple analysis.
|
14 |
+
|
15 |
Args:
|
16 |
+
text: The text to analyze for sentiment
|
17 |
+
|
18 |
+
Returns:
|
19 |
+
A string containing the sentiment analysis result
|
20 |
"""
|
21 |
+
# Simple sentiment analysis based on positive and negative word lists
|
22 |
+
positive_words = {'good', 'great', 'awesome', 'excellent', 'happy', 'love', 'wonderful', 'fantastic'}
|
23 |
+
negative_words = {'bad', 'terrible', 'awful', 'horrible', 'sad', 'hate', 'disappointing', 'poor'}
|
24 |
+
|
25 |
+
words = text.lower().split()
|
26 |
+
positive_count = sum(1 for word in words if word in positive_words)
|
27 |
+
negative_count = sum(1 for word in words if word in negative_words)
|
28 |
+
|
29 |
+
if positive_count > negative_count:
|
30 |
+
sentiment = "positive"
|
31 |
+
elif negative_count > positive_count:
|
32 |
+
sentiment = "negative"
|
33 |
+
else:
|
34 |
+
sentiment = "neutral"
|
35 |
+
|
36 |
+
return f"Text Analysis Results:\nSentiment: {sentiment}\nPositive words: {positive_count}\nNegative words: {negative_count}"
|
37 |
+
|
38 |
|
39 |
@tool
|
40 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
73 |
|
74 |
agent = CodeAgent(
|
75 |
model=model,
|
76 |
+
tools=[final_answer, analyze_text, get_current_time_in_timezone], ## add your tools here (don't remove final answer)
|
77 |
max_steps=6,
|
78 |
verbosity_level=1,
|
79 |
grammar=None,
|