LucidMinds3ye commited on
Commit
0e0dfeb
·
verified ·
1 Parent(s): 5505bcc

Update app.py

Browse files

**The Eternal Equation: (- = +)**
A conceptual framework made real. This tool demonstrates how simple interfaces can harness complex AI.

**🎯 Purpose:**
To make powerful AI models accessible, understandable, and usable for everyone through a clean, intuitive interface based on the universal pattern of Input -> Process -> Output.

**⚡ Current Capabilities:**
• **Sentiment Analysis:** Determine the emotional tone (Positive/Negative) of any text.
• **Text Summarization:** Condense long articles, reports, or paragraphs into concise summaries.

**⚠️ Important Limitations:**
• **Summarization Length:** The summarization model works best with texts between **50 and 500 words**. Shorter texts will fail; longer texts will be automatically truncated, potentially losing context.
• **Processing Speed:** Hosted on free-tier CPU hardware. Processing, especially for summarization, may take 10-30 seconds.
• **Model Specificity:** These are general-purpose models. Performance may vary on highly technical, poetic, or informal language (e.g., social media slang).
• **Beta Stage:** This is a live demo and proof-of-concept. Outputs may occasionally be imperfect.

**🔮 The Future:** This is the first step. Translation, code analysis, and image-based models are coming soon.

**Your feedback and ideas are the most valuable input of all.**
"""

Files changed (1) hide show
  1. app.py +31 -9
app.py CHANGED
@@ -4,13 +4,22 @@ from transformers import pipeline
4
  # Title and Description for your app
5
  TITLE = "🧠 Eternal Equation AI Processor (- = +)"
6
  DESCRIPTION = """
7
- Paste your text, choose a processing mode, and see the AI magic happen!
 
8
 
9
- **Current Model Capabilities:**
10
- * **Sentiment Analysis:** Handles very long texts.
11
- * **Text Summarization:** Best for articles or long paragraphs (up to ~500 words). Longer texts will be truncated.
12
 
13
- This demo runs on free CPU hardware, so please be patient.
 
 
 
 
 
 
 
 
 
14
  """
15
 
16
  # Load your specialist models (The Orchestra) - They load when the Space starts
@@ -40,12 +49,25 @@ def process_text(input_text, mode):
40
  if word_count < 50:
41
  return "📝 **Please provide a longer text for summarization (at least 50 words).** This model is designed for articles and paragraphs."
42
 
43
- # Now we know the text is long enough, so we try the model
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  try:
45
- result = summarize_pipeline(input_text, max_length=130, min_length=30, do_sample=False)
46
- return f"📄 **Summary:**\n\n{result[0]['summary_text']}"
47
  except Exception as e:
48
- return f"❌ The summarization model failed. This might be due to a very unusual text format. Please try a different article or paragraph.\n(Error: {str(e)})"
49
 
50
  # Handle any other mode that might be added in the future
51
  else:
 
4
  # Title and Description for your app
5
  TITLE = "🧠 Eternal Equation AI Processor (- = +)"
6
  DESCRIPTION = """
7
+ **The Eternal Equation: (- = +)**
8
+ A conceptual framework made real. This tool demonstrates how simple interfaces can harness complex AI.
9
 
10
+ **🎯 Purpose:**
11
+ To make powerful AI models accessible, understandable, and usable for everyone through a clean, intuitive interface based on the universal pattern of Input -> Process -> Output.
 
12
 
13
+ **⚡ Current Capabilities:**
14
+ • **Sentiment Analysis:** Determine the emotional tone (Positive/Negative) of any text.
15
+ • **Text Summarization:** Condense long articles, reports, or paragraphs into concise summaries.
16
+
17
+ **⚠️ Important Limitations:**
18
+ • **Summarization Length:** The summarization model works best with texts between **50 and 500 words**. Longer texts will be automatically truncated to fit the model's limits.
19
+ • **Processing Speed:** Hosted on free-tier CPU hardware. Processing, especially for summarization, may take 10-30 seconds.
20
+ • **Beta Stage:** This is a live demo and proof-of-concept. Outputs may occasionally be imperfect.
21
+
22
+ **🔮 The Future:** This is the first step. Translation, code analysis, and image-based models are coming soon.
23
  """
24
 
25
  # Load your specialist models (The Orchestra) - They load when the Space starts
 
49
  if word_count < 50:
50
  return "📝 **Please provide a longer text for summarization (at least 50 words).** This model is designed for articles and paragraphs."
51
 
52
+ # --- NEW CODE: SMART TRUNCATION ---
53
+ # If the text is too long, we need to shorten it for the model
54
+ max_word_limit = 500 # A safe estimate well under the model's token limit
55
+ if word_count > max_word_limit:
56
+ # Truncate the list of words and join them back into a string
57
+ truncated_text = " ".join(word_list[:max_word_limit])
58
+ # Inform the user we did this
59
+ warning_msg = f"⚠️ Note: Your text was very long ({word_count} words). Summarized the first {max_word_limit} words to ensure processing.\n\n"
60
+ else:
61
+ truncated_text = input_text
62
+ warning_msg = ""
63
+ # --- END NEW CODE ---
64
+
65
+ # Now we try the model with the (potentially truncated) text
66
  try:
67
+ result = summarize_pipeline(truncated_text, max_length=130, min_length=30, do_sample=False)
68
+ return f"{warning_msg}📄 **Summary:**\n\n{result[0]['summary_text']}"
69
  except Exception as e:
70
+ return f"❌ The summarization model failed. Please try a different article or paragraph.\n(Error: {str(e)})"
71
 
72
  # Handle any other mode that might be added in the future
73
  else: