You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Use function call to stabilize search query
* minor changes
* sort imports
* fix ruff
* s
* Update app/backend/approaches/chatreadretrieveread.py
Co-authored-by: Pamela Fox <[email protected]>
* s
* blacj format
* add test
* save
---------
Co-authored-by: Pamela Fox <[email protected]>
Copy file name to clipboardExpand all lines: app/backend/approaches/chatreadretrieveread.py
+43-7Lines changed: 43 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,4 @@
1
+
importjson
1
2
fromtypingimportAny, AsyncGenerator
2
3
3
4
importopenai
@@ -15,6 +16,8 @@ class ChatReadRetrieveReadApproach:
15
16
USER="user"
16
17
ASSISTANT="assistant"
17
18
19
+
NO_RESPONSE="0"
20
+
18
21
"""
19
22
Simple retrieve-then-read implementation, using the Cognitive Search and OpenAI APIs directly. It first retrieves
20
23
top documents from search, then constructs a prompt with them, and then uses OpenAI to generate an completion
@@ -33,6 +36,7 @@ class ChatReadRetrieveReadApproach:
33
36
Only generate questions and do not generate any text before or after the questions, such as 'Next Questions'"""
34
37
35
38
query_prompt_template="""Below is a history of the conversation so far, and a new question asked by the user that needs to be answered by searching in a knowledge base about employee healthcare plans and the employee handbook.
39
+
You have access to Azure Cognitive Search index with 100's of documents.
36
40
Generate a search query based on the conversation and the new question.
37
41
Do not include cited source filenames and document names e.g info.txt or doc.pdf in the search query terms.
38
42
Do not include any text inside [] or <<>> in the search query terms.
0 commit comments