Spaces:
Sleeping
Sleeping
Commit
·
8bc2404
1
Parent(s):
5f929fc
add chathistory for search
Browse files
app.py
CHANGED
@@ -98,11 +98,21 @@ def create_embeddings(files: list = []):
|
|
98 |
|
99 |
def get_response(user_query, chat_history):
|
100 |
docs = RETRIEVER.invoke(user_query)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
|
102 |
template = """
|
103 |
Your name is ADINA, who provides helpful information about Adina Consmetic Ingredients.
|
104 |
<rules>
|
105 |
-
- Answer the question based on the
|
106 |
- If the question can not be answered, simply say you can not annswer it.
|
107 |
- Avoid mentioning that you are answering based on retreived information.
|
108 |
</rules>
|
@@ -118,9 +128,10 @@ def get_response(user_query, chat_history):
|
|
118 |
--- Empathy and Understanding - Compassionate and Responsive:
|
119 |
Recognize and validate their feelings or concerns. Phrases like, “It’s completely normal to find this challenging,” can be comforting.
|
120 |
Be aware of the potential need for more frequent repetition or rephrasing of information for clarity.
|
121 |
-
Answer the following questions considering the history of the conversation and
|
122 |
Chat history: {chat_history}
|
123 |
-
|
|
|
124 |
User question: {user_question}
|
125 |
"""
|
126 |
|
@@ -133,6 +144,7 @@ def get_response(user_query, chat_history):
|
|
133 |
{
|
134 |
"chat_history": chat_history,
|
135 |
"retrieved_info": docs,
|
|
|
136 |
"user_question": user_query,
|
137 |
}
|
138 |
)
|
|
|
98 |
|
99 |
def get_response(user_query, chat_history):
|
100 |
docs = RETRIEVER.invoke(user_query)
|
101 |
+
additional_info = RETRIEVER.invoke(
|
102 |
+
user_query
|
103 |
+
+ ". ".join(
|
104 |
+
[
|
105 |
+
message.content
|
106 |
+
for message in st.session_state.chat_history
|
107 |
+
if isinstance(message, HumanMessage)
|
108 |
+
]
|
109 |
+
)
|
110 |
+
)
|
111 |
|
112 |
template = """
|
113 |
Your name is ADINA, who provides helpful information about Adina Consmetic Ingredients.
|
114 |
<rules>
|
115 |
+
- Answer the question based on the context and/or additional information only.
|
116 |
- If the question can not be answered, simply say you can not annswer it.
|
117 |
- Avoid mentioning that you are answering based on retreived information.
|
118 |
</rules>
|
|
|
128 |
--- Empathy and Understanding - Compassionate and Responsive:
|
129 |
Recognize and validate their feelings or concerns. Phrases like, “It’s completely normal to find this challenging,” can be comforting.
|
130 |
Be aware of the potential need for more frequent repetition or rephrasing of information for clarity.
|
131 |
+
Answer the following questions considering the history of the conversation, context and/or additional information.
|
132 |
Chat history: {chat_history}
|
133 |
+
Context: {retrieved_info}
|
134 |
+
Additional Information: {additional_info}
|
135 |
User question: {user_question}
|
136 |
"""
|
137 |
|
|
|
144 |
{
|
145 |
"chat_history": chat_history,
|
146 |
"retrieved_info": docs,
|
147 |
+
"additional_info": additional_info,
|
148 |
"user_question": user_query,
|
149 |
}
|
150 |
)
|