Keep LLMDetector working as a warning adapter

Aperta
#166 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
38/100
Tipo di issue
Refactoring
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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

Lingua principale
Python
Stelle
615
Fork
60
Merge medio
1g 8h
PR unite (30g)
10

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di KRLabsOrg/LettuceDetect

Tutte le issue di KRLabsOrg/LettuceDetect

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.