Skip to content

Commit d45a038

Browse files
Merge branch 'main' into update-langfuse-sdk-to-v3
2 parents db3c2c4 + 59ad325 commit d45a038

36 files changed

+4528
-208
lines changed

authors.yaml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ MW-OAI:
275275
dwigg-openai:
276276
name: "Danny Wigg"
277277
website: "https://www.linkedin.com/in/dannywigg/"
278-
avatar: "https://media.licdn.com/dms/image/v2/C4D03AQEjMSl0pMR_qw/profile-displayphoto-shrink_800_800/profile-displayphoto-shrink_800_800/0/1587647134114?e=1743033600&v=beta&t=XmULCSmk6V6YFmlyBggxj5uJeoYYuaYUKgcByKlS0K0"
278+
avatar: "https://avatars.githubusercontent.com/u/4661060?v=4"
279279

280280
msingh-openai:
281281
name: "Mandeep Singh"
@@ -370,4 +370,19 @@ joshbickett:
370370
lupie:
371371
name: "Lucie Lozinski"
372372
website: "https://twitter.com/thisloops"
373-
avatar: "https://avatars.githubusercontent.com/u/6293148"
373+
avatar: "https://avatars.githubusercontent.com/u/6293148"
374+
375+
alexl-oai:
376+
name: "Alex Lowden"
377+
website: "https://www.linkedin.com/in/alex-lowden01/"
378+
avatar: "https://avatars.githubusercontent.com/u/215167546"
379+
380+
lara-openai:
381+
name: "Lara Rachidi"
382+
website: "https://www.linkedin.com/in/lara-rachidi/"
383+
avatar: "https://avatars.githubusercontent.com/u/208707651?v=4"
384+
385+
glojain:
386+
name: "Glory Jain"
387+
website: "https://www.linkedin.com/in/gloryjain/"
388+
avatar: "https://media.licdn.com/dms/image/v2/C4E03AQH72n6Sm5q69Q/profile-displayphoto-shrink_400_400/profile-displayphoto-shrink_400_400/0/1557995338725?e=1756339200&v=beta&t=FGTXiCZwTZvqHCY-wd8It15EDf11Rex1oLlBKRGHNtY"

