Spaces:
Sleeping
Sleeping
Commit
·
67ee7a9
1
Parent(s):
815b476
fixing the none output error
Browse files
app.py
CHANGED
@@ -103,6 +103,21 @@ def get_opeanai_key(openai_key):
|
|
103 |
|
104 |
|
105 |
def slow_echo(usr_message, chat_history):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
try:
|
107 |
# Attempt to get a response from the OpenAI model
|
108 |
bot_result = answer_chain({"query": usr_message})
|
|
|
103 |
|
104 |
|
105 |
def slow_echo(usr_message, chat_history):
|
106 |
+
|
107 |
+
chat_model = ChatOpenAI(temperature=0, model_name='gpt-3.5-turbo', openai_api_key=OPENAI_API_KEY)
|
108 |
+
# customized memory
|
109 |
+
memory = ConversationBufferMemory(
|
110 |
+
return_messages=True,
|
111 |
+
output_key='result'
|
112 |
+
)
|
113 |
+
|
114 |
+
answer_chain = RetrievalQA.from_chain_type(
|
115 |
+
chat_model,
|
116 |
+
retriever=VectorStore.as_retriever(search_type="similarity", k=6),
|
117 |
+
memory = memory,
|
118 |
+
chain_type_kwargs={"prompt": QA_CHAIN_PROMPT},
|
119 |
+
return_source_documents=True
|
120 |
+
)
|
121 |
try:
|
122 |
# Attempt to get a response from the OpenAI model
|
123 |
bot_result = answer_chain({"query": usr_message})
|