Skip to content

Commit 4f3aa80

Browse files
committed
refactor setup, ch4, ch18 - for consistency in assignments
1 parent 1c79676 commit 4f3aa80

14 files changed

+93
-335
lines changed

.env.copy

+10-8
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
# Azure OpenAI configuration
2-
AZURE_OPENAI_ENDPOINT='<add your endpoint here>'
3-
AZURE_OPENAI_DEPLOYMENT='<add your deployment name here>'
4-
AZURE_OPENAI_KEY='<add your key here>'
5-
AZURE_OPENAI_EMBEDDINGS_DEPLOYMENT='<add your deployment name here>'
1+
# OpenAI Provider
2+
OPENAI_API_KEY='<add your OpenAI API key here>'
63

4+
## Azure OpenAI
5+
AZURE_OPENAI_API_VERSION='2024-02-01' # Default is set!
6+
AZURE_OPENAI_API_KEY='<add your AOAI key here>'
7+
AZURE_OPENAI_ENDPOINT='<add your AOIA service endpoint here>'
8+
AZURE_OPENAI_DEPLOYMENT='<add your chat completion model name here>'
9+
AZURE_OPENAI_EMBEDDINGS_DEPLOYMENT='<add your embeddings model name here>'
710

8-
# OpenAI Configuration
9-
10-
OPENAI_API_KEY='<add your OpenAI key here>'
11+
## Hugging Face
12+
HUGGING_FACE_API_KEY='<add your HuggingFace API or token here>'

00-course-setup/SETUP.md

+79-29
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,100 @@
11
# Setup Your Dev Environment
22

