Spaces:
Runtime error
Runtime error
File size: 754 Bytes
b6a2a7a 022b51f b6a2a7a 022b51f b6a2a7a 022b51f b6a2a7a 022b51f b6a2a7a 022b51f b6a2a7a 022b51f | 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 small, free conversational model
chatbot = pipeline("text-generation", model="microsoft/DialoGPT-small")
def reply(message, history=[]):
prompt = f"You are a helpful financial advisor.\nUser: {message}\nBot:"
output = chatbot(prompt, max_new_tokens=60)[0]['generated_text']
response = output.split("Bot:")[-1].strip()
history.append((message, response))
return history, history
with gr.Blocks() as demo:
gr.Markdown("## 💸 Ask your Financial Advisor Bot")
chatbot_ui = gr.Chatbot()
msg = gr.Textbox(label="Type your question about money, investing, etc.")
state = gr.State([])
msg.submit(reply, [msg, state], [chatbot_ui, state])
demo.launch()
|