From 9cca5434497e25834cebade1bdfaee2ae410a58a Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 27 Oct 2025 07:46:19 +0000 Subject: [PATCH 1/2] Update optimizer import documentation to use modern import pattern MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changed the documentation to reflect the current best practice of importing optimizers directly from dspy (e.g., `from dspy import MIPROv2`) rather than the legacy `from dspy.teleprompt import *` pattern. While the teleprompt import path still works for backward compatibility, the modern approach is cleaner and aligns with how optimizers are referenced throughout the rest of the documentation. Changes: - Updated line 38 to show `dspy.` import pattern - Updated example code to use `from dspy import BootstrapFewShotWithRandomSearch` 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- docs/docs/learn/optimization/optimizers.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/docs/learn/optimization/optimizers.md b/docs/docs/learn/optimization/optimizers.md index a684f6f5b4..f61c0b72c4 100644 --- a/docs/docs/learn/optimization/optimizers.md +++ b/docs/docs/learn/optimization/optimizers.md @@ -35,7 +35,7 @@ Different optimizers in DSPy will tune your program's quality by **synthesizing ## What DSPy Optimizers are currently available? -Optimizers can be accessed via `from dspy.teleprompt import *`. +Optimizers can be accessed directly as `dspy.` (e.g., `dspy.MIPROv2`, `dspy.BootstrapFewShot`) or via `from dspy import `. ### Automatic Few-Shot Learning @@ -93,7 +93,7 @@ They all share this general interface, with some differences in the keyword argu Let's see this with the most common one, `BootstrapFewShotWithRandomSearch`. ```python -from dspy.teleprompt import BootstrapFewShotWithRandomSearch +from dspy import BootstrapFewShotWithRandomSearch # Set up the optimizer: we want to "bootstrap" (i.e., self-generate) 8-shot examples of your program's steps. # The optimizer will repeat this 10 times (plus some initial attempts) before selecting its best attempt on the devset. From 4ea02e637e91601273b67bdb91e9ce975c621e2a Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 27 Oct 2025 08:03:00 +0000 Subject: [PATCH 2/2] Fix optimizer import example to use standard dspy. pattern MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Updated the example code to use `import dspy` followed by `dspy.BootstrapFewShotWithRandomSearch(...)` instead of importing the class directly. This matches the pattern used throughout the rest of the documentation. Also simplified line 38 to only mention the `dspy.` pattern, which is the standard approach in all code examples. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- docs/docs/learn/optimization/optimizers.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/docs/learn/optimization/optimizers.md b/docs/docs/learn/optimization/optimizers.md index f61c0b72c4..f3f54c840e 100644 --- a/docs/docs/learn/optimization/optimizers.md +++ b/docs/docs/learn/optimization/optimizers.md @@ -35,7 +35,7 @@ Different optimizers in DSPy will tune your program's quality by **synthesizing ## What DSPy Optimizers are currently available? -Optimizers can be accessed directly as `dspy.` (e.g., `dspy.MIPROv2`, `dspy.BootstrapFewShot`) or via `from dspy import `. +Optimizers can be accessed as `dspy.` (e.g., `dspy.MIPROv2`, `dspy.BootstrapFewShot`). ### Automatic Few-Shot Learning @@ -93,13 +93,13 @@ They all share this general interface, with some differences in the keyword argu Let's see this with the most common one, `BootstrapFewShotWithRandomSearch`. ```python -from dspy import BootstrapFewShotWithRandomSearch +import dspy # Set up the optimizer: we want to "bootstrap" (i.e., self-generate) 8-shot examples of your program's steps. # The optimizer will repeat this 10 times (plus some initial attempts) before selecting its best attempt on the devset. config = dict(max_bootstrapped_demos=4, max_labeled_demos=4, num_candidate_programs=10, num_threads=4) -teleprompter = BootstrapFewShotWithRandomSearch(metric=YOUR_METRIC_HERE, **config) +teleprompter = dspy.BootstrapFewShotWithRandomSearch(metric=YOUR_METRIC_HERE, **config) optimized_program = teleprompter.compile(YOUR_PROGRAM_HERE, trainset=YOUR_TRAINSET_HERE) ```