Update app.py
Browse files
app.py
CHANGED
|
@@ -1,18 +1,20 @@
|
|
| 1 |
from transformers import pipeline
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
-
#
|
| 5 |
-
generator = pipeline("
|
| 6 |
|
| 7 |
def interpret_prompt(prompt):
|
| 8 |
system_prompt = (
|
| 9 |
-
f"A user
|
| 10 |
-
"
|
| 11 |
-
"
|
|
|
|
| 12 |
)
|
| 13 |
|
| 14 |
-
output = generator(system_prompt,
|
| 15 |
|
|
|
|
| 16 |
if "Tip" in output:
|
| 17 |
parts = output.split("Tip", 1)
|
| 18 |
interpretations = parts[0].strip()
|
|
|
|
| 1 |
from transformers import pipeline
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
+
# Upgrade to FLAN-UL2 — more detailed, better reasoning
|
| 5 |
+
generator = pipeline("text2text-generation", model="google/flan-ul2")
|
| 6 |
|
| 7 |
def interpret_prompt(prompt):
|
| 8 |
system_prompt = (
|
| 9 |
+
f"A user gave this prompt to an AI: \"{prompt}\"\n"
|
| 10 |
+
"What are three different ways the AI could interpret this prompt?\n"
|
| 11 |
+
"Number each one.\n"
|
| 12 |
+
"Then give one short tip for how the user could improve their prompt."
|
| 13 |
)
|
| 14 |
|
| 15 |
+
output = generator(system_prompt, max_length=400)[0]['generated_text']
|
| 16 |
|
| 17 |
+
# Optional formatting fix
|
| 18 |
if "Tip" in output:
|
| 19 |
parts = output.split("Tip", 1)
|
| 20 |
interpretations = parts[0].strip()
|