symfonic.capabilities.knowledge.factory¶
factory ¶
Knowledge as something a composition root can compose.
The decision this file records: knowledge is not its own capability. The
package exports four sources -- retrieval, stored documents, attachments and
static text -- and every one of them has read. That is the same shape
persona_sources and guardrail_sources return, which means knowledge
already had a seam into a turn and it is the prompting capability's:
Agent(provider, capabilities=[
PromptingCapability(sources=[
*persona_sources(persona),
*knowledge_sources(retriever=my_retriever, query=question),
])
])
Writing a KnowledgeCapability with its own contribute() would have
declared a second prompt-assembly stage that competes with the compiler for the
same budget, to deliver contributions the compiler already knows how to render.
The gap was never a missing capability; it was a missing function that builds
the sources.
Trust. These sources declare their payload untrusted on the read, not on
the source, so a document is wrapped in the untrusted-data markers rather than
rendered as instruction. as_contributions defaults an unlabelled source to
a learned tier for exactly this reason -- a retrieved document read to the
model as though the deployment had written it is the prompt-injection path,
arrived at by omission.
knowledge_sources ¶
knowledge_sources(*, retriever: Any = None, query: str = '', store: Any = None, document_ids: Sequence[str] = (), attachments: Sequence[Any] = (), extractor: Any = None, context: str = '', **policies: Any) -> tuple[Any, ...]
The sources this deployment's knowledge reaches the prompt through.
Every argument is optional and each one adds a source only when it can
actually produce something -- a retriever with no query retrieves nothing,
and a store with no ids reads nothing. Returning a source that cannot
contribute would cost the compiler a budget slot and a delimiter for an
empty block, which is the same rule compose follows in governance:
leave it out rather than in-but-inert.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
retriever
|
Any
|
a |
None
|
query
|
str
|
what to retrieve. Required for |
''
|
store
|
Any
|
a |
None
|
document_ids
|
Sequence[str]
|
which documents to pin into the prompt. |
()
|
attachments
|
Sequence[Any]
|
refs the caller sent with the turn. |
()
|
extractor
|
Any
|
turns an attachment into text. Required for |
None
|
context
|
str
|
static text this deployment always wants present. |
''
|
**policies
|
Any
|
|
{}
|