copilot_test2 / app.py
ursbijju's picture
Update app.py
84d88b8 verified
raw
history blame contribute delete
768 Bytes
import gradio as gr
from transformers import pipeline
# Load a Hugging Face-hosted model for text generation
#generator = pipeline("text-generation", model="tiiuae/falcon-7b-instruct", max_new_tokens=200)
generator = pipeline("text-generation", model="microsoft/phi-2", max_new_tokens=200)
def chat_with_agent(user_input):
prompt = f"Q: {user_input}\nA:"
response = generator(prompt, do_sample=True, temperature=0.7)
return response[0]["generated_text"]
iface = gr.Interface(
fn=chat_with_agent,
inputs=gr.Textbox(lines=2, placeholder="Ask me anything..."),
outputs="text",
title="Hugging Face Agent",
description="Chat with an open-source language model hosted on Hugging Face."
)
if __name__ == "__main__":
iface.launch()