Spaces:
Sleeping
Sleeping
File size: 768 Bytes
3d24c5f 26c39a2 3d24c5f 84d88b8 3d24c5f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | 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() |