Repository Analysis

stanfordnlp/dspy

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

27.7 Moderate AI signal View on GitHub
27.7
Adjusted Score
27.7
Raw Score
100%
Time Factor
2026-05-29
Last Push
34,727
Stars
Python
Language
81,419
Lines of Code
441
Files
1783
Pattern Hits
2026-05-31
Scan Date

Score History

Severity Breakdown

CRITICAL 1HIGH 65MEDIUM 148LOW 1569

Pattern Findings

1783 matches across 19 categories. Click a row to expand file-level details.

Hyper-Verbose Identifiers1044 hits · 958 pts
SeverityFileLineSnippet
LOWdspy/propose/dataset_summary_generator.py30def order_input_keys_in_string(unordered_repr):
LOWdspy/propose/propose_base.py9 def propose_instructions_for_program(self):
LOWdspy/propose/propose_base.py12 def propose_instruction_for_predictor(self):
LOWdspy/propose/utils.py22def create_instruction_set_history_string(base_program, trial_logs, top_n):
LOWdspy/propose/utils.py58def parse_list_of_instructions(instruction_string):
LOWdspy/propose/utils.py70def get_program_instruction_set_string(program):
LOWdspy/propose/utils.py78def create_predictor_level_history_string(base_program, predictor_i, trial_logs, top_n):
LOWdspy/propose/grounded_proposer.py64def generate_instruction_class(
LOWdspy/propose/grounded_proposer.py155 def gather_examples_from_sets(candidate_sets, max_examples):
LOWdspy/propose/grounded_proposer.py306 def propose_instructions_for_program(
LOWdspy/propose/grounded_proposer.py366 def propose_instruction_for_predictor(
LOWdspy/clients/base_lm.py70 def supports_function_calling(self) -> bool:
LOWdspy/clients/base_lm.py147 def _declares_forward_contract(self) -> bool:
LOWdspy/clients/base_lm.py167 def _validate_typed_lm_response(self, response: Any) -> LMResponse:
LOWdspy/clients/base_lm.py176 def _validate_legacy_lm_response(
LOWdspy/clients/base_lm.py206 def supports_function_calling(self) -> bool:
LOWdspy/clients/base_lm.py505 def _extract_citations_from_response(self, choice):
LOWdspy/clients/embedding.py169def _cached_compute_embeddings(model, batch_inputs, caching=True, **kwargs):
LOWdspy/clients/embedding.py185async def _cached_acompute_embeddings(model, batch_inputs, caching=True, **kwargs):
LOWdspy/clients/__init__.py87def configure_litellm_logging(level: str = "ERROR"):
LOWdspy/clients/utils_finetune.py131def find_data_errors_completion(data_dict: dict[str, str]) -> str | None:
LOWdspy/clients/utils_finetune.py164def find_data_error_chat_message(message: dict[str, Any]) -> str | None:
LOWdspy/clients/openai.py123 def is_terminal_training_status(status: TrainingStatus) -> bool:
LOWdspy/clients/_litellm.py12def _configure_litellm_defaults(litellm: types.ModuleType) -> None:
LOWdspy/clients/_litellm.py38def is_litellm_context_window_error(error: Exception) -> bool:
LOWdspy/clients/lm.py47def _is_openai_reasoning_model(model: str) -> bool:
LOWdspy/clients/lm.py148 def supports_function_calling(self) -> bool:
LOWdspy/clients/lm.py172 def _get_cached_completion_fn(self, completion_fn, cache):
LOWdspy/clients/lm.py447def _get_stream_completion_fn(
LOWdspy/clients/lm.py588def litellm_responses_completion(request: dict[str, Any], num_retries: int, cache: dict[str, Any] | None = None):
LOWdspy/clients/lm.py604async def alitellm_responses_completion(request: dict[str, Any], num_retries: int, cache: dict[str, Any] | None = None):
LOWdspy/clients/lm.py620def _convert_chat_request_to_responses_request(request: dict[str, Any]):
LOWdspy/clients/lm.py660def _convert_content_item_to_responses_format(item: dict[str, Any]) -> dict[str, Any]:
LOWdspy/clients/lm.py700def _add_dspy_identifier_to_headers(headers: dict[str, Any] | None = None):
LOWdspy/clients/lm.py711def _safe_litellm_exception_class(name: str) -> type[Exception] | None:
LOWdspy/clients/lm.py716def _lm_error_class_from_litellm_exception(exc: Exception) -> type[LMError] | None:
LOWdspy/clients/lm.py751def _lm_error_class_from_status(status: int | None) -> type[LMError]:
LOWdspy/clients/databricks.py273def _create_directory_in_databricks_unity_catalog(w: "WorkspaceClient", databricks_unity_catalog_path: str):
LOWdspy/clients/databricks.py346def _validate_completion_data(data: dict[str, Any]):
LOWdspy/clients/openai_format.py123def to_openai_responses_request(request: LMRequest) -> dict[str, Any]:
LOWdspy/clients/openai_format.py163def parts_to_responses_content(parts: list[Any]) -> list[dict[str, Any]]:
LOWdspy/clients/openai_format.py170def tool_call_to_responses_input(tool_call_part: LMToolCallPart) -> dict[str, Any]:
LOWdspy/clients/openai_format.py180def content_block_to_responses(block: dict[str, Any]) -> dict[str, Any]:
LOWdspy/clients/openai_format.py536def completion_to_lm_response(response: Any, request: LMRequest) -> LMResponse:
LOWdspy/clients/openai_format.py645def provider_tool_call_to_part(tool_call: Any) -> LMToolCallPart:
LOWdspy/clients/openai_format.py661def responses_function_call_to_part(output_item: Any) -> LMToolCallPart:
LOWdspy/clients/openai_format.py689def extract_citations_from_choice(choice: Any) -> list[LMCitationPart]:
LOWdspy/clients/openai_format.py704def responses_annotations_to_citations(content_item: Any) -> list[LMCitationPart]:
LOWdspy/clients/openai_format.py898def lm_response_from_legacy_outputs(outputs: list[dict[str, Any] | str | None], request: LMRequest) -> LMResponse:
LOWdspy/clients/openai_format.py905def legacy_outputs_from_lm_response(response: LMResponse) -> list[dict[str, Any] | str | None]:
LOWdspy/clients/openai_format.py138def message_to_responses_input_items(message: LMMessage) -> list[dict[str, Any]]:
LOWdspy/clients/openai_format.py300def document_to_openai_blocks(document: LMDocumentPart) -> list[dict[str, Any]]:
LOWdspy/clients/openai_format.py369def assistant_tool_call_to_openai(call: LMToolCallPart) -> dict[str, Any]:
LOWdspy/clients/openai_format.py456def reasoning_to_responses_kwargs(reasoning: Any) -> dict[str, Any]:
LOWdspy/clients/openai_format.py465def _validate_openai_reasoning_temperature(config: LMConfig, *, model: str | None, endpoint: str) -> None:
LOWdspy/clients/openai_format.py488def _uses_max_completion_tokens(model: str | None) -> bool:
LOWdspy/clients/openai_format.py492def _is_openai_reasoning_model(model: str | None) -> bool:
LOWdspy/clients/openai_format.py510def response_format_to_responses(value: Any) -> Any:
LOWdspy/clients/openai_format.py516def responses_tool_output_text(content: Any) -> str:
LOWdspy/clients/openai_format.py627def response_content_item_to_parts(item: Any) -> list[Any]:
984 more matches not shown…
Docstring Block Structure46 hits · 230 pts
SeverityFileLineSnippet
HIGHdspy/clients/base_lm.py356Reconstruct an LM from `dump_state` output. Legacy states without a class marker load as `dspy.LM`. Custom LM
HIGHdspy/clients/provider.py13A future representing an asynchronous model fine-tuning job. This class extends `concurrent.futures.Future` to repr
HIGHdspy/clients/provider.py82A job for reinforcement learning-based fine-tuning. This class represents a reinforcement learning fine-tuning job
HIGHdspy/retrievers/embeddings.py151 Load the embeddings index from disk into the current instance. Args: path: Directory path
HIGHdspy/retrievers/embeddings.py211 Create an Embeddings instance from a saved index. This is the recommended way to load saved embeddings
HIGHdspy/core/types.py1286Create a system message for a direct LM call. A system message gives model-level instructions, such as tone, scope,
HIGHdspy/core/types.py1324Create a developer message for a direct LM call. A developer message carries instructions that sit between system g
HIGHdspy/core/types.py1363Create a user message for a direct LM call. A user message contains the request or data you want the model to answe
HIGHdspy/core/types.py1443Create an assistant message for a direct LM call. An assistant message represents a previous model response. Use it
HIGHdspy/core/types.py1498Create a tool-result message for a direct LM call. A tool-result message sends the output of a tool back to the mod
HIGHdspy/signatures/signature.py279Return a new Signature class with identical fields and new instructions. This method does not mutate `cls`. It
HIGHdspy/signatures/signature.py334Insert a field at index 0 of the `inputs` or `outputs` section. Args: name (str): Field name to add
HIGHdspy/signatures/signature.py361Insert a field at the end of the `inputs` or `outputs` section. Args: name (str): Field name to add
HIGHdspy/signatures/signature.py388Return a new Signature class without the given field. If `name` is not present, the fields are unchanged (no er
HIGHdspy/signatures/signature.py423Insert a field at a specific position among inputs or outputs. Negative indices are supported (e.g., `-1` appen
HIGHdspy/signatures/signature.py535Create a new Signature subclass with the specified fields and instructions. Args: signature: Either a strin
HIGHdspy/signatures/signature.py657Recursively parse an AST node representing a type annotation. This function converts Python's Abstract Syntax Tree
HIGHdspy/streaming/streamify.py39 Wrap a DSPy program so that it streams its outputs incrementally, rather than returning them all at once. It al
HIGHdspy/primitives/code_interpreter.py116Execute Python code and return the result. Args: code: Python code to execute variables
HIGHdspy/primitives/example.py224Mark which fields are inputs and return a new `Example`. Fields not listed here are treated as labels (expected
HIGHdspy/primitives/module.py41Base class for all DSPy modules (programs). A Module is a building block for DSPy programs that can contain predict
HIGHdspy/primitives/module.py226Apply a function to all named predictors in this module. This method iterates through all Predict instances in
HIGHdspy/primitives/module.py280 Processes a list of dspy.Example instances in parallel using the Parallel module. Args: ex
HIGHdspy/adapters/types/citation.py92Convert a list of dictionaries to a Citations instance. Args: citations_dicts: A list of dictionari
HIGHdspy/adapters/types/tool.py220 Build a DSPy tool from a LangChain tool. Args: tool: The LangChain tool to convert.
HIGHdspy/adapters/types/tool.py285Execute this individual tool call and return its result. Args: functions: Functions to sear
HIGHdspy/adapters/types/tool.py346Convert a list of dictionaries to a ToolCalls instance. Args: dict_list: A list of dictionaries, wh
HIGHdspy/adapters/types/image.py129 Encode an image or file to a base64 data URI. Args: image: The image or file to encode. Can be a PIL I
HIGHdspy/evaluate/metrics.py12Compute the Exact Match (EM) metric between a prediction and reference answers. Returns True if any reference exact
HIGHdspy/evaluate/metrics.py40Compute the maximum token-level F1 score against reference answers. Strings are normalized (same as in `EM`) and wh
HIGHdspy/evaluate/metrics.py64Compute the maximum HotPotQA-style F1 score against reference answers. Like `F1`, but if either normalized side is
HIGHdspy/evaluate/metrics.py88Normalize text for string and token comparisons. Steps: 1) Unicode NFD normalization 2) lowercasing
HIGHdspy/evaluate/metrics.py127Compute boolean exact match after normalization. Args: prediction (str): Predicted answer. ground_t
HIGHdspy/evaluate/metrics.py145Compute token-level F1 between prediction and reference (after normalization). Strings are normalized (see `normali
HIGHdspy/evaluate/metrics.py184Compute HotPotQA-style token F1 with special labels. If either normalized string is in {"yes", "no", "noanswer"} an
HIGHdspy/evaluate/metrics.py222Compute token-level precision of prediction against reference (after normalization). Precision is (# overlapping to
HIGHdspy/evaluate/metrics.py286Evaluate exact match or F1-thresholded match for an example/prediction pair. If `example.answer` is a string, compa
HIGHdspy/evaluate/metrics.py321Return True if any passage in `pred.context` contains the answer(s). Strings are normalized (and passages also use
HIGHdspy/evaluate/evaluate.py129 Args: program (dspy.Module): The DSPy program to evaluate. metric (Callable): The metri
HIGHdspy/predict/rlm.py625Execute RLM to produce outputs from the given inputs. Args: **input_args: Input values matching the
HIGHdspy/predict/rlm.py710Async version of forward(). Execute RLM to produce outputs. Args: **input_args: Input values matchi
HIGHdspy/predict/refine.py50 Refines a module by running it up to N times with different rollout IDs at `temperature=1.0` and return
HIGHdspy/predict/best_of_n.py16 Runs a module up to `N` times with different rollout IDs at `temperature=1.0` and returns the best pred
HIGHdspy/teleprompt/bettertogether.py211Compile and optimize a student program using a sequence of optimization strategies. Executes the optimizers spe
HIGHdspy/teleprompt/gepa/gepa.py196 ... ``` GEPA can also be used as a batch inference-time search strategy, by passing `valset=trainset,
HIGHtests/mock_interpreter.py75Execute code and return the next scripted response. Args: code: The code that would be executed (re
Unused Imports249 hits · 227 pts
SeverityFileLineSnippet
LOWdspy/__init__.py1
LOWdspy/__init__.py2
LOWdspy/__init__.py3
LOWdspy/__init__.py4
LOWdspy/__init__.py5
LOWdspy/__init__.py7
LOWdspy/__init__.py8
LOWdspy/__init__.py9
LOWdspy/__init__.py9
LOWdspy/__init__.py9
LOWdspy/__init__.py9
LOWdspy/__init__.py9
LOWdspy/__init__.py9
LOWdspy/__init__.py9
LOWdspy/__init__.py9
LOWdspy/__init__.py9
LOWdspy/__init__.py9
LOWdspy/__init__.py9
LOWdspy/__init__.py9
LOWdspy/__init__.py9
LOWdspy/__init__.py9
LOWdspy/__init__.py9
LOWdspy/__init__.py10
LOWdspy/__init__.py10
LOWdspy/__init__.py10
LOWdspy/__init__.py10
LOWdspy/__init__.py10
LOWdspy/__init__.py10
LOWdspy/__init__.py10
LOWdspy/__init__.py10
LOWdspy/__init__.py10
LOWdspy/__init__.py10
LOWdspy/__init__.py22
LOWdspy/__init__.py23
LOWdspy/__init__.py23
LOWdspy/__init__.py23
LOWdspy/__init__.py23
LOWdspy/__init__.py23
LOWdspy/__init__.py23
LOWdspy/__init__.py23
LOWdspy/__init__.py23
LOWdspy/__init__.py23
LOWdspy/__init__.py23
LOWdspy/__init__.py23
LOWdspy/__init__.py23
LOWdspy/__init__.py23
LOWdspy/__init__.py23
LOWdspy/__init__.py23
LOWdspy/__init__.py23
LOWdspy/__init__.py23
LOWdspy/__init__.py23
LOWdspy/__init__.py43
LOWdspy/__init__.py43
LOWdspy/__init__.py44
LOWdspy/__init__.py45
LOWdspy/__init__.py47
LOWdspy/__init__.py48
LOWdspy/__init__.py51
LOWdspy/__init__.py53
LOWdspy/__init__.py53
189 more matches not shown…
Decorative Section Separators61 hits · 214 pts
SeverityFileLineSnippet
MEDIUMdspy/clients/openai_format.py114# ---------------------------------------------------------------------------
MEDIUMdspy/clients/openai_format.py120# ---------------------------------------------------------------------------
MEDIUMdspy/clients/openai_format.py527# ---------------------------------------------------------------------------
MEDIUMdspy/clients/openai_format.py533# ---------------------------------------------------------------------------
MEDIUMdspy/clients/openai_format.py798# ---------------------------------------------------------------------------
MEDIUMdspy/clients/openai_format.py800# ---------------------------------------------------------------------------
MEDIUMdspy/clients/openai_format.py888# ---------------------------------------------------------------------------
MEDIUMdspy/clients/openai_format.py895# ---------------------------------------------------------------------------
MEDIUMdspy/clients/openai_format.py66# ---------------------------------------------------------------------------
MEDIUMdspy/clients/openai_format.py73# ---------------------------------------------------------------------------
MEDIUMdspy/clients/openai_format.py203# ---------------------------------------------------------------------------
MEDIUMdspy/clients/openai_format.py208# ---------------------------------------------------------------------------
MEDIUMdspy/clients/openai_format.py231# ---------------------------------------------------------------------------
MEDIUMdspy/clients/openai_format.py237# ---------------------------------------------------------------------------
MEDIUMdspy/primitives/python_interpreter.py31# =============================================================================
MEDIUMdspy/primitives/python_interpreter.py33# =============================================================================
MEDIUMdspy/predict/rlm.py168 # =========================================================================
MEDIUMdspy/predict/rlm.py170 # =========================================================================
MEDIUMdspy/predict/rlm.py285 # =========================================================================
MEDIUMdspy/predict/rlm.py287 # =========================================================================
MEDIUMdspy/predict/rlm.py339 # =========================================================================
MEDIUMdspy/predict/rlm.py341 # =========================================================================
MEDIUMdspy/predict/rlm.py421 # =========================================================================
MEDIUMdspy/predict/rlm.py423 # =========================================================================
MEDIUMdspy/predict/rlm.py462 # =========================================================================
MEDIUMdspy/predict/rlm.py464 # =========================================================================
MEDIUMdspy/predict/rlm.py620 # =========================================================================
MEDIUMdspy/predict/rlm.py622 # =========================================================================
MEDIUMtests/primitives/test_python_interpreter.py246# =============================================================================
MEDIUMtests/primitives/test_python_interpreter.py248# =============================================================================
MEDIUMtests/primitives/test_python_interpreter.py413# =============================================================================
MEDIUMtests/primitives/test_python_interpreter.py415# =============================================================================
MEDIUMtests/primitives/test_python_interpreter.py513# =============================================================================
MEDIUMtests/primitives/test_python_interpreter.py515# =============================================================================
MEDIUMtests/predict/test_rlm.py117# ============================================================================
MEDIUMtests/predict/test_rlm.py119# ============================================================================
MEDIUMtests/predict/test_rlm.py655# ============================================================================
MEDIUMtests/predict/test_rlm.py657# ============================================================================
MEDIUMtests/predict/test_rlm.py978# ============================================================================
MEDIUMtests/predict/test_rlm.py980# ============================================================================
MEDIUMtests/predict/test_rlm.py23# ============================================================================
MEDIUMtests/predict/test_rlm.py25# ============================================================================
MEDIUMtests/predict/test_rlm.py80# ============================================================================
MEDIUMtests/predict/test_rlm.py82# ============================================================================
MEDIUMtests/predict/test_rlm.py934# ============================================================================
MEDIUMtests/predict/test_rlm.py936# ============================================================================
MEDIUMtests/predict/test_rlm.py1065# ============================================================================
MEDIUMtests/predict/test_rlm.py1067# ============================================================================
MEDIUMtests/predict/test_rlm.py1161# ============================================================================
MEDIUMtests/predict/test_rlm.py1163# ============================================================================
MEDIUMtests/predict/test_rlm.py1195# ============================================================================
MEDIUMtests/predict/test_rlm.py1197# ============================================================================
MEDIUMtests/predict/test_rlm.py847# ============================================================================
MEDIUMtests/predict/test_rlm.py849# ============================================================================
MEDIUMtests/teleprompt/test_bettertogether.py103# ============================================================================
MEDIUMtests/teleprompt/test_bettertogether.py105# ============================================================================
MEDIUMtests/teleprompt/test_bettertogether.py41# ============================================================================
MEDIUMtests/teleprompt/test_bettertogether.py43# ============================================================================
MEDIUMtests/teleprompt/test_bettertogether.py80# ============================================================================
MEDIUMtests/teleprompt/test_bettertogether.py82# ============================================================================
1 more matches not shown…
Self-Referential Comments67 hits · 187 pts
SeverityFileLineSnippet
MEDIUMdspy/propose/grounded_proposer.py314 """This method is responsible for returning the full set of new instructions for our program, given the specifie
MEDIUMdspy/propose/grounded_proposer.py334 # Create an instruction for each predictor
MEDIUMdspy/propose/grounded_proposer.py376 """This method is responsible for returning a single instruction for a given predictor, using the specified crit
MEDIUMdspy/propose/grounded_proposer.py378 # Create an instruction history string for our predictor
MEDIUMdspy/clients/cache.py248 # Create a modified request that includes the function identifier so that it's incorporated into the cache
MEDIUMdspy/clients/databricks.py299 # Create the directory if it doesn't exist, we don't raise an error because this is a common case.
MEDIUMdspy/retrievers/embeddings.py234 # Create a minimal instance without triggering embedding computation
MEDIUMdspy/retrievers/databricks_rm.py44 # Create a Databricks Vector Search Endpoint
MEDIUMdspy/retrievers/databricks_rm.py51 # Create a Databricks Direct Access Vector Search Index
MEDIUMdspy/retrievers/databricks_rm.py66 # Create a DatabricksRM retriever module to query the Databricks Direct Access Vector
MEDIUMdspy/streaming/streamify.py72 # Create the program and wrap it with streaming functionality
MEDIUMdspy/streaming/streamify.py104 # Create the program and wrap it with streaming functionality
MEDIUMdspy/streaming/streamify.py130 # Create the program and wrap it with streaming functionality
MEDIUMdspy/primitives/base_module.py123 # Create an empty instance.
MEDIUMdspy/primitives/base_module.py211 # Create the directory (and any parent directories)
MEDIUMdspy/primitives/module.py22 # Create the instance without invoking ``__init__`` so we can inject
MEDIUMdspy/primitives/module.py297 # Create a list of execution pairs (self, example)
MEDIUMdspy/primitives/module.py300 # Create an instance of Parallel
MEDIUMdspy/adapters/two_step_adapter.py67 # Create a task description for the main LM
MEDIUMdspy/adapters/types/tool.py140 # Create a pydantic model wrapper with a dummy field `value` to parse the arg to the correct type.
MEDIUMdspy/predict/refine.py72 # Define a QA module with chain of thought
MEDIUMdspy/predict/refine.py75 # Define a reward function that checks for one-word answers
MEDIUMdspy/predict/refine.py79 # Create a refined module that tries up to 3 times
MEDIUMdspy/predict/code_act.py91 # Define the tool functions in the interpreter
MEDIUMdspy/predict/best_of_n.py34 # Define a QA module with chain of thought
MEDIUMdspy/predict/best_of_n.py37 # Define a reward function that checks for one-word answers
MEDIUMdspy/predict/best_of_n.py41 # Create a refined module that tries up to 3 times
MEDIUMdspy/predict/knn.py23 # Create a training dataset with examples
MEDIUMdspy/teleprompt/knn_fewshot.py29 # Define a QA module with chain of thought
MEDIUMdspy/teleprompt/knn_fewshot.py32 # Create a training dataset with examples
MEDIUMdspy/teleprompt/utils.py39 # Create the mini-batch using the sampled indices
MEDIUMdspy/teleprompt/utils.py221 # Define the save path for the program
MEDIUMdspy/teleprompt/utils.py249 # Create a logger
MEDIUMdspy/teleprompt/utils.py253 # Create a file handler that logs debug and higher level messages
MEDIUMdspy/teleprompt/utils.py260 # Create a console handler with a higher log level
MEDIUMdspy/teleprompt/mipro_optimizer_v2.py548 # Initialize optimization variables
MEDIUMdspy/teleprompt/mipro_optimizer_v2.py556 # Define the objective function
MEDIUMdspy/teleprompt/mipro_optimizer_v2.py568 # Create a new candidate program
MEDIUMdspy/teleprompt/gepa/instruction_proposal.py82 # Create a rich multimodal examples_with_feedback that includes both text and images
MEDIUMtests/clients/test_cache.py244 # Define a test function
MEDIUMtests/clients/test_cache.py301 # Define a test function
MEDIUMtests/clients/test_cache.py328 # Define a test function
MEDIUMtests/clients/test_cache.py215 # Create a new cache instance with disk cache disabled
MEDIUMtests/clients/test_cache.py271 # Define a test function
MEDIUMtests/test_utils/server/__init__.py24 # Create a server log file used to store request logs
MEDIUMtests/signatures/test_adapter_image.py346 # Create a dspy.Image object from the PDF URL with download=True
MEDIUMtests/signatures/test_adapter_image.py424 # Create a dspy.Image from the file
MEDIUMtests/utils/test_saving.py96 # Create a custom handler to capture log messages
MEDIUMtests/utils/test_settings.py127 # Define the coroutines to be run
MEDIUMtests/utils/test_settings.py225 # Create a temporary Python file with our custom module
MEDIUMtests/primitives/test_python_interpreter.py522 # Create a string just over the threshold
MEDIUMtests/primitives/test_python_interpreter.py534 # Create a string with recognizable pattern just over threshold
MEDIUMtests/primitives/test_base_module.py135 # Create a temporary Python file with our custom module
MEDIUMtests/primitives/test_base_module.py202 # Create a custom handler to capture log messages
MEDIUMtests/predict/test_rlm.py465 # Create a field with description and constraints
MEDIUMtests/predict/test_predict.py607 # Define a model for datetime inputs and outputs
MEDIUMtests/predict/test_predict.py1764 # Create an instance of the Query model
MEDIUMtests/predict/test_react.py215 # Create a simple tool for testing
MEDIUMtests/reliability/generate/utils.py297 # Create a GeneratedTestCase object and add it to the list
MEDIUMtests/teleprompt/test_copro_optimizer.py7# Define a simple metric function for testing
7 more matches not shown…
Excessive Try-Catch Wrapping122 hits · 141 pts
SeverityFileLineSnippet
LOWdspy/propose/dataset_summary_generator.py82 except Exception as e:
LOWdspy/propose/grounded_proposer.py222 except Exception as e:
MEDIUMdspy/propose/grounded_proposer.py224 print(f"Error getting program description. Running without program aware proposer. Error: {e}")
LOWdspy/propose/grounded_proposer.py289 except Exception as e:
MEDIUMdspy/propose/grounded_proposer.py290 print(f"Error getting source code: {e}.\n\nRunning without program aware proposer.")
LOWdspy/propose/grounded_proposer.py301 except Exception as e:
MEDIUMdspy/propose/grounded_proposer.py302 print(f"Error getting data summary: {e}.\n\nRunning without data aware proposer.")
LOWdspy/clients/base_lm.py520 except Exception:
LOWdspy/clients/disk_serialization.py64 except Exception as e:
LOWdspy/clients/lm_local.py222 except Exception:
MEDIUMdspy/clients/lm_local.py200def train_sft_locally(model_name, train_data, train_kwargs):
LOWdspy/clients/cache.py121 except Exception:
LOWdspy/clients/cache.py172 except Exception:
LOWdspy/clients/cache.py183 except Exception as e:
LOWdspy/clients/__init__.py71 except Exception as e:
LOWdspy/clients/openai.py109 except Exception:
LOWdspy/clients/openai.py119 except Exception:
LOWdspy/clients/lm.py257 except Exception as e:
LOWdspy/clients/lm.py315 except Exception as e:
LOWdspy/clients/lm.py394 except Exception as err:
LOWdspy/clients/databricks.py159 except Exception:
LOWdspy/clients/databricks.py259 except Exception as e:
LOWdspy/clients/databricks.py289 except Exception:
LOWdspy/clients/databricks.py298 except Exception:
MEDIUMdspy/clients/databricks.py263def _get_workspace_client() -> "WorkspaceClient":
LOWdspy/clients/openai_format.py653 except Exception as error:
LOWdspy/clients/openai_format.py668 except Exception as error:
LOWdspy/clients/openai_format.py699 except Exception:
LOWdspy/clients/openai_format.py790 except Exception:
LOWdspy/utils/callback.py271 except Exception as e:
LOWdspy/utils/callback.py283 except Exception as e:
LOWdspy/utils/callback.py311 except Exception as e:
LOWdspy/utils/callback.py341 except Exception as e:
LOWdspy/utils/magicattr.py25 except Exception as ex:
LOWdspy/utils/parallelizer.py60 except Exception as e:
LOWdspy/utils/parallelizer.py191 except Exception:
LOWdspy/utils/langchain_tool.py26 except Exception as e:
MEDIUMdspy/utils/langchain_tool.py22def func(**kwargs):
LOWdspy/utils/lazy_import.py113 except Exception:
LOWdspy/utils/unbatchify.py47 except Exception as e:
LOWdspy/utils/unbatchify.py72 except Exception as e:
LOWdspy/streaming/streaming_listener.py161 except Exception:
LOWdspy/streaming/streaming_listener.py369 except Exception:
MEDIUMdspy/streaming/streaming_listener.py366def _output_type(self) -> type | None:
LOWdspy/primitives/python_interpreter.py227 except Exception:
LOWdspy/primitives/python_interpreter.py334 except Exception as e:
LOWdspy/primitives/base_module.py120 except Exception:
LOWdspy/primitives/base_module.py133 except Exception:
LOWdspy/primitives/base_module.py141 except Exception:
LOWdspy/primitives/base_module.py222 except Exception as e:
LOWdspy/primitives/base_module.py238 except Exception as e:
LOWdspy/adapters/chat_adapter.py86 except Exception as e:
LOWdspy/adapters/chat_adapter.py106 except Exception as e:
LOWdspy/adapters/chat_adapter.py238 except Exception as e:
LOWdspy/adapters/xml_adapter.py111 except Exception as e:
LOWdspy/adapters/_legacy_type_markers.py86 except Exception:
LOWdspy/adapters/utils.py41 except Exception:
LOWdspy/adapters/utils.py196 except Exception:
LOWdspy/adapters/json_adapter.py89 except Exception:
LOWdspy/adapters/json_adapter.py116 except Exception:
62 more matches not shown…
Deep Nesting96 hits · 86 pts
SeverityFileLineSnippet
LOWdspy/propose/dataset_summary_generator.py48
LOWdspy/propose/utils.py146
LOWdspy/propose/grounded_proposer.py144
LOWdspy/propose/grounded_proposer.py306
LOWdspy/propose/grounded_proposer.py155
LOWdspy/clients/base_lm.py523
LOWdspy/clients/cache.py24
LOWdspy/clients/cache.py48
LOWdspy/clients/lm.py620
LOWdspy/clients/databricks.py305
LOWdspy/clients/databricks.py51
LOWdspy/clients/openai_format.py577
LOWdspy/clients/openai_format.py776
LOWdspy/retrievers/weaviate_rm.py73
LOWdspy/retrievers/weaviate_rm.py113
LOWdspy/core/types.py1573
LOWdspy/core/types.py1632
LOWdspy/core/types.py1788
LOWdspy/core/types.py259
LOWdspy/core/types.py1182
LOWdspy/signatures/signature.py54
LOWdspy/signatures/signature.py138
LOWdspy/datasets/hotpotqa.py7
LOWdspy/datasets/math.py36
LOWdspy/datasets/alfworld/alfworld.py6
LOWdspy/utils/annotation.py39
LOWdspy/utils/magicattr.py117
LOWdspy/utils/parallelizer.py105
LOWdspy/utils/inspect_history.py27
LOWdspy/utils/unbatchify.py51
LOWdspy/streaming/streaming_listener.py241
LOWdspy/streaming/streaming_listener.py312
LOWdspy/streaming/streamify.py31
LOWdspy/streaming/streamify.py179
LOWdspy/primitives/example.py324
LOWdspy/primitives/example.py335
LOWdspy/primitives/python_interpreter.py429
LOWdspy/primitives/python_interpreter.py470
LOWdspy/primitives/base_module.py23
LOWdspy/primitives/base_module.py69
LOWdspy/primitives/base_module.py110
LOWdspy/primitives/base_module.py34
LOWdspy/adapters/utils.py93
LOWdspy/adapters/json_adapter.py231
LOWdspy/adapters/json_adapter.py275
LOWdspy/adapters/base.py137
LOWdspy/adapters/base.py280
LOWdspy/adapters/base.py625
LOWdspy/adapters/baml_adapter.py89
LOWdspy/adapters/types/base_type.py135
LOWdspy/adapters/types/citation.py133
LOWdspy/adapters/types/citation.py182
LOWdspy/adapters/types/audio.py125
LOWdspy/adapters/types/tool.py392
LOWdspy/adapters/types/tool.py284
LOWdspy/adapters/types/image.py128
LOWdspy/adapters/types/image.py239
LOWdspy/predict/predict.py398
LOWdspy/predict/predict.py141
LOWdspy/predict/refine.py98
36 more matches not shown…
Cross-Language Confusion9 hits · 50 pts
SeverityFileLineSnippet
HIGHdspy/teleprompt/bootstrap.py121 assert predictor1.signature.equals(
HIGHdspy/teleprompt/gepa/gepa_utils.py224 trace_instances = [t for t in trace if t[0].signature.equals(module.signature)]
HIGHtests/signatures/test_signature.py117 assert sig1.equals(sig2)
HIGHtests/signatures/test_signature.py123 assert not sig1.equals(sig2)
HIGHtests/signatures/test_signature.py131 assert TestSignature.equals(TestSignature)
HIGHtests/signatures/test_signature.py486 assert sig1.equals(sig2)
HIGHtests/signatures/test_signature.py528 assert Sig1.equals(Sig2)
HIGHtests/adapters/test_chat_adapter.py796 '{"type": "null"}], "default": null, "title": "Document Title"}, "end_char_index": '
HIGHtests/adapters/test_chat_adapter.py799 '"string"}, {"type": "null"}], "default": null, "title": "Supported Text"}}, '
Redundant / Tautological Comments18 hits · 25 pts
SeverityFileLineSnippet
LOWdspy/clients/provider.py35 # Check if job is done
LOWdspy/clients/openai.py141 # Check if there is an active job
LOWdspy/signatures/signature.py689 # Check if it's a built-in known type or in the provided names
LOWdspy/signatures/signature.py695 # Check if it matches any known built-in type by name
LOWdspy/primitives/module.py339 # Check if forward is called through __call__ or directly
LOWdspy/adapters/utils.py133 # Check if the identifier is a valid enum member value *before* checking if it's a valid enum
LOWdspy/adapters/base.py558 # Check if all fields are present and not None
LOWdspy/adapters/base.py561 # Check if demo has at least one input and one output field
LOWdspy/adapters/types/citation.py193 # Check if the chunk has citation data in provider_specific_fields
LOWdspy/adapters/types/citation.py215 # Check if the response contains citations in the expected format
LOWdspy/adapters/types/reasoning.py159 # Check if this is a valid string method/attribute
LOWdspy/adapters/types/tool.py101 # Check if the type (or its origin) is a subclass of Pydantic's BaseModel
LOWdspy/teleprompt/bettertogether.py579 # Check if this is the best score so far
LOWtests/docs/test_mkdocs_links.py9 # Read file and extract nav section
LOWtests/docs/test_mkdocs_links.py28 # Check if files exist
LOWtests/reliability/generate/utils.py278 # Check if the directory contains a program.py and an inputs directory
LOWtests/reliability/generate/utils.py684 # Read the file contents
LOWtests/teleprompt/test_copro_optimizer.py148 # Check if the results_best and results_latest contain valid statistics
Magic Placeholder Names5 hits · 25 pts
SeverityFileLineSnippet
HIGHdocs/docs/tutorials/async/index.md60os.environ["OPENAI_API_KEY"] = "your_api_key"
HIGHdocs/docs/tutorials/async/index.md85os.environ["OPENAI_API_KEY"] = "your_api_key"
HIGHdocs/docs/tutorials/async/index.md142os.environ["OPENAI_API_KEY"] = "your_api_key"
HIGHdocs/docs/tutorials/streaming/index.md23os.environ["OPENAI_API_KEY"] = "your_api_key"
HIGHdocs/docs/tutorials/streaming/index.md471os.environ["OPENAI_API_KEY"] = "your_api_key"
Cross-File Repetition4 hits · 20 pts
SeverityFileLineSnippet
HIGHtests/adapters/test_json_adapter.py0answer the question with multiple answers and scores
HIGHtests/adapters/test_chat_adapter.py0answer the question with multiple answers and scores
HIGHtests/adapters/test_chat_adapter.py0answer the question with multiple answers and scores
HIGHtests/adapters/test_xml_adapter.py0answer the question with multiple answers and scores
Fake / Example Data17 hits · 20 pts
SeverityFileLineSnippet
LOWdspy/adapters/baml_adapter.py208 # PatientDetails(name='John Doe', age=45, address=PatientAddress(street='123 Main St', city='Anytown', country='US')
LOWdspy/adapters/baml_adapter.py208 # PatientDetails(name='John Doe', age=45, address=PatientAddress(street='123 Main St', city='Anytown', country='US')
LOWtests/adapters/test_baml_adapter.py258 name="John Doe", age=45, address=PatientAddress(street="123 Main St", city="Anytown", country="US")
LOWtests/adapters/test_baml_adapter.py258 name="John Doe", age=45, address=PatientAddress(street="123 Main St", city="Anytown", country="US")
LOWtests/adapters/test_baml_adapter.py265 assert '"name": "John Doe"' in user_message
LOWtests/adapters/test_baml_adapter.py267 assert '"street": "123 Main St"' in user_message
LOWtests/adapters/test_baml_adapter.py281 patient = PatientDetails(name="Jane Doe", age=30)
LOWtests/adapters/test_baml_adapter.py287 assert '"name": "Jane Doe"' in user_message
LOWtests/adapters/test_baml_adapter.py525 choices=[Choices(message=Message(content='{"patient": {"name": "John Doe", "age": 28}}'))],
LOWtests/adapters/test_baml_adapter.py534 assert result[0]["patient"].name == "John Doe"
LOWtests/adapters/test_baml_adapter.py623 user_profile = UserProfile(name="John Doe", email="john@example.com", age=30)
LOWtests/adapters/test_baml_adapter.py635 assert '"name": "John Doe"' in user_message
LOWtests/adapters/test_tool.py344 assert result["primary_address"]["street"] == "123 Main St"
LOWtests/adapters/test_tool.py333 Address(street="123 Main St", city="Test City", zip_code="12345", is_primary=True),
LOWdocs/docs/learn/programming/adapters.md194 "scientists_involved": ["John Doe", "Jane Smith"],
LOWdocs/docs/learn/evaluation/data.md59Values can be accessed using the `.`(dot) operator. You can access the value of key `name` in defined object `Example(na
LOWdocs/docs/deep-dive/data-handling/examples.md60Values can be accessed using the `.`(dot) operator. You can access the value of key `name` in defined object `Example(na
Over-Commented Block19 hits · 18 pts
SeverityFileLineSnippet
LOWdspy/predict/retry.py1# import copy
LOWdspy/predict/retry.py21# prefix="Previous " + actual_prefix,
LOWdspy/predict/retry.py41# # Convert the dict past_outputs={"answer": ...} to kwargs
LOWdspy/predict/retry.py61# pred = self.forward(**kwargs)
LOWdspy/teleprompt/grpo.py261
LOWdspy/teleprompt/grpo.py521 logger.warning(f"GRPOGroup has no diversity. This could be due to low temperature, or low number
LOWdspy/teleprompt/bootstrap_finetune.py221# ) -> dict[str, Any]:
LOWtests/predict/test_retry.py1# import functools
LOWtests/predict/test_retry.py21# result = retry_module.forward(
LOWtests/predict/test_retry.py41# print(f"SimpleModule got {result.answer=}")
LOWtests/predict/test_retry.py61# # class AnswerQuestion(dspy.Signature):
LOWtests/predict/test_retry.py81# # return result
LOWtests/predict/test_predict.py241
LOWtests/predict/test_predict.py261# content="¿Qué tal?",
LOWtests/reliability/reliability_conf.yaml1adapter: chat
LOWtests/reliability/reliability_conf.yaml21 - model_name: "gpt-4-turbo"
LOWtests/reliability/reliability_conf.yaml41 - model_name: "claude-3.5-haiku"
LOWtests/reliability/reliability_conf.yaml61 - model_name: "llama-3.1-70b-instruct"
LOWdocs/docs/stylesheets/home.css601#hp-tab-optimize:checked ~ .hp-tabs-wrapper .hp-tab-panels #hp-panel-optimize { display: grid; }
AI Slop Vocabulary8 hits · 14 pts
SeverityFileLineSnippet
MEDIUMdspy/propose/dataset_summary_generator.py22 """I will also provide you with a few observations I have already made. Please add your own observations or if you
LOWdspy/adapters/utils.py66 # (e.g. the value is a JSON string), just use the string representation of the value
LOWdspy/evaluate/evaluate.py38 # available, this method will simply return the input string.
MEDIUMdspy/teleprompt/gepa/instruction_proposal.py308 # instead of just the current instruction, for more holistic instruction proposals.
MEDIUMdspy/dsp/utils/settings.py153 # We check its existence and type to be more robust.
LOWtests/predict/test_rlm.py290 # Unclosed fence (just return the body)
MEDIUMtests/predict/test_rlm.py274 """Tests for robust fenced-code extraction."""
MEDIUMtests/teleprompt/test_gepa_instruction_proposer.py158 # Use a robust dummy LM with enough responses for optimization steps
Overly Generic Function Names9 hits · 13 pts
SeverityFileLineSnippet
LOWtests/clients/test_cache.py246 def test_function(prompt, model):
LOWtests/clients/test_cache.py303 async def test_function(prompt, model):
LOWtests/clients/test_cache.py330 def test_function(**kwargs):
LOWtests/utils/test_annotation.py6 def test_function():
LOWtests/utils/test_annotation.py17 def test_function():
LOWtests/utils/test_annotation.py55 def test_function():
LOWtests/utils/test_annotation.py64 def test_function():
LOWtests/utils/test_annotation.py72 def test_function():
LOWtests/utils/test_annotation.py84 def test_function():
Hallucination Indicators1 hit · 10 pts
SeverityFileLineSnippet
CRITICALdocs/docs/diving-deeper/adapters.md147**`dspy.adapters.types.tool.ToolCalls.from_dict_list(...)`**
Verbosity Indicators6 hits · 9 pts
SeverityFileLineSnippet
LOWdspy/signatures/signature.py801 # Step 1: Convert camelCase to snake_case
LOWdspy/signatures/signature.py809 # Step 2: Handle numbers by adding underscores around them
LOWdspy/signatures/signature.py823 # Step 3: Convert to Title Case while preserving acronyms
LOWdspy/teleprompt/mipro_optimizer_v2.py230 # Step 1: Bootstrap few-shot examples
LOWdspy/teleprompt/mipro_optimizer_v2.py243 # Step 2: Propose instruction candidates
LOWdspy/teleprompt/mipro_optimizer_v2.py261 # Step 3: Find optimal prompt parameters
Synthetic Comment Markers1 hit · 5 pts
SeverityFileLineSnippet
HIGHdocs/docs/community/built-with-dspy.md22| **[MedVAL](https://arxiv.org/abs/2507.03152)** | Expert-level validation of AI-generated medical text with scalable la
Dead Code1 hit · 2 pts
SeverityFileLineSnippet
MEDIUMtests/clients/test_lm.py1447