-
Notifications
You must be signed in to change notification settings - Fork 59.8k
Expand file tree
/
Copy pathgithubmodels-app.py
More file actions
37 lines (31 loc) · 996 Bytes
/
githubmodels-app.py
File metadata and controls
37 lines (31 loc) · 996 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
35
36
37
import os
from azure.ai.inference import ChatCompletionsClient
from azure.ai.inference.models import SystemMessage, UserMessage
from azure.core.credentials import AzureKeyCredential
token = os.environ["GITHUB_TOKEN"]
endpoint = "https://models.inference.ai.azure.com"
model_name = "gpt-4o"
client = ChatCompletionsClient(
endpoint=endpoint,
credential=AzureKeyCredential(token),
)
prompt = "Show me 5 recipes for a dish with the following ingredients: chicken, potatoes, and carrots. Per recipe, list all the ingredients used"
response = client.complete(
messages=[
{
"role": "system",
"content": "You are a helpful assistant.",
},
{
"role": "user",
"content": prompt,
},
],
model=model_name,
# Optional parameters
temperature=1.,
max_tokens=1000,
top_p=1.
)
if response.choices and response.choices[0].message is not None:
print(response.choices[0].message.content)