File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed
src/ContosoSuitesDashboard/pages Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,11 @@ def create_chat_completion(messages):
11
11
aoai_key = st .secrets ["aoai" ]["key" ]
12
12
aoai_deployment_name = st .secrets ["aoai" ]["deployment_name" ]
13
13
14
+ search_endpoint = st .secrets ["search" ]["endpoint" ]
15
+ search_key = st .secrets ["search" ]["key" ]
16
+ search_index_name = st .secrets ["search" ]["index_name" ]
17
+
18
+
14
19
client = openai .AzureOpenAI (
15
20
api_key = aoai_key ,
16
21
api_version = "2024-06-01" ,
@@ -23,9 +28,25 @@ def create_chat_completion(messages):
23
28
{"role" : m ["role" ], "content" : m ["content" ]}
24
29
for m in messages
25
30
],
26
- stream = True
31
+ stream = True ,
32
+ extra_body = {
33
+ "data_sources" : [
34
+ {
35
+ "type" : "azure_search" ,
36
+ "parameters" : {
37
+ "endpoint" : search_endpoint ,
38
+ "index_name" : search_index_name ,
39
+ "authentication" : {
40
+ "type" : "api_key" ,
41
+ "key" : search_key
42
+ }
43
+ }
44
+ }
45
+ ]
46
+ }
27
47
)
28
48
49
+
29
50
def handle_chat_prompt (prompt ):
30
51
"""Echo the user's prompt to the chat window.
31
52
Then, send the user's prompt to Azure OpenAI and display the response."""
You can’t perform that action at this time.
0 commit comments