crp.isa¶
Auto-generated reference for the crp.isa subpackage.
isa¶
crp.isa ¶
Intent & Speech-Act Positioning (CRP-SPEC-052).
CoreferenceResolver ¶
Resolve pronouns and deixis against a session entity registry.
resolve(turn, session_entities) ¶
Rewrite ambiguous references in turn using session_entities.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
turn | str | The raw user turn. | required |
session_entities | dict[str, str] | Mapping of entity id -> canonical mention text. | required |
Returns:
| Type | Description |
|---|---|
str | The resolved turn. Pronouns are replaced when a canonical antecedent |
str | can be found; ordinal deixis ("the second option") is resolved from |
str | the registry order. |
IntentClassifier ¶
Zero-dependency speech-act + intent classifier.
The classifier is deliberately simple: it meets the latency budget and gives downstream positioning reliable pragmatic signals. A SetFit/DeBERTa model can be swapped in by subclassing and overriding :meth:classify.
classify(turn, history=None) ¶
Classify a single user turn.
IntentTag dataclass ¶
Pragmatic tag for a user turn.
LLMIntentClassifier ¶
Bases: IntentClassifier
Optional intent classifier backed by a local OpenAI-compatible LLM.
Useful for tests against LM Studio or other local servers. Falls back to the rule-based classifier if the LLM is unreachable or refuses to answer.
ManagedIntentClassifier ¶
Bases: IntentClassifier
ML-first intent classifier with deterministic rule-based fallback.
Tries a registered local model (SetFit by default) under a millisecond budget. If the model is unavailable or slow, the rule-based classifier takes over instantly.
confidence(tag) ¶
Estimate classifier confidence for downstream clarification gate (SPEC-053).
Higher directness and recognized constraints increase confidence; unknown or expressive speech acts decrease it.
build_intent_section(raw_turn, intent_tag, resolved_turn) ¶
Assemble the interpreted_intent envelope section (SPEC-003).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw_turn | str | Original user text. | required |
intent_tag | IntentTag | Pragmatic classification from the intent classifier. | required |
resolved_turn | str | User text after coreference resolution. | required |
Returns:
| Type | Description |
|---|---|
dict | Dictionary ready to be attached to the context envelope. |
isa.coref¶
crp.isa.coref ¶
Cross-session coreference resolution (CRP-SPEC-052 §4.3.2).
Resolves pronouns/deixis ("it", "that approach", "the second option") against a session entity registry before the envelope is packed. The default implementation is rule-based and dependency-free; if fastcoref is installed, it is loaded lazily through :mod:crp.ml and constrained to a millisecond budget, falling back to the rule-based resolver if the model is slow or absent.
CoreferenceResolver ¶
Resolve pronouns and deixis against a session entity registry.
resolve(turn, session_entities) ¶
Rewrite ambiguous references in turn using session_entities.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
turn | str | The raw user turn. | required |
session_entities | dict[str, str] | Mapping of entity id -> canonical mention text. | required |
Returns:
| Type | Description |
|---|---|
str | The resolved turn. Pronouns are replaced when a canonical antecedent |
str | can be found; ordinal deixis ("the second option") is resolved from |
str | the registry order. |
isa.intent¶
crp.isa.intent ¶
Fast intent / speech-act classifier (CRP-SPEC-052 §4.3.1).
The base :class:IntentClassifier is rule-based and has zero heavy dependencies, keeping the positioned tool loop under the sub-10 ms budget. An optional :class:LLMIntentClassifier can call a local OpenAI-compatible endpoint (e.g. LM Studio) when a stronger pragmatic interpretation is needed.
ML-driven classifiers are default-on when their optional dependencies are installed, but they are loaded lazily and governed by the millisecond budget in :mod:crp.ml. If the model is absent, slow, or raises, classification degrades to the rule-based path automatically.
IntentTag dataclass ¶
Pragmatic tag for a user turn.
IntentClassifier ¶
Zero-dependency speech-act + intent classifier.
The classifier is deliberately simple: it meets the latency budget and gives downstream positioning reliable pragmatic signals. A SetFit/DeBERTa model can be swapped in by subclassing and overriding :meth:classify.
classify(turn, history=None) ¶
Classify a single user turn.
ManagedIntentClassifier ¶
Bases: IntentClassifier
ML-first intent classifier with deterministic rule-based fallback.
Tries a registered local model (SetFit by default) under a millisecond budget. If the model is unavailable or slow, the rule-based classifier takes over instantly.
LLMIntentClassifier ¶
Bases: IntentClassifier
Optional intent classifier backed by a local OpenAI-compatible LLM.
Useful for tests against LM Studio or other local servers. Falls back to the rule-based classifier if the LLM is unreachable or refuses to answer.
confidence(tag) ¶
Estimate classifier confidence for downstream clarification gate (SPEC-053).
Higher directness and recognized constraints increase confidence; unknown or expressive speech acts decrease it.
isa.position¶
crp.isa.position ¶
Build the interpreted-intent envelope section (CRP-SPEC-052 §4.3.3).
build_intent_section(raw_turn, intent_tag, resolved_turn) ¶
Assemble the interpreted_intent envelope section (SPEC-003).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw_turn | str | Original user text. | required |
intent_tag | IntentTag | Pragmatic classification from the intent classifier. | required |
resolved_turn | str | User text after coreference resolution. | required |
Returns:
| Type | Description |
|---|---|
dict | Dictionary ready to be attached to the context envelope. |