Repository Analysis

guardrails-ai/guardrails

Adding guardrails to large language models.

28.0 Moderate AI signal View on GitHub

Analysis Overview

This report presents the forensic synthetic code analysis of guardrails-ai/guardrails, a Python project with 7,236 GitHub stars. SynthScan v2.0 examined 52,595 lines of code across 468 source files, recording 1109 pattern matches distributed across 18 syntactic categories. The overall adjusted score of 28.0 places this repository in the Moderate AI signal band.

The scanner applied 160+ deterministic lexical heuristics, multi-line block detectors, abstract syntax tree depth profilers, and a cross-file Jaccard similarity matrix to construct a statistically normalised synthetic code estimate. All matches are individually weighted by severity coefficient and contextual multiplier before summation, and the resulting headline score is temporally discounted to account for the repository's development history relative to the commercial emergence of large language model coding tooling (November 2022 onward).

28.0
Adjusted Score
28.0
Raw Score
100%
Time Factor
2026-08-02
Last Push
7.2K
Stars
Python
Language
52.6K
Lines of Code
468
Files
1.1K
Pattern Hits
2026-08-02
Scan Date
0.06
HC Hit Rate

What These Metrics Mean

Adjusted Score
Primary synthetic code indicator. Raw score normalised per 1,000 lines of code and multiplied by the temporal discount factor. This is the definitive comparative metric — use it to rank repositories by AI authorship density.
Raw Score
The unmodified sum of all severity-weighted, context-multiplied pattern match scores before temporal discounting. Reflects the absolute signal strength independent of when the repository was last active.
Time Factor
The temporal discount multiplier (0–100%) applied to the raw score. Repositories last updated before ChatGPT's launch (Nov 2022) receive a 5% factor. Full signal is only assigned to repositories active in the post-adoption era (Jan 2024+).
Pattern Hits
Total count of individual pattern matches across all files and categories. A high hit count with a low score may indicate a very large codebase with isolated AI snippets; a low count with a high score indicates dense, concentrated AI signatures.
HC Hit Rate
High+Critical pattern hits per file, averaged across the repository. This orthogonal signal catches repositories where a few files are densely packed with high-severity AI tells — a strong indicator even when the normalised score appears moderate due to codebase size.
Lines of Code / Files
Total lines and files analysed. The scanner examines 94 file extensions. These denominators are used to normalise the score, enabling fair comparison between repositories of vastly different sizes.

Score History

Longitudinal tracking requires multiple scan runs. Once this repository is re-scanned after new commits land, this chart will visualise how the synthetic code signal evolves over time — enabling you to detect whether AI authorship is growing, stabilising, or being actively corrected by human engineers.

No multi-scan history yet — run the scanner again to build trend data.

Severity Breakdown

Classifies detected patterns by their diagnostic confidence and structural impact. CRITICAL patterns (coefficient 10) represent definitive synthetic signatures — hallucinated imports, explicit LLM attribution metadata — virtually never produced by human authors. HIGH (5) indicates strong structural tells such as cross-file repetition or cross-linguistic idioms. MEDIUM (2) covers recognisable conversational padding and AI-specific vocabulary. LOW (1) captures subtle indicators like tautological comments and generic boilerplate that require density to carry independent signal.

CRITICAL 1HIGH 26MEDIUM 149LOW 933

Directory Score Breakdown

This horizontal bar chart decomposes the repository's raw synthetic code score by top-level directory, allowing you to pinpoint precisely which modules or components carry the highest AI authorship density. Directories with disproportionately high scores relative to their size warrant targeted manual review: concentrated AI signatures often trace back to mass-generated configuration layers, auto-ported test suites, LLM-scaffolded boilerplate classes, or entire subsystems authored under heavy copilot assistance. Use this view to prioritise your human code-review effort.

Pattern Findings

The scanner identified 1109 distinct pattern matches across 18 syntactic categories. Each entry below represents a discrete location in the source code where the engine recorded a statistically significant AI authorship indicator. Expand any category row to inspect the individual file paths, line numbers, code snippets, and the lexical context (CODE, COMMENT, or STRING) in which each match was detected.

Reading the findings table: The Severity column indicates the diagnostic confidence level (CRITICAL / HIGH / MEDIUM / LOW). The Context column identifies whether the match occurred inside executable code, an inline comment, or a string literal — comment-context matches receive a ×1.5 weight because LLMs systematically over-annotate. The ⚡ bolt icon marks clustered matches: three or more patterns within a 10-line window, each receiving an additional ×1.5 density multiplier as dense clusters constitute far stronger evidence of synthetic authorship than isolated hits.

