ezgiturali commited on
Commit
ae956a1
·
verified ·
1 Parent(s): ae7a494

How It Works

Input: The user enters text (for example, "I'm so happy today!" or "Everything sucks.").

Analysis: The tool analyzes the emotional polarity of the text with the TextBlob library.

Output: The tool gives the user a personalized suggestion or feedback based on the emotional tone of the text.

Files changed (1) hide show
  1. app.py +17 -7
app.py CHANGED
@@ -7,16 +7,26 @@ 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:
 
7
 
8
  from Gradio_UI import GradioUI
9
 
10
+ from textblob import TextBlob
11
+
12
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
13
  @tool
14
+ def sentiment_analysis_and_reco(text: str) -> str:
15
+ '''
16
+ Analysis the text entered by the user and makes suggestions based on their emotional state.
17
+
18
  Args:
19
+ text: Text to be analyzed.
20
+ '''
21
+ blob = TextBlob(text)
22
+ polarity = blob.sentiment.polarity
23
+
24
+ if polarity > 0.2:
25
+ return 'Your text contains a positive feeling! 😊 Are you having a good day today? You can share this energy with others too!'
26
+ elif polarity < -0.2:
27
+ return "Your text has a negative feeling. 😔 Maybe you should take some time off or take care of yourself. Take a deep breath and show yourself some compassion."
28
+ else:
29
+ return "Your text has a neutral feeling. 🤔 Maybe you could express some deeper thoughts?"
30
 
31
  @tool
32
  def get_current_time_in_timezone(timezone: str) -> str: