pangukitsappdev.tool package

Subpackages

Submodules

pangukitsappdev.tool.in_memory_tool_provider module

class pangukitsappdev.tool.in_memory_tool_provider.InMemoryToolProvider

基类:ToolProvider

工具类持久化(内存)

add(tools: List[AbstractTool]) List[str]
provide(retrieved_tools: List[RetrievedTool], query: str) List[AbstractTool]

通过id查找工具 Args:

retrieved_tools: 通过ToolRetriever召回的工具 query: 查询语句

Returns: 实例化后的工具

remove(tool_ids: List[str])

pangukitsappdev.tool.python_sandbox module

class pangukitsappdev.tool.python_sandbox.PythonSandBox

基类:ABC

abstract run(code: str) str

执行一段Python代码 :param code: Python代码 :return: Python代码的执行结果

pangukitsappdev.tool.tool module

class pangukitsappdev.tool.tool.Tool(*, name: str, description: str, args_schema: Optional[Type[BaseModel]] = None, return_direct: bool = False, verbose: bool = False, callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, callback_manager: Optional[BaseCallbackManager] = None, tags: Optional[List[str]] = None, metadata: Optional[Dict[str, Any]] = None, handle_tool_error: Optional[Union[bool, str, Callable[[ToolException], str]]] = False, handle_validation_error: Optional[Union[bool, str, Callable[[ValidationError], str]]] = False, input_desc: str, output_desc: str, principle: str, func: Optional[Callable[[...], str]] = None, return_type: Optional[Type] = None, tool_input_schema: Optional[str] = None, tool_output_schema: Optional[str] = None, pangu_function: Optional[str] = None)

基类:AbstractTool

build_pangu_function()
static build_tool_schema(desc: str, class_type: Union[Type, BaseModel])
classmethod from_function(func: Optional[Callable], name: str, description: str, principle: str, input_desc: str, output_desc: str, args_schema: Optional[Type[BaseModel]] = None, return_type: Optional[Type] = None) AbstractTool

Initialize tool from a function.

get_input_schema() str

获取入参的Json Schema定义 Returns: str, 获取入参的Json Schema定义

get_output_schema() str

获取出参的Json Schema定义 Returns: str, 获取出参的Json Schema定义

get_pang_tool_schema(desc: str, class_type: Union[Type, BaseModel]) Any
get_pangu_function() str

获取pangu Function的定义 Returns: str, pangu Function的定义

pangu_function: Optional[str]
tool_input_schema: Optional[str]
tool_output_schema: Optional[str]

pangukitsappdev.tool.tool_provider module

class pangukitsappdev.tool.tool_provider.ToolProvider

基类:ABC

工具实例化提供者,通过toolId列表给出实例化工具

abstract provide(retrieved_tools: List[RetrievedTool], query: str) List[AbstractTool]

通过id查找工具 Args:

retrieved_tools: 通过ToolRetriever召回的工具 query: 查询语句

Returns: 实例化后的工具

Module contents