Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,15 +1,29 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
-
def my_function(input1, input2):
|
| 4 |
# Process the inputs (e.g., concatenate strings, perform calculations)
|
| 5 |
-
result = f"You entered: {input1} and {input2}"
|
| 6 |
-
return result
|
| 7 |
|
| 8 |
# Create the Gradio interface
|
| 9 |
interface = gr.Interface(fn=my_function,
|
| 10 |
inputs=["text", "text"],
|
| 11 |
outputs="text",
|
| 12 |
-
title="
|
| 13 |
-
description="Enter
|
| 14 |
|
| 15 |
interface.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
pipe = pipeline("text-generation", model="shivanikerai/TinyLlama-1.1B-Chat-v1.0-seo-optimised-title-suggestion-v1.0")
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
def my_function(keywords, product_info):
|
| 7 |
+
B_SYS, E_SYS = "<<SYS>>", "<</SYS>>"
|
| 8 |
+
B_INST, E_INST = "[INST]", "[/INST]"
|
| 9 |
+
B_in, E_in = "[Product Details]", "[/Product Details]"
|
| 10 |
+
B_out, E_out = "[Suggested Titles]", "[/Suggested Titles]"
|
| 11 |
+
prompt = f"""{B_INST} {B_SYS} You are a helpful, respectful and honest assistant for ecommerce product title creation. {E_SYS}
|
| 12 |
+
Create a SEO optimized e-commerce product title for the keywords:{keywords.strip()}
|
| 13 |
+
{B_in}{product_info}{E_in}\n{E_INST}\n\n{B_out}"""
|
| 14 |
+
predictions = pipe(prompt)
|
| 15 |
+
output=((predictions[0]['generated_text']).split(B_out)[-1]).strip()
|
| 16 |
+
return (output)
|
| 17 |
|
|
|
|
| 18 |
# Process the inputs (e.g., concatenate strings, perform calculations)
|
| 19 |
+
# result = f"You entered: {input1} and {input2}"
|
| 20 |
+
# return result
|
| 21 |
|
| 22 |
# Create the Gradio interface
|
| 23 |
interface = gr.Interface(fn=my_function,
|
| 24 |
inputs=["text", "text"],
|
| 25 |
outputs="text",
|
| 26 |
+
title="SEO Optimised Title Suggestion",
|
| 27 |
+
description="Enter Keywords and Product Info:")
|
| 28 |
|
| 29 |
interface.launch()
|