joshuarebo commited on
Commit
166fec7
·
verified ·
1 Parent(s): 5a8fa19

update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -2
app.py CHANGED
@@ -54,9 +54,18 @@ image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_co
54
  with open("prompts.yaml", 'r') as stream:
55
  prompt_templates = yaml.safe_load(stream)
56
 
 
57
  @tool
58
  def summarize_text(content: str) -> str:
59
- """A tool to summarize long passages of text."""
 
 
 
 
 
 
 
 
60
  try:
61
  from transformers import pipeline
62
  summarizer = pipeline("summarization")
@@ -65,9 +74,18 @@ def summarize_text(content: str) -> str:
65
  except Exception as e:
66
  return f"Error processing summary: {str(e)}"
67
 
 
68
  @tool
69
  def analyze_sentiment(text: str) -> str:
70
- """A tool to perform basic sentiment analysis."""
 
 
 
 
 
 
 
 
71
  from textblob import TextBlob
72
  sentiment_score = TextBlob(text).sentiment.polarity
73
  if sentiment_score > 0:
@@ -77,6 +95,7 @@ def analyze_sentiment(text: str) -> str:
77
  else:
78
  return "Neutral sentiment detected."
79
 
 
80
  # Ensure image generation is included
81
  tools_list = [final_answer, image_generation_tool, summarize_text, analyze_sentiment, get_current_time_in_timezone]
82
 
 
54
  with open("prompts.yaml", 'r') as stream:
55
  prompt_templates = yaml.safe_load(stream)
56
 
57
+
58
  @tool
59
  def summarize_text(content: str) -> str:
60
+ """
61
+ Summarizes a given text.
62
+
63
+ Args:
64
+ content (str): The text content that needs summarization.
65
+
66
+ Returns:
67
+ str: A summarized version of the input text.
68
+ """
69
  try:
70
  from transformers import pipeline
71
  summarizer = pipeline("summarization")
 
74
  except Exception as e:
75
  return f"Error processing summary: {str(e)}"
76
 
77
+
78
  @tool
79
  def analyze_sentiment(text: str) -> str:
80
+ """
81
+ Analyzes the sentiment of a given text.
82
+
83
+ Args:
84
+ text (str): The input text for sentiment analysis.
85
+
86
+ Returns:
87
+ str: A sentiment classification ('Positive', 'Negative', or 'Neutral').
88
+ """
89
  from textblob import TextBlob
90
  sentiment_score = TextBlob(text).sentiment.polarity
91
  if sentiment_score > 0:
 
95
  else:
96
  return "Neutral sentiment detected."
97
 
98
+
99
  # Ensure image generation is included
100
  tools_list = [final_answer, image_generation_tool, summarize_text, analyze_sentiment, get_current_time_in_timezone]
101