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#188 from corradocavalli/fix-setup-and-ch…
…04-issues Fixed documentation,broken notebooks and made it runnable inside DevContainer
- Loading branch information
Showing
14 changed files
with
1,117 additions
and
1,234 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
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 |
---|---|---|
@@ -1 +1,4 @@ | ||
OPENAI_API_KEY= | ||
AZURE_OPENAI_ENDPOINT='<add your endpoint here>' | ||
AZURE_OPENAI_DEPLOYMENT='<add your deployment name here>' | ||
AZURE_OPENAI_KEY='<add your key here>' | ||
AZURE_OPENAI_EMBEDDINGS_DEPLOYMENT='<add your deployment name here>' |
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
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,33 +1,28 @@ | ||
import openai | ||
from openai import AzureOpenAI | ||
import os | ||
import dotenv | ||
|
||
# import dotenv | ||
dotenv.load_dotenv() | ||
|
||
openai.api_key = os.getenv("API_KEY") | ||
# configure Azure OpenAI service client | ||
client = AzureOpenAI( | ||
azure_endpoint = os.environ["AZURE_OPENAI_ENDPOINT"], | ||
api_key=os.environ['AZURE_OPENAI_KEY'], | ||
api_version = "2023-10-01-preview" | ||
) | ||
|
||
# enable below if you use Azure Open AI | ||
openai.api_type = 'azure' | ||
openai.api_version = '2023-05-15' | ||
openai.api_base = os.getenv("API_BASE") | ||
deployment=os.environ['AZURE_OPENAI_DEPLOYMENT'] | ||
|
||
# add your completion code | ||
prompt = "Complete the following: Once upon a time there was a" | ||
|
||
# engine | ||
engine = "davinci-001" | ||
|
||
# deployment_id, azure specific | ||
deployment_name = os.getenv("DEPLOYMENT_NAME") | ||
|
||
completion = openai.Completion.create(engine=deployment_name, prompt=prompt, max_tokens=600) | ||
# make completion | ||
completion = client.completions.create(model=deployment, prompt=prompt) | ||
|
||
# print response | ||
print(completion.choices[0].text) | ||
|
||
|
||
# very unhappy _____. | ||
|
||
# Once upon a time there was a very unhappy mermaid. | ||
|
Oops, something went wrong.