Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed documentation,broken notebooks and made it runnable inside DevContainer #188

Merged
merged 26 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
c1b6ce0
ficed devcontainer and ch04 issues
corradocavalli Nov 15, 2023
8f41fa8
ckeaned notebook cells
corradocavalli Nov 15, 2023
becb539
fixed ch06
corradocavalli Nov 16, 2023
98f36fe
fixed ch07
corradocavalli Nov 16, 2023
49371cb
fixed ch07
corradocavalli Nov 17, 2023
1090320
fixed ch08 and others
corradocavalli Nov 17, 2023
38f2fea
fixed ch11
corradocavalli Nov 17, 2023
27b0602
fixed typo
corradocavalli Nov 17, 2023
3da4e55
removed link
corradocavalli Nov 20, 2023
db0e225
Update .env.copy
carlotta94c Nov 29, 2023
07772cd
Cleaning outputs notebook 1
carlotta94c Nov 29, 2023
796e315
Updating information about exercise notebook setup
carlotta94c Nov 29, 2023
3d88133
Minor changes to README.md
carlotta94c Nov 29, 2023
2e72806
Update notebook-azure-openai.ipynb to migrate to latest sdk version
carlotta94c Nov 29, 2023
f02b6fc
Update notebook-azure-openai.ipynb with new AOAI sdk
carlotta94c Nov 30, 2023
c63765a
adding changes to chapter 9
koreyspace Nov 30, 2023
1501539
Update app.py with latest AOAI sdk release
carlotta94c Nov 30, 2023
14c1579
Update app-recipe.py to latest AOAI sdk
carlotta94c Nov 30, 2023
babf629
Merge branch 'main' into fix-setup-and-ch04-issues
koreyspace Dec 1, 2023
5559fea
Update notebook-azure-openai.ipynb to the latest AOAI sdk
carlotta94c Dec 1, 2023
92fff95
Adding cosine similarity def as per doc
carlotta94c Dec 1, 2023
b26b503
Updating cosine similarity definition as per official doc
carlotta94c Dec 1, 2023
341afd4
Fix 'tuple indices must be integers or slices, not str' error in solu…
carlotta94c Dec 1, 2023
b8156f1
Updating text similarity model to text-embedding-ada-002 model
carlotta94c Dec 1, 2023
8ed83b4
Delete .env
carlotta94c Dec 1, 2023
9f05a2d
Fixing .env.copy
carlotta94c Dec 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .devcontainer/post-create.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /bin/bash
#!/bin/bash

# Install OpenAI and Dotenv for Python
# TODO: Check why this can't be done in requirements.txt
Expand Down
5 changes: 4 additions & 1 deletion .env.copy
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>'
26 changes: 15 additions & 11 deletions 04-prompt-engineering-fundamentals/1-introduction.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -81,18 +81,22 @@
"\n",
"## Updated\n",
"import os\n",
"import openai\n",
"from openai import OpenAI\n",
"from openai import AzureOpenAI\n",
"from dotenv import load_dotenv\n",
"load_dotenv()\n",
"\n",
"client = OpenAI(\n",
" api_key=os.environ['OPENAI_API_KEY'], # this is also the default, it can be omitted\n",
")\n",
"client = AzureOpenAI(\n",
" api_key=os.environ['AZURE_OPENAI_KEY'], # this is also the default, it can be omitted\n",
" api_version = \"2023-05-15\"\n",
" )\n",
"\n",
"deployment=os.environ['AZURE_OPENAI_DEPLOYMENT']\n",
"\n",
"## Updated\n",
"def get_completion(prompt, model=\"gpt-3.5-turbo\"):\n",
" messages = [{\"role\": \"user\", \"content\": prompt}]\n",
" response = openai.chat.completions.create(\n",
" model=model,\n",
"def get_completion(prompt):\n",
" messages = [{\"role\": \"user\", \"content\": prompt}] \n",
" response = client.chat.completions.create( \n",
" model=deployment, \n",
" messages=messages,\n",
" temperature=0, # this is the degree of randomness of the model's output\n",
" max_tokens=1024\n",
Expand Down Expand Up @@ -210,8 +214,8 @@
"metadata": {},
"outputs": [],
"source": [
"response = openai.chat.completions.create(\n",
" model=\"gpt-3.5-turbo\",\n",
"response = client.chat.completions.create(\n",
" model=deployment,\n",
" messages=[\n",
" {\"role\": \"system\", \"content\": \"You are a sarcastic assistant.\"},\n",
" {\"role\": \"user\", \"content\": \"Who won the world series in 2020?\"},\n",
Expand Down
794 changes: 395 additions & 399 deletions 04-prompt-engineering-fundamentals/README.md

Large diffs are not rendered by default.

27 changes: 10 additions & 17 deletions 06-text-generation-apps/app-recipe.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import openai
from openai import AzureOpenAI
import os
import dotenv

# import dotenv
dotenv.load_dotenv()

openai.api_key = os.getenv("API_KEY")

# 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")
# 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"
)

deployment=os.environ['AZURE_OPENAI_DEPLOYMENT']

no_recipes = input("No of recipes (for example, 5: ")

Expand All @@ -23,12 +24,8 @@
prompt = f"Show me {no_recipes} recipes for a dish with the following ingredients: {ingredients}. Per recipe, list all the ingredients used, no {filter}: "


# engine

# deployment_id
deployment_name = os.getenv("DEPLOYMENT_NAME")
completion = client.completions.create(model=deployment, prompt=prompt, max_tokens=600, temperature = 0.1)

completion = openai.Completion.create(engine=deployment_name, prompt=prompt, max_tokens=600, temperature=0.1)

# print response
print("Recipes:")
Expand All @@ -38,13 +35,9 @@
prompt_shopping = "Produce a shopping list, and please don't include ingredients that I already have at home: "

new_prompt = f"Given ingredients at home {ingredients} and these generated recipes: {old_prompt_result}, {prompt_shopping}"
completion = openai.Completion.create(engine=deployment_name, prompt=new_prompt, max_tokens=600)
completion = client.completions.create(model=deployment, prompt=prompt, max_tokens=600)

# print response
print("\n=====Shopping list ======= \n")
print(completion.choices[0].text)

# very unhappy _____.

# Once upon a time there was a very unhappy mermaid.

25 changes: 10 additions & 15 deletions 06-text-generation-apps/app.py
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.

Loading
Loading