Skip to content

Examples and guides for using the OpenAI API

create/check data dir for arxiv's papers (#531)

Elmira Ghorbani28fef26cc9df
diff --git a/examples/How_to_call_functions_for_knowledge_retrieval.ipynb b/examples/How_to_call_functions_for_knowledge_retrieval.ipynb
index 2383f135..48125e49 100644
--- a/examples/How_to_call_functions_for_knowledge_retrieval.ipynb
+++ b/examples/How_to_call_functions_for_knowledge_retrieval.ipynb
@@ -150,6 +150,8 @@
"metadata": {},
"outputs": [],
"source": [
+ "import os\n",
+ "\n",
"import arxiv\n",
"import ast\n",
"import concurrent\n",
@@ -190,6 +192,25 @@
"id": "2de5d32d",
"metadata": {},
"outputs": [],
+ "source": [
+ "directory = './data/papers'\n",
+ "\n",
+ "# Check if the directory already exists\n",
+ "if not os.path.exists(directory):\n",
+ " # If the directory doesn't exist, create it and any necessary intermediate directories\n",
+ " os.makedirs(directory)\n",
+ " print(f\"Directory '{directory}' created successfully.\")\n",
+ "else:\n",
+ " # If the directory already exists, print a message indicating it\n",
+ " print(f\"Directory '{directory}' already exists.\")"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "ae5cb7a1",
+ "metadata": {},
+ "outputs": [],
"source": [
"# Set a directory to store downloaded papers\n",
"data_dir = os.path.join(os.curdir, \"data\", \"papers\")\n",
@@ -197,7 +218,7 @@
"\n",
"# Generate a blank dataframe where we can store downloaded files\n",
"df = pd.DataFrame(list())\n",
- "df.to_csv(paper_dir_filepath)\n"
+ "df.to_csv(paper_dir_filepath)"
]
},
{