MotiMeter / moti_chat.py
Jiaaaaaaax's picture
Create moti_chat.py
b563417 verified
raw
history blame
1.16 kB
import streamlit as st
import openai
from datetime import datetime
def show_moti_chat():
st.title("Moti Chat - AI Therapist")
# Initialize chat history
if "messages" not in st.session_state:
st.session_state.messages = []
# Display chat history
for message in st.session_state.messages:
with st.chat_message(message["role"]):
st.markdown(message["content"])
# Chat input
if prompt := st.chat_input("What's on your mind?"):
# Add user message to chat history
st.session_state.messages.append({"role": "user", "content": prompt})
# Display user message
with st.chat_message("user"):
st.markdown(prompt)
# Generate AI response
with st.chat_message("assistant"):
response = generate_response(prompt)
st.markdown(response)
# Add AI response to chat history
st.session_state.messages.append({"role": "assistant", "content": response})
def generate_response(prompt):
# Implement your OpenAI API call here using the MI prompts
# Return the response
pass