Skip to content

Examples and guides for using the OpenAI API

dummy key naming

simonpfish90863fe6d526
diff --git a/examples/Question_answering_using_a_search_API.ipynb b/examples/Question_answering_using_a_search_API.ipynb
index a610ef67..e1190b5a 100644
--- a/examples/Question_answering_using_a_search_API.ipynb
+++ b/examples/Question_answering_using_a_search_API.ipynb
@@ -49,7 +49,7 @@
"outputs": [],
"source": [
"%%capture\n",
- "%env NEWS_API_KEY = YOUR_API_KEY\n"
+ "%env NEWS_API_KEY = YOUR_NEWS_API_KEY\n"
]
},
{
@@ -93,7 +93,7 @@
"\n",
"def embeddings(input: list[str]) -> list[list[str]]:\n",
" response = openai.Embedding.create(model=\"text-embedding-ada-002\", input=input)\n",
- " return [data.embedding for data in response.data]"
+ " return [data.embedding for data in response.data]\n"
]
},
{
@@ -113,7 +113,7 @@
"outputs": [],
"source": [
"# User asks a question\n",
- "USER_QUESTION = \"Who won the NBA championship? And who was the MVP? Tell me a bit about the last game.\""
+ "USER_QUESTION = \"Who won the NBA championship? And who was the MVP? Tell me a bit about the last game.\"\n"
]
},
{
@@ -179,7 +179,7 @@
"# Let's include the original question as well for good measure\n",
"queries.append(USER_QUESTION)\n",
"\n",
- "queries"
+ "queries\n"
]
},
{
@@ -282,7 +282,7 @@
" print(\"Title:\", article[\"title\"])\n",
" print(\"Description:\", article[\"description\"])\n",
" print(\"Content:\", article[\"content\"][0:100] + \"...\")\n",
- " print()\n"
+ " print()"
]
},
{
@@ -326,7 +326,7 @@
"\n",
"hypothetical_answer = json_gpt(HA_INPUT)[\"hypotheticalAnswer\"]\n",
"\n",
- "hypothetical_answer\n"
+ "hypothetical_answer"
]
},
{
@@ -376,7 +376,7 @@
"for article_embedding in article_embeddings:\n",
" cosine_similarities.append(dot(hypothetical_answer_embedding, article_embedding))\n",
"\n",
- "cosine_similarities[0:10]\n"
+ "cosine_similarities[0:10]"
]
},
{
@@ -440,7 +440,7 @@
" print(\"Description:\", article[\"description\"])\n",
" print(\"Content:\", article[\"content\"][0:100] + \"...\")\n",
" print(\"Score:\", score)\n",
- " print()\n"
+ " print()"
]
},
{
@@ -500,7 +500,7 @@
"for chunk in completion:\n",
" text += chunk.choices[0].delta.get(\"content\", \"\")\n",
" display.clear_output(wait=True)\n",
- " display.display(display.Markdown(text))"
+ " display.display(display.Markdown(text))\n"
]
}
],