Hyper-Verbose Identifiers513 hits · 499 pts
SeverityFileLineSnippetContext
LOWguardrails/validator_base.py47def split_sentence_word_tokenizers_jl_separator(CODE
LOWguardrails/llm_providers.py902def model_is_supported_server_side(CODE
LOWguardrails/document_store.py213 def get_pages_for_for_indexes(self, indexes: List[int]) -> List[Page]:CODE
LOWguardrails/guard.py186 def must_be_valid_json_schema(CODE
LOWguardrails/guard.py1081 def response_format_json_schema(self) -> Dict[str, Any]:CODE
LOWguardrails/guard.py1084 def json_function_calling_tool(CODE
LOW…ails/validator_service/sequential_validator_service.py110 def run_validators_stream_fix(CODE
LOW…ails/validator_service/sequential_validator_service.py259 def run_validators_stream_noop(CODE
LOWguardrails/classes/llm/llm_response.py83 def deserialize_stream_output(cls, stream_output: Any | None) -> Iterator | None:CODE
LOWguardrails/classes/llm/llm_response.py94 def serialize_async_stream_output(CODE
LOWguardrails/classes/llm/llm_response.py112 def deserialize_async_stream_output(CODE
LOWguardrails/classes/history/iteration.py83 def completion_tokens_consumed(self) -> Optional[int]:CODE
LOWguardrails/classes/history/call.py218 def completion_tokens_consumed(self) -> Optional[int]:CODE
LOWguardrails/classes/history/outputs.py60 def deserialize_validation_response(CODE
LOWguardrails/classes/validation/validator_logs.py51 def serialize_validation_result(CODE
LOWguardrails/classes/validation/validator_logs.py60 def deserialize_validation_result(CODE
LOWguardrails/classes/validation/validation_summary.py12 def _generate_summaries_from_validator_logs(CODE
LOWguardrails/classes/validation/validation_summary.py47 def from_validator_logs_only_fails(CODE
LOWguardrails/vectordb/faiss.py82 def similarity_search_vector_with_threshold(CODE
LOWguardrails/vectordb/base.py43 def similarity_search_vector_with_threshold(CODE
LOWguardrails/vectordb/base.py66 def similarity_search_with_threshold(CODE
LOWguardrails/hub_telemetry/hub_tracing.py19def get_guard_call_attributes(CODE
LOWguardrails/hub_telemetry/hub_tracing.py56def get_validator_inference_attributes(CODE
LOWguardrails/hub_telemetry/hub_tracing.py76def get_validator_usage_attributes(CODE
LOWguardrails/formatters/json_formatter.py28def _jsonschema_to_jsonformer(CODE
LOWguardrails/utils/pydantic_utils.py16def convert_pydantic_model_to_openai_fn(CODE
LOWguardrails/utils/validator_utils.py174def verify_metadata_requirements(CODE
LOWguardrails/utils/validator_utils.py187def parse_validator_reference(ref: ValidatorReference) -> Optional[Validator]:CODE
LOWguardrails/utils/structured_data_utils.py21def set_additional_properties_false_iteratively(schema):CODE
LOWguardrails/utils/structured_data_utils.py53def json_function_calling_tool(CODE
LOWguardrails/utils/structured_data_utils.py62def output_format_json_schema(schema: ModelOrListOfModels) -> dict:CODE
LOWguardrails/utils/docs_utils.py24def messages_to_prompt_string(CODE
LOWguardrails/utils/docs_utils.py74 def prompt_template_token_length(self, prompt_template: Prompt) -> int:CODE
LOWguardrails/utils/prompt_utils.py20def prompt_content_for_string_schema(CODE
LOWguardrails/utils/prompt_utils.py44def prompt_content_for_schema(CODE
LOWguardrails/utils/prompt_utils.py55def messages_to_prompt_string(CODE
LOWguardrails/utils/api_utils.py15def extract_serializeable_metadata(metadata: Dict[str, Any]) -> Dict[str, Any]:CODE
LOWguardrails/utils/openai_utils/v1.py71 def construct_nonchat_response(CODE
LOWguardrails/cli/version.py15def version_warnings_if_applicable(console: Console):CODE
LOWguardrails/cli/create.py152def split_and_install_validators(CODE
LOWguardrails/cli/create.py162 def install_local_models_confirm():CODE
LOWguardrails/cli/hub/utils.py52def pip_process_with_custom_exception(CODE
LOW…ls/integrations/llama_index/guardrails_query_engine.py106 def _update_response_metadata(self, validated_output):CODE
LOW…drails/integrations/databricks/ml_flow_instrumentor.py228 def _instrument_stream_runner_step(CODE
LOW…drails/integrations/databricks/ml_flow_instrumentor.py232 def trace_stream_step_wrapper(CODE
LOW…drails/integrations/databricks/ml_flow_instrumentor.py291 def _instrument_async_stream_runner_step(CODE
LOW…drails/integrations/databricks/ml_flow_instrumentor.py295 async def trace_async_stream_step_wrapper(CODE
LOW…drails/integrations/databricks/ml_flow_instrumentor.py167 async def _async_guard_execute_wrapper(CODE
LOW…drails/integrations/databricks/ml_flow_instrumentor.py266 def _instrument_async_runner_step(CODE
LOW…drails/integrations/databricks/ml_flow_instrumentor.py354 def _instrument_async_runner_call(CODE
LOW…drails/integrations/databricks/ml_flow_instrumentor.py379 def _instrument_validator_validate(CODE
LOW…drails/integrations/databricks/ml_flow_instrumentor.py445 def _instrument_validator_async_validate(CODE
LOW…drails/integrations/databricks/ml_flow_instrumentor.py450 async def trace_async_validator_wrapper(*args, **kwargs):CODE
LOWguardrails/schema/rail_schema.py516def build_choice_case_element_from_if(CODE
LOWguardrails/schema/rail_schema.py609def build_choice_case_element_from_discriminator(CODE
LOWguardrails/schema/rail_schema.py903def json_schema_to_rail_output(CODE
LOWguardrails/prompt/base_prompt.py85 def get_format_instructions_idx(self, text: str) -> Optional[int]:CODE
LOWguardrails/actions/reask.py205def get_reask_setup_for_string(CODE
LOWguardrails/actions/reask.py555def sub_reasks_with_fixed_values(value: Any) -> Any:CODE
LOWguardrails/applications/text2sql.py157 def _create_docstore_with_examples(STRING
453 more matches not shown…
Modern AI Meta-Vocabulary113 hits · 291 pts
SeverityFileLineSnippetContext
MEDIUMSECURITY_ADVISORY.md1# Security Advisory: Malicious code in guardrails-ai 0.10.1COMMENT
MEDIUMSECURITY_ADVISORY.md3**Status:** Active. Package quarantined on PyPI. Tracking issue: [#1473](https://github.com/guardrails-ai/guardrails/issCODE
MEDIUMSECURITY_ADVISORY.md3**Status:** Active. Package quarantined on PyPI. Tracking issue: [#1473](https://github.com/guardrails-ai/guardrails/issCODE
MEDIUMSECURITY_ADVISORY.md20### 1. Do not install `guardrails-ai==0.10.1`COMMENT
MEDIUMSECURITY_ADVISORY.md31pip install git+https://github.com/guardrails-ai/guardrails.git@v0.10.0CODE
MEDIUMSECURITY_ADVISORY.md71- Worked with PyPI to lift the quarantine and publish a clean release (tracked in [#1473](https://github.com/guardrails-CODE
MEDIUMSECURITY_ADVISORY.md71- Worked with PyPI to lift the quarantine and publish a clean release (tracked in [#1473](https://github.com/guardrails-CODE
MEDIUMSECURITY_ADVISORY.md84- Tracking issue: [#1473](https://github.com/guardrails-ai/guardrails/issues/1473)CODE
MEDIUMSECURITY_ADVISORY.md84- Tracking issue: [#1473](https://github.com/guardrails-ai/guardrails/issues/1473)CODE
MEDIUMSECURITY_ADVISORY.md85- GHSA: [GHSA-xmpw-2vmm-p4p6](https://github.com/guardrails-ai/guardrails/security/advisories/GHSA-xmpw-2vmm-p4p6)CODE
MEDIUMpyproject.toml13documentation = "https://www.guardrailsai.com/guardrails/docs"CODE
MEDIUMREADME.md3<img src="https://raw.githubusercontent.com/guardrails-ai/guardrails/main/docs/assets/Guardrails-ai-logo-for-dark-bg.svgCODE
MEDIUMREADME.md4<img src="https://raw.githubusercontent.com/guardrails-ai/guardrails/main/docs/assets/Guardrails-ai-logo-for-white-bg.svCODE
MEDIUMREADME.md9![PyPI - Python Version](https://img.shields.io/pypi/pyversions/guardrails-ai)CODE
MEDIUMREADME.md10[![Downloads](https://static.pepy.tech/badge/guardrails-ai/month)](https://pepy.tech/project/guardrails-ai)CODE
MEDIUMREADME.md11[![CI](https://github.com/guardrails-ai/guardrails/actions/workflows/ci.yml/badge.svg)](https://github.com/guardrails-aiCODE
MEDIUMREADME.md12[![codecov](https://codecov.io/gh/guardrails-ai/guardrails/graph/badge.svg?token=CPkjw91Ngo)](https://codecov.io/gh/guarCODE
MEDIUMREADME.md16[![Static Badge](https://img.shields.io/badge/Docs-blue?link=https%3A%2F%2Fwww.guardrailsai.com%2Fdocs)](https://guardraCODE
MEDIUMREADME.md18[![Gurubase](https://img.shields.io/badge/Gurubase-Ask%20Guardrails%20Guru-006BFF)](https://gurubase.io/g/guardrails)CODE
MEDIUMREADME.md33<img src="https://raw.githubusercontent.com/guardrails-ai/guardrails/main/docs/assets/with_and_without_guardrails.svg" aCODE
MEDIUMREADME.md42<img src="https://raw.githubusercontent.com/guardrails-ai/guardrails/main/docs/assets/guardrails_hub.gif" alt="GuardrailCODE
MEDIUMREADME.md112 ) # Both the guardrails passCODE
MEDIUMREADME.md117 ) # Both the guardrails failCODE
MEDIUMREADME.md1783. Create a config: `guardrails create --validators=hub://guardrails/two_words --guard-name=two-word-guard`STRING
MEDIUMREADME.md182# with the guardrails clientSTRING
MEDIUMREADME.md217Yes, Guardrails can be used with proprietary and open-source LLMs. Check out this guide on [how to use Guardrails with aSTRING
MEDIUMREADME.md221Yes, you can create your own validators and contribute them to Guardrails Hub. Check out this guide on [how to create yoSTRING
MEDIUMCONTRIBUTING.md121. Clone the repository: `git clone https://github.com/guardrails-ai/guardrails.git`CODE
MEDIUMCLAUDE.md36make type # pyright guardrails/CODE
MEDIUMguardrails/__init__.py1# Set up __init__.py so that users can do from guardrails import Response, Schema, etc.COMMENT
MEDIUMguardrails/guard.py876 # https://github.com/guardrails-ai/guardrails/pull/525 is mergedCOMMENT
MEDIUMguardrails/guard.py876 # https://github.com/guardrails-ai/guardrails/pull/525 is mergedCOMMENT
MEDIUMguardrails/classes/output_type.py1# TODO: Move this file to guardrails.typesCOMMENT
MEDIUMguardrails/utils/constants.py5# TODO: Move this to guardrails/constants/__init__.pyCOMMENT
MEDIUMguardrails/utils/constants.py10# TODO: Consolidate this and guardrails/utils/prompt_utils.pyCOMMENT
MEDIUMguardrails/utils/constants.py11# into guardrails/utils/templating_utils.pyCOMMENT
MEDIUMguardrails/cli/configure.py130 guardrails hub install hub://guardrails/regex_matchCODE
MEDIUMguardrails/cli/create.py40 " For example hub:template://guardrails/chatbot or hub:template://guardrails/summarizer."CODE
MEDIUMguardrails/cli/hub/create_validator.py20The template repository can be found here: https://github.com/guardrails-ai/validator-templateCODE
MEDIUMguardrails/cli/hub/create_validator.py70 $ guardrails hub install hub://guardrails/${package_name}CODE
MEDIUMguardrails/cli/hub/create_validator.py162 https://github.com/guardrails-ai/validator-template?tab=readme-ov-file#how-to-create-a-guardrails-validatorCODE
MEDIUMguardrails/cli/hub/create_validator.py162 https://github.com/guardrails-ai/validator-template?tab=readme-ov-file#how-to-create-a-guardrails-validatorCODE
MEDIUMguardrails/cli/hub/create_validator.py176 https://github.com/guardrails-ai/validator-templateCODE
MEDIUMguardrails/cli/hub/submit.py47 guardrails hub install hub://guardrails/${package_name}STRING
MEDIUMguardrails/cli/hub/uninstall.py60 help="URI to the package to uninstall. Example: hub://guardrails/regex_match."CODE
MEDIUMguardrails/cli/hub/install.py13# Quick note: This is the command for `guardrails hub install`. We change the name ofCOMMENT
MEDIUMguardrails/cli/hub/install.py16# call install from a script, please consider importing install from guardrails,COMMENT
MEDIUMguardrails/cli/hub/install.py17# not guardrails.cli.hub.install.COMMENT
MEDIUMguardrails/cli/hub/install.py23 help="URIs to the packages to install. Example: hub://guardrails/regex_match hub://guardrails/toxic_language",CODE
MEDIUMguardrails/telemetry/default_otlp_tracer_mod.py67 do that is in our (docs)[https://guardrailsai.com/guardrails/docs/concepts/telemetry]STRING
MEDIUMguardrails/hub/install.py57 >>> RegexMatch = install("hub://guardrails/regex_match").RegexMatchSTRING
MEDIUMguardrails/hub/install.py58 >>> RegexMatch = install("hub://guardrails/regex_match~=1.4").RegexMatchSTRING
MEDIUMguardrails/hub/install.py61 >>> install("hub://guardrails/regex_match>=1.4,==1.*.")STRING
MEDIUMguardrails/hub/validator_package_service.py341 # ``guardrails-ai-<name>`` (e.g. ``guardrails/detect_pii`` ->STRING
MEDIUMguardrails/hub/validator_package_service.py342 # ``guardrails-ai-detect-pii``). The hub namespace component of theSTRING
MEDIUMguardrails/hub/validator_package_service.py343 # validator id is dropped because every guardrails-owned validator nowSTRING
MEDIUMguardrails/hub/validator_package_service.py344 # publishes under the single ``guardrails-ai-*`` dist namespace onSTRING
MEDIUMguardrails/hub/validator_package_service.py355 # package: ``guardrails/detect_pii`` -> ``guardrails_ai.detect_pii``.STRING
MEDIUMguardrails/hub/validator_package_service.py375 # Validators now publish to public PyPI as ``guardrails-ai-<name>``;STRING
MEDIUMtests/unit_tests/cli/hub/test_deprecation.py12 ("hub://guardrails/detect_pii", "guardrails-ai-detect-pii"),CODE
53 more matches not shown…
Unused Imports188 hits · 188 pts
SeverityFileLineSnippetContext
LOWguardrails/validator_base.py24CODE
LOWguardrails/embedding.py19CODE
LOWguardrails/llm_providers.py270CODE
LOWguardrails/llm_providers.py375CODE
LOWguardrails/__init__.py3CODE
LOWguardrails/__init__.py4CODE
LOWguardrails/__init__.py5CODE
LOWguardrails/__init__.py6CODE
LOWguardrails/__init__.py7CODE
LOWguardrails/__init__.py7CODE
LOWguardrails/__init__.py7CODE
LOWguardrails/__init__.py8CODE
LOWguardrails/__init__.py8CODE
LOWguardrails/__init__.py9CODE
LOWguardrails/__init__.py10CODE
LOWguardrails/__init__.py10CODE
LOWguardrails/__init__.py11CODE
LOWguardrails/__init__.py12CODE
LOWguardrails/__init__.py13CODE
LOWguardrails/__init__.py14CODE
LOWguardrails/types/__init__.py1CODE
LOWguardrails/types/__init__.py2CODE
LOWguardrails/types/__init__.py3CODE
LOWguardrails/types/__init__.py4CODE
LOWguardrails/types/__init__.py4CODE
LOWguardrails/types/__init__.py4CODE
LOWguardrails/types/__init__.py9CODE
LOWguardrails/types/__init__.py10CODE
LOWguardrails/types/__init__.py10CODE
LOWguardrails/types/__init__.py10CODE
LOWguardrails/types/__init__.py10CODE
LOWguardrails/types/__init__.py10CODE
LOWguardrails/types/__init__.py10CODE
LOWguardrails/validator_service/__init__.py15CODE
LOWguardrails/classes/__init__.py1CODE
LOWguardrails/classes/__init__.py2CODE
LOWguardrails/classes/__init__.py3CODE
LOWguardrails/classes/__init__.py4CODE
LOWguardrails/classes/__init__.py4CODE
LOWguardrails/classes/__init__.py4CODE
LOWguardrails/classes/__init__.py4CODE
LOWguardrails/classes/__init__.py10CODE
LOWguardrails/classes/schema/__init__.py1CODE
LOWguardrails/classes/execution/__init__.py1CODE
LOWguardrails/classes/history/iteration.py1CODE
LOWguardrails/classes/history/__init__.py1CODE
LOWguardrails/classes/history/__init__.py2CODE
LOWguardrails/classes/history/__init__.py3CODE
LOWguardrails/classes/history/__init__.py4CODE
LOWguardrails/classes/history/__init__.py5CODE
LOWguardrails/classes/history/inputs.py1CODE
LOWguardrails/classes/history/call_inputs.py1CODE
LOWguardrails/classes/history/call.py1CODE
LOWguardrails/classes/history/outputs.py1CODE
LOWguardrails/classes/generic/async_iterable.py1CODE
LOWguardrails/classes/generic/__init__.py1CODE
LOWguardrails/classes/generic/__init__.py2CODE
LOWguardrails/classes/generic/__init__.py3CODE
LOWguardrails/classes/validation/validation_result.py1CODE
LOWguardrails/classes/validation/validation_result.py5CODE
128 more matches not shown…
Cross-Language Confusion18 hits · 112 pts
SeverityFileLineSnippetContext
HIGHguardrails/async_guard.py231 self.history.push(call_log)CODE
HIGHguardrails/guard.py571 self.history.push(call_log)CODE
HIGHguardrails/run/runner.py232 call_log.iterations.push(iteration)CODE
HIGHguardrails/run/async_stream_runner.py94 call_log.iterations.push(iteration)CODE
HIGHguardrails/run/stream_runner.py92 call_log.iterations.push(iteration)CODE
HIGHguardrails/run/async_runner.py157 call_log.iterations.push(iteration)CODE
HIGHtests/unit_tests/test_guard.py574 guard.history.push(mock_call)CODE
HIGHtests/unit_tests/test_guard.py591 guard.history.push(mock_call)CODE
HIGHtests/unit_tests/test_guard.py717 guard.history.push(call1)CODE
HIGHtests/unit_tests/test_guard.py718 guard.history.push(call2)CODE
HIGHtests/unit_tests/test_guard.py719 guard.history.push(call3)CODE
HIGHtests/unit_tests/classes/generic/test_stack.py38 stack.push(1)CODE
HIGHtests/unit_tests/classes/generic/test_stack.py42 stack.push(2)CODE
HIGHtests/unit_tests/classes/generic/test_stack.py50 stack.push(1)CODE
HIGHtests/unit_tests/classes/generic/test_stack.py54 stack.push(2)CODE
HIGHtests/unit_tests/classes/generic/test_stack.py111 stack.push(1)CODE
HIGH…s/integrations/databricks/test_ml_flow_instrumentor.py383 call.iterations.push(iteration)CODE
HIGH…s/integrations/databricks/test_ml_flow_instrumentor.py475 call.iterations.push(iteration)CODE
Excessive Try-Catch Wrapping83 hits · 89 pts
SeverityFileLineSnippetContext
LOWREADME.md83 except Exception as e:CODE
LOWREADME.md118 except Exception as e:CODE
LOWguardrails/llm_providers.py620 except Exception as e:CODE
MEDIUMguardrails/llm_providers.py615def __call__(self, *args, **kwargs) -> LLMResponse:CODE
LOWguardrails/guard.py1063 except Exception as e:CODE
LOWguardrails/api_client.py49 except Exception:CODE
LOWguardrails/api_client.py70 except Exception:CODE
LOWguardrails/api_client.py98 except Exception as e:CODE
LOWguardrails/api_client.py113 except Exception as e:CODE
LOWguardrails/types/rail.py43 except Exception:CODE
LOWguardrails/types/primitives.py15 except Exception as e:CODE
LOWguardrails/types/on_fail.py42 except Exception as e:CODE
LOWguardrails/classes/output_type.py24 except Exception:CODE
LOWguardrails/classes/llm/prompt_callable.py35 except Exception as e:CODE
MEDIUMguardrails/classes/llm/prompt_callable.py30def __call__(self, *args, **kwargs) -> LLMResponse:CODE
LOWguardrails/utils/parsing_utils.py277 except Exception:CODE
LOWguardrails/utils/sql_utils.py70 except Exception as ex:CODE
LOWguardrails/utils/sql_utils.py86 except Exception as ex:CODE
LOWguardrails/utils/serialization_utils.py32 except Exception as e:CODE
LOWguardrails/utils/serialization_utils.py58 except Exception as e:CODE
LOWguardrails/utils/safe_get.py13 except Exception as e:CODE
LOWguardrails/utils/casting_utils.py9 except Exception:CODE
LOWguardrails/utils/casting_utils.py17 except Exception:CODE
LOWguardrails/utils/casting_utils.py25 except Exception:CODE
LOWguardrails/cli/configure.py113 except Exception as e:CODE
LOWguardrails/cli/server/hub_client.py75 except Exception as e:CODE
LOWguardrails/cli/server/hub_client.py137 except Exception as e:CODE
LOWguardrails/cli/server/hub_client.py159 except Exception as e:CODE
LOWguardrails/cli/server/hub_client.py177 except Exception as e:CODE
LOWguardrails/cli/server/hub_client.py205 except Exception as e:CODE
MEDIUMguardrails/cli/server/hub_client.py165def get_auth():CODE
LOWguardrails/cli/hub/submit.py57 except Exception as e:CODE
LOWguardrails/cli/hub/deprecation.py23 except Exception:CODE
LOWguardrails/cli/hub/utils.py85 except Exception:CODE
LOWguardrails/cli/hub/utils.py100 except Exception as e:CODE
LOWguardrails/cli/hub/utils.py157 except Exception:CODE
LOWguardrails/cli/hub/utils.py174 except Exception as e:CODE
LOWguardrails/cli/hub/utils.py211 except Exception:CODE
LOWguardrails/cli/hub/utils.py234 except Exception as e:CODE
LOWguardrails/cli/hub/install.py80 except Exception as e:CODE
LOW…ls/integrations/llama_index/guardrails_query_engine.py102 except Exception as e:CODE
LOW…ils/integrations/llama_index/guardrails_chat_engine.py74 except Exception as e:CODE
LOW…drails/integrations/databricks/ml_flow_instrumentor.py221 except Exception as e:CODE
LOW…drails/integrations/databricks/ml_flow_instrumentor.py284 except Exception as e:CODE
LOW…drails/integrations/databricks/ml_flow_instrumentor.py145 except Exception as e:CODE
LOW…drails/integrations/databricks/ml_flow_instrumentor.py200 except Exception as e:CODE
LOW…drails/integrations/databricks/ml_flow_instrumentor.py254 except Exception as e:CODE
LOW…drails/integrations/databricks/ml_flow_instrumentor.py320 except Exception as e:CODE
LOW…drails/integrations/databricks/ml_flow_instrumentor.py347 except Exception as e:CODE
LOW…drails/integrations/databricks/ml_flow_instrumentor.py372 except Exception as e:CODE
LOW…drails/integrations/databricks/ml_flow_instrumentor.py428 except Exception as e:CODE
LOW…drails/integrations/databricks/ml_flow_instrumentor.py489 except Exception as e:CODE
LOWguardrails/telemetry/legacy_validator_tracing.py22 except Exception:CODE
LOWguardrails/telemetry/guard_tracing.py202 except Exception as e:STRING
LOWguardrails/telemetry/guard_tracing.py289 except Exception as e:STRING
LOWguardrails/telemetry/validator_tracing.py129 except Exception as e:CODE
LOWguardrails/telemetry/validator_tracing.py196 except Exception as e:CODE
LOWguardrails/telemetry/common.py30 except Exception as e:CODE
LOWguardrails/telemetry/common.py48 except Exception:CODE
LOWguardrails/telemetry/common.py64 except Exception:CODE
23 more matches not shown…
Deep Nesting64 hits · 62 pts
SeverityFileLineSnippetContext
LOWguardrails/merge.py14CODE
LOWguardrails/embedding.py149CODE
LOWguardrails/guard.py884CODE
LOWguardrails/guard.py953CODE
LOWguardrails/api_client.py251CODE
LOW…ails/validator_service/sequential_validator_service.py110CODE
LOW…ails/validator_service/sequential_validator_service.py259CODE
LOW…ails/validator_service/sequential_validator_service.py315CODE
LOWguardrails/classes/rc.py27CODE
LOWguardrails/classes/history/call.py151CODE
LOWguardrails/classes/history/outputs.py119CODE
LOWguardrails/classes/history/outputs.py152CODE
LOWguardrails/classes/generic/default_json_encoder.py8CODE
LOWguardrails/classes/validation/validator_logs.py60CODE
LOWguardrails/hub_telemetry/hub_tracing.py94CODE
LOWguardrails/formatters/json_formatter.py28CODE
LOWguardrails/utils/misc.py13CODE
LOWguardrails/utils/validator_utils.py111CODE
LOWguardrails/utils/structured_data_utils.py21CODE
LOWguardrails/utils/docs_utils.py127CODE
LOWguardrails/utils/parsing_utils.py141CODE
LOWguardrails/utils/parsing_utils.py281CODE
LOWguardrails/utils/serialization_utils.py12CODE
LOWguardrails/utils/serialization_utils.py40CODE
LOWguardrails/utils/openai_utils/streaming_utils.py27CODE
LOWguardrails/cli/create.py20CODE
LOW…ls/integrations/llama_index/guardrails_query_engine.py52CODE
LOW…drails/integrations/databricks/ml_flow_instrumentor.py228CODE
LOW…drails/integrations/databricks/ml_flow_instrumentor.py291CODE
LOW…drails/integrations/databricks/ml_flow_instrumentor.py232CODE
LOW…drails/integrations/databricks/ml_flow_instrumentor.py295CODE
LOWguardrails/schema/pydantic_schema.py30CODE
LOWguardrails/schema/pydantic_schema.py84CODE
LOWguardrails/schema/pydantic_schema.py167CODE
LOWguardrails/schema/rail_schema.py105CODE
LOWguardrails/schema/rail_schema.py653CODE
LOWguardrails/schema/rail_schema.py756CODE
LOWguardrails/schema/rail_schema.py809CODE
LOWguardrails/schema/generator.py96CODE
LOWguardrails/schema/generator.py211CODE
LOWguardrails/actions/refrain.py10CODE
LOWguardrails/actions/filter.py8CODE
LOWguardrails/actions/reask.py130CODE
LOWguardrails/actions/reask.py293CODE
LOWguardrails/actions/reask.py489CODE
LOWguardrails/actions/reask.py584CODE
LOWguardrails/actions/reask.py528CODE
LOWguardrails/actions/reask.py609CODE
LOWguardrails/telemetry/guard_tracing.py137CODE
LOWguardrails/telemetry/guard_tracing.py168CODE
LOWguardrails/telemetry/guard_tracing.py209CODE
LOWguardrails/telemetry/guard_tracing.py241CODE
LOWguardrails/telemetry/open_inference.py49CODE
LOWguardrails/telemetry/common.py35CODE
LOWguardrails/telemetry/common.py52CODE
LOWguardrails/telemetry/common.py177CODE
LOWguardrails/telemetry/runner_tracing.py109CODE
LOWguardrails/telemetry/runner_tracing.py189CODE
LOWguardrails/telemetry/runner_tracing.py279CODE
LOWguardrails/telemetry/runner_tracing.py281CODE
4 more matches not shown…
Self-Referential Comments21 hits · 56 pts
SeverityFileLineSnippetContext
MEDIUMguardrails/classes/schema/processed_schema.py11 """This class is just a container for the various pieces of information weSTRING
MEDIUMguardrails/utils/misc.py32 # Create the artifact dir if it doesn't exist.COMMENT
MEDIUMguardrails/utils/tokenization_utils.py1# This file contains code adapted from the WordTokenizers.jlCOMMENT
MEDIUMguardrails/utils/hub_telemetry_utils.py74 # Create a resourceCOMMENT
MEDIUMguardrails/utils/hub_telemetry_utils.py83 # Create a tracer provider and a processorCOMMENT
MEDIUMguardrails/utils/sql_utils.py107 # Create a nicely formatted schema from the dictionaryCOMMENT
MEDIUMguardrails/applications/text2sql.py110 # Initialize the Guard class.STRING
MEDIUMguardrails/applications/text2sql.py137 # Initialize the Guard classSTRING
MEDIUMguardrails/telemetry/guard_tracing.py151 # Create a new span and link it to the previous spanSTRING
MEDIUMguardrails/telemetry/guard_tracing.py221 # Create a new span and link it to the previous spanSTRING
MEDIUMguardrails/telemetry/common.py71 """This function is designed to ensure that a given OpenTelemetry contextSTRING
MEDIUMtests/unit_tests/test_guard.py560 # Create a mock call with iterationsCOMMENT
MEDIUMtests/unit_tests/test_guard.py587 # Create a mock call that raises AttributeErrorCOMMENT
MEDIUMtests/unit_tests/test_guard.py462 # Create a real Guard to return from the mockCOMMENT
MEDIUMtests/unit_tests/test_guard.py490 # Create a real Guard to return from the mockCOMMENT
MEDIUMtests/unit_tests/utils/openai_utils/test_v1.py444 # Create a custom class for message with controlled attribute accessCOMMENT
MEDIUMtests/unit_tests/utils/openai_utils/test_v1.py550 # Create a custom class for message with controlled attribute accessCOMMENT
MEDIUMtests/unit_tests/cli/server/test_hub_client.py49 # Create a JWT that expires in the futureCOMMENT
MEDIUMtests/unit_tests/cli/hub/test_submit.py22 # Create a temporary file with the package nameCOMMENT
MEDIUMtests/integration_tests/test_guard.py1035 # Create a Guard with a top level list return typeCOMMENT
MEDIUM.github/workflows/cli-compatibility.yml70 # Create a simple RAIL spec for testing validate commandCOMMENT
Fake / Example Data35 hits · 33 pts
SeverityFileLineSnippetContext
LOWtests/unit_tests/test_guard_log.py11 "Lorem ipsum dolor sit amet",CODE
LOWtests/unit_tests/test_guard_log.py11 "Lorem ipsum dolor sit amet",CODE
LOWtests/integration_tests/test_datatypes.py25 guard.parse(llm_output='{"name": "John Doe", "dob": "2021-01-01"}', num_reasks=0)STRING
LOWtests/integration_tests/test_datatypes.py56 llm_output='{"name": "John Doe", "dob": "' + date_string + '"}', num_reasks=0STRING
LOWtests/integration_tests/test_datatypes.py92 llm_output='{"name": "John Doe", "dob": "' + date_string + '"}',STRING
LOWtests/integration_tests/test_guard.py46 <email name="dummy_email" description="Any dummy email" />CODE
LOWtests/integration_tests/test_guard.py76 "dummy_email": "example@example.com",CODE
LOWtests/integration_tests/test_guard.py97 "dummy_email": "example@example.com",CODE
LOW…tegration_tests/test_assets/string/llm_list_output.txt4 {'user_id': 2, 'user_name': 'Jane Doe', 'num_orders': 20, 'last_order_date': '2020-02-01'},CODE
LOW…tegration_tests/test_assets/string/llm_list_output.txt7 {'user_id': 5, 'user_name': 'John Doe', 'num_orders': 50, 'last_order_date': '2020-05-01'},CODE
LOW…integration_tests/test_assets/validators/detect_pii.py20 For example, if the map is {"John Doe": "REDACTED"}, then the text "JohnSTRING
LOW…tion_tests/test_assets/pydantic/llm_output_reask_2.txt4 "name": "John Doe",CODE
LOW…tion_tests/test_assets/pydantic/llm_output_reask_2.txt9 "name": "Jane Doe",CODE
LOW…tion_tests/test_assets/pydantic/llm_output_reask_1.txt4 "name": "John Doe",CODE
LOW…tion_tests/test_assets/pydantic/llm_output_reask_1.txt9 "name": "Jane Doe",CODE
LOW…tests/test_assets/pydantic/llm_output_full_reask_2.txt4 "name": "John Doe",CODE
LOW…tests/test_assets/pydantic/llm_output_full_reask_2.txt9 "name": "Jane Doe",CODE
LOW…tests/test_assets/pydantic/llm_output_full_reask_1.txt4 "name": "John Doe",CODE
LOW…tests/test_assets/pydantic/llm_output_full_reask_1.txt9 "name": "Jane Doe",CODE
LOW…tests/test_assets/pydantic/validated_response_reask.py93 "name": "John Doe",CODE
LOW…tests/test_assets/pydantic/validated_response_reask.py106 {"name": "Jane Doe", "age": 32, "zip_code": "94103"},CODE
LOW…tests/test_assets/pydantic/validated_response_reask.py115 "name": "John Doe",CODE
LOW…tests/test_assets/pydantic/validated_response_reask.py132 {"name": "Jane Doe", "age": 32, "zip_code": "94103"},CODE
LOW…tests/test_assets/pydantic/validated_response_reask.py141 "name": "John Doe",CODE
LOW…tests/test_assets/pydantic/validated_response_reask.py158 {"name": "Jane Doe", "age": 32, "zip_code": "94103"},CODE
LOW…/integration_tests/test_assets/pydantic/llm_output.txt4 "name": "John Doe",CODE
LOW…/integration_tests/test_assets/pydantic/llm_output.txt9 "name": "Jane Doe",CODE
LOW…/test_assets/pydantic/compiled_prompt_full_reask_2.txt7 "name": "John Doe",CODE
LOW…/test_assets/pydantic/compiled_prompt_full_reask_2.txt18 "name": "Jane Doe",CODE
LOW…ntegration_tests/test_assets/pydantic/parsing_reask.py18Lorem ipsum dolor sit amet, consectetur adipiscing elit,CODE
LOW…ntegration_tests/test_assets/pydantic/parsing_reask.py18Lorem ipsum dolor sit amet, consectetur adipiscing elit,CODE
LOW…ntegration_tests/test_assets/pydantic/parsing_reask.py35Lorem ipsum dolor sit amet, consectetur adipiscing elit,CODE
LOW…ntegration_tests/test_assets/pydantic/parsing_reask.py35Lorem ipsum dolor sit amet, consectetur adipiscing elit,CODE
LOW…/test_assets/pydantic/compiled_prompt_full_reask_1.txt7 "name": "John Doe",CODE
LOW…/test_assets/pydantic/compiled_prompt_full_reask_1.txt17 "name": "Jane Doe",CODE
Modern Structural Boilerplate31 hits · 31 pts
SeverityFileLineSnippetContext
LOWguardrails/__init__.py16__all__ = [CODE
LOWguardrails/guard.py219 def _set_num_reasks(self, num_reasks: Optional[int] = None) -> None:CODE
LOWguardrails/types/__init__.py19__all__ = [CODE
LOWguardrails/classes/__init__.py12__all__ = [CODE
LOWguardrails/classes/schema/__init__.py3__all__ = ["ProcessedSchema"]CODE
LOWguardrails/classes/execution/__init__.py3__all__ = ["GuardExecutionOptions"]CODE
LOWguardrails/classes/history/__init__.py7__all__ = ["Call", "Iteration", "Inputs", "Outputs", "CallInputs"]CODE
LOWguardrails/classes/generic/__init__.py5__all__ = ["ArbitraryModel", "Stack", "Serializeable"]CODE
LOWguardrails/remote_inference/__init__.py3__all__ = ["get_use_remote_inference"]CODE
LOWguardrails/vectordb/__init__.py4__all__ = ["VectorDBBase", "Faiss"]CODE
LOWguardrails/stores/context.py10def set_guard_name(guard_name: str) -> None:CODE
LOWguardrails/stores/context.py18def set_call_kwargs(kwargs: Dict[str, Any]) -> None:CODE
LOWguardrails/formatters/__init__.py21__all__ = [CODE
LOWguardrails/utils/__init__.py5__all__ = ["args", "kwargs", "on_fail"]CODE
LOWguardrails/utils/openai_utils/__init__.py4__all__ = [CODE
LOWguardrails/cli/hub/utils.py17logger = logging.getLogger(__name__)CODE
LOWguardrails/integrations/llama_index/__init__.py8__all__ = ["GuardrailsQueryEngine", "GuardrailsChatEngine"]CODE
LOWguardrails/integrations/databricks/__init__.py3__all__ = ["MlFlowInstrumentor"]CODE
LOWguardrails/prompt/__init__.py5__all__ = [CODE
LOWguardrails/actions/__init__.py7__all__ = [CODE
LOWguardrails/actions/reask.py179def update_response_by_path(output: dict, path: List[Any], value: Any) -> None:CODE
LOWguardrails/validators/__init__.py10__all__ = [CODE
LOWguardrails/telemetry/__init__.py23__all__ = [CODE
LOWguardrails/errors/__init__.py22__all__ = ["ValidationError", "UserFacingException"]CODE
LOWguardrails/run/__init__.py7__all__ = [CODE
LOWguardrails/call_tracing/__init__.py12__all__ = ["GuardTraceEntry", "TraceHandler"]CODE
LOW…ration_tests/test_assets/entity_extraction/__init__.py85__all__ = [CODE
LOW…/integration_tests/test_assets/python_rail/__init__.py39__all__ = [CODE
LOWtests/integration_tests/test_assets/string/__init__.py35__all__ = [CODE
LOW…s/integration_tests/test_assets/validators/__init__.py13__all__ = [CODE
LOW…sts/integration_tests/test_assets/pydantic/__init__.py52__all__ = [CODE
Cross-File Repetition6 hits · 30 pts
SeverityFileLineSnippetContext
HIGHguardrails/settings.py0whether to use a local server for running guardrails.STRING
HIGHguardrails/telemetry/default_otlp_tracer_mod.py0whether to use a local server for running guardrails.STRING
HIGH…rdrails/telemetry/default_otel_collector_tracer_mod.py0whether to use a local server for running guardrails.STRING
HIGHtests/integration_tests/test_guard.py0test that the entity extraction works with re-asking.STRING
HIGHtests/integration_tests/test_pydantic.py0test that the entity extraction works with re-asking.STRING
HIGHtests/integration_tests/test_async.py0test that the entity extraction works with re-asking.STRING
Decorative Section Separators8 hits · 26 pts
SeverityFileLineSnippetContext
MEDIUMtests/unit_tests/test_api_client.py204# ─── upsert_guard ─────────────────────────────────────────────────────────────COMMENT
MEDIUMtests/unit_tests/test_api_client.py15# ─── Helpers ──────────────────────────────────────────────────────────────────COMMENT
MEDIUMtests/unit_tests/test_api_client.py112# ─── Init ─────────────────────────────────────────────────────────────────────COMMENT
MEDIUMtests/unit_tests/test_api_client.py306# ─── fetch_guard ──────────────────────────────────────────────────────────────COMMENT
MEDIUMtests/unit_tests/test_api_client.py392# ─── delete_guard ─────────────────────────────────────────────────────────────COMMENT
MEDIUMtests/unit_tests/test_api_client.py463# ─── validate ─────────────────────────────────────────────────────────────────COMMENT
MEDIUMtests/unit_tests/test_api_client.py604# ─── stream_validate ──────────────────────────────────────────────────────────COMMENT
MEDIUMtests/unit_tests/test_api_client.py767# ─── get_history ──────────────────────────────────────────────────────────────COMMENT
Redundant / Tautological Comments7 hits · 12 pts
SeverityFileLineSnippetContext
LOWguardrails/llm_providers.py485 # Check if kwargs stream is passed inCOMMENT
LOWguardrails/guard.py255 # Check if the validator from the referenceCOMMENT
LOWguardrails/utils/parsing_utils.py123 # Check if text is already verifiedCOMMENT
LOWguardrails/utils/parsing_utils.py127 # Check if text is valid JSONCOMMENT
LOWguardrails/utils/parsing_utils.py134 # Check if error is due to missing commaCOMMENT
LOW.github/workflows/scripts/run_notebooks.sh13# Check if the notebook should be processedCOMMENT
LOW…hub/actions/validator_pypi_publish/add_build_prefix.py36 # Check if the [tool.setuptools] section already existsSTRING
Docstring Block Structure2 hits · 10 pts
SeverityFileLineSnippetContext
HIGHguardrails/validator_base.py355Makes a request to the Validator Hub to run a ML based validation model. This request is authed through the hub STRING
HIGHguardrails/hub/install.py44Install a validator package from a hub URI. Args: package_uri (str): The URI of the package to install. STRING
Over-Commented Block10 hits · 10 pts
SeverityFileLineSnippetContext
LOWguardrails/schema/rail_schema.py321COMMENT
LOWguardrails/actions/reask.py101 # raise RuntimeError("FieldReAsk path is None")COMMENT
LOWguardrails/telemetry/guard_tracing.py81 if number_of_reasks is not None:COMMENT
LOWguardrails/telemetry/guard_tracing.py101 # /COMMENT
LOWguardrails/telemetry/guard_tracing.py121 # )COMMENT
LOWtests/unit_tests/actions/test_reask.py581# property = SubElement(non_empty_root, "list", name="dummy")COMMENT
LOWtests/unit_tests/actions/test_reask.py601# fail_results=[FailResult(error_message="child should not be None")], # noqaCOMMENT
LOWtests/integration_tests/test_streaming.py641# pii_entities="pii",COMMENT
LOWtests/integration_tests/test_streaming.py661# model="gpt-4",COMMENT
LOWdocs/pydocs/pydocs_to_md.py121# pydoc.COMMENT
Hallucination Indicators1 hit · 10 pts
SeverityFileLineSnippetContext
CRITICALtests/unit_tests/test_api_client.py223 mc.http.put.return_value.raise_for_status.assert_called_once()CODE
AI Slop Vocabulary3 hits · 8 pts
SeverityFileLineSnippetContext
MEDIUMguardrails/telemetry/legacy_validator_tracing.py27# We want to encourage users to utilize the validator spansCOMMENT
MEDIUMguardrails/telemetry/legacy_validator_tracing.py82# We want to encourage users to utilize the validator spansCOMMENT
LOWtests/integration_tests/test_guard.py1511# the prompt and instructions and just pass in the messages.COMMENT
AI Structural Patterns5 hits · 5 pts
SeverityFileLineSnippetContext
LOWguardrails/guard.py112CODE
LOWguardrails/applications/text2sql.py62CODE
LOWguardrails/telemetry/open_inference.py49CODE
LOWguardrails/run/runner.py81CODE
LOWguardrails/run/async_runner.py30CODE
Overly Generic Function Names1 hit · 2 pts
SeverityFileLineSnippetContext
LOW…/unit_tests/utils/openai_utils/test_streaming_utils.py277 "content": "Here's how to write a function in Python:\n\ndef my_function():\n pass", # noqaCODE