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.
Adding support to non-Azure OpenAI endpoints, applying new folder str…
…ucture
- Loading branch information
1 parent
c586374
commit 11239ce
Showing
6 changed files
with
82 additions
and
13 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 |
---|---|---|
@@ -1,4 +1,8 @@ | ||
# Azure OpenAI configuration | ||
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>' | ||
|
||
# OpenAI Configuration | ||
OPENAI_API_KEY='<add your OpenAI key 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
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
File renamed without changes.
65 changes: 65 additions & 0 deletions
65
07-building-chat-applications/python/oai-assigment-simple.ipynb
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,65 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import os\n", | ||
"from openai import OpenAI\n", | ||
"from dotenv import load_dotenv\n", | ||
"\n", | ||
"load_dotenv()\n", | ||
"\n", | ||
"API_KEY = os.getenv(\"OPENAI_API_KEY\",\"\").strip()\n", | ||
"assert API_KEY, \"ERROR: OpenAI Key is missing\"\n", | ||
"client = OpenAI(\n", | ||
" api_key=API_KEY\n", | ||
" )\n", | ||
"\n", | ||
"model = \"gpt-3.5-turbo\" " | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Create your first prompt\n", | ||
"text_prompt = \" My foot hurts, what can be wrong?\"\n", | ||
"\n", | ||
"response = client.chat.completions.create(\n", | ||
" model=model,\n", | ||
" messages = [\n", | ||
" {\"role\":\"system\", \"content\":\"I'm a doctor, specialist on surgery\"},\n", | ||
" {\"role\":\"user\",\"content\":text_prompt},])\n", | ||
"\n", | ||
"response.choices[0].message.content" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.10.13" | ||
}, | ||
"orig_nbformat": 4 | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
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