Jiaaaaaaax commited on
Commit
b563417
·
verified ·
1 Parent(s): 8747a63

Create moti_chat.py

Browse files
Files changed (1) hide show
  1. moti_chat.py +37 -0
moti_chat.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import openai
3
+ from datetime import datetime
4
+
5
+ def show_moti_chat():
6
+ st.title("Moti Chat - AI Therapist")
7
+
8
+ # Initialize chat history
9
+ if "messages" not in st.session_state:
10
+ st.session_state.messages = []
11
+
12
+ # Display chat history
13
+ for message in st.session_state.messages:
14
+ with st.chat_message(message["role"]):
15
+ st.markdown(message["content"])
16
+
17
+ # Chat input
18
+ if prompt := st.chat_input("What's on your mind?"):
19
+ # Add user message to chat history
20
+ st.session_state.messages.append({"role": "user", "content": prompt})
21
+
22
+ # Display user message
23
+ with st.chat_message("user"):
24
+ st.markdown(prompt)
25
+
26
+ # Generate AI response
27
+ with st.chat_message("assistant"):
28
+ response = generate_response(prompt)
29
+ st.markdown(response)
30
+
31
+ # Add AI response to chat history
32
+ st.session_state.messages.append({"role": "assistant", "content": response})
33
+
34
+ def generate_response(prompt):
35
+ # Implement your OpenAI API call here using the MI prompts
36
+ # Return the response
37
+ pass