Spaces:
Sleeping
Sleeping
Aswinth
feat: Extract AI persona definition to `prompt.py` and remove pipeline initialization from `app.py`.
0ac3b14
| 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() | |