forked from microsoft/generative-ai-for-beginners
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request microsoft#560 from ryubidragonfire/chyam/06
06, added githubmodels-app.py, updated githubmodels-assignment.ipynb
- Loading branch information
Showing
5 changed files
with
66 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
name: <environment-name> | ||
channels: | ||
- defaults | ||
dependencies: | ||
- python=3.12 | ||
- openai | ||
- python-dotenv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
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. | ||
) | ||
|
||
print(response.choices[0].message.content) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,5 @@ pandas==1.5.3 | |
tqdm==4.66.3 | ||
python-dotenv==1.0.0 | ||
openai>=0.28.0 | ||
tiktoken | ||
tiktoken | ||
azure-ai-inference |