Repository navigation
feat(classify): classify an asset or a text with the decision model - #494
Merged
Merged
Conversation
POST /classify, the MCP tool classify and the assistant's classify say which of some labels fits an asset or a text, how sure, and every label ranked: labels given, Lens's content types or a namespace's topics. The decision model answers, else the language model; with apply, an editor's sure answer sets the content type, suggests the topic or adds the tag. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GKv2oVRvFRdiSf4USLsM1N
21 of 23 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Adeel · project thread
Description
Before: the decision model (
decide.choose: Jev, Laya or the LLM) picked a namespace and a few other routine things inside Lens, but an agent couldn't ask it anything. To label an asset ("which desk does this go to?", "what content type is this?", "which topic is it about?"), an agent had to write its own prompt.After: one core classify service, used by the API (
POST /api/v1/classify), the MCP server (classify) and the assistant (classify). It says which of some labels fits an asset or a piece of text, how sure it is, and ranks every label. The labels can be:["science", "sport: games and teams"], with an optional meaning after:) or{label: meaning}, 2 to 60 of them;vocabulary: content_type);vocabulary: topic), the most used first.The decision model answers when it's set up, else the language model.
bysays which one answered, and every call is in the activity ledger, counted for the asset and its namespace. Withapply(editors only), a sure answer acts:"Sure" means
decisions.act_above, 0.8 by default. An answer that isn't sure changes nothing, and neither does a topic the asset already has. Applying is audited (recording.classify). MCP and the assistant only read.Motivation and Context
Adeel asked for core services that agents and workflows can use: classify, plus find by face, voice, entity, type, content type, date and other attributes. Find merged in #398. This PR is classify. A Classify node for workflows follows in its own PR.
How:
domain/classify.pybuilds the options from the given labels or a vocabulary (content_types.all_types,topics). It describes the asset with its title, file, kind, length, language, tags, accepted topics, summary, most-mentioned entities and the start of its text. The archive's words are wrapped withuntrusted.wrap, so instructions in them are read as data. It then callsdecide.chooseinsideactivity.scopeand acts through the existingcontent_types.choose,topics.proposeandlibrary.retag.Types of changes
!in the title)Checklist:
make hookschecks it on commit).docs/accordingly.## UnreleasedinCHANGELOG.md.Done questions (AGENTS.md)
POST /classify, MCPclassifyand assistantclassify.decisions.act_above(Settings → AI assistant).apply, and only on a sure answer. Topics are only suggested. Defaults are unchanged.by) and how sure it is. Docs label the planned parts.tests/api/test_classify.py,docs/processing.md#classifying,docs/api.md,docs/mcp.md,docs/assistant.md,make openapi.decide.choose/decide.sure,activity.scope,untrusted.wrap,content_types.choose,topics.propose,library.retag.Local checks:
ruff check,ruff format --check,mypy, classify/find/MCP tests,mkdocs build --strict. Before this rebase, the full backend suite passed: 1095 passed, 20 skipped.Generated by Claude Code