Keep LLMDetector working as a warning adapter

Abierto
#166 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
38/100
Tipo de issue
Refactorización
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
python

Línea de trabajo

Read the parent issue #126, blockers #156 and #162, and the Errors and logging section of CONTRIBUTING.md; branch from stateless_core. Locate LLMDetector, LLMJudgeDetector, GenerativeDetector, HallucinationDetector, and the golden fixtures and existing tests. Compare current behavior with the acceptance criteria, then verify the old outputs, typed errors, warning behavior, and cache behavior against those tests.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

ready-for-agent

Parent

#126

Branch

Branch from stateless_core and open the pull request against it, not main. Close this ticket by hand once its pull request merges there: GitHub only closes issues automatically on merges into main.

What to build

Everyone who builds LLMDetector today keeps working and learns what to change. LLMDetector becomes a thin adapter: it chooses LLMJudgeDetector or GenerativeDetector by today's name rule or by native=, builds the client and the cache the old way when the caller passes none, and warns for each deprecated use, naming the replacement. The default cache file inside the installed package directory is gone: a file is written only when the caller passes cache_file.

The old predict* output, including the token output of the LLM detector, stays as today's golden fixtures record it.

Acceptance criteria

  • Constructing LLMDetector from outside the package warns LettuceDetectDeprecationWarning naming LLMJudgeDetector and GenerativeDetector; constructing it from inside the package does not warn.
  • LLMDetector picks GenerativeDetector for a model name that matches today's rule, and LLMJudgeDetector for any other. native=True or native=False overrides the rule.
  • native=True (or a name that matches the rule) together with zero_shot, fewshot_path or prompt_path raises ConfigurationError (native_options_conflict, with param), as today's ValueError case does.
  • Without client, LLMDetector builds one from provider and **client_kwargs as today and warns that the client should be passed; passing provider or client_kwargs warns as a deprecated argument.
  • cache_file builds a FileCache and warns as a deprecated argument naming cache=. With no cache_file the detector has no cache and no file is written anywhere.
  • predict, predict_prompt and predict_prompt_batch convert the new detector's Detection into today's dicts, with confidence taken from score and each key present exactly as today (golden fixtures), apart from spans that had no confidence now carrying 1.0.
  • predict(output_format="tokens") still returns one token, pred and prob dict per whitespace token, with prob the overlapping span's confidence when there is one, else 0.9 for a flagged token and 0.1 for the others, as in the golden fixtures.
  • The old methods raise InvalidInputError (unsupported_output_format, length_mismatch, invalid_min_score) and surface the typed errors of the new detector.
  • predict_prompt_batch is unchanged apart from the above until the batch task.
  • LLMDetector also exposes detect and adetect, forwarding to the chosen delegate: the result equals the delegate's, model_id is the delegate's, and no warning is added beyond the one at construction.
  • LLMDetector has the docstring note from the deprecation mechanism, and HallucinationDetector(method="llm", ...) returns today's output without a warning.
  • The existing tests pass unchanged.
  • The changed code follows the Errors and logging section of CONTRIBUTING.md, and no customer text is logged outside lettucedetect.content.

Blocked by

#156, #162

User stories covered

40, 44, 45, 46, 47, 48, 57

Lenguaje dominante
Python
Estrellas
615
Forks
60
Merge medio
1 d 8 h
PR fusionados (30 d)
10

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de KRLabsOrg/LettuceDetect

Todos los issues de KRLabsOrg/LettuceDetect

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.