AS AgentScopeAPI 手册 / API Reference
类class agentscope.middleware

Parameters

class Parameters(BaseModel)
源码Source 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)
modeLiteral['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_kint
`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_thresholdfloat | None
分数阈值字段。
Field(default=None, title='Score Threshold', description='Minimum similarity score for a hit to be kept. Leave empty to disable filtering.')
rerank_candidate_kint | 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_eventbool
`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_hintbool
`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_templateSkipJsonSchema[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_promptSkipJsonSchema[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.

源码Source agentscope/middleware/_rag.py:660

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.')

模式字段。声明为 Literal['static', 'agentic']。

Retrieval is either agentic, letting the Agent decide when to retrieve, or static, triggering on every user input.

源码Source agentscope/middleware/_rag.py:662

top_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.

源码Source agentscope/middleware/_rag.py:671

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.')

分数阈值字段。声明为 float | None。

Minimum similarity score for a hit to be kept.

源码Source agentscope/middleware/_rag.py:682

rerank_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.

源码Source agentscope/middleware/_rag.py:691

emit_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.

源码Source agentscope/middleware/_rag.py:704

persist_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.

源码Source agentscope/middleware/_rag.py:713

hint_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.

源码Source agentscope/middleware/_rag.py:723

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.')

重排提示词字段。声明为 SkipJsonSchema[str]。

Instruction part of the rerank prompt, with a {query} and an optional {top_k} placeholder.

源码Source agentscope/middleware/_rag.py:738
基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.