FeelMate / app.py
rahulhans's picture
Update app.py
593b07c verified
import gradio as gr
from chain import get_feelmate_chain
# Load the LangChain-powered FeelMate
feelmate_chain = get_feelmate_chain()
def chat_with_feelmate(user_message, history):
if history is None:
history = []
if not user_message.strip():
return "Please share something with me πŸ’¬", history
# Add user input to memory and get the response
response = feelmate_chain.predict(input=user_message)
# Add the current conversation to the history
history.append((user_message, response))
# Limit the number of history items if it's too long
history = history[-10:] # Keep last 10 exchanges
return response.strip(), history
# Gradio interface with memory to display history
iface = gr.Interface(
fn=chat_with_feelmate,
inputs=[gr.Textbox(lines=3, placeholder="Tell me how you're feeling today..."), gr.State()],
outputs=[gr.Textbox(), gr.State()],
title="πŸ«‚ FeelMate - Your Emotional Support Buddy",
description="No judgment. Just kindness, understanding, and a little light. πŸ’œ",
live=True
)
if __name__ == "__main__":
iface.launch()