testing_model / app.py
Aswinth
feat: Extract AI persona definition to `prompt.py` and remove pipeline initialization from `app.py`.
0ac3b14
raw
history blame contribute delete
422 Bytes
import gradio as gr
from transformers import pipeline
from prompt import PREAMBLE
pipe = pipeline(
"text-generation",
model="HuggingFaceH4/zephyr-7b-alpha"
)
def ask(prompt):
full_prompt = f"""
{PREAMBLE}
User question:
{prompt}
Answer:
"""
result = pipe(full_prompt, max_new_tokens=120)
return result[0]["generated_text"]
demo = gr.Interface(fn=ask, inputs="text", outputs="text")
demo.launch()