3-
We have setup this repository and course with a _dev container_ that comes with a Python 3 runtime. Open the repo in GitHub Codespaces or on your local Docker Desktop, to activate the runtime automatically. Then open th Jupyter notebook and select the Python 3.x kernel to prepare the Notebook for execution.
3+
We setup this repository and course with a [development container](https://containers.dev?WT.mc_id=academic-105485-koreyst) that has a Universal runtime that can support Python3, .NET, Node.js and Java development. The related configuration is defined in the `devcontainer.json` file located in the `.devcontainer/` folder at the root of this repository.
44

5-
## 1. Create `.env` file
5+
To activate the dev container, launch it in [GitHub Codespaces](https://docs.github.com/en/codespaces/overview?WT.mc_id=academic-105485-koreyst) (for a cloud-hosted runtime) or in [Docker Desktop](https://docs.docker.com/desktop/?WT.mc_id=academic-105485-koreyst) (for a local device-hosted runtime). Read [this documentation](https://code.visualstudio.com/docs/devcontainers/containers?WT.mc_id=academic-105485-koreyst) for more details on how dev containers work within VS Code.
66

7-
The default notebook (identified by the 'aoai-' suffix) is set up for use with an [Azure OpenAI service resource](https://learn.microsoft.com/azure/ai-services/openai?WT.mc_id=academic-105485-koreyst). However, you have the option to run your assignments by using non-Azure openAI endpoints (choose the 'oai-' prefixed notebooks in this case).
7+
> [!TIP]
8+
> We recommend using GitHub Codespaces for a quick start with minimal effort. It provides a generous [free usage quota](https://docs.github.com/billing/managing-billing-for-github-codespaces/about-billing-for-github-codespaces#monthly-included-storage-and-core-hours-for-personal-accounts) for personal accounts. Configure [timeouts](https://docs.github.com/codespaces/setting-your-user-preferences/setting-your-timeout-period-for-github-codespaces) to stop or delete inactive codespaces to maximize your quota usage.
89
9-
To configure this, we need to setup local environment variables for Azure as follows:
1010

11-
1. Look in the root folder for a `.env.copy` file. It should contain a list of name-value pairs like this:
11+
## 1. Executing Assignments
12+
13+
Each lesson will have _optional_ assignments that may be provided in one or more programming languages including: Python, .NET/C#, Java and JavaScript/TypeScript. This section provides general guidance related to executing those assignments.
14+
15+
### 1.1 Python Assignments
16+
17+
Python assignments are provided either as applications (`.py` files) or Jupyter notebooks (`.ipynb` files).
18+
- To run the notebook, open it in Visual Studio Code then click _Select Kernel_ (at top right) and select the default Python 3 option shown. You can now _Run All_ to execute the notebook.
19+
- To run Python applications from command-line, follow assignment-specific instructions to ensure you select the right files and provide required arguments
20+
21+
## 2. Configuring Providers
22+
23+
Assignments **may** also be setup to work against one or more Large Language Model (LLM) deployments through a supported service provider like OpenAI, Azure or Hugging Face. These provide a _hosted endpoint_ (API) that we can access programmatically with the right credentials (API key or token). In this course, we discuss these providers:
24+
25+
- [OpenAI](https://platform.openai.com/docs/models) with diverse models including the core GPT series.
26+
- [Azure OpenAI](https://learn.microsoft.com/en-us/azure/ai-services/openai/) for OpenAI models with enterprise readiness in focus
27+
- [Hugging Face](https://huggingface.co/docs/hub/index) for open-source models and inference server
28+
29+
**You will need to use your own accounts for these exercises**. Assignments are optional so you can choose to setup one, all - or none - of the providers based on your interests. Some guidance for signup:
30+
31+
| Signup | Cost | API Key | Playground | Comments |
32+
|:---|:---|:---|:---|:---|
33+
| [OpenAI](https://platform.openai.com/signup)| [Pricing](https://openai.com/pricing#language-models)| [Project-based](https://platform.openai.com/api-keys) | [No-Code, Web](https://platform.openai.com/playground) | Multiple Models Available |
34+
| [Azure](https://aka.ms/azure/free)| [Pricing](https://azure.microsoft.com/pricing/details/cognitive-services/openai-service/)| [SDK Quickstart](https://learn.microsoft.com/azure/ai-services/openai/quickstart?tabs=command-line%2Cpython-new&pivots=programming-language-python#retrieve-key-and-endpoint)| [Studio Quickstart](https://learn.microsoft.com/azure/ai-services/openai/quickstart?tabs=command-line%2Cpython-new&pivots=programming-language-studio#playground) | [Must Apply Ahead For Access](https://learn.microsoft.com/azure/ai-services/openai/)|
35+
| [Hugging Face](https://huggingface.co/join) | [Pricing](https://huggingface.co/pricing) | [Access Tokens](https://huggingface.co/docs/hub/security-tokens) | [Hugging Chat](https://huggingface.co/chat/)| [Hugging Chat has limited models](https://huggingface.co/chat/models) |
36+
| | | | | |
37+
38+
Follow the directions below to _configure_ this repository for use with different providers. Assignments that require a specific provider will contain one of these tags in their filename:
39+
- `aoai` - requires Azure OpenAI endpoint, key
40+
- `oai` - requires OpenAI endpoint, key
41+
- `hf` - requires Hugging Face token
42+
43+
You can configure one, none, or all providers. Related assignments will simply error out on missing credentials.
44+
45+
### 2.1. Create `.env` file
46+
47+
We assume that you have already read the guidance above and signed up with the relevant provider, and obtained the required authentication credentials (API_KEY or token). In the case of Azure OpenAI, we assume you also have a valid deployment of an Azure OpenAI service (endpoint) with at least one GPT model deployed for chat completion.
48+
49+
The next step is to configure your **local environment variables** as follows:
50+
51+
52+
1. Look in the root folder for a `.env.copy` file that should have contents like this:
1253

1354
```bash
14-
AZURE_OPENAI_ENDPOINT='<add your endpoint here>'
15-
AZURE_OPENAI_DEPLOYMENT='<add your deployment name here>'
16-
AZURE_OPENAI_KEY='<add your key here>'
17-
AZURE_OPENAI_EMBEDDINGS_DEPLOYMENT='<add your deployment name here>'
55+
# OpenAI Provider
56+
OPENAI_API_KEY='<add your OpenAI API key here>'
57+
58+
## Azure OpenAI
59+
AZURE_OPENAI_API_VERSION='2024-02-01' # Default is set!
60+
AZURE_OPENAI_API_KEY='<add your AOAI key here>'
61+
AZURE_OPENAI_ENDPOINT='<add your AOIA service endpoint here>'
62+
AZURE_OPENAI_DEPLOYMENT='<add your chat completion model name here>'
63+
AZURE_OPENAI_EMBEDDINGS_DEPLOYMENT='<add your embeddings model name here>'
64+
65+
## Hugging Face
66+
HUGGING_FACE_API_KEY='<add your HuggingFace API or token here>'
1867
```
1968

20-
2. Make a copy of that file called `.env` using a command like this at the terminal:
69+
2. Copy that file to `.env` using the command below. This file is _gitignore-d_, keeping secrets safe.
2170

2271
```bash
2372
cp .env.copy .env
2473
```
2574

26-
This should create an identical copy _except that this file is .gitignore-d and will never get checked into source control_. We can now populate **this .env file** with the environment variable values (secrets) without fear of them being checked in accidentally. You can now move to the next section to start populating these variables.
75+
3. Fill in the values (replace placeholders on right side of `=`) as described in the next section.
2776

2877
3. (Option) If you use GitHub Codespaces, you have the option to save environment variables as _Codespaces secrets_ associated with this repository. In that case, you won't need to setup a local .env file. **However, note that this option works only if you use GitHub Codespaces.** You will still need to setup the .env file if you use Docker Desktop instead.
2978

30-
The above steps should be executed also if you are using the non-Azure OpenAI endpoints. In that case, you will need to populate the .env file with the appropriate values for the OpenAI service.
31-
32-
```bash
33-
OPENAI_API_KEY='<add your OpenAI key here>'
34-
```
3579

36-
## 2. Populate `.env` file
80+
### 2.2. Populate `.env` file
3781

3882
Let's take a quick look at the variable names to understand what they represent:
3983

40-
| Variable | Description |
41-
| :--------------------------------- | :--------------------------------------------------------------------------------- |
42-
| AZURE_OPENAI_ENDPOINT | This is the deployed endpoint for an Azure OpenAI resource |
43-
| AZURE_OPENAI_KEY | This is the authorization key for using that service |
44-
| OPENAI_API_KEY | This is the authorization key for using the service for non-Azure OpenAI endpoints |
45-
| AZURE_OPENAI_DEPLOYMENT | This is the _text generation_ model deployment endpoint |
46-
| AZURE_OPENAI_EMBEDDINGS_DEPLOYMENT | This is the _text embeddings_ model deployment endpoint |
47-
| | |
84+
| Variable | Description |
85+
| :--- | :--- |
86+
| HUGGING_FACE_API_KEY | This is the user access token you setup in your profile |
87+
| OPENAI_API_KEY | This is the authorization key for using the service for non-Azure OpenAI endpoints |
88+
| AZURE_OPENAI_KEY | This is the authorization key for using that service |
89+
| AZURE_OPENAI_ENDPOINT | This is the deployed endpoint for an Azure OpenAI resource |
90+
| AZURE_OPENAI_DEPLOYMENT | This is the _text generation_ model deployment endpoint |
91+
| AZURE_OPENAI_EMBEDDINGS_DEPLOYMENT | This is the _text embeddings_ model deployment endpoint |
92+
| | |
93+
94+
Note: The last two Azure OpenAI variables reflect a default model for chat completion (text generation) and vector search (embeddings) respectively. Instructions for setting them will be defined in relevant assignments.
4895

49-
For context, the last two variables refer to specific models that are used in chat completion (text generation model) and vector search (embeddings model) activities that are frequently used in generative AI applications. In the following sections, we'll locate the _values_ for these variables and set them in `.env` (replacing the content within the `' '`, but preserving the quotes).
5096

51-
### 2.1 Use Azure Portal
97+
### 2.3 Configure Azure: From Portal
5298

5399
The Azure OpenAI endpoint and key values will be found in the [Azure Portal](https://portal.azure.com?WT.mc_id=academic-105485-koreyst) so let's start there.
54100

@@ -65,7 +111,7 @@ Next, we need the endpoints for the specific models we've deployed.
65111

66112
This will take you to the Azure OpenAI Studio website, where we'll find the other values as described below.
67113

68-
### 2.2 Use Azure OpenAI Studio
114+
### 2.4 Configure Azure: From Studio
69115

70116
1. Navigate to [Azure OpenAI Studio](https://oai.azure.com?WT.mc_id=academic-105485-koreyst) **from your resource** as described above.
71117
1. Click the **Deployments** tab (sidebar, left) to view currently deployed models.
@@ -82,6 +128,10 @@ AZURE_OPENAI_EMBEDDINGS_DEPLOYMENT='text-embedding-ada-002'
82128

83129
**Don't forget to save the .env file when done**. You can now exit the file and return to the instructions for running the notebook.
84130

85-
### 2.3 Use OpenAI Public API
131+
### 2.5 Configure OpenAI: From Profile
86132

87133
Your OpenAI API key can be found in your [OpenAI account](https://platform.openai.com/api-keys?WT.mc_id=academic-105485-koreyst). If you don't have one, you can sign up for an account and create an API key. Once you have the key, you can use it to populate the `OPENAI_API_KEY` variable in the `.env` file.
134+
135+
### 2.6 Configure Hugging Face: From Profile
136+
137+
Your Hugging Face token can be found in your profile under [Access Tokens](https://huggingface.co/settings/tokens). Don't post or share these publicly. Instead, create a new token for this project usage and copy that into the `.env` file under the `HUGGING_FACE_API_KEY` variable. _Note:_ This is technically not an API key but is used for authentication so we are keeping that naming convention for consistency.

04-prompt-engineering-fundamentals/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ The Jupyter Notebook accompanying this lesson provides a _sandbox_ environment w
2929

3030
1. **An Azure OpenAI API key** - the service endpoint for a deployed LLM.
3131
2. **A Python Runtime** - in which the Notebook can be executed.
32-
3. **Local Env Variables** - _complete the [SETUP](SETUP.md) steps now to get ready_.
32+
3. **Local Env Variables** - _complete the [SETUP](./../00-course-setup/SETUP.md) steps now to get ready_.
3333

3434
The notebook comes with _starter_ exercises - but you are encouraged to add your own _Markdown_ (description) and _Code_ (prompt requests) sections to try out more examples or ideas - and build your intuition for prompt design.
3535

18-fine-tuning/SETUP.md

-75
This file was deleted.

18-fine-tuning/assignments/python/README.md

-1
This file was deleted.

0 commit comments

Comments
 (0)