likhonhfai commited on
Commit
373bb0a
·
verified ·
1 Parent(s): 3c6cec7

Fix TabbedInterface parameter to tab_names and ensure code runs

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -1,8 +1,10 @@
1
  import gradio as gr
2
 
3
  # Lists of positive and negative words for simple sentiment analysis
4
- positive_words = {"good", "great", "excellent", "awesome", "happy", "love", "like", "fantastic", "positive", "amazing", "wonderful", "best"}
5
- negative_words = {"bad", "terrible", "poor", "hate", "dislike", "awful", "sad", "negative", "horrible", "worst", "dreadful"}
 
 
6
 
7
  def analyze_sentiment(text):
8
  """Analyze sentiment by counting positive and negative words."""
@@ -34,7 +36,6 @@ def generate_code(task: str) -> str:
34
  for key, code in code_templates.items():
35
  if key in task_lower:
36
  return code
37
- # Fallback message when no template matches
38
  return "# Sorry, I can't generate code for that task yet."
39
 
40
  # Create separate interfaces for sentiment analysis and code generation
@@ -57,7 +58,7 @@ code_interface = gr.Interface(
57
  # Combine both interfaces into a tabbed interface for a better user experience
58
  demo = gr.TabbedInterface(
59
  [sentiment_interface, code_interface],
60
- tab_labels=["Sentiment Analysis", "Code Generation"],
61
  )
62
 
63
  if __name__ == "__main__":
 
1
  import gradio as gr
2
 
3
  # Lists of positive and negative words for simple sentiment analysis
4
+ positive_words = {"good", "great", "excellent", "awesome", "happy", "love",
5
+ "like", "fantastic", "positive", "amazing", "wonderful", "best"}
6
+ negative_words = {"bad", "terrible", "poor", "hate", "dislike", "awful",
7
+ "sad", "negative", "horrible", "worst", "dreadful"}
8
 
9
  def analyze_sentiment(text):
10
  """Analyze sentiment by counting positive and negative words."""
 
36
  for key, code in code_templates.items():
37
  if key in task_lower:
38
  return code
 
39
  return "# Sorry, I can't generate code for that task yet."
40
 
41
  # Create separate interfaces for sentiment analysis and code generation
 
58
  # Combine both interfaces into a tabbed interface for a better user experience
59
  demo = gr.TabbedInterface(
60
  [sentiment_interface, code_interface],
61
+ tab_names=["Sentiment Analysis", "Code Generation"],
62
  )
63
 
64
  if __name__ == "__main__":