chore: import upstream snapshot with attribution
Code Quality / Python Lint & Format (push) Has been cancelled
Code Quality / Python Tests (push) Has been cancelled
Code Quality / JavaScript/TypeScript Lint (advisory) (push) Has been cancelled
Security Scan / CodeQL Analysis (python) (push) Has been cancelled
Security Scan / Dependency Review (push) Has been cancelled
Security Scan / CodeQL Analysis (javascript-typescript) (push) Has been cancelled
Code Quality / Python Lint & Format (push) Has been cancelled
Code Quality / Python Tests (push) Has been cancelled
Code Quality / JavaScript/TypeScript Lint (advisory) (push) Has been cancelled
Security Scan / CodeQL Analysis (python) (push) Has been cancelled
Security Scan / Dependency Review (push) Has been cancelled
Security Scan / CodeQL Analysis (javascript-typescript) (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
import os
|
||||
from azure.ai.inference import ChatCompletionsClient
|
||||
from azure.ai.inference.models import SystemMessage, UserMessage
|
||||
from azure.core.credentials import AzureKeyCredential
|
||||
|
||||
# Get these from your Microsoft Foundry project's "Overview" page
|
||||
# (GitHub Models is retiring end of July 2026 - see https://ai.azure.com/catalog/models)
|
||||
token = os.environ["AZURE_INFERENCE_CREDENTIAL"]
|
||||
endpoint = os.environ["AZURE_INFERENCE_ENDPOINT"]
|
||||
|
||||
model_name = "gpt-4o-mini"
|
||||
|
||||
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)
|
||||
Reference in New Issue
Block a user