Spaces:
Sleeping
Sleeping
Commit
·
f6c85ec
1
Parent(s):
63dc793
feat: set memory in chain
Browse files
app.py
CHANGED
@@ -37,19 +37,20 @@ def initialize_session_state():
|
|
37 |
model="text-davinci-003",
|
38 |
)
|
39 |
|
40 |
-
|
|
|
|
|
41 |
st.session_state.conversation = ConversationalRetrievalChain.from_llm(
|
42 |
-
llm=llm, retriever=retriever, verbose=True
|
43 |
)
|
44 |
|
45 |
|
46 |
def on_click_callback():
|
47 |
with get_openai_callback() as cb:
|
48 |
human_prompt = st.session_state.human_prompt
|
49 |
-
llm_response = st.session_state.conversation
|
50 |
{
|
51 |
"question": human_prompt,
|
52 |
-
"chat_history": st.session_state.memory.buffer,
|
53 |
}
|
54 |
)
|
55 |
st.session_state.history.append(Message("human", human_prompt))
|
|
|
37 |
model="text-davinci-003",
|
38 |
)
|
39 |
|
40 |
+
memory = ConversationBufferMemory(
|
41 |
+
memory_key="chat_history", return_messages=True
|
42 |
+
)
|
43 |
st.session_state.conversation = ConversationalRetrievalChain.from_llm(
|
44 |
+
llm=llm, retriever=retriever, verbose=True, memory=memory
|
45 |
)
|
46 |
|
47 |
|
48 |
def on_click_callback():
|
49 |
with get_openai_callback() as cb:
|
50 |
human_prompt = st.session_state.human_prompt
|
51 |
+
llm_response = st.session_state.conversation(
|
52 |
{
|
53 |
"question": human_prompt,
|
|
|
54 |
}
|
55 |
)
|
56 |
st.session_state.history.append(Message("human", human_prompt))
|