-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_comparison_from_content.py
More file actions
34 lines (28 loc) · 938 Bytes
/
get_comparison_from_content.py
File metadata and controls
34 lines (28 loc) · 938 Bytes
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
import os
import requests
ENDPOINT = os.environ["AZURE_OPENAI_ENDPOINT"]
API_KEY = os.environ["AZURE_OPENAI_API_KEY"]
DEPLOYMENT = os.environ["AZURE_OPENAI_DEPLOYMENT"]
API_VERSION = os.environ["AZURE_OPENAI_API_VERSION"]
def call_llm(prompt, content):
url = f"{ENDPOINT}/openai/deployments/{DEPLOYMENT}/chat/completions?api-version={API_VERSION}"
headers = {
"Content-Type": "application/json",
"api-key": API_KEY
}
payload = {
"messages": [
{
"role": "system",
"content": "You are a professional comparison engine."
},
{
"role": "user",
"content": f"{prompt}\n\n{content}"
}
],
"temperature": 0.2
}
response = requests.post(url, headers=headers, json=payload)
response.raise_for_status()
return response.json()["choices"][0]["message"]["content"]