Skip to content

armgit / dspy

Public Imported from GitHub
0

DSPy: The framework for programming—not prompting—language models

Python

Support for running notebooks off colab

Thomas D Ahle82524baf49c5
diff --git a/examples/longformqa/longformqa_assertions.ipynb b/examples/longformqa/longformqa_assertions.ipynb
index d3059b1cb..b37be6adf 100644
--- a/examples/longformqa/longformqa_assertions.ipynb
+++ b/examples/longformqa/longformqa_assertions.ipynb
@@ -47,6 +47,12 @@
"import os\n",
"repo_clone_path = '/content/DSPy_LongFormQA_Cache'\n",
"\n",
+ "# Check if '/content' is writable\n",
+ "if not os.access('/content', os.W_OK):\n",
+ " # If '/content' is not writable, choose an alternative directory\n",
+ " # Example: using a directory relative to the current working directory\n",
+ " repo_clone_path = os.path.join(os.getcwd(), 'DSPy_LongFormQA_Cache')\n",
+ "\n",
"# Set up the cache for this notebook\n",
"os.environ[\"DSP_NOTEBOOK_CACHEDIR\"] = repo_clone_path"
]
diff --git a/examples/quiz/quiz_assertions.ipynb b/examples/quiz/quiz_assertions.ipynb
index 8cdbdbcc9..48385d97e 100644
--- a/examples/quiz/quiz_assertions.ipynb
+++ b/examples/quiz/quiz_assertions.ipynb
@@ -37,6 +37,12 @@
"import os\n",
"repo_clone_path = '/content/DSPy_QuizGen_Cache'\n",
"\n",
+ "# Check if '/content' is writable\n",
+ "if not os.access('/content', os.W_OK):\n",
+ " # If '/content' is not writable, choose an alternative directory\n",
+ " # Example: using a directory relative to the current working directory\n",
+ " repo_clone_path = os.path.join(os.getcwd(), 'DSPy_QuizGen_Cache')\n",
+ "\n",
"# Set up the cache for this notebook\n",
"os.environ[\"DSP_NOTEBOOK_CACHEDIR\"] = repo_clone_path"
]
diff --git a/examples/tweets/tweets_assertions.ipynb b/examples/tweets/tweets_assertions.ipynb
index 22c2db296..46afc29cc 100644
--- a/examples/tweets/tweets_assertions.ipynb
+++ b/examples/tweets/tweets_assertions.ipynb
@@ -37,6 +37,12 @@
"import os\n",
"repo_clone_path = '/content/DSPy_TweetGen_Cache'\n",
"\n",
+ "# Check if '/content' is writable\n",
+ "if not os.access('/content', os.W_OK):\n",
+ " # If '/content' is not writable, choose an alternative directory\n",
+ " # Example: using a directory relative to the current working directory\n",
+ " repo_clone_path = os.path.join(os.getcwd(), 'DSPy_TweetGen_Cache')\n",
+ "\n",
"# Set up the cache for this notebook\n",
"os.environ[\"DSP_NOTEBOOK_CACHEDIR\"] = repo_clone_path"
]