Spaces:
Sleeping
Sleeping
Update page1.py
Browse files
page1.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
from PyPDF2 import PdfReader
|
| 3 |
from langchain_core.messages import HumanMessage, AIMessage
|
|
|
|
| 4 |
from langchain_google_genai import ChatGoogleGenerativeAI
|
| 5 |
from langchain.chains import LLMChain
|
| 6 |
from langchain.prompts import PromptTemplate
|
|
@@ -92,7 +93,15 @@ def text():
|
|
| 92 |
max_retries=6
|
| 93 |
|
| 94 |
)
|
| 95 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
# Display chat messages
|
| 97 |
chat_container = st.container()
|
| 98 |
with chat_container:
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
from PyPDF2 import PdfReader
|
| 3 |
from langchain_core.messages import HumanMessage, AIMessage
|
| 4 |
+
from langchain_core.messages import SystemMessage
|
| 5 |
from langchain_google_genai import ChatGoogleGenerativeAI
|
| 6 |
from langchain.chains import LLMChain
|
| 7 |
from langchain.prompts import PromptTemplate
|
|
|
|
| 93 |
max_retries=6
|
| 94 |
|
| 95 |
)
|
| 96 |
+
# Add system prompt (psychological assistant)
|
| 97 |
+
system_prompt = (
|
| 98 |
+
"You are a compassionate and emotionally intelligent AI assistant trained in cognitive behavioral therapy (CBT), "
|
| 99 |
+
"mindfulness, and active listening. You provide supportive, empathetic responses without making medical diagnoses. "
|
| 100 |
+
"Use a warm tone and guide users to explore their feelings, reframe thoughts, and reflect gently."
|
| 101 |
+
)
|
| 102 |
+
|
| 103 |
+
# Add SystemMessage to chat history
|
| 104 |
+
st.session_state.chat_history.add_message(SystemMessage(content=system_prompt))
|
| 105 |
# Display chat messages
|
| 106 |
chat_container = st.container()
|
| 107 |
with chat_container:
|