agentscope.middlewareParameters
class Parameters(BaseModel)
agentscope/middleware/_rag.py:648–798参数,驱动智能体的推理、工具调用与会话执行。位于 agentscope.middleware 包。
The fields here are exactly the keys the hosted service persists
into SessionKnowledgeConfig.parameters and the keys
:class:RAGMiddleware accepts as search_config. Every field
is annotated with a title and description so the front-end
can render them as labels and tooltips via
model_json_schema().
属性摘要Attribute Summary
| 属性Attribute | 类型Type | 说明Description | 值Value |
|---|---|---|---|
model_config | — | 模型配置字段。 | ConfigDict(frozen=True) |
mode | Literal['static', 'agentic'] | 模式字段。 | Field(default='agentic', title='Mode', description='Retrieval is either agentic, letting the Agent decide when to retrieve, or static, triggering on every user input.') |
top_k | int | `top_k` 字段。 | Field(default=5, ge=1, le=50, title='Top K', description='Maximum number of chunks returned per search, across all configured knowledge bases.') |
score_threshold | float | None | 分数阈值字段。 | Field(default=None, title='Score Threshold', description='Minimum similarity score for a hit to be kept. Leave empty to disable filtering.') |
rerank_candidate_k | int | None | `rerank_candidate_k` 字段。 | Field(default=None, ge=1, le=_MAX_CANDIDATE_K, title='Rerank Candidate K', description='Number of chunks retrieved for the rerank model to judge, from which top_k are kept. Must be at least top_k, and defaults to twice it. Ignored when no rerank model is configured.') |
emit_hint_event | bool | `emit_hint_event` 字段。 | Field(default=True, title='Show matched chunks in chat', description='Emit a `HintBlockEvent` in static mode so the front-end can display the matched snippets to the user.') |
persist_hint | bool | `persist_hint` 字段。 | Field(default=False, title='Persist Hint', description='In `static` mode, keep the injected hint block in the agent context instead of removing it right after the model call.') |
hint_template | SkipJsonSchema[str] | `hint_template` 字段。 | Field(default=_DEFAULT_HINT_TEMPLATE, title='Hint template', description='Template wrapping the formatted search results in static mode, with a `{context}` placeholder.') |
rerank_prompt | SkipJsonSchema[str] | 重排提示词字段。 | Field(default=_DEFAULT_RERANK_PROMPT, title='Rerank prompt', description='Instruction part of the rerank prompt, with a `{query}` and an optional `{top_k}` placeholder. The candidates are appended to it by the middleware.') |
属性详情Attribute Detail
model_config
= ConfigDict(frozen=True)模型配置字段。
The model config field.
agentscope/middleware/_rag.py:660mode
Literal['static', 'agentic'] = Field(default='agentic', title='Mode', description='Retrieval is either agentic, letting the Agent decide when to retrieve, or static, triggering on every user input.')模式字段。声明为 Literal['static', 'agentic']。
Retrieval is either agentic, letting the Agent decide when to retrieve, or static, triggering on every user input.
agentscope/middleware/_rag.py:662top_k
int = Field(default=5, ge=1, le=50, title='Top K', description='Maximum number of chunks returned per search, across all configured knowledge bases.')top_k 字段。声明为 int。
Maximum number of chunks returned per search, across all configured knowledge bases.
agentscope/middleware/_rag.py:671score_threshold
float | None = Field(default=None, title='Score Threshold', description='Minimum similarity score for a hit to be kept. Leave empty to disable filtering.')分数阈值字段。声明为 float | None。
Minimum similarity score for a hit to be kept.
agentscope/middleware/_rag.py:682rerank_candidate_k
int | None = Field(default=None, ge=1, le=_MAX_CANDIDATE_K, title='Rerank Candidate K', description='Number of chunks retrieved for the rerank model to judge, from which top_k are kept. Must be at least top_k, and defaults to twice it. Ignored when no rerank model is configured.')rerank_candidate_k 字段。声明为 int | None。
Number of chunks retrieved for the rerank model to judge, from which top_k are kept.
agentscope/middleware/_rag.py:691emit_hint_event
bool = Field(default=True, title='Show matched chunks in chat', description='Emit a `HintBlockEvent` in static mode so the front-end can display the matched snippets to the user.')emit_hint_event 字段。声明为 bool。
Emit a HintBlockEvent in static mode so the front-end can display the matched snippets to the user.
agentscope/middleware/_rag.py:704persist_hint
bool = Field(default=False, title='Persist Hint', description='In `static` mode, keep the injected hint block in the agent context instead of removing it right after the model call.')persist_hint 字段。声明为 bool。
In static mode, keep the injected hint block in the agent context instead of removing it right after the model call.
agentscope/middleware/_rag.py:713hint_template
SkipJsonSchema[str] = Field(default=_DEFAULT_HINT_TEMPLATE, title='Hint template', description='Template wrapping the formatted search results in static mode, with a `{context}` placeholder.')hint_template 字段。声明为 SkipJsonSchema[str]。
Template wrapping the formatted search results in static mode, with a {context} placeholder.
agentscope/middleware/_rag.py:723rerank_prompt
SkipJsonSchema[str] = Field(default=_DEFAULT_RERANK_PROMPT, title='Rerank prompt', description='Instruction part of the rerank prompt, with a `{query}` and an optional `{top_k}` placeholder. The candidates are appended to it by the middleware.')重排提示词字段。声明为 SkipJsonSchema[str]。
Instruction part of the rerank prompt, with a {query} and an optional {top_k} placeholder.
agentscope/middleware/_rag.py:738