-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
53 lines (43 loc) · 1.62 KB
/
Copy pathmain.py
File metadata and controls
53 lines (43 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# this is just the hellow world as test
import json
from openai import AzureOpenAI
with open("ChatSetup.json", "r") as file:
chat_setup = json.load(file)
search_endpoint = "https://ehb-search.search.windows.net"
search_key = chat_setup["searchKey"]
search_index_name = "ehb"
client = AzureOpenAI(
azure_endpoint="https://ehb-france-central.openai.azure.com/",
api_key=chat_setup["api_key"],
api_version="2024-02-01",
)
conversation = []
while True:
user_message = input("You: ")
conversation.append({"role": "user", "content": user_message})
response = client.chat.completions.create(
model=chat_setup["chatParameters"]["chatParameters"],
messages=conversation,
extra_body={
"data_sources": [
{
"type": "azure_search",
"parameters": {
"endpoint": search_endpoint,
"index_name": search_index_name,
"semantic_configuration": "default",
"query_type": "simple",
"fields_mapping": {},
"role_information": chat_setup["systemPrompt"],
"strictness": 3,
"top_n_documents": 5,
"authentication": {"type": "api_key", "key": search_key},
"key": search_key,
},
}
],
},
)
system_response = response.choices[0].message.content
print("Systeem:", system_response)
conversation.append({"role": "assistant", "content": system_response})