Add transitional learning detect with in-dialog mask review.
Senses grow from confirmations instead of a word list, so a later local pipeline can decide homonyms on a short passage. Default stays semantic. Local detect waits longer, and the reverse-proxy timeout is documented so Dev does not 504 first. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
59921fc5b5
commit
fa1c11c33e
29 files changed
+1135
-45
No files matched your search
@@ -31,7 +31,9 @@ from providers import ChatResult, ProviderError, complete_chat, detect_provider
|
||||
DETECT_CHUNK_CHARS = 4000
|
||||
DETECT_CHUNK_OVERLAP = 250
|
||||
DETECT_TIMEOUT = 90.0
|
||||
DETECT_TIMEOUT_LOCAL = 300.0
|
||||
DETECT_MAX_TOKENS = 1024
|
||||
DETECT_MAX_TOKENS_LOCAL = 256
|
||||
JSON_BLOCK = re.compile(r"\{.*\}", re.DOTALL)
|
||||
ALLOWED_ENTITY_FIELDS = frozenset({"start", "end", "text", "entity_type"})
|
||||
ALLOWED_ROOT_FIELDS = frozenset({"entities"})
|
||||
@@ -573,6 +575,13 @@ def _add_usage(stats: DetectionStats, usage: dict | None) -> None:
|
||||
pass
|
||||
|
||||
|
||||
def detect_chat_limits(config) -> tuple[float, int]:
|
||||
"""Remote detect stays at 90s/1024. Local CPU hosts need a longer wait and a shorter cap."""
|
||||
if getattr(config, "local", False):
|
||||
return DETECT_TIMEOUT_LOCAL, DETECT_MAX_TOKENS_LOCAL
|
||||
return DETECT_TIMEOUT, DETECT_MAX_TOKENS
|
||||
|
||||
|
||||
def _llm_chunk(config, excerpt: str, *, schema_retry: bool = False) -> ChatResult:
|
||||
prompt = resolve_template(
|
||||
_detect_prompt()["template"],
|
||||
@@ -580,11 +589,12 @@ def _llm_chunk(config, excerpt: str, *, schema_retry: bool = False) -> ChatResul
|
||||
)
|
||||
if schema_retry:
|
||||
prompt = f"{prompt.rstrip()}\n\n{SCHEMA_RETRY_HINT}"
|
||||
timeout, max_tokens = detect_chat_limits(config)
|
||||
return complete_chat(
|
||||
config,
|
||||
[{"role": "user", "content": prompt}],
|
||||
timeout=DETECT_TIMEOUT,
|
||||
max_tokens=DETECT_MAX_TOKENS,
|
||||
timeout=timeout,
|
||||
max_tokens=max_tokens,
|
||||
disable_context_compression=True,
|
||||
)
|
||||
|
||||
|
||||
Reference in new issue
Block a user