from typing import Sequence
from typing import Union
from typing import Any
-from typing import Callable
from loguru import logger
from agentscope.agents.operator import Operator
-from agentscope.models import load_model_by_name
+from agentscope.models import load_model_by_config_name
from agentscope.memory import TemporaryMemory
@@ -128,9 +126,8 @@ Source code for agentscope.agents.agent
def __init__(
self,
name: str,
- config: Optional[dict] = None,
sys_prompt: Optional[str] = None,
- model: Optional[Union[Callable[..., Any], str]] = None,
+ model_config_name: str = None,
use_memory: bool = True,
memory_config: Optional[dict] = None,
) -> None:
@@ -139,17 +136,12 @@ Source code for agentscope.agents.agent
Args:
name (`str`):
The name of the agent.
- config (`Optional[dict]`):
- The configuration of the agent, if provided, the agent will
- be initialized from the config rather than the other
- parameters.
sys_prompt (`Optional[str]`):
The system prompt of the agent, which can be passed by args
or hard-coded in the agent.
- model (`Optional[Union[Callable[..., Any], str]]`, defaults to
- None):
- The callable model object or the model name, which is used to
- load model from configuration.
+ model_config_name (`str`, defaults to None):
+ The name of the model config, which is used to load model from
+ configuration.
use_memory (`bool`, defaults to `True`):
Whether the agent has memory.
memory_config (`Optional[dict]`):
@@ -157,17 +149,14 @@ Source code for agentscope.agents.agent
"""
self.name = name
- self.config = config
self.memory_config = memory_config
if sys_prompt is not None:
self.sys_prompt = sys_prompt
- if model is not None:
- if isinstance(model, str):
- self.model = load_model_by_name(model)
- else:
- self.model = model
+ # TODO: support to receive a ModelWrapper instance
+ if model_config_name is not None:
+ self.model = load_model_by_config_name(model_config_name)
if use_memory:
self.memory = TemporaryMemory(memory_config)
diff --git a/_modules/agentscope/agents/dialog_agent.html b/_modules/agentscope/agents/dialog_agent.html
index 6f24a448d..20abb8f63 100644
--- a/_modules/agentscope/agents/dialog_agent.html
+++ b/_modules/agentscope/agents/dialog_agent.html
@@ -52,7 +52,6 @@
AgentScope API Reference
- Agents package
-- Configs package
- Memory package
- Models package
- Pipelines package
@@ -90,7 +89,7 @@
Source code for agentscope.agents.dialog_agent
# -*- coding: utf-8 -*-
"""A general dialog agent."""
-from typing import Any, Optional, Union, Callable
+from typing import Optional
from ..message import Msg
from .agent import AgentBase
@@ -107,9 +106,8 @@ Source code for agentscope.agents.dialog_agent
def __init__(
self,
name: str,
- config: Optional[dict] = None,
sys_prompt: Optional[str] = None,
- model: Optional[Union[Callable[..., Any], str]] = None,
+ model_config_name: str = None,
use_memory: bool = True,
memory_config: Optional[dict] = None,
prompt_type: Optional[PromptType] = PromptType.LIST,
@@ -119,17 +117,12 @@
Source code for agentscope.agents.dialog_agent
Arguments:
name (`str`):
The name of the agent.
- config (`Optional[dict]`):
- The configuration of the agent, if provided, the agent will
- be initialized from the config rather than the other
- parameters.
sys_prompt (`Optional[str]`):
The system prompt of the agent, which can be passed by args
or hard-coded in the agent.
- model (`Optional[Union[Callable[..., Any], str]]`, defaults to
- None):
- The callable model object or the model name, which is used to
- load model from configuration.
+ model_config_name (`str`, defaults to None):
+ The name of the model config, which is used to load model from
+ configuration.
use_memory (`bool`, defaults to `True`):
Whether the agent has memory.
memory_config (`Optional[dict]`):
@@ -140,12 +133,11 @@
Source code for agentscope.agents.dialog_agent
`PromptType.LIST` or `PromptType.STRING`.
"""
super().__init__(
- name,
- config,
- sys_prompt,
- model,
- use_memory,
- memory_config,
+ name=name,
+ sys_prompt=sys_prompt,
+ model_config_name=model_config_name,
+ use_memory=use_memory,
+ memory_config=memory_config,
)
# init prompt engine
@@ -179,7 +171,7 @@
Source code for agentscope.agents.dialog_agent
)
# call llm and generate response
- response = self.model(prompt)
+ response = self.model(prompt).text
msg = Msg(self.name, response)
# Print/speak the message in this agent's voice
diff --git a/_modules/agentscope/agents/dict_dialog_agent.html b/_modules/agentscope/agents/dict_dialog_agent.html
index 200c0b54a..d1db16b0e 100644
--- a/_modules/agentscope/agents/dict_dialog_agent.html
+++ b/_modules/agentscope/agents/dict_dialog_agent.html
@@ -52,7 +52,6 @@
AgentScope API Reference