Repository Analysis

guidance-ai/guidance

A guidance language for controlling large language models.

18.7 Moderate AI signal View on GitHub
18.7
Adjusted Score
18.7
Raw Score
100%
Time Factor
2026-05-21
Last Push
21,484
Stars
Jupyter Notebook
Language
35,924
Lines of Code
228
Files
542
Pattern Hits
2026-05-31
Scan Date

Score History

Severity Breakdown

CRITICAL 0HIGH 12MEDIUM 32LOW 498

Pattern Findings

542 matches across 14 categories. Click a row to expand file-level details.

Hyper-Verbose Identifiers217 hits · 214 pts
SeverityFileLineSnippet
LOWREADME.md175def zero_shot_multiple_choice(
LOWguidance/_ast.py217 def is_allowed_in_lark_terminal(self) -> bool:
LOWguidance/_ast.py225 def is_allowed_in_lark_rule_with_attrs(self) -> bool:
LOWguidance/_ast.py348 def is_allowed_in_lark_terminal(self) -> bool:
LOWguidance/_ast.py352 def is_allowed_in_lark_rule_with_attrs(self) -> bool:
LOWguidance/_ast.py450 def is_allowed_in_lark_terminal(self) -> bool:
LOWguidance/_ast.py489 def is_allowed_in_lark_terminal(self) -> bool:
LOWguidance/_ast.py519 def is_allowed_in_lark_terminal(self) -> bool:
LOWguidance/_ast.py533 def is_allowed_in_lark_terminal(self) -> bool:
LOWguidance/_ast.py537 def is_allowed_in_lark_rule_with_attrs(self) -> bool:
LOWguidance/_uri_validation.py66def _validate_hostname_not_private(hostname: str, original_url: str) -> None:
LOWguidance/chat.py83def _template_class_from_string(template_str):
LOWguidance/_utils.py128def strip_multiline_string_indents(f):
LOWguidance/_utils.py423def apply_top_k_and_top_p_filter(logits: np.ndarray, sampling_params: Optional["SamplingParams"]) -> np.ndarray:
LOWguidance/models/_mock.py94 def get_next_token_with_top_k(
LOWguidance/models/_openai_base.py217 def streaming_chat_completions(
LOWguidance/models/_openai_base.py232 def streaming_chat_completions(
LOWguidance/models/_azureai.py76def create_azure_openai_model(
LOWguidance/models/_azureai.py162 def streaming_chat_completions(
LOWguidance/models/_azureai.py220def create_azure_aifoundry_model(
LOWguidance/models/_transformers.py179 def _byte_tokens_from_byte_decoder(
LOWguidance/models/_transformers.py194 def _byte_tokens_from_sp_model(
LOWguidance/models/_transformers.py217 def _byte_tokens_by_encoding_token_strings(
LOWguidance/models/_transformers.py278 def check_byte_decoder_has_all_bytes() -> None:
LOWguidance/models/_transformers.py287 def check_byte_decoder_complex_round_trip() -> None:
LOWguidance/models/experimental/_litellm.py46 def streaming_chat_completions(
LOWguidance/models/_engine/_engine.py542 def get_next_token_with_top_k(
LOWguidance/models/_engine/_engine.py659 def chat_completion_streaming(
LOWguidance/models/_engine/_engine.py732def apply_temp_and_sampling_params(
LOWguidance/models/_base/_model.py192 def _update_open_block_captures(self) -> Self:
LOWguidance/_bg/__init__.py20def _asyncio_background_thread() -> tuple[threading.Thread, AbstractEventLoop]:
LOWtests/tokenizer_common.py37 def base_eos_bos_token_round_trip(self, model_name: str):
LOWtests/utils.py114def check_match_success_with_guards(grammar, test_string: str):
LOWtests/utils.py194def check_run_with_temperature(lm: models.Model, desired_temperature: float):
LOWtests/unit/test_parser.py17def test_zero_or_more_and_one_or_more():
LOWtests/unit/test_parser.py34def test_zero_or_more_and_one_or_more_mixed():
LOWtests/unit/test_parser.py117def test_char_set_one_or_more():
LOWtests/unit/test_model.py58def test_step_every_k_injection():
LOWtests/unit/test_model.py84def test_step_stop_token_trigger_injection():
LOWtests/unit/test_grammar.py24def test_select_ambiguous_lexeme_boundary():
LOWtests/unit/test_grammar.py33def test_select_ambiguous_lexeme_boundary_manual_fix():
LOWtests/unit/test_grammar.py50def test_grammar_plus_fstring():
LOWtests/unit/test_grammar.py82 def test_multiple_mutual_recursion(self):
LOWtests/unit/test_grammar.py99 def test_branching_mutual_recursion(self):
LOWtests/unit/test_grammar.py140 def test_raises_on_incomplete_input(self):
LOWtests/unit/test_uri_validation.py11 def test_https_allowed_by_default(self):
LOWtests/unit/test_uri_validation.py16 def test_http_blocked_by_default(self):
LOWtests/unit/test_uri_validation.py20 def test_ftp_blocked_by_default(self):
LOWtests/unit/test_uri_validation.py24 def test_http_allowed_when_configured(self):
LOWtests/unit/test_uri_validation.py28 def test_custom_scheme_allowed(self):
LOWtests/unit/test_uri_validation.py32 def test_scheme_check_is_case_insensitive(self):
LOWtests/unit/test_uri_validation.py38 def test_file_uri_blocked_when_allow_local_false(self):
LOWtests/unit/test_uri_validation.py42 def test_file_uri_allowed_when_allow_local_true(self):
LOWtests/unit/test_uri_validation.py46 def test_file_uri_not_subject_to_scheme_allowlist(self):
LOWtests/unit/test_uri_validation.py105 def test_ip_literal_in_url_blocked(self):
LOWtests/unit/test_uri_validation.py118 def test_dns_resolution_failure_raises(self):
LOWtests/unit/test_uri_validation.py129 def test_all_resolved_addresses_checked(self):
LOWtests/unit/test_bytes_from.py12 def test_blocks_http_by_default(self):
LOWtests/unit/test_bytes_from.py16 def test_allows_http_when_configured(self):
LOWtests/unit/test_bytes_from.py24 def test_blocks_private_ip_by_default(self):
157 more matches not shown…
Unused Imports119 hits · 114 pts
SeverityFileLineSnippet
LOWguidance/_tools.py11
LOWguidance/__init__.py8
LOWguidance/__init__.py11
LOWguidance/_ast.py31
LOWguidance/_ast.py31
LOWguidance/_parser.py13
LOWguidance/_utils.py21
LOWguidance/metrics/__init__.py3
LOWguidance/metrics/__init__.py3
LOWguidance/metrics/__init__.py3
LOWguidance/trace/__init__.py9
LOWguidance/trace/__init__.py9
LOWguidance/trace/__init__.py9
LOWguidance/trace/__init__.py9
LOWguidance/trace/__init__.py9
LOWguidance/trace/__init__.py9
LOWguidance/trace/__init__.py9
LOWguidance/trace/__init__.py9
LOWguidance/trace/__init__.py9
LOWguidance/trace/__init__.py9
LOWguidance/trace/__init__.py9
LOWguidance/trace/__init__.py9
LOWguidance/trace/__init__.py9
LOWguidance/trace/__init__.py9
LOWguidance/trace/__init__.py9
LOWguidance/trace/__init__.py9
LOWguidance/trace/__init__.py9
LOWguidance/trace/__init__.py9
LOWguidance/trace/__init__.py9
LOWguidance/trace/__init__.py9
LOWguidance/library/__init__.py3
LOWguidance/library/__init__.py3
LOWguidance/library/__init__.py3
LOWguidance/library/__init__.py3
LOWguidance/library/__init__.py3
LOWguidance/library/__init__.py4
LOWguidance/library/__init__.py4
LOWguidance/library/__init__.py7
LOWguidance/library/__init__.py8
LOWguidance/library/__init__.py9
LOWguidance/library/__init__.py9
LOWguidance/library/__init__.py10
LOWguidance/library/__init__.py10
LOWguidance/library/__init__.py11
LOWguidance/library/__init__.py11
LOWguidance/library/__init__.py12
LOWguidance/library/__init__.py13
LOWguidance/library/__init__.py14
LOWguidance/library/__init__.py14
LOWguidance/library/__init__.py14
LOWguidance/library/__init__.py14
LOWguidance/library/__init__.py17
LOWguidance/library/__init__.py17
LOWguidance/library/__init__.py17
LOWguidance/library/__init__.py17
LOWguidance/library/__init__.py17
LOWguidance/library/__init__.py18
LOWguidance/library/__init__.py19
LOWguidance/library/__init__.py19
LOWguidance/library/_subgrammar.py2
59 more matches not shown…
Over-Commented Block94 hits · 93 pts
SeverityFileLineSnippet
LOWguidance/models/broken_models/_lite_llm.py1# import tiktoken
LOWguidance/models/broken_models/_lite_llm.py21# "Please install the litellm package version >= 1.7 using `pip install litellm -U` in order to use guid
LOWguidance/models/broken_models/_lite_llm.py41# )
LOWguidance/models/broken_models/_lite_llm.py61
LOWguidance/models/broken_models/_lite_llm.py81
LOWguidance/models/broken_models/_lite_llm.py101# n=1,
LOWguidance/models/broken_models/_lite_llm.py121# else:
LOWguidance/models/broken_models/_lite_llm.py141# raise Exception(
LOWguidance/models/broken_models/_lite_llm.py161# except Exception as e: # TODO: add retry logic
LOWguidance/models/broken_models/_lite_llm.py181# messages = []
LOWguidance/models/broken_models/_lite_llm.py201# pos += end_pos + len(role_end)
LOWguidance/models/broken_models/_lite_llm.py221# except Exception as e: # TODO: add retry logic
LOWguidance/models/broken_models/_cohere.py1# from ._lite_llm import LiteLLMEngine, LiteLLM, LiteLLMCompletion, LiteLLMInstruct
LOWguidance/models/broken_models/_cohere.py21
LOWguidance/models/broken_models/_cohere.py41# class CohereCompletion(Cohere, LiteLLMCompletion):
LOWguidance/models/broken_models/_azure_openai.py1# import pathlib
LOWguidance/models/broken_models/_azure_openai.py21# """Represents an Azure OpenAI model as exposed through their remote API.
LOWguidance/models/broken_models/_azure_openai.py41# max_streaming_tokens: int = 1000,
LOWguidance/models/broken_models/_azure_openai.py61# if not is_openai or not hasattr(openai_package, "OpenAI"):
LOWguidance/models/broken_models/_azure_openai.py81
LOWguidance/models/broken_models/_azure_openai.py101# engine_instance,
LOWguidance/models/broken_models/_googleai.py1# import re
LOWguidance/models/broken_models/_googleai.py21# model,
LOWguidance/models/broken_models/_googleai.py41# genai.configure(api_key=api_key)
LOWguidance/models/broken_models/_googleai.py61# timeout=0.5,
LOWguidance/models/broken_models/_googleai.py81
LOWguidance/models/broken_models/_googleai.py101# engine=engine_map[self.__class__](
LOWguidance/models/broken_models/_googleai.py121# assistant_start = b"<|im_start|>assistant\n"
LOWguidance/models/broken_models/_googleai.py141# end_pos = prompt[pos:].find(role_end)
LOWguidance/models/broken_models/_googleai.py161# )
LOWguidance/models/broken_models/_googleai.py181
LOWguidance/models/broken_models/_googleai.py201# formated_messages = []
LOWguidance/models/broken_models/_googleai.py221# formated_messages.append(Content(role=m["role"], parts=parts))
LOWguidance/models/broken_models/_googleai.py241# class GoogleAIChat(GoogleAI, Chat):
LOWguidance/models/broken_models/_Gemini.py1# import os
LOWguidance/models/broken_models/_Gemini.py21
LOWguidance/models/broken_models/_Gemini.py41# is_vertexai = True
LOWguidance/models/broken_models/_Gemini.py61# # caching=caching,
LOWguidance/models/broken_models/_Gemini.py81# # tokenizer=tokenizer,
LOWguidance/models/broken_models/_Gemini.py101# # the superclass does all the work
LOWguidance/models/broken_models/_Gemini.py121# # last_user_text = messages[-1]["content"]
LOWguidance/models/broken_models/_Gemini.py141
LOWguidance/models/broken_models/_anthropic.py1# import os
LOWguidance/models/broken_models/_anthropic.py21# except ModuleNotFoundError:
LOWguidance/models/broken_models/_anthropic.py41# except:
LOWguidance/models/broken_models/_anthropic.py61# ("assistant", b"<|im_start|>assistant\n"),
LOWguidance/models/broken_models/_anthropic.py81
LOWguidance/models/broken_models/_anthropic.py101# temperature=temperature,
LOWguidance/models/broken_models/_anthropic.py121# there are some things we cannot do, like force the model to follow a pattern inside
LOWguidance/models/broken_models/_anthropic.py141# tokenizer=tokenizer,
LOWguidance/models/broken_models/_azureai_studio.py1# import hashlib
LOWguidance/models/broken_models/_azureai_studio.py21# class AzureAIStudioChatEngine(GrammarlessEngine):
LOWguidance/models/broken_models/_azureai_studio.py41# "Detected OpenAI compatible model; please install openai package"
LOWguidance/models/broken_models/_azureai_studio.py61
LOWguidance/models/broken_models/_azureai_studio.py81# found = True
LOWguidance/models/broken_models/_azureai_studio.py101# message_content = btext.decode("utf8")
LOWguidance/models/broken_models/_azureai_studio.py121# cache_key = self._hash_prompt(prompt)
LOWguidance/models/broken_models/_azureai_studio.py141
LOWguidance/models/broken_models/_azureai_studio.py161# response_score = requests.post(
LOWguidance/models/broken_models/_azureai_studio.py181# yield encoded_chunk
34 more matches not shown…
Decorative Section Separators22 hits · 69 pts
SeverityFileLineSnippet
MEDIUMguidance/chat.py91# --------------------------------------------------
MEDIUMguidance/chat.py93# --------------------------------------------------
MEDIUMguidance/chat.py111# --------------------------------------------------
MEDIUMguidance/chat.py113# --------------------------------------------------
MEDIUMguidance/chat.py146# --------------------------------------------------
MEDIUMguidance/chat.py148# --------------------------------------------------
MEDIUMguidance/chat.py173# --------------------------------------------------
MEDIUMguidance/chat.py175# --------------------------------------------------
MEDIUMguidance/chat.py230# --------------------------------------------------
MEDIUMguidance/chat.py232# --------------------------------------------------
MEDIUMguidance/chat.py251# --------------------------------------------------
MEDIUMguidance/chat.py253# --------------------------------------------------
MEDIUMguidance/chat.py285# --------------------------------------------------
MEDIUMguidance/chat.py287# --------------------------------------------------
MEDIUMguidance/chat.py317# --------------------------------------------------
MEDIUMguidance/chat.py319# --------------------------------------------------
MEDIUMguidance/chat.py345# --------------------------------------------------
MEDIUMguidance/chat.py347# --------------------------------------------------
MEDIUMguidance/chat.py371# --------------------------------------------------
MEDIUMguidance/chat.py373# --------------------------------------------------
MEDIUMguidance/models/broken_models/_azure_openai.py49# ----------
MEDIUMguidance/models/broken_models/_azureai_studio.py214# ----------
Cross-File Repetition9 hits · 45 pts
SeverityFileLineSnippet
HIGHguidance/models/_llama_cpp.py0computes the logits for the given token state. this overrides a method from the localengine class that is used to get in
HIGHguidance/models/_transformers.py0computes the logits for the given token state. this overrides a method from the localengine class that is used to get in
HIGHguidance/models/_onnxruntime.py0computes the logits for the given token state. this overrides a method from the localengine class that is used to get in
HIGHguidance/visual/_renderer.py0initializes. args: trace_handler: trace handler of an engine.
HIGHguidance/visual/_renderer.py0initializes. args: trace_handler: trace handler of an engine.
HIGHguidance/visual/_renderer.py0initializes. args: trace_handler: trace handler of an engine.
HIGHtests/model_specific/test_onnxruntime_genai.py0tweak this proverb to apply to model instructions instead. {gen("verse", max_tokens=2)}
HIGHtests/model_specific/test_transformers.py0tweak this proverb to apply to model instructions instead. {gen("verse", max_tokens=2)}
HIGHtests/model_specific/llama_cpp_tests/test_llama_cpp.py0tweak this proverb to apply to model instructions instead. {gen("verse", max_tokens=2)}
Self-Referential Comments10 hits · 34 pts
SeverityFileLineSnippet
MEDIUMguidance/models/_openai_base.py484 # Create an in-memory WAV file
MEDIUMguidance/models/_transformers.py405 # Create the tokenizer
MEDIUMguidance/models/_base/_model.py368 # Define the target function for the thread
MEDIUMtests/unit/test_decorator.py407 # Create a weak reference to the object
MEDIUMtests/unit/test_decorator.py420 # Create a weak reference to the object
MEDIUMtests/unit/test_decorator.py433 # Create a weak reference to the object
MEDIUMtests/unit/test_decorator.py435 # Create a weak reference to the cached method
MEDIUMdocs/conf.py7# This file is execfile()d with the current directory set to its
MEDIUMscripts/extract_python_from_readme.py18 # This function contains 95% CoPilot vibes by volume
MEDIUMpackages/python/stitch/docs/source/conf.py6# This file is execfile()d with the current directory set to its
Deep Nesting32 hits · 32 pts
SeverityFileLineSnippet
LOWguidance/_schema.py184
LOWguidance/_grammar.py61
LOWguidance/_ast.py682
LOWguidance/_parser.py324
LOWguidance/_guidance.py129
LOWguidance/_guidance.py140
LOWguidance/metrics/_metrics.py126
LOWguidance/trace/_trace.py357
LOWguidance/library/_json.py13
LOWguidance/library/_substring.py11
LOWguidance/models/_mock.py117
LOWguidance/models/_openai_base.py168
LOWguidance/models/_openai_base.py336
LOWguidance/models/_llama_cpp.py81
LOWguidance/models/_transformers.py217
LOWguidance/models/_transformers.py444
LOWguidance/models/broken_models/_vertexai.py21
LOWguidance/models/broken_models/_vertexai.py174
LOWguidance/models/experimental/_sglang.py99
LOWguidance/models/experimental/_litellm.py209
LOWguidance/models/experimental/_vllm.py29
LOWguidance/models/_engine/_engine.py94
LOWguidance/models/_engine/_interpreter.py65
LOWguidance/models/_base/_model.py115
LOWguidance/models/_base/_model.py161
LOWguidance/models/_base/_model.py361
LOWguidance/visual/_renderer.py199
LOWguidance/visual/_renderer.py329
LOWguidance/visual/_renderer.py524
LOWguidance/visual/_renderer.py541
LOWguidance/visual/_trace.py17
LOWtests/unit/test_ll.py62
Redundant / Tautological Comments18 hits · 29 pts
SeverityFileLineSnippet
LOWguidance/debug.py27 # Check if the auto renderer has a JupyterWidgetRenderer inside
LOWguidance/debug.py53 # Check if the auto renderer has a JupyterWidgetRenderer inside
LOWguidance/debug.py81 # Check if the auto renderer has a JupyterWidgetRenderer inside
LOWguidance/models/_transformers.py299 # Check if the tokenizer has a bos_token attribute, and if it does, check
LOWguidance/models/broken_models/_azureai_studio.py123# # Check if the result is already in the cache
LOWguidance/models/_engine/_engine.py315 # Check if the accumulated text ends with any stop string
LOWguidance/models/_engine/_engine.py357 # Check if we've accumulated enough to match the stop string
LOWguidance/models/_engine/_engine.py426 # Set flag to indicate this is an injection backtrack
LOWguidance/models/_engine/_engine.py474 # Set flag to indicate this is an injection backtrack
LOWguidance/models/_engine/_interpreter.py87 # Check if this is an injection backtrack (should happen before adding text)
LOWguidance/models/_base/_model.py181 # Set start_index to the current length
LOWguidance/models/_base/_model.py392 # Check if the thread is still alive
LOWguidance/visual/_renderer.py482 # Check if message has diverged from prev messages
LOWguidance/visual/_trace.py32 # Check if any input is a role opener or closer
LOWguidance/visual/_trace.py93 # Check if any input in active role is a RoleCloserInput
LOWtests/unit/test_decorator.py415 # Check if the object was garbage collected
LOWtests/unit/test_decorator.py428 # Check if the object was garbage collected
LOWtests/unit/test_decorator.py444 # Check if the object was garbage collected
Cross-Language Confusion3 hits · 20 pts
SeverityFileLineSnippet
HIGHtests/unit/library/json/test_allOf.py352 # valid: foo is null, bar is equal to 5, baz is null
HIGHtests/unit/library/json/test_allOf.py443 # valid: foo is null, bar is equal to 5, baz is null
HIGHpackages/python/stitch/stitch/tests/conftest.py43 _widget_attrs["_comm_default"] = getattr(Widget, "_comm_default", undefined)
Excessive Try-Catch Wrapping10 hits · 10 pts
SeverityFileLineSnippet
LOWguidance/metrics/_metrics.py93 except Exception as e: # noqa BLE001
LOWguidance/metrics/_metrics.py141 except Exception as e: # noqa BLE001
LOWguidance/metrics/_metrics.py177 except Exception as e:
LOWguidance/models/_transformers.py310 except Exception as e:
LOWguidance/models/broken_models/_vertexai.py132 except Exception as e: # TODO: add retry logic
LOWguidance/visual/_renderer.py153 except Exception: # noqa: BLE001
LOWguidance/visual/_renderer.py195 except Exception as _: # noqa: BLE001
LOWguidance/visual/_renderer.py237 except Exception as _: # noqa: BLE001
LOWtests/unit/test_visual.py82 except Exception as e:
LOWtests/model_specific/test_visual.py51 except Exception as e:
AI Slop Vocabulary2 hits · 3 pts
SeverityFileLineSnippet
LOWguidance/models/_transformers.py127 # (that will just add extra spaces during an encode-decode cycle)
LOWguidance/models/_engine/_engine.py614 # If we have top_k, we can just return the first one
Fake / Example Data3 hits · 3 pts
SeverityFileLineSnippet
LOWtests/model_specific/test_transformers.py35 big_opts = ["Lorem ipsum dolor sit amet", "Duis aute irure dolor "]
LOWtests/model_specific/test_transformers.py35 big_opts = ["Lorem ipsum dolor sit amet", "Duis aute irure dolor "]
LOWtests/model_integration/library/test_subgrammar.py62 lm += "John Doe's name, age, and birthday:\n"
Slop Phrases1 hit · 2 pts
SeverityFileLineSnippet
LOWguidance/models/broken_models/_lite_llm.py139# # make sure you don't try and instruct the same model twice
Overly Generic Function Names2 hits · 2 pts
SeverityFileLineSnippet
LOWtests/model_integration/test_model.py41 def my_function(lm):
LOWtests/model_integration/test_model.py77 def my_function(lm):