pangukitsappdev.agent package

Submodules

pangukitsappdev.agent.agent_action module

class pangukitsappdev.agent.agent_action.AgentAction(*, req: Optional[str] = None, resp: Optional[str] = None, thought: Optional[str] = None, action_json: Optional[str] = None, action: Optional[str] = None, action_input: Optional[Any] = None, observation: Optional[str] = None, user_feedback: Optional[str] = None)

基类:BaseModel

Agent执行的action Attributes:

req: LLM的原始请求 resp: LLM的原始响应 thought: LLM的思考 action_json: LLM输出的原始Action字符串 action: LLM将要采取的行动,即Tool action_input: 行动的输入,即Tool的输入 observation: 采取行动后给LLM观察的结果,即Tool的执行结果 user_feedback: 用户对该步骤的反馈,可能需要更改工具调用参数

action: Optional[str]
action_input: Optional[Any]
action_json: Optional[str]
observation: Optional[str]
req: Optional[str]
resp: Optional[str]
thought: Optional[str]
user_feedback: Optional[str]

pangukitsappdev.agent.agent_session module

class pangukitsappdev.agent.agent_session.AgentSession(*, messages: List[ConversationMessage], session_id: str, current_action: Optional[AgentAction] = None, agent_session_status: str, is_by_step: Optional[bool] = None, current_message: Optional[ConversationMessage] = None)

基类:BaseModel

Agent运行Session,包含历史Action,当前Action,状态 Attributes:

messages: 本次session的用户的输入 session_id: UUID,在一个session内唯一 current_action: 当前Action agent_session_status: Agent状态 is_by_step: 是否是逐步执行 current_message: 当前的AssistantMessage

agent_session_status: str
current_action: Optional[AgentAction]
current_message: Optional[ConversationMessage]
is_by_step: Optional[bool]
messages: List[ConversationMessage]
session_id: str

pangukitsappdev.agent.react_agent module

class pangukitsappdev.agent.react_agent.ReactAgent(llm: LLMApi)

基类:AbstractAgent

DEFAULT_SYS_PROMPT = '您是一个智能助手,尽可能有帮助和准确地回答用户提出的问题'
PLACEHOLDER_ACTION = 'Action:'
PLACEHOLDER_OBSERVATION = 'Observation:'
PLACEHOLDER_THOUGHT = 'Thought:'
get_action(answer: str) AgentAction
static get_agent_action(action_str: str) AgentAction
get_tool_desc() str
get_tool_names() str
react(agent_session: AgentSession)

迭代解决问题 :param agent_session: 历史迭代几率

pangukitsappdev.agent.react_pangu_agent module

class pangukitsappdev.agent.react_pangu_agent.ReactPanguAgent(llm: LLMApi)

基类:AbstractAgent

DEFAULT_SYS_PROMPT = '你的名字叫智子,是由华为开发的智能助手'
MODULE_VERSION_PREFIX_N2 = 'N2'
TEMPLATE_VERSION_AGENT_V2 = 'agent_v2'
TEMPLATE_VERSION_UNIFY = 'unify'
VERTICAL_SEPERATOR = '|'
get_react_template() PromptTemplate
get_template_version() str
get_tool_desc()
get_tool_desc_template() PromptTemplate
is_n2_module() bool
is_plugin_v1_version(template_version) bool
normalize_prompt_template(prompt_str: str) str

根据实际模型配置的占位符替换prompt模板中的占位符 :param prompt_str: 输入prompt :return: 更换占位符后prompt

react(agent_session: AgentSession)

迭代解决问题 :param agent_session: 历史迭代几率

set_cot_desc(cot_desc: str)
set_default_unify_tag()

给模型提供默认占位符

Module contents