Package updates, more Ollama, fixes
This commit is contained in:
@@ -572,7 +572,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.11.3"
|
||||
"version": "3.11.11"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
"<table style=\"margin: 0; text-align: left;\">\n",
|
||||
" <tr>\n",
|
||||
" <td style=\"width: 150px; height: 150px; vertical-align: middle;\">\n",
|
||||
" <img src=\"../important.jpg\" width=\"150\" height=\"150\" style=\"display: block;\" />\n",
|
||||
" <img src=\"../../important.jpg\" width=\"150\" height=\"150\" style=\"display: block;\" />\n",
|
||||
" </td>\n",
|
||||
" <td>\n",
|
||||
" <h2 style=\"color:#900;\">Important Note - Please read me</h2>\n",
|
||||
@@ -41,7 +41,7 @@
|
||||
"<table style=\"margin: 0; text-align: left;\">\n",
|
||||
" <tr>\n",
|
||||
" <td style=\"width: 150px; height: 150px; vertical-align: middle;\">\n",
|
||||
" <img src=\"../resources.jpg\" width=\"150\" height=\"150\" style=\"display: block;\" />\n",
|
||||
" <img src=\"../../resources.jpg\" width=\"150\" height=\"150\" style=\"display: block;\" />\n",
|
||||
" </td>\n",
|
||||
" <td>\n",
|
||||
" <h2 style=\"color:#f71;\">Reminder about the resources page</h2>\n",
|
||||
@@ -610,7 +610,7 @@
|
||||
"<table style=\"margin: 0; text-align: left;\">\n",
|
||||
" <tr>\n",
|
||||
" <td style=\"width: 150px; height: 150px; vertical-align: middle;\">\n",
|
||||
" <img src=\"../important.jpg\" width=\"150\" height=\"150\" style=\"display: block;\" />\n",
|
||||
" <img src=\"../../important.jpg\" width=\"150\" height=\"150\" style=\"display: block;\" />\n",
|
||||
" </td>\n",
|
||||
" <td>\n",
|
||||
" <h2 style=\"color:#900;\">Before you continue</h2>\n",
|
||||
@@ -646,7 +646,7 @@
|
||||
"<table style=\"margin: 0; text-align: left;\">\n",
|
||||
" <tr>\n",
|
||||
" <td style=\"width: 150px; height: 150px; vertical-align: middle;\">\n",
|
||||
" <img src=\"../business.jpg\" width=\"150\" height=\"150\" style=\"display: block;\" />\n",
|
||||
" <img src=\"../../business.jpg\" width=\"150\" height=\"150\" style=\"display: block;\" />\n",
|
||||
" </td>\n",
|
||||
" <td>\n",
|
||||
" <h2 style=\"color:#181;\">Business relevance</h2>\n",
|
||||
@@ -667,7 +667,7 @@
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": ".venv",
|
||||
"display_name": "Python 3 (ipykernel)",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
@@ -681,7 +681,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.9.6"
|
||||
"version": "3.11.11"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
||||
@@ -641,7 +641,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.11.10"
|
||||
"version": "3.11.11"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
||||
@@ -466,7 +466,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.11.10"
|
||||
"version": "3.11.11"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
||||
@@ -292,7 +292,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.11.10"
|
||||
"version": "3.11.11"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
||||
@@ -315,7 +315,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.11.10"
|
||||
"version": "3.11.11"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
||||
@@ -104,8 +104,8 @@
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# import for google\n",
|
||||
"# in rare cases, this seems to give an error on some systems. Please reach out to me if this happens,\n",
|
||||
"# or you can feel free to skip Gemini - it's the lowest priority of the frontier models that we use\n",
|
||||
"# in rare cases, this seems to give an error on some systems, or even crashes the kernel\n",
|
||||
"# If this happens to you, simply ignore this cell - I give an alternative approach for using Gemini later\n",
|
||||
"\n",
|
||||
"import google.generativeai"
|
||||
]
|
||||
@@ -148,14 +148,22 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Connect to OpenAI, Anthropic and Google\n",
|
||||
"# All 3 APIs are similar\n",
|
||||
"# Having problems with API files? You can use openai = OpenAI(api_key=\"your-key-here\") and same for claude\n",
|
||||
"# Having problems with Google Gemini setup? Then just skip Gemini; you'll get all the experience you need from GPT and Claude.\n",
|
||||
"# Connect to OpenAI, Anthropic\n",
|
||||
"\n",
|
||||
"openai = OpenAI()\n",
|
||||
"\n",
|
||||
"claude = anthropic.Anthropic()\n",
|
||||
"claude = anthropic.Anthropic()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "425ed580-808d-429b-85b0-6cba50ca1d0c",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# This is the set up code for Gemini\n",
|
||||
"# Having problems with Google Gemini setup? Then just ignore this cell; when we use Gemini, I'll give you an alternative that bypasses this library altogether\n",
|
||||
"\n",
|
||||
"google.generativeai.configure()"
|
||||
]
|
||||
@@ -308,7 +316,9 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# The API for Gemini has a slightly different structure\n",
|
||||
"# The API for Gemini has a slightly different structure.\n",
|
||||
"# I've heard that on some PCs, this Gemini code causes the Kernel to crash.\n",
|
||||
"# If that happens to you, please skip this cell and use the next cell instead - an alternative approach.\n",
|
||||
"\n",
|
||||
"gemini = google.generativeai.GenerativeModel(\n",
|
||||
" model_name='gemini-1.5-flash',\n",
|
||||
@@ -318,6 +328,28 @@
|
||||
"print(response.text)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "49009a30-037d-41c8-b874-127f61c4aa3a",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# As an alternative way to use Gemini that bypasses Google's python API library,\n",
|
||||
"# Google has recently released new endpoints that means you can use Gemini via the client libraries for OpenAI!\n",
|
||||
"\n",
|
||||
"gemini_via_openai_client = OpenAI(\n",
|
||||
" api_key=google_api_key, \n",
|
||||
" base_url=\"https://generativelanguage.googleapis.com/v1beta/openai/\"\n",
|
||||
")\n",
|
||||
"\n",
|
||||
"response = gemini_via_openai_client.chat.completions.create(\n",
|
||||
" model=\"gemini-1.5-flash\",\n",
|
||||
" messages=prompts\n",
|
||||
")\n",
|
||||
"print(response.choices[0].message.content)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
@@ -534,7 +566,7 @@
|
||||
"\n",
|
||||
"Try creating a 3-way, perhaps bringing Gemini into the conversation! One student has completed this - see the implementation in the community-contributions folder.\n",
|
||||
"\n",
|
||||
"Try doing this yourself before you look at the solutions.\n",
|
||||
"Try doing this yourself before you look at the solutions. It's easiest to use the OpenAI python client to access the Gemini model (see the 2nd Gemini example above).\n",
|
||||
"\n",
|
||||
"## Additional exercise\n",
|
||||
"\n",
|
||||
@@ -584,7 +616,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.11.10"
|
||||
"version": "3.11.11"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
||||
@@ -186,6 +186,7 @@
|
||||
"source": [
|
||||
"# Adding share=True means that it can be accessed publically\n",
|
||||
"# A more permanent hosting is available using a platform called Spaces from HuggingFace, which we will touch on next week\n",
|
||||
"# NOTE: Some Anti-virus software and Corporate Firewalls might not like you using share=True. If you're at work on on a work network, I suggest skip this test.\n",
|
||||
"\n",
|
||||
"gr.Interface(fn=shout, inputs=\"textbox\", outputs=\"textbox\", flagging_mode=\"never\").launch(share=True)"
|
||||
]
|
||||
@@ -565,7 +566,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.11.10"
|
||||
"version": "3.11.11"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
||||
@@ -296,7 +296,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.11.10"
|
||||
"version": "3.11.11"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
||||
@@ -44,7 +44,12 @@
|
||||
" print(\"OpenAI API Key not set\")\n",
|
||||
" \n",
|
||||
"MODEL = \"gpt-4o-mini\"\n",
|
||||
"openai = OpenAI()"
|
||||
"openai = OpenAI()\n",
|
||||
"\n",
|
||||
"# As an alternative, if you'd like to use Ollama instead of OpenAI\n",
|
||||
"# Check that Ollama is running for you locally (see week1/day2 exercise) then uncomment these next 2 lines\n",
|
||||
"# MODEL = \"llama3.2\"\n",
|
||||
"# openai = OpenAI(base_url='http://localhost:11434/v1', api_key='ollama')\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -249,7 +254,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.11.10"
|
||||
"version": "3.11.11"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
||||
@@ -296,7 +296,7 @@
|
||||
"id": "f4975b87-19e9-4ade-a232-9b809ec75c9a",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Audio\n",
|
||||
"## Audio (NOTE - Audio is optional for this course - feel free to skip Audio if it causes trouble!)\n",
|
||||
"\n",
|
||||
"And let's make a function talker that uses OpenAI's speech model to generate Audio\n",
|
||||
"\n",
|
||||
@@ -410,12 +410,14 @@
|
||||
"source": [
|
||||
"# For Windows users\n",
|
||||
"\n",
|
||||
"## if you get a permissions error writing to a temp file, then this code should work instead.\n",
|
||||
"## First try the Mac version above, but if you get a permissions error writing to a temp file, then this code should work instead.\n",
|
||||
"\n",
|
||||
"A collaboration between students Mark M. and Patrick H. and Claude got this resolved!\n",
|
||||
"\n",
|
||||
"Below are 3 variations - hopefully one of them will work on your PC. If not, message me please!\n",
|
||||
"\n",
|
||||
"And for Mac people - all 3 of the below work on my Mac too - please try these if the Mac version gave you problems.\n",
|
||||
"\n",
|
||||
"## PC Variation 1"
|
||||
]
|
||||
},
|
||||
@@ -695,7 +697,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.11.10"
|
||||
"version": "3.11.11"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.11.10"
|
||||
"version": "3.11.11"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
||||
Reference in New Issue
Block a user