AgentscopeFactory
@Factory @Requires(classes = ReActAgent.class) public class AgentscopeFactory
源码Source
io/agentscope/micronaut/AgentscopeFactory.java:115–201Agentscope 工厂,承载智能体的部署、调度与服务化运行。位于 io.agentscope.micronaut 包。核心成员包括 agentscopeMemory、agentscopeToolkit、agentscopeModel、agentscopeReActAgent。
Micronaut factory that exposes default Model, Memory, Toolkit and ReActAgent beans for AgentScope.
Basic configuration with DashScope (default provider):
`agentscope:
# Select model provider (defaults to dashscope when omitted)
model:
provider: dashscope
dashscope:
enabled: true
api-key: ${DASHSCOPE_API_KEY}
model-name: qwen-plus
stream: true
enable-thinking: true
agent:
enabled: true
name: "Assistant"
sys-prompt: "You are a helpful AI assistant."
max-iters: 10
`
Using OpenAI as provider:
`agentscope:
model:
provider: openai
openai:
enabled: true
api-key: ${OPENAI_API_KEY}
model-name: gpt-4.1-mini
stream: true
`
Using Gemini as provider (direct API):
`agentscope:
model:
provider: gemini
gemini:
enabled: true
api-key: ${GEMINI_API_KEY}
model-name: gemini-2.0-flash
stream: true
`
Using Gemini via Vertex AI:
`agentscope:
model:
provider: gemini
gemini:
enabled: true
project: your-gcp-project-id
location: us-central1
model-name: gemini-2.0-flash
vertex-ai: true
stream: true
`
Using Anthropic as provider:
`agentscope:
model:
provider: anthropic
anthropic:
enabled: true
api-key: ${ANTHROPIC_API_KEY}
model-name: claude-sonnet-4.5
stream: true
`
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public Memory agentscopeMemory() | 返回 `agentscopeMemory` 结果。 Default Memory implementation backed by InMemoryMemory. |
public Toolkit agentscopeToolkit() | 返回 `agentscopeToolkit` 结果。 Default Toolkit implementation with an initially empty tool set. |
public Model agentscopeModel(AgentscopeProperties properties) | 设置该参数。 Default Model implementation. |
public ReActAgent agentscopeReActAgent(Model model, Memory memory, Toolkit toolkit, AgentscopeProperties properties) | 执行 `agentscopeReActAgent` 方法。 Default ReActAgent that wires together the configured Model, Memory and Toolkit beans using
`AgentProperties`. |
方法详情Method Detail
agentscopeMemory
public Memory agentscopeMemory()
返回 agentscopeMemory 结果。
Default Memory implementation backed by InMemoryMemory.
Memory返回记忆。Returns memory.
源码Source
io/agentscope/micronaut/AgentscopeFactory.java:126–130agentscopeToolkit
public Toolkit agentscopeToolkit()
返回 agentscopeToolkit 结果。
Default Toolkit implementation with an initially empty tool set.
Toolkit返回工具包。Returns toolkit.
源码Source
io/agentscope/micronaut/AgentscopeFactory.java:139–143agentscopeModel
public Model agentscopeModel(AgentscopeProperties properties)
设置该参数。
Default Model implementation.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
properties | AgentscopeProperties | 属性(类型 `AgentscopeProperties`)。The properties. |
Model返回模型。Returns model.
源码Source
io/agentscope/micronaut/AgentscopeFactory.java:151–156agentscopeReActAgent
public ReActAgent agentscopeReActAgent(Model model, Memory memory, Toolkit toolkit, AgentscopeProperties properties)
执行 agentscopeReActAgent 方法。
Default ReActAgent that wires together the configured Model, Memory and Toolkit beans using AgentProperties.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
model | Model | 模型实例(类型 `Model`)。The model. |
memory | Memory | 记忆(类型 `Memory`)。The memory. |
toolkit | Toolkit | 工具包(类型 `Toolkit`)。The toolkit. |
properties | AgentscopeProperties | 属性(类型 `AgentscopeProperties`)。The properties. |
ReActAgent返回ReActAgent。Returns ReAct agent.
源码Source
io/agentscope/micronaut/AgentscopeFactory.java:166–200