examples/Context_summarization_with_realtime_api.ipynb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,14 @@
333333
" return resp.choices[0].message.content.strip()"
334334
]
335335
},
336+
{
337+
"cell_type": "markdown",
338+
"metadata": {},
339+
"source": [
340+
"Important implementation detail:\n",
341+
"- The summary is appended as a SYSTEM message rather than an ASSISTANT message. Testing revealed that, during extended conversations, using ASSISTANT messages for summaries can cause the model to mistakenly switch from audio responses to text responses. By using SYSTEM messages for summaries (which can also include additional custom instructions), we clearly signal to the model that these are context-setting instructions, preventing it from incorrectly adopting the modality of the ongoing user-assistant interaction."
342+
]
343+
},
336344
{
337345
"cell_type": "code",
338346
"execution_count": 11,
@@ -367,8 +375,8 @@
367375
" \"item\": {\n",
368376
" \"id\": summary_id,\n",
369377
" \"type\": \"message\",\n",
370-
" \"role\": \"assistant\",\n",
371-
" \"content\": [{\"type\": \"text\", \"text\": summary_text}],\n",
378+
" \"role\": \"system\",\n",
379+
" \"content\": [{\"type\": \"input_text\", \"text\": summary_text}],\n",
372380
" },\n",
373381
" }))\n",
374382
"\n",

examples/Fine_tuning_direct_preference_optimization_guide.ipynb

Lines changed: 698 additions & 0 deletions
Large diffs are not rendered by default.

examples/Prompt_migration_guide.ipynb

Lines changed: 891 additions & 0 deletions
Large diffs are not rendered by default.

examples/Reinforcement_Fine_Tuning.ipynb

Lines changed: 230 additions & 161 deletions
Large diffs are not rendered by default.

examples/Speech_transcription_methods.ipynb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
"\n",
1414
"By the end you will be able to select and use the appropriate transcription method for your use use cases.\n",
1515
"\n",
16-
"*Note: For simplicity and ease of use, this notebook uses WAV audio files. Real-time microphone streaming (e.g., from web apps or microphones) is not utilized.*"
16+
"*Note:*\n",
17+
"- *This notebook uses WAV audio files for simplicity. It does **not** demonstrate real-time microphone streaming (such as from a web app or direct mic input).*\n",
18+
"- *This notebook uses WebSockets to connect to the Realtime API. Alternatively, you can use WebRTC, see the [OpenAI docs](https://platform.openai.com/docs/guides/realtime#connect-with-webrtc) for details.*"
1719
]
1820
},
1921
{

examples/chatgpt/gpt_actions_library/gpt_action_snowflake_direct.ipynb

Lines changed: 97 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,15 @@
9999
"cell_type": "markdown",
100100
"metadata": {},
101101
"source": [
102-
"## ChatGPT Steps"
102+
"## 1. Configure the Custom GPT"
103103
]
104104
},
105105
{
106106
"cell_type": "markdown",
107107
"metadata": {},
108108
"source": [
109109
"\n",
110-
"### Custom GPT Instructions\n",
110+
"### Set GPT Instructions\n",
111111
"\n",
112112
"Once you've created a Custom GPT, copy the text below in the Instructions panel. Have questions? Check out [Getting Started Example](https://platform.openai.com/docs/actions/getting-started) to see how this step works in more detail."
113113
]
@@ -217,7 +217,7 @@
217217
"cell_type": "markdown",
218218
"metadata": {},
219219
"source": [
220-
"## Authentication Instructions"
220+
"## 2. Configure Snowflake Integration"
221221
]
222222
},
223223
{
@@ -231,20 +231,11 @@
231231
"cell_type": "markdown",
232232
"metadata": {},
233233
"source": [
234-
"### Pre-Action Steps"
235-
]
236-
},
237-
{
238-
"cell_type": "markdown",
239-
"metadata": {},
240-
"source": [
241-
"Before you set up authentication in ChatGPT, please take the following steps in Snowflake.\n",
242-
"\n",
243-
"### 1. Optional: Configure IP Whitelisting for ChatGPT\n",
234+
"### Configure IP Whitelisting for ChatGPT\n",
244235
"Snowflake accounts with network policies that limit connections by IP, may require exceptions to be added for ChatGPT.\n",
245236
"* Review the Snowflake documentation on [Network Policies](https://docs.snowflake.com/en/user-guide/network-policies)\n",
246237
"* Go to the Snowflake Worksheets\n",
247-
"* Create a network rule with the ChatGPT IP egress ranges listed [here](https://platform.openai.com/docs/actions/production/ip-egress-ranges)\n",
238+
"* Create a network rule with the ChatGPT IP egress ranges listed [here](https://platform.openai.com/docs/actions/production/ip-egress-ranges#ip-egress-ranges)\n",
248239
"* Create a corresponding Network Policy"
249240
]
250241
},
@@ -258,26 +249,11 @@
258249
},
259250
"outputs": [],
260251
"source": [
261-
"## Example with ChatGPT IPs as of October 23, 2024\n",
262-
"## Make sure to get the current IP ranges from https://platform.openai.com/docs/actions/production\n",
252+
"## ChatGPT IP ranges available at https://openai.com/chatgpt-actions.json\n",
263253
"CREATE NETWORK RULE chatgpt_network_rule\n",
264254
" MODE = INGRESS\n",
265255
" TYPE = IPV4\n",
266-
" VALUE_LIST = ('23.102.140.112/28',\n",
267-
" '13.66.11.96/28',\n",
268-
" '104.210.133.240/28',\n",
269-
" '70.37.60.192/28',\n",
270-
" '20.97.188.144/28',\n",
271-
" '20.161.76.48/28',\n",
272-
" '52.234.32.208/28',\n",
273-
" '52.156.132.32/28',\n",
274-
" '40.84.220.192/28',\n",
275-
" '23.98.178.64/28',\n",
276-
" '51.8.155.32/28',\n",
277-
" '20.246.77.240/28',\n",
278-
" '172.178.141.0/28',\n",
279-
" '172.178.141.192/28',\n",
280-
" '40.84.180.128/28');\n",
256+
" VALUE_LIST = ('23.102.140.112/28',...,'40.84.180.128/28');\n",
281257
"\n",
282258
"CREATE NETWORK POLICY chatgpt_network_policy\n",
283259
" ALLOWED_NETWORK_RULE_LIST = ('chatgpt_network_rule');"
@@ -287,14 +263,14 @@
287263
"cell_type": "markdown",
288264
"metadata": {},
289265
"source": [
290-
"Network policies can be applied at the account, security integration, and user level. The most specific network policy overrides the more general network policies. Depending on how these policies are applied, you may need to alter the policies for individual users in addition to the security integration. If you face this issue, you may encounter Snowflake's error code 390422."
266+
"Network policies can be applied at the account, security integration, and user level. The most specific network policy overrides the more general network policies. Depending on how these policies are applied, you may need to alter the policies for individual users in addition to the security integration. If you face this issue, you may encounter Snowflake's error code 390422 or a generic \"Invalid Client\" error."
291267
]
292268
},
293269
{
294270
"cell_type": "markdown",
295271
"metadata": {},
296272
"source": [
297-
"### 2. Set up the Security Integration\n",
273+
"### Create the Security Integration\n",
298274
"* Review the Snowflake OAuth Overview: [https://docs.snowflake.com/en/user-guide/oauth-snowflake-overview](https://docs.snowflake.com/en/user-guide/oauth-snowflake-overview)\n",
299275
"* Create new OAuth credentials through a [Security Integration](https://docs.snowflake.com/en/sql-reference/sql/create-security-integration-oauth-snowflake) - you will need a new one for each OAuth app/custom GPT since Snowflake Redirect URIs are 1-1 mapped to Security Integrations"
300276
]
@@ -324,7 +300,89 @@
324300
"cell_type": "markdown",
325301
"metadata": {},
326302
"source": [
327-
"\n",
303+
"<details>\n",
304+
" <summary>Optional: Automate Network Rule Configuration</summary>\n",
305+
" \n",
306+
" There are now over 100 egress IP addresses used by ChatGPT. The list updates irregularly and without announcement. To keep up to date with it, we can fetch the list on a daily basis and apply it to our network rule.\n",
307+
"\n",
308+
" ### Network rule to allow outbound traffic to OpenAI\n",
309+
" ```sql\n",
310+
" CREATE OR REPLACE NETWORK RULE chatgpt_actions_rule\n",
311+
" MODE = EGRESS -- outbound\n",
312+
" TYPE = HOST_PORT\n",
313+
" VALUE_LIST = ('openai.com:443');\n",
314+
" ```\n",
315+
" ### Access Integration to apply the rule\n",
316+
" ```sql\n",
317+
" CREATE OR REPLACE EXTERNAL ACCESS INTEGRATION chatgpt_actions_integration\n",
318+
" ALLOWED_NETWORK_RULES = (chatgpt_actions_rule)\n",
319+
" ENABLED = TRUE;\n",
320+
" ```\n",
321+
"\n",
322+
" ### UDF to Fetch the IP ranges\n",
323+
" ```sql\n",
324+
" CREATE OR REPLACE FUNCTION getChatGPTActionsAddresses()\n",
325+
" RETURNS ARRAY -- array<varchar>\n",
326+
" LANGUAGE PYTHON\n",
327+
" RUNTIME_VERSION = 3.10\n",
328+
" PACKAGES = ('requests')\n",
329+
" EXTERNAL_ACCESS_INTEGRATIONS = (chatgpt_actions_integration)\n",
330+
" HANDLER = 'get_ip_address_ranges'\n",
331+
"AS\n",
332+
"$$\n",
333+
"import requests\n",
334+
"\n",
335+
"def get_ip_address_ranges():\n",
336+
" resp = requests.get(\"https://openai.com/chatgpt-actions.json\", timeout=10)\n",
337+
" resp.raise_for_status()\n",
338+
" data = [entry[\"ipv4Prefix\"] for entry in resp.json().get(\"prefixes\", []) if \"ipv4Prefix\" in entry]\n",
339+
" return data\n",
340+
"$$;\n",
341+
" ```\n",
342+
" ### Procedure to update the network rule\n",
343+
" ```sql\n",
344+
" CREATE OR REPLACE PROCEDURE update_chatgpt_network_rule()\n",
345+
" RETURNS STRING\n",
346+
" LANGUAGE SQL\n",
347+
"AS\n",
348+
"$$\n",
349+
"DECLARE\n",
350+
" ip_list STRING;\n",
351+
"BEGIN\n",
352+
" -- Properly quote the IPs for use in VALUE_LIST\n",
353+
" ip_list := '''' || ARRAY_TO_STRING(getChatGPTActionsAddresses(), ''',''') || '''';\n",
354+
"\n",
355+
" -- Run the dynamic SQL to update the rule\n",
356+
" EXECUTE IMMEDIATE\n",
357+
" 'ALTER NETWORK RULE chatgpt_network_rule SET VALUE_LIST = (' || ip_list || ')';\n",
358+
"\n",
359+
" RETURN 'chatgpt_network_rule updated with ' || ARRAY_SIZE(getChatGPTActionsAddresses()) || ' entries';\n",
360+
"END;\n",
361+
"$$;\n",
362+
" ```\n",
363+
"\n",
364+
" ### Call the procedure\n",
365+
" ```sql\n",
366+
" CALL update_chatgpt_network_rule();\n",
367+
" ```\n",
368+
"\n",
369+
" ### Run the procedure every day at 6AM Pacific Time\n",
370+
" ```sql\n",
371+
" CREATE OR REPLACE TASK auto_update_chatgpt_network_rule\n",
372+
" WAREHOUSE = COMPUTE_WH\n",
373+
" SCHEDULE = 'USING CRON 0 6 * * * America/Los_Angeles'\n",
374+
"AS\n",
375+
" CALL update_chatgpt_network_rule();\n",
376+
" ```\n",
377+
"</details>"
378+
]
379+
},
380+
{
381+
"cell_type": "markdown",
382+
"metadata": {},
383+
"source": [
384+
"## 3. Configure GPT Action Authentication\n",
385+
"### Gather key information from Snowflake\n",
328386
"* Retrieve your OAuth Client ID, Auth URL, and Token URL\n"
329387
]
330388
},
@@ -346,7 +404,7 @@
346404
"metadata": {},
347405
"source": [
348406
"\n",
349-
"You’ll find the required information in these 3 columns:"
407+
"You’ll find the required information in these 3 rows:"
350408
]
351409
},
352410
{
@@ -391,7 +449,7 @@
391449
"cell_type": "markdown",
392450
"metadata": {},
393451
"source": [
394-
"### In ChatGPT"
452+
"### Set OAuth Values in GPT Action Authentication"
395453
]
396454
},
397455
{
@@ -407,18 +465,18 @@
407465
"| Client Secret | OAUTH_CLIENT_SECRET from SHOW_OAUTH_CLIENT_SECRETS |\n",
408466
"| Authorization URL | OAUTH_AUTHORIZATION_ENDPOINT from DESCRIBE SECURITY INTEGRATION |\n",
409467
"| Token URL | OAUTH_TOKEN_ENDPOINT from DESCRIBE SECURITY INTEGRATION |\n",
410-
"| Scope | session:role:your_role* |\n",
468+
"| Scope | session:role:CHATGPT_INTEGRATION_ROLE* |\n",
411469
"| Token Exchange Method | Default (POST Request) |\n",
412470
"\n",
413471
"\n",
414-
"*Snowflake scopes pass the role in the format `session:role:<your_role>` for example `session:role:CHATGPT_INTEGRATION_ROLE`. It's possible to leave this empty and specify the role in the instructions, but by adding it here it becomes included in OAuth Consent Request which can sometimes be more reliable. "
472+
"*Snowflake scopes pass the role in the format `session:role:<your_role>` for example `session:role:CHATGPT_INTEGRATION_ROLE`. You can optionally leave this field empty and specify the role in the GPT instructions, but by adding it here it becomes included in OAuth Consent Request which can sometimes be more reliable. "
415473
]
416474
},
417475
{
418476
"cell_type": "markdown",
419477
"metadata": {},
420478
"source": [
421-
"### Post-Action Steps"
479+
"### 4. Update the Snowflake Integration Redirect URI"
422480
]
423481
},
424482
{
121 KB
Loading
305 KB
Loading
91 KB
Loading

0 commit comments

Comments
 (0)