Spaces:
Runtime error
Runtime error
Commit
·
7bf4fa8
1
Parent(s):
fef8023
Update main.py
Browse files
main.py
CHANGED
@@ -197,23 +197,23 @@ def chat():
|
|
197 |
results = []
|
198 |
# Update the model name to "text-davinci-003" (Ada)
|
199 |
prompt = "\n".join([f"{msg['role']}: {msg['content']}" for msg in messages])
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
date = time.ctime(time.time())
|
207 |
texte = prompt
|
208 |
data = Question(date, texte)
|
209 |
db.session.add(data)
|
210 |
db.session.commit()
|
211 |
question_id = data.id
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
for collection_name in collection_names:
|
218 |
search_results = perform_search_and_get_results(collection_name, prompt)
|
219 |
results.extend(search_results)
|
|
|
197 |
results = []
|
198 |
# Update the model name to "text-davinci-003" (Ada)
|
199 |
prompt = "\n".join([f"{msg['role']}: {msg['content']}" for msg in messages])
|
200 |
+
response = openai.completions.create(
|
201 |
+
model="gpt-3.5-turbo-instruct",
|
202 |
+
prompt=start_message +'\n'+ context + question ,
|
203 |
+
max_tokens=500,
|
204 |
+
temperature=0
|
205 |
+
)
|
206 |
date = time.ctime(time.time())
|
207 |
texte = prompt
|
208 |
data = Question(date, texte)
|
209 |
db.session.add(data)
|
210 |
db.session.commit()
|
211 |
question_id = data.id
|
212 |
+
resulta = response.choices[0].text
|
213 |
+
chat_references = filtergpt(resulta)
|
214 |
+
for law, article in chat_references:
|
215 |
+
search_results = perform_search_and_get_results_with_filter(collection_names[0], prompt, reference_filter=article)
|
216 |
+
results.extend(search_results)
|
217 |
for collection_name in collection_names:
|
218 |
search_results = perform_search_and_get_results(collection_name, prompt)
|
219 |
results.extend(search_results)
|