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()