Skip to content

Commit 5ead357

Browse files
I did stuff
1 parent a09f4a1 commit 5ead357

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

src/ContosoSuitesDashboard/pages/1_Chat_with_Data.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ def create_chat_completion(messages):
1111
aoai_key = st.secrets["aoai"]["key"]
1212
aoai_deployment_name = st.secrets["aoai"]["deployment_name"]
1313

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+
1419
client = openai.AzureOpenAI(
1520
api_key=aoai_key,
1621
api_version="2024-06-01",
@@ -23,9 +28,25 @@ def create_chat_completion(messages):
2328
{"role": m["role"], "content": m["content"]}
2429
for m in messages
2530
],
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+
}
2747
)
2848

49+
2950
def handle_chat_prompt(prompt):
3051
"""Echo the user's prompt to the chat window.
3152
Then, send the user's prompt to Azure OpenAI and display the response."""

0 commit comments

Comments
 (0)