Spaces:
Runtime error
Runtime error
ryanrwatkins
commited on
Commit
Β·
a874e7a
1
Parent(s):
44ab821
Update app.py
Browse files
app.py
CHANGED
@@ -95,7 +95,7 @@ def submit_message(prompt, prompt_template, temperature, max_tokens, context_len
|
|
95 |
if prompt_template:
|
96 |
system_prompt = [{ "role": "system", "content": prompt_template }]
|
97 |
|
98 |
-
prompt_msg =
|
99 |
|
100 |
|
101 |
try:
|
@@ -103,9 +103,10 @@ def submit_message(prompt, prompt_template, temperature, max_tokens, context_len
|
|
103 |
|
104 |
# completion = openai.ChatCompletion.create(model="gpt-3.5-turbo", messages=system_prompt + history[-context_length*2:] + [prompt_msg], temperature=temperature, max_tokens=max_tokens)
|
105 |
|
106 |
-
completion_chain = load_qa_chain(
|
107 |
completion = RetrievalQA(combine_documents_chain=completion_chain, retriever=vectordb.as_retriever())
|
108 |
-
|
|
|
109 |
# from https://blog.devgenius.io/chat-with-document-s-using-openai-chatgpt-api-and-text-embedding-6a0ce3dc8bc8
|
110 |
|
111 |
history.append(prompt_msg)
|
|
|
95 |
if prompt_template:
|
96 |
system_prompt = [{ "role": "system", "content": prompt_template }]
|
97 |
|
98 |
+
prompt_msg = { "role": "user", "content": prompt }
|
99 |
|
100 |
|
101 |
try:
|
|
|
103 |
|
104 |
# completion = openai.ChatCompletion.create(model="gpt-3.5-turbo", messages=system_prompt + history[-context_length*2:] + [prompt_msg], temperature=temperature, max_tokens=max_tokens)
|
105 |
|
106 |
+
completion_chain = load_qa_chain(OpenAI(temperature=temperature, max_tokens=max_tokens, model_name="gpt-3.5-turbo"), chain_type="stuff" )
|
107 |
completion = RetrievalQA(combine_documents_chain=completion_chain, retriever=vectordb.as_retriever())
|
108 |
+
query = str(system_prompt + history[-context_length*2:] + [prompt_msg])
|
109 |
+
completion = completion.run(query)
|
110 |
# from https://blog.devgenius.io/chat-with-document-s-using-openai-chatgpt-api-and-text-embedding-6a0ce3dc8bc8
|
111 |
|
112 |
history.append(prompt_msg)
|