From e6056859abd891463640f59cc6a71a08b66a0f15 Mon Sep 17 00:00:00 2001 From: C9luster <138663536+C9luster@users.noreply.github.com> Date: Wed, 18 Dec 2024 20:28:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0SDK=E6=96=87=E6=A1=A3?= =?UTF-8?q?=EF=BC=8C=E5=B9=B6=E6=9B=B4=E6=96=B0README=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E7=9B=AE=E5=BD=95=E7=9B=B8=E5=AF=B9=E9=93=BE=E6=8E=A5=20(#669)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 更新SDK文档内容以及更换README文件文档链接 * update * update * update --------- Co-authored-by: yinjiaqi --- README.md | 90 +-- .../Application/Agent/BasicKnowledge/agent.md | 759 ++++++++++++++++++ docs/Application/Agent/ToolCall/tool_call.md | 633 +++++++++++++++ .../Agent/ToolChoice/tool_choice.md | 176 ++++ .../use_official_components.md | 32 + .../RAG/DatasetManage/dataset_manage.md | 64 ++ .../AdvancedDevelopment/README.md | 14 + .../ErrorMessage/error_message.md | 92 +++ .../HowToContributeCode/README.md | 444 +++++++++- docs/README.md | 89 +- docs/README_en.md | 91 +-- docs/README_ja.md | 91 +-- mkdocs.yml | 17 +- 13 files changed, 2378 insertions(+), 214 deletions(-) create mode 100644 docs/Application/Agent/BasicKnowledge/agent.md create mode 100644 docs/Application/Agent/ToolCall/tool_call.md create mode 100644 docs/Application/Agent/ToolChoice/tool_choice.md create mode 100644 docs/Application/Agent/UseOfficialComponents/use_official_components.md create mode 100644 docs/Application/RAG/DatasetManage/dataset_manage.md create mode 100644 docs/DevelopGuide/AdvancedDevelopment/README.md create mode 100644 docs/DevelopGuide/ErrorMessage/error_message.md diff --git a/README.md b/README.md index 004dece09..bc2b9f88a 100644 --- a/README.md +++ b/README.md @@ -287,54 +287,48 @@ Hook: - 产业实践应用范例: - [SDK使用示例](https://github.com/baidubce/app-builder/blob/master/docs/QuickStart/ExamplesOfIndustrialPracticeApplications/README.md) - [SDK当前支持的编程语言](https://github.com/baidubce/app-builder/blob/master/docs/QuickStart/CurrentlySupportedProgrammingLanguages/README.md) - - 基础: - - 模型: - - [获取模型列表](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Model/get_model_list.md) - - [组件](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Components/Components.md) - - 监控: - - [TRACE基础功能](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Trace/basic.md) - - [TRACE拓展功能](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Trace/phoenix_method.md) - - [Debug功能](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Trace/Debug.md) - - 部署: - - [交互式前端部署](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Deployment/AgentChainlit.md) - - [公有云部署](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Deployment/cloud.md) - - [API 访问](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Deployment/flask.md) - - [AgentRuntime](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Deployment/agentruntime.md) - - [UserSession](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Deployment/usersession.md) - - 平台: - - 应用: - - [AppBuilderClient组件](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Platform/Application/appbuilder_client.md) - - [获取AppBuilder已发布的应用列表](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Platform/Application/get_app_list.md) - - 知识库: - - [知识库组件](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Platform/KnowledgeBase/knowledgebase.md) - - 自定义组件: - - [基础能力组件](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Platform/CustomComponents/components.md) - - 应用: - - Agent: - - [基础知识](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) - - [使用官方组件](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) - - [ToolCall](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) - - [ToolChoice](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) - - [使用异步和流式加速客户端调用](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) - - RAG: - - [基础知识](https://github.com/baidubce/app-builder/blob/master/docs/Application/RAG/BasicKnowledge/rag.md) - - [知识库管理](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) - - [Reference信息处理](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) - - Workflow: - - [基础知识](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) - - [从零使用Workflow组装一个RAG应用](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) - - [从零使用Workflow组装一个Agent应用](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) - - 开发者指南: - - [如何贡献代码](https://github.com/baidubce/app-builder/blob/master/docs/DevelopGuide/HowToContributeCode/README.md) - - [版本升级日志](https://github.com/baidubce/app-builder/blob/master/docs/DevelopGuide/ChangeLog/changelog.md) - - [常见问题FAQ](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) - - [日志管理](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) - - [错误信息](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) - - [环境参数](https://github.com/baidubce/app-builder/blob/master/docs/DevelopGuide/EnvironmentalParameters/env.md) - - API Reference: - - [Python API Reference](https://github.com/baidubce/app-builder/blob/master/docs/API-Reference/Python/PythonAPI.md) - - [Java API Reference](https://github.com/baidubce/app-builder/blob/master/docs/API-Reference/Java/JavaAPI.md) - - [Go API Reference](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) + - 基础: + - 模型: + - [获取模型列表](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Model/get_model_list.md) + - [组件](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Components/Components.md) + - 监控: + - [TRACE基础功能](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Trace/basic.md) + - [TRACE拓展功能](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Trace/phoenix_method.md) + - 部署: + - [交互式前端部署](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Deployment/AgentChainlit.md) + - [公有云部署](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Deployment/cloud.md) + - [API 访问](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Deployment/flask.md) + - [AgentRuntime](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Deployment/agentruntime.md) + - [UserSession](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Deployment/usersession.md) + - 平台: + - 应用: + - [AppBuilderClient组件](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Platform/Application/appbuilder_client.md) + - [获取AppBuilder已发布的应用列表](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Platform/Application/get_app_list.md) + - 知识库: + - [知识库组件](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Platform/KnowledgeBase/knowledgebase.md) + - 自定义组件: + - [基础能力组件](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Platform/CustomComponents/components.md) + - 应用: + - Agent: + - [基础知识](https://github.com/baidubce/app-builder/blob/master/docs/Application/Agent/BasicKnowledge/agent.md) + - [使用官方组件](https://github.com/baidubce/app-builder/blob/master/docs/Application/Agent/UseOfficialComponents/use_official_components.md) + - [ToolCall](https://github.com/baidubce/app-builder/blob/master/docs/Application/Agent/ToolCall/tool_call.md) + - [ToolChoice](https://github.com/baidubce/app-builder/blob/master/docs/Application/Agent/ToolChoice/tool_choice.md) + - [使用异步和流式加速客户端调用](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) + - RAG: + - [基础知识](https://github.com/baidubce/app-builder/blob/master/docs/Application/RAG/BasicKnowledge/rag.md) + - [知识库管理](https://github.com/baidubce/app-builder/blob/master/docs/Application/RAG/DatasetManage/dataset_manage.md) + - [Reference信息处理](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) + - Workflow: + - [基础知识](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) + - [从零使用Workflow组装一个RAG应用](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) + - [从零使用Workflow组装一个Agent应用](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) + - 开发者指南: + - [如何贡献代码](https://github.com/baidubce/app-builder/blob/master/docs/DevelopGuide/HowToContributeCode/README.md) + - [二次开发](https://github.com/baidubce/app-builder/blob/master/docs/DevelopGuide/AdvancedDevelopment/README.md) + - [版本升级日志](https://github.com/baidubce/app-builder/blob/master/docs/DevelopGuide/ChangeLog/changelog.md) + - [错误信息](https://github.com/baidubce/app-builder/blob/master/docs/DevelopGuide/ErrorMessage/error_message.md) + - [环境参数](https://github.com/baidubce/app-builder/blob/master/docs/DevelopGuide/EnvironmentalParameters/env.md) ## 开源社区与活动 diff --git a/docs/Application/Agent/BasicKnowledge/agent.md b/docs/Application/Agent/BasicKnowledge/agent.md new file mode 100644 index 000000000..5fd0f65bc --- /dev/null +++ b/docs/Application/Agent/BasicKnowledge/agent.md @@ -0,0 +1,759 @@ +# console端Agent操作工具(Agent) + +## 简介 + +AIAgent是能够感知环境,基于目标进行决策并执行动作的智能化应用。不同于传统人工智能应用(主要指以规则引擎、机器学习、深度学习等技术为核心)和RPA机器人,AIAgent能够基于目标和对现状能力的认知,在环境约束中,依赖特定资源和现有工具,找到行动规则并将行动拆解为必要的步骤,自主执行步骤,达成目标。 + +AIAgent具备三个核心能力:独立思考、自主执行、持续迭代。 +- 独立思考是指AlAgent能够根据给定任务目标和约束条件,进行任务规划和问题拆解,形成执行步骤(即工作流); +- 自主执行是指AlAgent能够调取各类组件和工具,按照执行步骤依次执行,实现任务目标; +- 持续选代是指AlAgent能够自动记录任务目标、工作流和执行结果,基于结果反馈,沉淀专家知识和案例。 + +AICopilot、AIAgent、大模型等名词在各类文章上经常混淆,此处简要说明下三者的区别。大模型一般是指大模型技术,AlAgent和Al Copilot是基于大模型技术的智能化应用,AlAgent和AlCopilot在功能和场景上存在差别。 + +自主性是AIAgent和AI Copilot之间最大的区别。AI Copilot是“副驾驶”,只是提供建议而非决策,AIAgent是“主驾驶”,需要真正做出决策并开展行动。 + +drawing + +创建的AgentBuilder应用,请参考[AppBuilder应用](../../../BasisModule/Platform/Application/appbuilder_client.md)进行调用。 + + +### 功能介绍 + +利用线上Agent应用进行问答 + +### 特色优势 + +与线上应用联动,利用线上Agent应用进行问答 + +### 应用场景 + +使用SDK利用线上Agent应用进行问答 + +## 基本用法 + +以下是使用SDK进行问答的示例代码,包含Python、Java、Go语言 + + +## Python基本用法 + + +### `AppBuilderClient().__init__()` + + +#### 方法参数 + +| 参数名称 | 参数类型 | 描述 | 示例值 | +| -------- | -------- | ----------------- | -------------- | +| app_id | string | 线上Agent应用的ID | "正确的应用ID" | + +#### 方法返回值 + +```AppBuilderClient```实例化对象 + + +### `AppBuilderClient().create_conversation()-> str` +#### 方法参数 +无 + +#### 方法返回值 + + | 参数名称 | 参数类型 | 描述 | 示例值 | + | --------------- | -------- | -------- | -------------------------------------- | + | conversation_id | string | 会话的ID | "80c5bbee-931d-4ed9-a4ff-63e1971bd071" | + + +### `AppBuilderClient().upload_local_file(file_path: str)-> str` +#### 方法参数 +| 参数名称 | 参数类型 | 描述 | 示例值 | +| --------- | -------- | -------- | ---------------- | +| file_path | string | 文件路径 | "正确的文件路径" | +#### 方法返回值 +| 参数名称 | 参数类型 | 描述 | 示例值 | +| -------- | -------- | ------ | ---------------------------------- | +| file_id | string | 文件ID | "80c5bbee-931d-4ed9-a4ff-63e1971bd | + + +### `AppBuilderClient().run() -> Message` + +#### 方法参数 + +| 参数名称 | 参数类型 | 是否必须 | 描述 | 示例值 | +| --------------- | ------------------ | -------- | ------------------------------------------------------------ | ----------------- | +| conversation_id | String | 是 | 会话ID | | +| query | String | 否 | query问题内容 | "今天天气怎么样?" | +| file_ids | list[String] | 否 | 对话可引用的文档ID | | +| stream | Bool | 否 | 为true时则流式返回,为false时则一次性返回所有内容, 推荐设为true,降低首token时延 | False | +| end_user_id | String | 否 | 终端用户ID,限制6 - 64字符 | | +| tools | List[Tool] | 否 | 一个列表,其中每个字典对应一个工具的配置 | | +| tools[0] | Tool | 否 | 工具配置 | | +| +type | String | 否 | 枚举:
**file_retrieval**: 知识库检索工具能够理解文档内容,支持用户针对文档内容的问答。
**code_interpreter**: 代码解释器, 代码解释器能够生成并执行代码,从而协助用户解决复杂问题,涵盖科学计算(包括普通数学计算题)、数据可视化、文件编辑处理(图片、PDF文档、视频、音频等)、文件格式转换(如WAV、MP3、text、SRT、PNG、jpg、MP4、GIF、MP3等)、数据分析&清洗&处理(文件以excel、csv格式为主)、机器学习&深度学习建模&自然语言处理等多个领域。
**function**: 支持fucntion call模式调用工具 | | +| +function | Function | 否 | Function工具描述
仅当**type为**`**function**` 时需要且必须填写 | | +| ++name | String | 否 | 函数名
只允许数字、大小写字母和中划线和下划线,最大长度为64个字符。一次运行中唯一。 | | +| ++description | String | 否 | 工具描述 | | +| ++parameters | Dict | 否 | 工具参数, json_schema格式 | | +| tool_outputs | List[ToolOutput] | 否 | 内容为本地的工具执行结果,以自然语言/json dump str描述 | | +| tool_outputs[0] | ToolOutput | 否 | 工具执行结果 | | +| +tool_call_id | String | 否 | 工具调用ID | | +| +output | String | 否 | 工具输出 | | +| tool_choice | ToolChoice | 否 | 控制大模型使用组件的方式,仅对自主规划Agent生效。 | | +| +type | String | 否 | auto/function,auto表示由LLM自动判断调什么组件;function表示由用户指定调用哪个组件。 | | +| +function | ToolChoiceFunction | 否 | 组件对象,包括组件的英文名称和入参 | | +| ++name | String | 否 | 组件的英文名称(唯一标识) | | +| ++input | String | 否 | 组件入参,当组件没有入参时填入空对象{} | | +| action | Action | 否 | 对话时要进行的特殊操作。如回复工作流agent中“信息收集节点“的消息 | | +| +action_type | String | 是 | 要执行的操作。
可选值为:
resume:回复“信息收集节点” 的消息 | | +| +parameters | Object | 是 | 执行操作时所需的参数 | | + +#### Run方法非流式返回值 + +Run非流式方法返回一个`Message`对象,该对象包含以下属性: + +| 参数名称 | 参数类型 | 描述 | 示例值 | +| -------------- | ---------------------- | -------------------- | --------------------------------------------------------------------------------------- | +| content | AppBuilderClientAnswer | 对话返回结果 | | +| +answer | String | 智能体应用返回的回答 | | +| +events | List[Event] | 事件列表 | | +| +events[0] | Event | 具体事件内容 | | +| ++code | String | 错误码 | | +| ++message | String | 错误具体消息 | | +| ++status | String | 事件状态 | 状态描述,preparing(准备运行)running(运行中)error(执行错误) done(执行完成) | +| ++event_type | String | 事件类型 | | +| ++content_type | String | 内容类型 | 可选值包括:code text, image, status,image, function_call, rag, audio、video等 | +| ++detail | Dict | 事件输出详情 | 代码解释器、文生图、工具组件、RAG等的详细输出内容 | +| ++usage | Usage | 模型调用的token用量 | Usage(prompt_tokens=1322, completion_tokens=80, total_tokens=1402, name='ERNIE-4.0-8K') | + +`AppBuilderClientAnswer`类型定义如下: +```python +class AppBuilderClientAnswer(BaseModel): + """执行步骤的具体内容 + 属性: + answer(str): query回答内容 + events( list[Event]): 事件列表 + """ + answer: str = "" + events: list[Event] = [] +``` + +`Event`类型定义如下: +```python +class Event(BaseModel): + """执行步骤的具体内容 + 属性: + code (int): 响应code码 + message (str): 错误详情 + status (str): 状态描述,preparing(准备运行)running(运行中)error(执行错误) done(执行完成) + event_type(str): 事件类型 + content_type(str): 内容类型 + detail(dict): 事件详情 + usage(Usage): 大模型调用的token用量 + """ + code: int = 0 + message: str = "" + status: str = "" + event_type: str = "" + content_type: str = "" + detail: dict = {} + usage: Optional[Usage] = None +``` + + +#### Run方法流式返回值 + +| 参数名称 | 参数类型 | 描述 | 示例值 | +| -------- | ---------------- | ---------------------------------------------- | ------ | +| content | Python Generator | 可迭代,每次迭代返回AppBuilderClientAnswer类型 | 无 | + +#### 非流式调用示例 + +```python +import appbuilder +import os + +# 请前往千帆AppBuilder官网创建密钥,流程详见:https://cloud.baidu.com/doc/AppBuilder/s/Olq6grrt6#1%E3%80%81%E5%88%9B%E5%BB%BA%E5%AF%86%E9%92%A5 +# 设置环境变量 +os.environ["APPBUILDER_TOKEN"] = '...' +app_id = '...' # 已发布AppBuilder应用ID,可在console端查看 +# 初始化智能体 +builder = appbuilder.AppBuilderClient(app_id) +# 创建会话 +conversation_id = builder.create_conversation() +# 运行对话 +out = builder.run(conversation_id, "北京今天天气怎么样") +# 打印会话结果 +print(out.content.answer) +``` + +#### 流式调用示例 + +```python + +import appbuilder +from appbuilder.core.console.appbuilder_client import data_class +import os + +# 请前往千帆AppBuilder官网创建密钥,流程详见:https://cloud.baidu.com/doc/AppBuilder/s/Olq6grrt6#1%E3%80%81%E5%88%9B%E5%BB%BA%E5%AF%86%E9%92%A5 +# 设置环境变量 +os.environ["APPBUILDER_TOKEN"] = '...' +app_id = '...' # 已发布AppBuilder应用的ID +# 初始化智能体 +client = appbuilder.AppBuilderClient(app_id) +# 创建会话 +conversation_id = client.create_conversation() + +# 上传一个介绍某汽车产品的说明文档 +file_id = client.upload_local_file(conversation_id, "/path/to/pdf/file") +# 引用上传的文档,开始对话 +# 注意file_ids不是必填项,如果不需要引用特定文档,file_ids留空即可 +message = client.run(conversation_id, "汽车性能参数怎么样", file_ids=[file_id, ], stream=True) + +answer = "" + +# 每次迭代返回AppBuilderClientAnswer结构,内可能包括多个事件内容 +for content in message.content: + # stream=True时,将answer拼接起来才是完整的的对话结果 + answer += content.answer + for event in content.events: + content_type = event.content_type + detail = event.detail + # 根据content类型对事件详情进行解析 + if content_type == "code": + code_detail = data_class.CodeDetail(**detail) + print(code_detail.code) + elif content_type == "text": + text_detail = data_class.TextDetail(**detail) + print(text_detail.text) + elif content_type == "image": + image_detail = data_class.ImageDetail(**detail) + print(image_detail.url) + elif content_type == "rag": + rag_detail = data_class.RAGDetail(**detail) + if len(rag_detail.references) > 0: + print(rag_detail.references) + elif content_type == "function_call": + function_call_detail = data_class.FunctionCallDetail(**detail) + print(function_call_detail.video) + elif content_type == "audio": + audio_detail = data_class.AudioDetail(**detail) + print(audio_detail) + elif content_type == "video": + video_detail = data_class.VideoDetail(**detail) + print(video_detail) + elif content_type == "status": + status_detail = data_class.StatusDetail(**detail) + print(status_detail) + else: + default_detail = data_class.DefaultDetail(**detail) + print(default_detail) + +# 打印完整的answer结果 +print(answer) +``` + +## Java基本用法 + +### ```new AppBuilderClient(appId)``` + +#### 方法参数 + +| 参数名称 | 参数类型 | 描述 | 示例值 | +| -------- | -------- | ----------------- | -------------- | +| appID | String | 线上Agent应用的ID | "正确的应用ID" | + + +#### 方法返回值 + +```AppBuilderClient```实例化对象 + +### ```AppBuilderClient().createConversation()``` + +#### 方法参数 +无 + +#### 方法返回值 + +| 参数名称 | 参数类型 | 描述 | 示例值 | +| -------------- | -------- | ------------ | -------------- | +| conversationId | String | 创建的会话ID | "正确的会话ID" | + +### ```AppBuilderClient().run()``` + +#### Run方法入参`AppBuilderCientRunRequest` + +| 参数名称 | 参数类型 | 是否必须 | 描述 | 示例值 | +| --------------- | ------------------ | -------- | ------------------------------------------------------------ | -------------------- | +| query | String | 是 | query内容 | "汽车性能参数怎么样" | +| conversationId | String | 是 | 对话id,可以通过createConversation()获取 | | +| stream | boolean | 是 | 为true时则流式返回,为false时则一次性返回所有内容, 推荐设为true,降低首token时延 | | +| tools | List[Tool] | 否 | 一个列表,其中每个字典对应一个工具的配置 | | +| tools[0] | Tool | 否 | 工具配置 | | +| +type | String | 否 | 枚举:
**file_retrieval**: 知识库检索工具能够理解文档内容,支持用户针对文档内容的问答。
**code_interpreter**: 代码解释器, 代码解释器能够生成并执行代码,从而协助用户解决复杂问题,涵盖科学计算(包括普通数学计算题)、数据可视化、文件编辑处理(图片、PDF文档、视频、音频等)、文件格式转换(如WAV、MP3、text、SRT、PNG、jpg、MP4、GIF、MP3等)、数据分析&清洗&处理(文件以excel、csv格式为主)、机器学习&深度学习建模&自然语言处理等多个领域。
**function**: 支持fucntion call模式调用工具 | | +| +function | Function | 否 | Function工具描述
仅当**type为**`**function**` 时需要且必须填写 | | +| ++name | String | 否 | 函数名
只允许数字、大小写字母和中划线和下划线,最大长度为64个字符。一次运行中唯一。 | | +| ++description | String | 否 | 工具描述 | | +| ++parameters | Dict | 否 | 工具参数, json_schema格式 | | +| tool_outputs | List[ToolOutput] | 否 | 内容为本地的工具执行结果,以自然语言/json dump str描述 | | +| tool_outputs[0] | ToolOutput | 否 | 工具执行结果 | | +| +tool_call_id | String | 否 | 工具调用ID | | +| +output | String | 否 | 工具输出 | | +| tool_choice | ToolChoice | 否 | 控制大模型使用组件的方式,仅对自主规划Agent生效。 | | +| +type | String | 否 | auto/function,auto表示由LLM自动判断调什么组件;function表示由用户指定调用哪个组件。 | | +| +function | ToolChoiceFunction | 否 | 组件对象,包括组件的英文名称和入参 | | +| ++name | String | 否 | 组件的英文名称(唯一标识) | | +| ++input | String | 否 | 组件入参,当组件没有入参时填入空对象{} | | +| action | Action | 否 | 对话时要进行的特殊操作。如回复工作流agent中“信息收集节点“的消息 | | +| +action_type | String | 是 | 要执行的操作。
可选值为:
resume:回复“信息收集节点” 的消息 | | +| +parameters | Object | 是 | 执行操作时所需的参数 | | + +#### Run方法出参 +| 参数名称 | 参数类型 | 描述 | 示例值 | +| ------------------------ | ------------------------ | -------------------------------------------------------------------------------- | ------ | +| AppBuilderClientIterator | AppBuilderClientIterator | 回答迭代器,流式/非流式均统一返回该类型,每次迭代返回AppBuilderClientIterator类型 | | + +#### 迭代AppBuilderClientIterator +| 参数名称 | 参数类型 | 描述 | 示例值 | +| ------------- | ------------------- | -------------------- | --------------------------------------------------------------------------------------- | +| +answer | String | 智能体应用返回的回答 | | +| +events | Event[] | 事件列表 | | +| +events[0] | Event | 具体事件内容 | | +| ++code | string | 错误码 | | +| ++message | string | 错误具体消息 | | +| ++status | string | 事件状态 | 状态描述,preparing(准备运行)running(运行中)error(执行错误) done(执行完成) | +| ++eventType | string | 事件类型 | | +| ++contentType | string | 内容类型 | 可选值包括:code text, image, status,image, function_call, rag, audio、video等 | +| ++detail | Map | 事件输出详情 | 代码解释器、文生图、工具组件、RAG等的详细输出内容 | +| ++usage | Usage | 模型调用的token用量 | Usage(prompt_tokens=1322, completion_tokens=80, total_tokens=1402, name='ERNIE-4.0-8K') | + + +#### 示例代码 + +```Java +package org.example; + +import java.io.IOException; +import java.util.*; + +import com.google.gson.annotations.SerializedName; + +import com.baidubce.appbuilder.base.exception.AppBuilderServerException; +import com.baidubce.appbuilder.console.appbuilderclient.AppBuilderClient; +import com.baidubce.appbuilder.model.appbuilderclient.AppBuilderClientIterator; +import com.baidubce.appbuilder.model.appbuilderclient.AppBuilderClientResult; +import com.baidubce.appbuilder.model.appbuilderclient.Event; +import com.baidubce.appbuilder.base.utils.json.JsonUtils; + +class AppBuilderClientDemo { + + public static void main(String[] args) throws IOException, AppBuilderServerException { + System.setProperty("APPBUILDER_TOKEN", "请设置正确的应用密钥"); + String appId = "请设置正确的应用ID"; + AppBuilderClient builder = new AppBuilderClient(appId); + String conversationId = builder.createConversation(); + // 填写上传文件路径 + String fileId = builder.uploadLocalFile(conversationId, "/Users/zhangxiaoyu15/PycharmProjects/app-builder/test_app_builder_client/test.pdf"); + // 输入query + // 注意file_ids不是必填项,如果不需要引用特定文档,则将new String[]{fileId}更换为new String[]{}即可 + AppBuilderClientIterator itor = builder.run("中国四大传统节日是哪四个", conversationId, new String[]{fileId}, false); + StringBuilder answer = new StringBuilder(); + // itor.hasNext()返回false时,表示流式调用结束 + while(itor.hasNext()) + { + AppBuilderClientResult response = itor.next(); + answer.append(response.getAnswer()); + for (Event event : response.getEvents()) { + switch (event.getContentType()) { + case "rag": + List references = (List)event.getDetail().get("references"); + for (Object reference : references) { + ReferenceDetail ragDetail = JsonUtils.deserialize(JsonUtils.serialize(reference), ReferenceDetail.class); + System.out.println("-----------------------------------"); + System.out.println("参考文献ID:"+ragDetail.getId()); + System.out.println("参考文献内容:"+ragDetail.getContent()); + System.out.println("来源:"+ragDetail.getFrom()); + System.out.println("BaiduSearch链接:"+ragDetail.getUrl()); + System.out.println("类型:"+ragDetail.getType()); + System.out.println("文档片段ID:"+ragDetail.getSegmentId()); + System.out.println("文档ID:"+ragDetail.getDocumentId()); + System.out.println("文档名称:"+ragDetail.getDocumentName()); + System.out.println("文档所属数据集ID:"+ragDetail.getDatasetId()); + System.out.println("-----------------------------------"); + } + break; + default: + // System.out.println(event); + } + } + } + System.out.print("输出:"); + System.out.println(answer); + } +} + +class ReferenceDetail { + private int id; + private String content; + private String from; + private String url; + private String type; + @SerializedName("segment_id") + private String segmentId; + @SerializedName("document_id") + private String documentId; + @SerializedName("document_name") + private String documentName; + @SerializedName("dataset_id") + private String datasetId; + @SerializedName("knowledgebase_id") + private String knowledgebaseId; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getFrom() { + return from; + } + + public void setFrom(String from) { + this.from = from; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getSegmentId() { + return segmentId; + } + + public void setSegmentId(String segmentId) { + this.segmentId = segmentId; + } + + public String getDocumentId() { + return documentId; + } + + public void setDocumentId(String documentId) { + this.documentId = documentId; + } + + public String getDocumentName() { + return documentName; + } + + public void setDocumentName(String documentName) { + this.documentName = documentName; + } + + public String getDatasetId() { + return datasetId; + } + + public void setDatasetId(String datasetId) { + this.datasetId = datasetId; + } + + public String getKnowledgebaseId() { + return knowledgebaseId; + } + + public void setKnowledgebaseId(String knowledgebaseId) { + this.knowledgebaseId = knowledgebaseId; + } + + @Override + public String toString() { + return "RAGReference{" + + "id=" + id + + ", content='" + content + '\'' + + ", from='" + from + '\'' + + ", url='" + url + '\'' + + ", type='" + type + '\'' + + ", segmentId='" + segmentId + '\'' + + ", documentId='" + documentId + '\'' + + ", documentName='" + documentName + '\'' + + ", datasetId='" + datasetId + '\'' + + ", knowledgebaseId='" + knowledgebaseId + '\'' + + '}'; + } +} +``` + +## Go基本用法 + +### ```NewAppBuilderClient()``` + +#### 方法参数 + +| 参数名称 | 参数类型 | 描述 | 示例值 | +| -------- | --------- | ----------------- | -------------- | +| app_id | string | 线上Agent应用的ID | "正确的应用ID" | +| config | SDKConfig | SDK配置信息 | | + +### ```CreateConversation()``` +#### 方法入参 +无 +#### 方法出参 +| 参数名称 | 参数类型 | 描述 | 示例值 | +| -------------- | -------- | -------------------------------------------- | ------ | +| ConversationId | str | 创建成功的对话对象,后续操作都基于该对象进行 | | + + +### `Run()` +#### Run方法入参`AppBuilderClientRunRequest` + +| 参数名称 | 参数类型 | 是否必须 | 描述 | 示例值 | +| -------------- | ---------- | -------- | ------------------------------------------------------------ | -------------------- | +| ConversationID | string | 是 | 对话ID,可以通过CreateConversation()获取 | | +| Query | string | 是 | query内容 | "汽车性能参数怎么样" | +| Stream | bool | 是 | 为true时则流式返回,为false时则一次性返回所有内容, 推荐设为true,降低首token时延 | | +| AppID | string | 是 | 应用ID,线上Agent应用的ID | | +| Tools | []Tool | 否 | 一个列表,其中每个字典对应一个工具的配置 | | +| ToolOuptus | []ToolOupt | 否 | 内容为本地的工具执行结果,以自然语言/json dump str描述 | | +| ToolChoice | ToolChoice | 否 | 控制大模型使用组件的方式,仅对自主规划Agent生效。 | | + +`Tool`、`ToolOutput`、`ToolChoice`定义如下: + +```go +type Tool struct { + Type string `json:"type"` + Function Function `json:"function"` +} + +type Function struct { + Name string `json:"name"` + Description string `json:"description"` + Parameters map[string]interface{} `json:"parameters"` +} + +type ToolOutput struct { + ToolCallID string `json:"tool_call_id" description:"工具调用ID"` + Output string `json:"output" description:"工具输出"` +} + +type ToolChoice struct { + Type string `json:"type"` + Function ToolChoiceFunction `json:"function"` +} + +type ToolChoiceFunction struct { + Name string `json:"name"` + Input map[string]interface{} `json:"input"` +} +``` + +#### Run方法出参 + +| 参数名称 | 参数类型 | 描述 | 示例值 | +| ------------------------ | ------------------------ | --------------------------------------- | ------ | +| AppBuilderClientIterator | AppBuilderClientIterator | 回答迭代器,流式/非流式均统一返回该类型 | | +| error | error | 存在错误时error不为nil,反之 | | + +#### 迭代AgentBuilderIterator + +| 参数名称 | 参数类型 | 描述 | 示例值 | +| ------------- | ----------- | -------------------- | --------------------------------------------------------------------------------------- | +| +Answer | string | 智能体应用返回的回答 | | +| +Events | []Event | 事件列表 | | +| +Events[0] | Event | 具体事件内容 | | +| ++Code | string | 错误码 | | +| ++Message | string | 错误具体消息 | | +| ++Status | string | 事件状态 | 状态描述,preparing(准备运行)running(运行中)error(执行错误) done(执行完成) | +| ++EventType | string | 事件类型 | | +| ++ContentType | string | 内容类型 | 可选值包括:code text, image, status,image, function_call, rag, audio、video等 | +| ++Detail | interface{} | 事件输出详情 | 代码解释器、文生图、工具组件、RAG等的详细输出内容 | +| ++Usage | Usage | 模型调用的token用量 | Usage(prompt_tokens=1322, completion_tokens=80, total_tokens=1402, name='ERNIE-4.0-8K') | + + +#### Run示例代码 + + +```Go +// 安装说明: +// go get github.com/baidubce/app-builder/go/appbuilder + +package main + +import ( + "errors" + "fmt" + "io" + "os" + + "github.com/baidubce/app-builder/go/appbuilder" +) + +func main() { + // 设置环境中的TOKEN,以下TOKEN请替换为您的个人TOKEN,个人TOKEN可通过该页面【获取鉴权参数】或控制台页【密钥管理】处获取 + os.Setenv("APPBUILDER_TOKEN", "bce-v3/ALTAK-xxx90ea58") + // 从AppBuilder控制台【个人空间】-【应用】网页获取已发布应用的ID + appID := "4678492a-xxx-654538d3503c" + config, err := appbuilder.NewSDKConfig("", "") + if err != nil { + fmt.Println("new config failed: ", err) + return + } + + builder, err := appbuilder.NewAppBuilderClient(appID, config) + if err != nil { + fmt.Println("new agent builder failed: ", err) + return + } + conversationID, err := builder.CreateConversation() + if err != nil { + fmt.Println("create conversation failed: ", err) + return + } + + i, err := builder.Run(conversationID, "你好,你能做什么?", nil, false) + if err != nil { + fmt.Println("run failed: ", err) + return + } + + var answer *appbuilder.AppBuilderClientAnswer + for answer, err = i.Next(); err == nil; answer, err = i.Next() { + fmt.Println(answer.Answer) + } +} +``` + +#### ToolCall功能示例代码 + +```go +package main + +import ( + "errors" + "fmt" + "io" + "os" + + "github.com/baidubce/app-builder/go/appbuilder" +) + +func main() { + // 设置APPBUILDER_TOKEN、GATEWAY_URL_V2环境变量 + os.Setenv("APPBUILDER_TOKEN", "请设置正确的应用密钥") + // 默认可不填,默认值是 https://qianfan.baidubce.com + os.Setenv("GATEWAY_URL_V2", "") + config, err := appbuilder.NewSDKConfig("", "") + if err != nil { + fmt.Println("new config failed: ", err) + return + } + // 初始化实例 + appID := "请填写正确的应用ID" + builder, err := appbuilder.NewAppBuilderClient(appID, config) + if err != nil { + fmt.Println("new agent builder failed: ", err) + return + } + // 创建对话ID + conversationID, err := builder.CreateConversation() + if err != nil { + fmt.Println("create conversation failed: ", err) + return + } + + jsonStr := ` + { + "type": "function", + "function": { + "name": "get_cur_whether", + "description": "这是一个获得指定地点天气的工具", + "parameters": { + "type": "object", + "properties": { + "location": { + "type": "string", + "description": "省,市名,例如:河北省" + }, + "unit": { + "type": "string", + "enum": ["摄氏度", "华氏度"] + } + }, + "required": ["location"] + } + } + }` + + var tool Tool + err = json.Unmarshal([]byte(jsonStr), &tool) + if err != nil { + fmt.Println("unmarshal tool error:", err) + return + } + + i, err := client.Run(appbuilder.AppBuilderClientRunRequest{ + AppID: appID, + Query: "今天北京的天气怎么样?", + ConversationID: conversationID, + Stream: true, + Tools: []appbuilder.Tool{tool}, + }) + if err != nil { + fmt.Println("run failed:", err) + } + totalAnswer := "" + toolCallID := "" + for answer, err := i.Next(); err == nil; answer, err = i.Next() { + totalAnswer += answer.Answer + lastEvent := answer.Events[len(answer.Events)-1] + toolCallID = lastEvent.ToolCalls[len(lastEvent.ToolCalls)-1].ID + } + + i2, err := client.Run(appbuilder.AppBuilderClientRunRequest{ + ConversationID: conversationID, + AppID: appID, + ToolOutputs: []appbuilder.ToolOutput{ + { + ToolCallID: toolCallID, + Output: "北京今天35度", + }, + }, + Stream: true, + }) + + if err != nil { + fmt.Println("run failed: ", err) + } + + for answer, err := i2.Next(); err == nil; answer, err = i2.Next() { + totalAnswer = totalAnswer + answer.Answer + for _, ev := range answer.Events { + evJSON, _ := json.Marshal(ev) + fmt.Println(string(evJSON)) + } + } + + fmt.Println("----------------answer-------------------") + fmt.Println(totalAnswer) +} +``` diff --git a/docs/Application/Agent/ToolCall/tool_call.md b/docs/Application/Agent/ToolCall/tool_call.md new file mode 100644 index 000000000..a4318c072 --- /dev/null +++ b/docs/Application/Agent/ToolCall/tool_call.md @@ -0,0 +1,633 @@ +# Agent 本地ToolCall(Functioncall) + +## 概述 + +### 什么是ToolCall + +解释该问题,需要了解以下的知识点:`Agent工具` -> `FunctionCall` - `ToolCall` + +AIAgent 有四大核心组件:记忆、规划、工具和执行。其中工具部分,与我们的开发关系最密切,在各类Agent开发平台/工具中,常被称为“组件”、"插件"、"能力"等. + +关于Agent的工具的定义与分类,如下图~ + +drawing + +Agent使用工具的流程,一般称为`FunctionCall`,最早由OpenAI提出,并在[Assistant API](https://platform.openai.com/docs/assistants/overview)中广泛应用。 + + +ToolCall,则是AppBuilder平台提出的一种进阶的FunctionCall,本质与OpenAI的FunctionCall一致,但具有以下两个特点: + +- **端云组件联动**: Agent 调用工具时,可以同时调用云端和本地组件。 + +- **组件类型泛化**: AppBuilder在未来会支持多种类型组件,已经超出了Function的含义,例如数据库、记忆库、工作流等等 + +### 什么是端云组件联动,要解决什么问题 + +我们首先从工具的执行位置出发展开~ 在使用如AppBuilder / Coze 等平台开发Agent时,我们可以使用很多平台组件广场中,官方提供的组件,这里组件开箱即用,非常方便。 + +drawing + +但是存在一个问题,基于平台云端组件开发的应用,无法调用内网/局域网/私域的知识与能力,也无法与本地的工具进行联动,限制了Agent的灵活性。 + +我们在解决实际业务问题时,常遇到需要访问内网链接API或本地/硬件功能的FunctionCall需求,AppBuilder ToolCall可以解决这个问题: + +* 1、用户可注册一个本地运行的组件到已发布的应用 +* 2、由AppBuilder-Agent的云端思考模型进行规划和参数生成 +* 3、用户基于生成的参数调用本地组件,并再上传运行结果 +* 4、以此实现将本地组件能力嵌入到应用整体流程 + + +drawing + +## ToolCall(FunctionCall)基础知识介绍 + +### Agent是如何调用Tool的 + +我们可以将Agent的黑箱拆解为以下几个部分: +1. Agent的背景信息 +2. Agent的输入信息 +3. Agent的思考过程 +4. Agent触发组件调用 +5. Agent基于组件输出反思总结 + +#### Agent的背景信息包含以下几个部分 +- 角色定义描述(Prompt):定义Agent的角色 +- 能力描述(Prompt):定义Agent可以干什么 +- 工具描述(JsonSchema/Str):将工具的输入和输出,按照规范,定义为一段字符串,作为最终大模型Prompt的一部分 + +#### Agent的输入信息包含以下几个部分 +- 用户输入(Query/Prompt):用户输入的文本 +- 对话相关的文件(File/Url):与本地对话相关的文件路径 + +#### Agent的思考过程 +AppBuilder-Agent会将背景信息与输入信息,拼接为最终的Prompt,然后调用大模型推理。 + +Prompt的一个简单且直观的例子是: + +你是`{角色定义描述}`,你可以做以下事情:`{能力描述}`,你可以使用这些工具:`{工具描述-description}`,工具依赖的输入是:`{工具描述-paramters-properties-name}`,这些输入的格式分别是`{工具描述-paramters-properties-type}`。现在用户的问题是`{用户输入}`,与该问题相关的文件是`{对话相关的文件}`,请你解决用户的这个问题。 + +#### Agent触发组件调用 + +如果用户的query和组件能够解决的问题匹配,那么大模型就会尝试根据prompt里给出的工具的描述,从query中提炼出该次调用工具所需的参数,生成一个ToolCall命令,交给执行组件的模块去执行。 + +例如,我们给出的组件能力是"查找公司内指定人员的信息",函数的参数名为"name"。当用户输入"查找张三的信息",大模型会从query中提炼出参数"name=张三"这个信息。 + +drawing + +#### Agent基于组件输出反思总结 + +组件运行模块执行组件后,会给出字符串形式的结果给到Agent,Agent会再次将结果拼接为Prompt,然后调用大模型推理。判断用户的需求是否已经解决。如果解决了,则经过一个对话模块,总结用户的需求,并生成一个对话记录。如果未解决,则继续调用大模型推理,尝试调用更多的工具,直到用户的需求被解决。 + +### 开发者如何命令Agent调用本地Tool + +我们以AppBuilder-SDK中的AppBuilder-Client的基础代码为例,介绍开发者应该如何使用ToolCall功能 + + +```python +import appbuilder + +# 实例化AppBuilderClient +app_client = appbuilder.AppBuilderClient(app_id) +conversation_id = app_client.create_conversation() + +# 第一次对话,输入原始的query 和 工具描述 +message_1 = app_client.run( + conversation_id=conversation_id, + query="请问张三同学的生日是哪天?", + tools=tools +) +tool_call = message_1.content.events[-1].tool_calls[-1] +tool_call_id = tool_call.id + +# 第二次对话,在本地执行组件后,上传组件的运行结果 +tool_call_result = "张三同学的生日是2008年8月8日" +message_2 = app_client.run( + conversation_id=conversation_id, + tool_outputs=[{ + "tool_call_id": tool_call_id, + "output": tool_call_result + }] +) +print(message_2.content) +``` + +其中`AppBuilderClient`的`run`方法是核心,我们展开该函数的定义和参数介绍: + +`AppBuilderClient().run() -> Message` + +```python +def run(self, conversation_id: str, + query: str = "", + file_ids: list = [], + stream: bool = False, + tools: list[data_class.Tool] = None, + tool_outputs: list[data_class.ToolOutput] = None, + **kwargs + ) -> Message: + r""" + 参数: + query (str: 必须): query内容 + conversation_id (str, 必须): 唯一会话ID,如需开始新的会话,请使用self.create_conversation创建新的会话 + file_ids(list[str], 可选): + stream (bool, 可选): 为True时,流式返回,需要将message.content.answer拼接起来才是完整的回答;为False时,对应非流式返回 + tools(list[data_class.Tools], 可选): 一个Tools组成的列表,其中每个Tools对应一个工具的配置, 默认为None + tool_outputs(list[data_class.ToolOutput], 可选): 工具输出列表,格式为list[ToolOutput], ToolOutputd内容为本地的工具执行结果,以自然语言/json dump str描述,默认为None + 返回: message (obj: `Message`): 对话结果. + """ + pass +``` + + +| 参数名称 | 参数类型 | 是否必须 | 描述 | 示例值 | +| --------------- | ---------------- | -------- | ------------------------------------------------------------ | ----------------- | +| conversation_id | String | 是 | 会话ID | | +| query | String | 否 | query问题内容 | "今天天气怎么样?" | +| file_ids | list[String] | 否 | 对话可引用的文档ID | | +| stream | Bool | 否 | 为true时则流式返回,为false时则一次性返回所有内容, 推荐设为true,降低首token时延 | False | +| tools | List[Tool] | 否 | 一个列表,其中每个字典对应一个工具的配置 | | +| tools[0] | Tool | 否 | 工具配置 | | +| +type | String | 否 | 枚举:
**file_retrieval**: 知识库检索工具能够理解文档内容,支持用户针对文档内容的问答。
**code_interpreter**: 代码解释器, 代码解释器能够生成并执行代码,从而协助用户解决复杂问题,涵盖科学计算(包括普通数学计算题)、数据可视化、文件编辑处理(图片、PDF文档、视频、音频等)、文件格式转换(如WAV、MP3、text、SRT、PNG、jpg、MP4、GIF、MP3等)、数据分析&清洗&处理(文件以excel、csv格式为主)、机器学习&深度学习建模&自然语言处理等多个领域。
**function**: 支持fucntion call模式调用工具 | | +| +function | Function | 否 | Function工具描述
仅当**type为**`**function**` 时需要且必须填写 | | +| ++name | String | 否 | 函数名
只允许数字、大小写字母和中划线和下划线,最大长度为64个字符。一次运行中唯一。 | | +| ++description | String | 否 | 工具描述 | | +| ++parameters | Dict | 否 | 工具参数, json_schema格式 | | +| tool_outputs | List[ToolOutput] | 否 | 内容为本地的工具执行结果,以自然语言/json dump str描述 | | +| tool_outputs[0] | ToolOutput | 否 | 工具执行结果 | | +| +tool_call_id | String | 否 | 工具调用ID | | +| +output | String | 否 | 工具输出 | | + +`Tool`与`Function`是本地组件的描述,类型为object,其定义如下: + +```python +class Tool(BaseModel): + type: str = "function" + function: Function = Field(..., description="工具信息") + +class Function(BaseModel): + name: str = Field(..., description="工具名称") + description: str = Field(..., description="工具描述") + parameters: dict = Field(..., description="工具参数, json_schema格式") +``` + +`ToolOutput`是本地组件的执行结果,需要再次上传到Agent,参与思考,类型为object,其定义如下: +```python +class ToolOutput(BaseModel): + tool_call_id: str = Field(..., description="工具调用ID") + output: str = Field(..., description="工具输出") + +``` + + +#### Run方法带ToolCall调用示例--Python + +以下示例展示了三种方式来使用 ToolCall 进行调用,并演示了如何在 AppBuilder 环境中配置和执行会话调用。 + +**方式1:使用 JSONSchema 格式直接描述 tools 调用** + +```python +import appbuilder +from appbuilder.core.console.appbuilder_client import data_class +import os + +# 请前往千帆AppBuilder官网创建密钥,流程详见:https://cloud.baidu.com/doc/AppBuilder/s/Olq6grrt6#1%E3%80%81%E5%88%9B%E5%BB%BA%E5%AF%86%E9%92%A5 +# 设置环境变量 +os.environ["APPBUILDER_TOKEN"] = "..." +app_id = "..." # 已发布AppBuilder应用的ID +# 初始化智能体 +client = appbuilder.AppBuilderClient(app_id) +# 创建会话 +conversation_id = client.create_conversation() +tools = [ + { + "type": "function", + "function": { + "name": "get_current_weather", + "description": "仅支持中国城市的天气查询,参数location为中国城市名称,其他国家城市不支持天气查询", + "parameters": { + "type": "object", + "properties": { + "location": { + "type": "string", + "description": "城市名,举例:北京", + }, + "unit": {"type": "string", "enum": ["celsius", "fahrenheit"]}, + }, + "required": ["location", "unit"], + }, + }, + } +] + +msg = client.run( + conversation_id=conversation_id, query="今天北京天气怎么样?", tools=tools +) +print(msg.model_dump_json(indent=4)) + +event = msg.content.events[-1] + +msg_2 = client.run( + conversation_id=conversation_id, + tool_outputs=[{"tool_call_id": event.tool_calls[-1].id, "output": "北京今天35度"}], +) +print(msg_2.model_dump_json(indent=4)) +``` + +**方式2: 使用 function_to_model 将函数对象传递为 ToolCall 的调用** + +```python +import appbuilder +import os + +# 请前往千帆AppBuilder官网创建密钥,流程详见:https://cloud.baidu.com/doc/AppBuilder/s/Olq6grrt6#1%E3%80%81%E5%88%9B%E5%BB%BA%E5%AF%86%E9%92%A5 +# 设置环境变量 +os.environ["APPBUILDER_TOKEN"] = "..." +app_id = "..." # 已发布AppBuilder应用的ID +# 初始化智能体 +client = appbuilder.AppBuilderClient(app_id) +# 创建会话 +conversation_id = client.create_conversation() +#注意:要使用此方法要为函数写好注释。最好按照谷歌规范来写 + +#定义示例函数 +def get_current_weather(location: str, unit: str) -> str: + """获取指定中国城市的当前天气信息。 + + 仅支持中国城市的天气查询。参数 `location` 为中国城市名称,其他国家城市不支持天气查询。 + + Args: + location (str): 城市名,例如:"北京"。 + unit (int): 温度单位,支持 "celsius" 或 "fahrenheit"。 + + Returns: + str: 天气情况描述 + """ + return "北京今天25度" + +#定义函数列表 +functions = [get_current_weather] +function_map = {f.__name__: f for f in functions} +#调用大模型 +msg = client.run( + conversation_id=conversation_id, + query="今天北京的天气怎么样?", + tools = [appbuilder.Manifest.from_function(f) for f in functions] + ) +print(msg.model_dump_json(indent=4)) +# 获取最后的事件和工具调用信息 +event = msg.content.events[-1] +tool_call = event.tool_calls[-1] + +# 获取函数名称和参数 +name = tool_call.function.name +args = tool_call.function.arguments + +# 将函数名称映射到具体的函数并执行 +raw_result = function_map[name](**args) + +# 传递工具的输出 +msg_2 = client.run( + conversation_id=conversation_id, + tool_outputs=[{ + "tool_call_id": tool_call.id, + "output": str(raw_result) + }], +) +print(msg_2.model_dump_json(indent=4)) +``` + +**方式3: 使用装饰器进行描述** + +```python +import os +import json +import appbuilder +from appbuilder import manifest, manifest_parameter + +# 请前往千帆AppBuilder官网创建密钥,流程详见:https://cloud.baidu.com/doc/AppBuilder/s/Olq6grrt6#1%E3%80%81%E5%88%9B%E5%BB%BA%E5%AF%86%E9%92%A5 +# 设置环境变量 +os.environ["APPBUILDER_TOKEN"] = "" +app_id = "" # 已发布AppBuilder应用的ID +# 初始化智能体 +client = appbuilder.AppBuilderClient(app_id) +# 创建会话 +conversation_id = client.create_conversation() + +#使用manifest装饰描述函数,manifest_parameter装饰器描述参数,manifest_return装饰器描述函数返回值。 +@manifest(description="获取指定中国城市的当前天气信息。仅支持中国城市的天气查询。参数 `location` 为中国城市名称,其他国家城市不支持天气查询。") +@manifest_parameter(name="location", description="城市名,例如:北京。") +@manifest_parameter(name="unit", description="温度单位,支持 'celsius' 或 'fahrenheit'") +#定义示例函数 +def get_current_weather(location: str, unit: str) -> str: + return "北京今天25度" + +print(json.dumps(appbuilder.Manifest.from_function(get_current_weather), indent=4, ensure_ascii=False)) +#定义函数列表 +functions = [get_current_weather] +function_map = {f.__name__: f for f in functions} +#调用大模型 +msg = client.run( + conversation_id=conversation_id, + query="今天北京的天气怎么样?", + tools = [appbuilder.Manifest.from_function(f) for f in functions] + ) +print(msg.model_dump_json(indent=4)) +# 获取最后的事件和工具调用信息 +event = msg.content.events[-1] +tool_call = event.tool_calls[-1] + +# 获取函数名称和参数 +name = tool_call.function.name +args = tool_call.function.arguments + +# 将函数名称映射到具体的函数并执行 +raw_result = function_map[name](**args) + +# 传递工具的输出 +msg_2 = client.run( + conversation_id=conversation_id, + tool_outputs=[{ + "tool_call_id": tool_call.id, + "output": str(raw_result) + }], +) +print(msg_2.model_dump_json(indent=4)) +``` + +#### Run方法带ToolCall调用示例--Java + +**创建tool的json文件** + +```json +{ + "type": "function", + "function": { + "name": "get_cur_whether", + "description": "这是一个获得指定地点天气的工具", + "parameters": { + "type": "object", + "properties": { + "location": { + "type": "string", + "description": "省,市名,例如:河北省" + }, + "unit": { + "type": "string", + "enum": [ + "摄氏度", + "华氏度" + ] + } + }, + "required": [ + "location" + ] + } + } +} +``` + +```java +package org.example; + +import java.io.IOException; +import java.util.*; + +import com.google.gson.annotations.SerializedName; + +import com.baidubce.appbuilder.base.exception.AppBuilderServerException; +import com.baidubce.appbuilder.console.appbuilderclient.AppBuilderClient; +import com.baidubce.appbuilder.model.appbuilderclient.AppBuilderClientIterator; +import com.baidubce.appbuilder.model.appbuilderclient.AppBuilderClientResult; +import com.baidubce.appbuilder.model.appbuilderclient.Event; +import com.baidubce.appbuilder.base.utils.json.JsonUtils; + +class AppBuilderClientDemo { + + public static void main(String[] args) throws IOException, AppBuilderServerException { + System.setProperty("APPBUILDER_TOKEN", "请设置正确的应用密钥"); + String appId = "请设置正确的应用ID"; + AppBuilderClient builder = new AppBuilderClient(appId); + String conversationId = builder.createConversation(); + + AppBuilderClientRunRequest request = new AppBuilderClientRunRequest(appId, conversationId, "今天北京的天气怎么样?", false); + + String toolJson = new String(Files.readAllBytes(Paths.get("json文件所在的路径"))); + request.setTools(toolJson); + + AppBuilderClientIterator itor = builder.run(request); + String ToolCallID = ""; + while (itor.hasNext()) { + AppBuilderClientResult result = itor.next(); + Event lastEvent = result.getEvents()[result.getEvents().length - 1]; + ToolCallID = lastEvent.getToolCalls()[lastEvent.getToolCalls().length - 1].getId(); + System.out.println(result); + } + + AppBuilderClientRunRequest request2 = new AppBuilderClientRunRequest(appId, conversationId); + request2.setToolOutputs(ToolCallID, "北京今天35度"); + AppBuilderClientIterator itor2 = builder.run(request2); + while (itor2.hasNext()) { + AppBuilderClientResult result = itor2.next(); + System.out.println(result); + } + } +} + +``` + +#### ToolCall功能示例代码--Go + +```go +package main + +import ( + "errors" + "fmt" + "io" + "os" + + "github.com/baidubce/app-builder/go/appbuilder" +) + +func main() { + // 设置APPBUILDER_TOKEN、GATEWAY_URL_V2环境变量 + os.Setenv("APPBUILDER_TOKEN", "请设置正确的应用密钥") + // 默认可不填,默认值是 https://qianfan.baidubce.com + os.Setenv("GATEWAY_URL_V2", "") + config, err := appbuilder.NewSDKConfig("", "") + if err != nil { + fmt.Println("new config failed: ", err) + return + } + // 初始化实例 + appID := "请填写正确的应用ID" + builder, err := appbuilder.NewAppBuilderClient(appID, config) + if err != nil { + fmt.Println("new agent builder failed: ", err) + return + } + // 创建对话ID + conversationID, err := builder.CreateConversation() + if err != nil { + fmt.Println("create conversation failed: ", err) + return + } + + jsonStr := ` + { + "type": "function", + "function": { + "name": "get_cur_whether", + "description": "这是一个获得指定地点天气的工具", + "parameters": { + "type": "object", + "properties": { + "location": { + "type": "string", + "description": "省,市名,例如:河北省" + }, + "unit": { + "type": "string", + "enum": ["摄氏度", "华氏度"] + } + }, + "required": ["location"] + } + } + }` + + var tool Tool + err = json.Unmarshal([]byte(jsonStr), &tool) + if err != nil { + fmt.Println("unmarshal tool error:", err) + return + } + + i, err := client.Run(appbuilder.AppBuilderClientRunRequest{ + AppID: appID, + Query: "今天北京的天气怎么样?", + ConversationID: conversationID, + Stream: true, + Tools: []appbuilder.Tool{tool}, + }) + if err != nil { + fmt.Println("run failed:", err) + } + totalAnswer := "" + toolCallID := "" + for answer, err := i.Next(); err == nil; answer, err = i.Next() { + totalAnswer += answer.Answer + lastEvent := answer.Events[len(answer.Events)-1] + toolCallID = lastEvent.ToolCalls[len(lastEvent.ToolCalls)-1].ID + } + + i2, err := client.Run(appbuilder.AppBuilderClientRunRequest{ + ConversationID: conversationID, + AppID: appID, + ToolOutputs: []appbuilder.ToolOutput{ + { + ToolCallID: toolCallID, + Output: "北京今天35度", + }, + }, + Stream: true, + }) + + if err != nil { + fmt.Println("run failed: ", err) + } + + for answer, err := i2.Next(); err == nil; answer, err = i2.Next() { + totalAnswer = totalAnswer + answer.Answer + for _, ev := range answer.Events { + evJSON, _ := json.Marshal(ev) + fmt.Println(string(evJSON)) + } + } + + fmt.Println("----------------answer-------------------") + fmt.Println(totalAnswer) +} +``` + +#### ToolChoice示例代码 + +* 注意:当前功能为试运行阶段,可能存在如下问题,如使用过程遇到其他问题,欢迎提issue或微信群讨论。 + + * 需开启"组件/知识库结论可直接作为回复" + + * 组件名称不是界面上的原始名字,而是个人空间组件列表中的英文名 + + * 自定义组件的参数不能使用系统参数,可以使用用户添加的参数 + + * 部分官方组件使用的参数与界面上的参数不一致 + + +```go +package main + +import ( + "errors" + "fmt" + "io" + "os" + + "github.com/baidubce/app-builder/go/appbuilder" +) + +func main() { + // 设置APPBUILDER_TOKEN、GATEWAY_URL_V2环境变量 + os.Setenv("APPBUILDER_TOKEN", "请设置正确的应用密钥") + // 默认可不填,默认值是 https://qianfan.baidubce.com + os.Setenv("GATEWAY_URL_V2", "") + config, err := appbuilder.NewSDKConfig("", "") + if err != nil { + fmt.Println("new config failed: ", err) + return + } + // 初始化实例 + appID := "请填写正确的应用ID" + builder, err := appbuilder.NewAppBuilderClient(appID, config) + if err != nil { + fmt.Println("new agent builder failed: ", err) + return + } + // 创建对话ID + conversationID, err := builder.CreateConversation() + if err != nil { + fmt.Println("create conversation failed: ", err) + return + } + + // 注意使用创建应用中用到的组件。名称、参数均以实际使用的组件为准。 + input := make(map[string]any) + input["city"] = "北京" + end_user_id := "go_toolchoice_demo" + i, err := client.Run(AppBuilderClientRunRequest{ + ConversationID: conversationID, + AppID: appID, + Query: "", + EndUserID: &end_user_id, + Stream: false, + ToolChoice: &ToolChoice{ + Type: "function", + Function: ToolChoiceFunction{ + Name: "WeatherQuery", + Input: input, + }, + }, + }) + + if err != nil { + fmt.Println("run failed: ", err) + return + } + + for answer, err := i.Next(); err == nil; answer, err = i.Next() { + for _, ev := range answer.Events { + evJSON, _ := json.Marshal(ev) + fmt.Println(string(evJSON)) + } + } +} +``` diff --git a/docs/Application/Agent/ToolChoice/tool_choice.md b/docs/Application/Agent/ToolChoice/tool_choice.md new file mode 100644 index 000000000..7d9d70e84 --- /dev/null +++ b/docs/Application/Agent/ToolChoice/tool_choice.md @@ -0,0 +1,176 @@ +# ToolChoice + +#### Run方法带ToolChoice使用示例: + +* 注意:当前功能为试运行阶段,可能存在如下问题,如使用过程遇到其他问题,欢迎提issue或微信群讨论。 + * 需开启"组件/知识库结论可直接作为回复" + * 组件名称不是界面上的原始名字,而是个人空间组件列表中的英文名 + * 自定义组件的参数不能使用系统参数,可以使用用户添加的参数 + * 部分官方组件使用的参数与界面上的参数不一致 + +```python +import appbuilder +import os + +# 请前往千帆AppBuilder官网创建密钥,流程详见:https://cloud.baidu.com/doc/AppBuilder/s/Olq6grrt6#1%E3%80%81%E5%88%9B%E5%BB%BA%E5%AF%86%E9%92%A5 +# 设置环境变量 +os.environ["APPBUILDER_TOKEN"] = "..." + +app_id = "..." # 已发布AppBuilder应用的ID +# 初始化智能体 +client = appbuilder.AppBuilderClient(app_id) +# 创建会话 +conversation_id = client.create_conversation() + +# 注意使用创建应用中用到的组件。名称、参数均以实际使用的组件为准。 +answer = app_builder_client.run( + conversation_id, + "北京今天的天气", + stream=False, + end_user_id="user_id_toolchoice", + tool_choice={ + "type": "function", + "function": {"name": "WeatherQuery", "input": {"city": "北京"}}, + }, +) +``` + +#### Run方法带Toolchoice使用示例--Java + +* 注意:当前功能为试运行阶段,可能存在如下问题,如使用过程遇到其他问题,欢迎提issue或微信群讨论。 + + * 需开启"组件/知识库结论可直接作为回复" + + * 组件名称不是界面上的原始名字,而是个人空间组件列表中的英文名 + + * 自定义组件的参数不能使用系统参数,可以使用用户添加的参数 + + * 部分官方组件使用的参数与界面上的参数不一致 + +```java +package org.example; + +import java.io.IOException; +import java.util.*; + +import com.google.gson.annotations.SerializedName; + +import com.baidubce.appbuilder.base.exception.AppBuilderServerException; +import com.baidubce.appbuilder.console.appbuilderclient.AppBuilderClient; +import com.baidubce.appbuilder.model.appbuilderclient.AppBuilderClientIterator; +import com.baidubce.appbuilder.model.appbuilderclient.AppBuilderClientResult; +import com.baidubce.appbuilder.model.appbuilderclient.AppBuilderClientRunRequest; +import com.baidubce.appbuilder.model.appbuilderclient.Event; +import com.baidubce.appbuilder.base.utils.json.JsonUtils; + +class AppBuilderClientDemo { + + public static void main(String[] args) throws IOException, AppBuilderServerException { + System.setProperty("APPBUILDER_TOKEN", "请设置正确的应用密钥"); + String appId = "请设置正确的应用ID"; + AppBuilderClient builder = new AppBuilderClient(appId); + String conversationId = builder.createConversation(); + + AppBuilderClientRunRequest request = new AppBuilderClientRunRequest(appId, conversationId, "你能干什么", false); + request.setEndUserId("java_toolchoice_demo"); + + // 注意使用创建应用中用到的组件。名称、参数均以实际使用的组件为准。 + Map input = new HashMap<>(); + input.put("city", "北京"); + AppBuilderClientRunRequest.ToolChoice.Function func = new AppBuilderClientRunRequest.ToolChoice.Function( + "WeatherQuery", input); + AppBuilderClientRunRequest.ToolChoice choice = new AppBuilderClientRunRequest.ToolChoice("function", func); + request.setToolChoice(choice); + + AppBuilderClientIterator itor = builder.run(request); + while (itor.hasNext()) { + AppBuilderClientResult result = itor.next(); + System.out.println(result); + } + } +} + +``` + + +#### ToolChoice示例代码--Go + +* 注意:当前功能为试运行阶段,可能存在如下问题,如使用过程遇到其他问题,欢迎提issue或微信群讨论。 + + * 需开启"组件/知识库结论可直接作为回复" + + * 组件名称不是界面上的原始名字,而是个人空间组件列表中的英文名 + + * 自定义组件的参数不能使用系统参数,可以使用用户添加的参数 + + * 部分官方组件使用的参数与界面上的参数不一致 + + +```go +package main + +import ( + "errors" + "fmt" + "io" + "os" + + "github.com/baidubce/app-builder/go/appbuilder" +) + +func main() { + // 设置APPBUILDER_TOKEN、GATEWAY_URL_V2环境变量 + os.Setenv("APPBUILDER_TOKEN", "请设置正确的应用密钥") + // 默认可不填,默认值是 https://qianfan.baidubce.com + os.Setenv("GATEWAY_URL_V2", "") + config, err := appbuilder.NewSDKConfig("", "") + if err != nil { + fmt.Println("new config failed: ", err) + return + } + // 初始化实例 + appID := "请填写正确的应用ID" + builder, err := appbuilder.NewAppBuilderClient(appID, config) + if err != nil { + fmt.Println("new agent builder failed: ", err) + return + } + // 创建对话ID + conversationID, err := builder.CreateConversation() + if err != nil { + fmt.Println("create conversation failed: ", err) + return + } + + // 注意使用创建应用中用到的组件。名称、参数均以实际使用的组件为准。 + input := make(map[string]any) + input["city"] = "北京" + end_user_id := "go_toolchoice_demo" + i, err := client.Run(AppBuilderClientRunRequest{ + ConversationID: conversationID, + AppID: appID, + Query: "", + EndUserID: &end_user_id, + Stream: false, + ToolChoice: &ToolChoice{ + Type: "function", + Function: ToolChoiceFunction{ + Name: "WeatherQuery", + Input: input, + }, + }, + }) + + if err != nil { + fmt.Println("run failed: ", err) + return + } + + for answer, err := i.Next(); err == nil; answer, err = i.Next() { + for _, ev := range answer.Events { + evJSON, _ := json.Marshal(ev) + fmt.Println(string(evJSON)) + } + } +} +``` \ No newline at end of file diff --git a/docs/Application/Agent/UseOfficialComponents/use_official_components.md b/docs/Application/Agent/UseOfficialComponents/use_official_components.md new file mode 100644 index 000000000..0be61140f --- /dev/null +++ b/docs/Application/Agent/UseOfficialComponents/use_official_components.md @@ -0,0 +1,32 @@ +# Client应用调用官方组件 + +## 简介 + +Agent是基于线上Agent应用的问答组件,可以使用该组件利用线上Agent应用进行问答,同时可以在线上为Client应用添加组件,丰富Agent能力。 + +## Agent添加Components官方组件 + +整体使用流程包括以下两个环节: + +1. 在[百度智能云千帆AppBuilder官网](https://cloud.baidu.com/product/AppBuilder)创建并发布应用(在创建应用时可添加官方组件)、获取应用ID、获取密钥 +2. 引用AppBuilderSDK代码,初始化AppBuilderClient实例、创建会话、上传文档(可选)、执行对话 + +## 示例 + +- 接下来将展示创建一个机票查询Agent应用,并添加官方组件。 + +### 创建应用 + +- 创建应用并添加自己的角色指令,并按照自己的需求设置模型、记忆功能等参数 +![](https://bj.bcebos.com/v1/appbuilder-sdk-components/%E5%88%9B%E5%BB%BA%E8%88%AA%E7%8F%AD%E6%9F%A5%E8%AF%A2%E5%BA%94%E7%94%A8.png?authorization=bce-auth-v1%2FALTAKGa8m4qCUasgoljdEDAzLm%2F2024-12-17T03%3A51%3A31Z%2F-1%2Fhost%2Fde4a26a46469066111552bf91d50202433ef1cdd89f4945e7924ad11de38fb36) + +### 添加官方组件 + +- 添加官方组件航班查询组件 +![](https://bj.bcebos.com/v1/appbuilder-sdk-components/%E6%B7%BB%E5%8A%A0%E8%88%AA%E7%8F%AD%E6%9F%A5%E8%AF%A2%E6%8C%87%E4%BB%A4.png?authorization=bce-auth-v1%2FALTAKGa8m4qCUasgoljdEDAzLm%2F2024-12-17T03%3A52%3A17Z%2F-1%2Fhost%2F9dfcafb04d9e5992a4feda63f58ffe2211afb01b1e7b0f4f3ec4822ba840562c) + +### 发布应用并调用 + +- 完成应用设置,并发布应用,接下来就可以调用添加了官方组件的Client应用了,应用的具体调用方法请参考[Agent应用基础知识](https://github.com/baidubce/app-builder/blob/master/docs/Application/Agent/BasicKnowledge/agent.md) + + diff --git a/docs/Application/RAG/DatasetManage/dataset_manage.md b/docs/Application/RAG/DatasetManage/dataset_manage.md new file mode 100644 index 000000000..057332145 --- /dev/null +++ b/docs/Application/RAG/DatasetManage/dataset_manage.md @@ -0,0 +1,64 @@ +# console端知识库操作助手 + +## 目标 +用户可通过SDK对console端知识库进行操作,实现创建知识库、添加知识文档、查询知识库文档、删除知识文档等操作,可在平台console中查看结果。 + +```python +# 设置环境变量 +import os + +# 设置环境变量 +# 请前往千帆AppBuilder官网创建密钥,流程详见:https://cloud.baidu.com/doc/AppBuilder/s/Olq6grrt6#1%E3%80%81%E5%88%9B%E5%BB%BA%E5%AF%86%E9%92%A5 +os.environ["APPBUILDER_TOKEN"] = "..." +``` + +## 管理知识库 + +### 初始化已有知识库 +获取线上已有知识库的ID,可在[console](https://console.bce.baidu.com/ai_apaas/dataset)端查看,示例 + +image + +```python +import appbuilder +# 初始化已有线上知识库, dataset_id 可在平台console中查看 +dataset_id = "..." +dataset = appbuilder.console.Dataset(dataset_id) +``` + +### 创建全新知识库 + +```python +# 创建全新知识库 +dataset = appbuilder.console.Dataset.create_dataset("my_dataset") +``` + +### 上传文档到知识库 + +```python +# 设置文档路径,例如“./test.pdf” +file_path1 = "..." +file_path2 = "..." +file_paths = [file_path1, file_path2] +# 将文档上传到知识库 +document_infos = dataset.add_documents(file_paths) +print(document_infos) +``` + +### 获取知识库关联文档 +```python +# 获取第一页的文档列表, 每页10条 +document_list = dataset.get_documents(1, 10) +print(document_list) +``` + +### 删除知识库中的文档 +```python +# 删除第一个文档 +document_ids = [document_list.data[0].id] +dataset.delete_documents(document_ids) +``` + +### 知识库使用示例 + +- [知识库使用示例](https://github.com/baidubce/app-builder/blob/master/cookbooks/end2end_application/rag/qa_system_1_dataset.ipynb) \ No newline at end of file diff --git a/docs/DevelopGuide/AdvancedDevelopment/README.md b/docs/DevelopGuide/AdvancedDevelopment/README.md new file mode 100644 index 000000000..0c496f2dd --- /dev/null +++ b/docs/DevelopGuide/AdvancedDevelopment/README.md @@ -0,0 +1,14 @@ +# 开发指引 + +该文档目录包含以下内容: + +- [二次开发基本介绍](https://github.com/baidubce/app-builder/blob/master/docs/DevelopGuide/AdvancedDevelopment/README.md) +- [AppBuilder SDK 运行环境超参配置说明](https://github.com/baidubce/app-builder/blob/master/docs/DevelopGuide/EnvironmentalParameters/env.md) + + +## 二次开发 +当前已集成Python版本AppBuilder-SDK 0.9.4及相关依赖,方便开发者融入个人已有的大模型应用程序。此部分仍在不断建设中。 +二次开发可以采用官方提供的开发镜像,便于快速安装各种依赖库。也可在镜像中使用已安装的`appbuilder_trace_server`、`appbuilder_bce_deploy`工具。 +``` shell +docker pull registry.baidubce.com/appbuilder/appbuilder-sdk-devel:0.9.8 +``` \ No newline at end of file diff --git a/docs/DevelopGuide/ErrorMessage/error_message.md b/docs/DevelopGuide/ErrorMessage/error_message.md new file mode 100644 index 000000000..de9205112 --- /dev/null +++ b/docs/DevelopGuide/ErrorMessage/error_message.md @@ -0,0 +1,92 @@ +# SDK 错误信息 + +1、 `BaseRPCException` + +- 报错解释: + - Base RPC exception, + - SDK基类异常 + +2、 `BadRequestException` + +- 报错解释: + - BadRequestException represent HTTP Code 400 + - BadRequestException 表示请求错误,错误码为400 + +3、 `ForbiddenException` + +- 报错解释: + - ForbiddenException represent HTTP Code 403 + - ForbiddenException 表示禁止访问,错误码为403 + +4、 `NotFoundException` + +- 报错解释: + - NotFoundException represent HTTP Code 404 + - NotFoundException 表示资源不存在,错误码为404 + +5、 `PreconditionFailedException` + +- 报错解释: + - PreconditionFailedException represent HTTP Code 412 + - PreconditionFailedException 表示前置条件失败,错误码为412 + +6、 `InternalServerErrorException` + +- 报错解释: + - InternalServerErrorException represent HTTP Code 500 + - InternalServerErrorException 表示内部服务器错误,错误码为500 + + +7、 `HTTPConnectionException` + +- 报错解释: + - HTTPConnectionException represent HTTP Connection error + - HTTPConnectionException 表示HTTP连接错误 + +8、 `ModelNotSupportedException` + +- 报错解释: + - ModelNotSupportedException represent model is not supported + - ModelNotSupportedException 表示模型不支持 + +9、 `TypeNotSupportedException` + +- 报错解释: + - TypeNotSupportedException represent type is not supported + - TypeNotSupportedException 表示类型不支持 + +10、 `AppBuilderServerException` + +- 报错解释: + - AppBuilderServerException represent backend server failed response + - AppBuilderServerException 表示后端服务器响应失败 + +11、 `AssistantServerException` + +- 报错解释: + - AssistantSercerException represent assistant server failed response. + - AssistantSercerException 表示助理服务器响应失败 + +12、 `InvalidRequestArgumentError` + +- 报错解释: + - InvalidRequestArgumentError invalid request param + - InvalidRequestArgumentError 表示请求参数无效 + +13、 `RiskInputException` + +- 报错解释: + - RiskInputException represent risk input error + - RiskInputException 表示异常输入错误 + +14、 `AppbuilderBuildexException` + +- 报错解释: + - Appbuilder buledex exception + - AppbuilderBuildexException 表示AppBuilder-SDK构建异常,报错使用与Appbuilder-SDK的构造代码单元检测不符合规范 + +15、 `AppbuilderTraceException` + +- 报错解释: + - Appbuilder trace exception + - AppbuilderTraceException 表示AppBuilder-SDK追踪框架异常,使用`export APPBUILDER_TRACE_DEBUG=TRUE`来开启Appbuilder-SDK的追踪框架的DEBUG模式,展示报错的完整链路并调试 \ No newline at end of file diff --git a/docs/DevelopGuide/HowToContributeCode/README.md b/docs/DevelopGuide/HowToContributeCode/README.md index e56877380..46433c917 100644 --- a/docs/DevelopGuide/HowToContributeCode/README.md +++ b/docs/DevelopGuide/HowToContributeCode/README.md @@ -1,19 +1,23 @@ -# 开发指引 +# SDK 贡献代码规范 -该文档目录包含以下内容: +## 组件开发规范 -- [二次开发基本介绍](https://github.com/baidubce/app-builder/blob/master/docs/DevelopGuide/HowToContributeCode/README.md) -- [AppBuilder SDK 运行环境超参配置说明](https://github.com/baidubce/app-builder/blob/master/docs/DevelopGuide/EnvironmentalParameters/env.md) +### 组件整体介绍 +在无特殊情况下,一个官方组件(class Component)的实现可以拆解为以下几个关键模块,分别是 -## 二次开发 -当前已集成Python版本AppBuilder-SDK 0.9.4及相关依赖,方便开发者融入个人已有的大模型应用程序。此部分仍在不断建设中。 -二次开发可以采用官方提供的开发镜像,便于快速安装各种依赖库。也可在镜像中使用已安装的`appbuilder_trace_server`、`appbuilder_bce_deploy`工具。 -``` shell -docker pull registry.baidubce.com/appbuilder/appbuilder-sdk-devel:0.9.8 -``` +* def run:组件的run函数,规范体现在该函数的输入和输出 + * 输入规范 + * 输出规范 +* def tool_eval:组件功能的核心实现,规范体现在该函数的输入和输出 + * 输入规范 + * 输出规范 +* dict manifest:组件参与FunctionCall时,帮助大模型理解组件功能的说明,规范体现在manifest的内容和格式 + * manifest规范 + +### `run` 函数 -### 消息(Message) +#### 消息(Message) - 构建大模型应用的统一数据结构,基于Pydantic构建,在不同的Component之间流动。Message基类的默认字段是content,类型是Any。 ```python from appbuilder import Message @@ -22,9 +26,13 @@ input_list = Message(["text1", "text2", "text3"]) input_str = Message("红烧肉怎么做") ``` -### 组件(Component) -- 所有能力单元的标准结构,以Message结构作为输入输出,内部执行逻辑可在本地执行或调用云端服务,以下是官方组件的实现示例。 +#### `run` 函数输入输出规范 + +- 所有能力单元的标准结构,以Message结构作为输入输出,内部执行逻辑可在本地执行或调用云端服务,以下是官方组件的实现示例。`run` 函数需要添加 `@components_run_trace` 装饰器,实现对组件的trace。 + ```python +from appbuilder.utils.trace.tracer_wrapper import components_run_trace + class SimilarQuestionMeta(ComponentArguments): """ SimilarQuestionMeta """ @@ -67,6 +75,7 @@ class SimilarQuestion(CompletionBaseComponent): """ super().__init__(SimilarQuestionMeta, model=model) + @components_run_trace def run(self, message, stream=False, temperature=1e-10): """ 给定输入(message)到模型运行,同时指定运行参数,并返回结果。 @@ -80,4 +89,411 @@ class SimilarQuestion(CompletionBaseComponent): obj:`Message`: 模型运行后的输出消息。 """ return super().run(message=message, stream=stream, temperature=temperature) -``` \ No newline at end of file +``` + +### `tool_eval` 函数 + +#### `ComponentOutput` 类 + +```python +class ComponentOutput(BaseModel): + role: str = Field(default="tool", + description="role是区分当前消息来源的重要字段,对于绝大多数组件而言,都是填写tool,标明role所在的消息来源为组件。部分思考及问答组件,role需要填写为assistant") + content: list[Content] = Field(default=[], + description="content是当前组件返回内容的主要payload,List[Content],每个Content Dict 包括了当前输出的一个元素") +``` + +#### `tool_eval` 函数输入输出规范 + +- 组件的核心实现,需要添加 `@components_run_stream_trace` 装饰器,实现对组件的trace。 + +##### `tool_eval` 函数 输入参数 + +* 组件tool_eval方法的输入,除了在manifest中约定的参数外,也可能会传入以下系统变量,辅助组件的运行。 +* 系统入参列表中的字段是保留字段,组件定义的manifest不能与系统参数重名。系统参数中有可以被用户设置的参数例如uploaded_files,也有不能设置的字段例如traceid等。 +* 在组件的开发中,以下系统输入字段体现为 def tool_eval(self, key1, key2, \*\*kwargs)中\*\*kwargs包含的内容,key1和key2是manifest中约定的参数,kwargs中的内容是系统入参。 + +##### `tool_eval` 函数 组件返回字段 + +* 组件返回参数统一采用json字段,固定key名称和对应的value,value默认是dict类型,value本身需要指定visible_scope。 +* 非流式返回结果,按照所有流式内容的key-value进行合并,例如两个event都是references,那么需要两组references合并,所有组件需要支持非流式返回。 +* 基于sse协议提供流式数据 +* content 本身是个 List[Dict],每个 Dict是当前 event 的一个元素,一般有多个元素的返回例如 urls/files 才需要多个 Dict + +###### 组件返回字段总览 + +|字段|类型|是否必须|默认值 及 取值范围|作用说明|备注| +|---|---|---|---|---|---| +|role|str|否|- tool 默认
- user
- assistant
|ole是区分当前消息来源的重要字段,对于绝大多数组件而言,都是填写tool,标明role所在的消息来源为组件。部分思考及问答组件,role需要填写为assistant|{"role": "tool"}| +|content|list[dict]|是|[]Event|当前组件返回内容的主要payload,List[Dict],每个 Dict 包括了当前 event 的一个元素|| +|+ name|str|否|part1,part2或者3d_pics,title|介绍当前yield内容的step name使用name的必要条件,是有不同content需要是属于结构上的不同字段,但又是streaming的|| +|+ type|str|是|* text 默认
* code
* files
* urls
* oral_text
* references
* image
* chart
* audio
* json|代表event 类型,包括 text、code、files、urls、oral_text、references、image、chart、audio、tought、json
该字段的取值决定了下面text字段的内容结构|| +|+ text|dict
object|是|{}|代表当前 event 元素的内容,每一种 event 对应的 text 结构固定|保留字段
"text": {'filename': 'chart_url.png', 'url': 'https://chart_url.png'},| +|+ visible_scope|str|否|all 默认
llm
user
空|为了界面展示明确的说明字段
* llm为思考模型可见,类似function calling结果中submit的执行结果
* user为终端用户可见|workflow中存在消息通知节点,类型为notice
目前实测,llm、user、all用户都可见,只是气泡不一样。llm在下拉框中,user直接输出到气泡中。| +|+ raw_data|dict
object|否|{}|内部信息,由开发者请求透传,内部系统返回的信息,例如API节点收到的resp,大模型节点的MB resp|{
"origin_response": "xxxxx"
}| +|+ usage|list of dict
object|否|{}|大模型的token用量|{
"prompt_tokens": 1547,
"completion_tokens": 2,
"total_tokens": 1549,
"name": "ERNIE Speed-AppBuilder"
}| +|+ metrics|dict
object|否|{}|耗时、性能、内存等trace及debug所需信息|{
"begin_timestamp": xxxxx
"end_timestamp": xxxxx
}| + +##### 包含 `manifests` 定义的 `tool_eval` 函数返回示例 + +```python +class SimilarQuestion(CompletionBaseComponent): + r""" + 基于输入的问题, 挖掘出与该问题相关的类似问题。广泛用于客服、问答等场景。 + + Examples: + + .. code-block:: python + + import os + import appbuilder + + os.environ["APPBUILDER_TOKEN"] = "..." + + qa_mining = appbuilder.SimilarQuestion(model="Qianfan-Agent-Speed-8k") + + msg = "我想吃冰淇淋,哪里的冰淇淋比较好吃?" + msg = appbuilder.Message(msg) + answer = qa_mining(msg) + + print("Answer: \n{}".format(answer.content)) + """ + name = "similar_question" + version = "v1" + meta = SimilarQuestionMeta + + manifests = [ + { + "name": "similar_question", + "description": "基于输入的问题,挖掘出与该问题相关的类似问题。", + "parameters": { + "type": "object", + "properties": { + "query": { + "type": "string", + "description": "输入的问题,用于大模型根据该问题输出相关的类似问题。" + } + }, + "required": [ + "query" + ] + } + } + ] + + def __init__( + self, + model: str="Qianfan-Agent-Speed-8K", + secret_key: Optional[str] = None, + gateway: str = "", + lazy_certification: bool = True, + ): + """初始化StyleRewrite模型。 + + Args: + model (str|None): 模型名称,用于指定要使用的千帆模型。 + secret_key (str, 可选): 用户鉴权token, 默认从环境变量中获取: os.getenv("APPBUILDER_TOKEN", ""). + gateway (str, 可选): 后端网关服务地址,默认从环境变量中获取: os.getenv("GATEWAY_URL", "") + lazy_certification (bool, 可选): 延迟认证,为True时在第一次运行时认证. Defaults to False. + + Returns: + None + + """ + super().__init__( + SimilarQuestionMeta, model=model, secret_key=secret_key, gateway=gateway, + lazy_certification=lazy_certification) + + @components_run_stream_trace + def tool_eval(self, + query: str, + **kwargs): + """ + 根据给定的query和可选参数生成并返回文本输出。 + + Args: + query (str): 需要生成文本的输入查询字符串。 + **kwargs: 其他可选参数。 + + Returns: + Generator[Output]: 返回一个生成器,生成类型为Output的对象。 + + """ + traceid = kwargs.get("_sys_traceid") + msg = Message(query) + model_configs = kwargs.get('model_configs', {}) + temperature = model_configs.get("temperature", 1e-10) + top_p = model_configs.get("top_p", 0.0) + message = super().run(message=msg, stream=False, temperature=temperature, top_p=top_p, request_id=traceid) + + yield self.create_output(type="text", text=str(message.content), name="text", usage=message.token_usage) +``` + +### `manifest` 规范 + +* 若组件有tool_eval方法,则必须要求存在manifest + * 现状:算法手动撰写;未来:提供工具,自动从python函数的入参及注释转manifest +* mainfests是一个list[dict],是对组件多个能力的规范化描述,如无特殊情况,一般list中只有一个元素,对应tool_eval的能力 +* manifest dict要满足json schema协议要求 +* 要求manifest dict中parameters-properties定义的参数,与def tool_eval的入参一致 +* 组件中的version字段,会影响的组件URL,参考组件API:组件调用形如: + * /v2/components/${component}/version/{$version}?action=${action} +* 遵循新规范的组件,因输入输出与原组件不兼容,在实现上有显著的标志区分 + +#### Json Schema协议 + +- [Json Schema协议](https://json-schema.org/overview/what-is-jsonschema),以下是示例 + +```python +class BaiduSearchWithModel(Component): + r""" + 百度搜索总结工具 + """ + name = "baidu_search_with_model" + version = "v1" # 修改此处,会影响组件的调用URL + manifests = [ + { + "name": "baidu_search_with_model", # 组件名称 + "description": "对百度搜索结果进行大模型总结", # 组件描述,该字段重要,影响 function calling 效果 + "parameters": { # parameters 描述组件入参列表 + "type": "object", + "properties": { # 多个参数可以指定多个 properties + "query": { + "type": "string", # 参数query 的类型 + "description": "搜索关键词" # 参数query 的描述,该字段重要,影响 function calling 效果 + } + }, + "required": [ + "query" # query参数为必填字段 + ] + } + } + ] +``` + +## 代码合入单元测试规范 + +* 现状: 当前开源Appbuilder-SDK已经部署了单元测试流水线,并要求90%的单元测试覆盖率合入要求,要求开发者实现完整已开发的代码的端到端的测试,并且要求代码增量行覆盖率为90% + +### 单元测试规范 + +#### 单元测试要求 + +- 覆盖if-else分支 + - 对于包含if-else逻辑的代码,需要编写测试用例来确保每个分支都被执行到 +- 输入的边界条件检查 + - 边界条件通常指的是数据范围的极值(如最小值和最大值),或者特定情况下的特殊值(如空值、空字符串、负值等) +- Error raise的覆盖 + - 确保测试覆盖了所有可能抛出异常的代码路径,包括代码自身的预期错误,以及访问远程服务失败后的错误处理 + +#### Test文件目录 + +* test文件需要为『test_』开头 +* 测试类需要形如『class TestAgentRuntime(unittest.TestCase)::』的定义方式 +* test文件需要置于appbuilder-sdk-ext/appbuilder_sdk_ext/tests路径下 + +#### UnitTest提供三种标签实现两种运行模式 + +* 添加下列标签,单元测试脚本实现cpu并行 + * @unittest.skipUnless(os.getenv("TEST_CASE", "UNKNOWN") == "CPU_PARALLEL", "") +* 不添加标签,单元测试脚本默认使用cpu串行 +* 添加下列标签,暂时跳过当前单元测试脚本 + * @unittest.skip(reason="单测暂时跳过") + +##### SKIP标签代码示例 +```python +@unittest.skipUnless(os.getenv("TEST_CASE", "UNKNOWN") == "CPU_PARALLEL", "") +class TestCreateChatPrompt(unittest.TestCase): + pass + + +class TestCreateChatPrompt(unittest.TestCase): + pass + + +@unittest.skip(reason="单测暂时跳过") +class TestCreateChatPrompt(unittest.TestCase): + pass +``` + +#### SDK测试代码示例 + +下面给出一个通过parameterized库进行多种参数组合的示例,可以大幅简化单测代码,但需注意,多种参数的测试case会并行运行,对服务的QPS有要求 + +```python +import unittest +from parameterized import parameterized, param +import appbuilder + +class TestHandwritingOcr(unittest.TestCase): + @parameterized.expand([ + param(image_url, None, None), + param(image_url, None, 0), + param(image_url, float(120), None), + param(image_url, None, 1), + param(image_url, 120.5, 1), + param(image_url, float(12000), None), + ]) + def test_normal_case(self, image, timeout, retry): + """ + 正常用例 + """ + # 创建表格识别组件实例 + handwrite_ocr = appbuilder.HandwriteOCR() + # 执行识别操作并获取结果 + if timeout is None and retry is None: + out = handwrite_ocr.run(appbuilder.Message(content={"url": image})) + elif timeout is None: + out = handwrite_ocr.run(appbuilder.Message(content={"url": image}), retry=retry) + elif retry is None: + out = handwrite_ocr.run(appbuilder.Message(content={"url": image}), timeout=timeout) + else: + out = handwrite_ocr.run(appbuilder.Message(content={"url": image}), timeout=timeout, retry=retry) + res = out.content + self.assertIsNotNone(res["contents"], "识别结果为空") + self.assertEqual(len(res["contents"]), 6) + + @parameterized.expand([ + # timeout为0 + param(image_url, 0, 0, "ValueError", "timeout", 'but the timeout cannot be set to a value ' + 'less than or equal to 0.'), + # timeout为字符串 + param(image_url, "a", 0, "appbuilder.core._exception.InvalidRequestArgumentError", "timeout", + 'timeout must be float or tuple of float'), + # timeout为0.1,太短了 + param(image_url, float(0.1), 0, "requests.exceptions.ReadTimeout", "timeout", + "Read timed out. (read timeout=0.1)"), + # retry为字符串 + param(image_url, float(10), "a", "TypeError", "str", "'<' not supported between instances of" + " 'str' and 'int'"), + # image_url错误 + param("https://bj.bcebos.com/v1/appbuilder/xxx", 12.5, 1, + "appbuilder.core._exception.AppBuilderServerException", "url", + "service_err_message=url format illegal"), + ]) + def test_abnormal_case(self, image, timeout, retry, err_type, err_param, err_msg): + """ + 异常用例 + """ + try: + # 创建表格识别组件实例 + handwrite_ocr = appbuilder.HandwriteOCR() + # 执行识别操作并获取结果 + out = handwrite_ocr.run(appbuilder.Message(content={"url": image}), timeout=timeout, retry=retry) + res = out.content + log.info(res) + assert False, "未捕获到错误信息" + except Exception as e: + self.assertIsInstance(e, eval(err_type), "捕获的异常不是预期的类型 实际:{}, 预期:{}".format(e, err_type)) + self.assertIn(err_param, str(e), "捕获的异常参数类型不正确, 预期 参数:{}, 实际:{}".format(err_param, str(e))) + self.assertIn(err_msg, str(e), "捕获的异常消息不正确, 预期:{}, 实际:{}".format(err_msg, str(e))) +``` + +## 注释规范 + +- SDK使用注释自动生成API文档,因此非私有函数的注释需要严格按照Google代码注释规范编写 + +### object类注释 + +```python +class AppBuilderClient(Component): + r""" + AppBuilderClient 组件支持调用在[百度智能云千帆AppBuilder](https://cloud.baidu.com/product/AppBuilder)平台上 + 构建并发布的智能体应用,具体包括创建会话、上传文档、运行对话等。 + + Examples: + + .. code-block:: python + + import appbuilder + # 请前往千帆AppBuilder官网创建密钥,流程详见:https://cloud.baidu.com/doc/AppBuilder/s/Olq6grrt6#1%E3%80%81%E5%88%9B%E5%BB%BA%E5%AF%86%E9%92%A5 + os.environ["APPBUILDER_TOKEN"] = '...' + # 可在Console 应用页面获取 + app_id = "app_id" + client = appbuilder.AppBuilderClient("app_id") + conversation_id = client.create_conversation() + file_id = client.upload_local_file(conversation_id, "/path/to/file") + message = client.run(conversation_id, "今天你好吗?") + # 打印对话结果 + print(message.content) + + """ +``` +- 注意 + - 注释必须使用 Examples:之后必须存在一行空行,.. code-block:: python之后也必须要有一行空行 + - code-block前为两点(..)之后为两个冒号(::) + - 方法的示例注释与此规范相同 + +### 函数注释 + +- 私有函数如_recognize_w_post_process等无需按照规范注释函数 + +```python +@components_run_stream_trace +def tool_eval( + self, + name: str, + streaming: bool, + origin_query: str, + **kwargs, +) -> Union[Generator[str, None, None], str]: + """ + 执行工具函数,通过调用底层接口进行动物识别。 + + Args: + name (str): 工具名 + streaming (bool): 是否流式返回结果,True 表示流式返回,False 表示一次性返回 + origin_query (str): 用户原始查询字符串 + **kwargs: 工具调用的额外关键字参数 + + Returns: + Union[Generator[str, None, None], str]: 动物识别结果。如果 streaming 为 True,则返回一个生成器,可以逐个返回识别结果; + 如果 streaming 为 False,则返回一个字符串,包含识别出的动物类别和相应的置信度信息。 + + """ +``` + +### google风格指南与规范示例 + +- Google详情见 [Google注释风格指南](https://google.github.io/styleguide/pyguide.html) + + +```python +class GoogleStyle: + '''Google注释风格 + 用 ``缩进`` 分隔, + 适用于倾向水平,短而简单的文档 + Attributes: + dividend (int or float): 被除数 + name (:obj:`str`, optional): 该类的命名 + ''' + + def __init__(self, dividend, name='GoogleStyle'): + '''初始化''' + self.dividend = dividend + self.name = name + + def divide(self, divisor): + '''除法 + Google注释风格的函数, + 类型主要有Args、Returns、Raises、Examples + Args: + divisor (int):除数 + Returns: + 除法结果 + Raises: + ZeroDivisionError: division by zero + Examples: + + .. code-block:: python + + # 实例代码 + + References: + 除法_百度百科 https://baike.baidu.com/item/%E9%99%A4%E6%B3%95/6280598 + ''' + try: + return self.dividend / divisor + except ZeroDivisionError as e: + return e +``` diff --git a/docs/README.md b/docs/README.md index 8bb36d53f..5bf0a4f9e 100644 --- a/docs/README.md +++ b/docs/README.md @@ -9,53 +9,48 @@ - 产业实践应用范例: - [SDK使用示例](https://github.com/baidubce/app-builder/blob/master/docs/QuickStart/ExamplesOfIndustrialPracticeApplications/README.md) - [SDK当前支持的编程语言](https://github.com/baidubce/app-builder/blob/master/docs/QuickStart/CurrentlySupportedProgrammingLanguages/README.md) - - 基础: - - 模型: - - [获取模型列表](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Model/get_model_list.md) - - [组件](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Components/Components.md) - - 监控: - - [TRACE基础功能](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Trace/basic.md) - - [TRACE拓展功能](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Trace/phoenix_method.md) - - 部署: - - [交互式前端部署](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Deployment/AgentChainlit.md) - - [公有云部署](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Deployment/cloud.md) - - [API 访问](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Deployment/flask.md) - - [AgentRuntime](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Deployment/agentruntime.md) - - [UserSession](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Deployment/usersession.md) - - 平台: - - 应用: - - [AppBuilderClient组件](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Platform/Application/appbuilder_client.md) - - [获取AppBuilder已发布的应用列表](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Platform/Application/get_app_list.md) - - 知识库: - - [知识库组件](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Platform/KnowledgeBase/knowledgebase.md) - - 自定义组件: - - [基础能力组件](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Platform/CustomComponents/components.md) - - 应用: - - Agent: - - [基础知识](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) - - [使用官方组件](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) - - [ToolCall](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) - - [ToolChoice](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) - - [使用异步和流式加速客户端调用](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) - - RAG: - - [基础知识](https://github.com/baidubce/app-builder/blob/master/docs/Application/RAG/BasicKnowledge/rag.md) - - [知识库管理](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) - - [Reference信息处理](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) - - Workflow: - - [基础知识](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) - - [从零使用Workflow组装一个RAG应用](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) - - [从零使用Workflow组装一个Agent应用](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) - - 开发者指南: - - [如何贡献代码](https://github.com/baidubce/app-builder/blob/master/docs/DevelopGuide/HowToContributeCode/README.md) - - [版本升级日志](https://github.com/baidubce/app-builder/blob/master/docs/DevelopGuide/ChangeLog/changelog.md) - - [常见问题FAQ](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) - - [日志管理](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) - - [错误信息](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) - - [环境参数](https://github.com/baidubce/app-builder/blob/master/docs/DevelopGuide/EnvironmentalParameters/env.md) - - API Reference: - - [Python API Reference](https://github.com/baidubce/app-builder/blob/master/docs/API-Reference/Python/PythonAPI.md) - - [Java API Reference](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) - - [Go API Reference](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) + - 基础: + - 模型: + - [获取模型列表](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Model/get_model_list.md) + - [组件](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Components/Components.md) + - 监控: + - [TRACE基础功能](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Trace/basic.md) + - [TRACE拓展功能](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Trace/phoenix_method.md) + - 部署: + - [交互式前端部署](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Deployment/AgentChainlit.md) + - [公有云部署](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Deployment/cloud.md) + - [API 访问](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Deployment/flask.md) + - [AgentRuntime](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Deployment/agentruntime.md) + - [UserSession](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Deployment/usersession.md) + - 平台: + - 应用: + - [AppBuilderClient组件](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Platform/Application/appbuilder_client.md) + - [获取AppBuilder已发布的应用列表](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Platform/Application/get_app_list.md) + - 知识库: + - [知识库组件](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Platform/KnowledgeBase/knowledgebase.md) + - 自定义组件: + - [基础能力组件](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Platform/CustomComponents/components.md) + - 应用: + - Agent: + - [基础知识](https://github.com/baidubce/app-builder/blob/master/docs/Application/Agent/BasicKnowledge/agent.md) + - [使用官方组件](https://github.com/baidubce/app-builder/blob/master/docs/Application/Agent/UseOfficialComponents/use_official_components.md) + - [ToolCall](https://github.com/baidubce/app-builder/blob/master/docs/Application/Agent/ToolCall/tool_call.md) + - [ToolChoice](https://github.com/baidubce/app-builder/blob/master/docs/Application/Agent/ToolChoice/tool_choice.md) + - [使用异步和流式加速客户端调用](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) + - RAG: + - [基础知识](https://github.com/baidubce/app-builder/blob/master/docs/Application/RAG/BasicKnowledge/rag.md) + - [知识库管理](https://github.com/baidubce/app-builder/blob/master/docs/Application/RAG/DatasetManage/dataset_manage.md) + - [Reference信息处理](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) + - Workflow: + - [基础知识](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) + - [从零使用Workflow组装一个RAG应用](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) + - [从零使用Workflow组装一个Agent应用](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) + - 开发者指南: + - [如何贡献代码](https://github.com/baidubce/app-builder/blob/master/docs/DevelopGuide/HowToContributeCode/README.md) + - [二次开发](https://github.com/baidubce/app-builder/blob/master/docs/DevelopGuide/AdvancedDevelopment/README.md) + - [版本升级日志](https://github.com/baidubce/app-builder/blob/master/docs/DevelopGuide/ChangeLog/changelog.md) + - [错误信息](https://github.com/baidubce/app-builder/blob/master/docs/DevelopGuide/ErrorMessage/error_message.md) + - [环境参数](https://github.com/baidubce/app-builder/blob/master/docs/DevelopGuide/EnvironmentalParameters/env.md) ## 平台文档 diff --git a/docs/README_en.md b/docs/README_en.md index 99b24c4d6..88a1a5594 100644 --- a/docs/README_en.md +++ b/docs/README_en.md @@ -254,54 +254,49 @@ Hook: - Industrial practice application examples: - [SDK usage examples](https://github.com/baidubce/app-builder/blob/master/docs/QuickStart/ExamplesOfIndustrialPracticeApplications/README.md) - [Currently supported programming languages by SDK](https://github.com/baidubce/app-builder/blob/master/docs/QuickStart/CurrentlySupportedProgrammingLanguages/README.md) - - Basics: - - Models: - - [Get model list](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Model/get_model_list.md) - - [Components](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Components/Components.md) - - Monitoring: - - [TRACE basic functions](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Trace/basic.md) - - [TRACE extended functions](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Trace/phoenix_method.md) - - [Debug functionality](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Trace/Debug.md) - - Deployment: - - [Interactive front-end deployment](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Deployment/AgentChainlit.md) - - [Public cloud deployment](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Deployment/cloud.md) - - [API access](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Deployment/flask.md) - - [AgentRuntime](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Deployment/agentruntime.md) - - [UserSession](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Deployment/usersession.md) - - Platform: - - Applications: - - [AppBuilderClient component](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Platform/Application/appbuilder_client.md) - - [Get the list of applications published by AppBuilder](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Platform/Application/get_app_list.md) - - Knowledge Base: - - [Knowledge Base component](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Platform/KnowledgeBase/knowledgebase.md) - - Custom Components: - - [Basic capabilities component](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Platform/CustomComponents/components.md) - - Applications: - - Agent: - - [Basic knowledge](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) - - [Using official components](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) - - [ToolCall](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) - - [ToolChoice](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) - - [Using asynchronous and streaming accelerated client calls](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) - - RAG: - - [Basic knowledge](https://github.com/baidubce/app-builder/blob/master/docs/Application/RAG/BasicKnowledge/rag.md) - - [Knowledge Base Management](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) - - [Reference Information Processing](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) - - Workflow: - - [Basic knowledge](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) - - [Assembling a RAG application from scratch using Workflow](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) - - [Assembling an Agent application from scratch using Workflow](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) - - Developer Guide: - - [How to contribute code](https://github.com/baidubce/app-builder/blob/master/docs/DevelopGuide/HowToContributeCode/README.md) - - [Version upgrade log](https://github.com/baidubce/app-builder/blob/master/docs/DevelopGuide/ChangeLog/changelog.md) - - [FAQ](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) - - [Log Management](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) - - [Error messages](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) - - [Environmental parameters](https://github.com/baidubce/app-builder/blob/master/docs/DevelopGuide/EnvironmentalParameters/env.md) - - API Reference: - - [Python API Reference](https://github.com/baidubce/app-builder/blob/master/docs/API-Reference/Python/PythonAPI.md) - - [Java API Reference](https://github.com/baidubce/app-builder/blob/master/docs/API-Reference/Java/JavaAPI.md) - - [Go API Reference](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) + - Basics: + - Models: + - [Get model list](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Model/get_model_list.md) + - [Components](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Components/Components.md) + - Monitoring: + - [TRACE basic functions](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Trace/basic.md) + - [TRACE extended functions](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Trace/phoenix_method.md) + - [Debug functionality](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Trace/Debug.md) + - Deployment: + - [Interactive front-end deployment](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Deployment/AgentChainlit.md) + - [Public cloud deployment](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Deployment/cloud.md) + - [API access](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Deployment/flask.md) + - [AgentRuntime](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Deployment/agentruntime.md) + - [UserSession](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Deployment/usersession.md) + - Platform: + - Applications: + - [AppBuilderClient component](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Platform/Application/appbuilder_client.md) + - [Get the list of applications published by AppBuilder](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Platform/Application/get_app_list.md) + - Knowledge Base: + - [Knowledge Base component](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Platform/KnowledgeBase/knowledgebase.md) + - Custom Components: + - [Basic capabilities component](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Platform/CustomComponents/components.md) + - Applications: + - Agent: + - [Basic knowledge](https://github.com/baidubce/app-builder/blob/master/docs/Application/Agent/BasicKnowledge/agent.md) + - [Using official components](https://github.com/baidubce/app-builder/blob/master/docs/Application/Agent/UseOfficialComponents/use_official_components.md) + - [ToolCall](https://github.com/baidubce/app-builder/blob/master/docs/Application/Agent/ToolCall/tool_call.md) + - [ToolChoice](https://github.com/baidubce/app-builder/blob/master/docs/Application/Agent/ToolChoice/tool_choice.md) + - [Using asynchronous and streaming accelerated client calls](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) + - RAG: + - [Basic knowledge](https://github.com/baidubce/app-builder/blob/master/docs/Application/RAG/BasicKnowledge/rag.md) + - [Knowledge Base Management](https://github.com/baidubce/app-builder/blob/master/docs/Application/RAG/DatasetManage/dataset_manage.md) + - [Reference Information Processing](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) + - Workflow: + - [Basic knowledge](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) + - [Assembling a RAG application from scratch using Workflow](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) + - [Assembling an Agent application from scratch using Workflow](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) + - Developer Guide: + - [How to contribute code](https://github.com/baidubce/app-builder/blob/master/docs/DevelopGuide/HowToContributeCode/README.md) + - [Secondary Development](https://github.com/baidubce/app-builder/blob/master/docs/DevelopGuide/AdvancedDevelopment/README.md) + - [Version upgrade log](https://github.com/baidubce/app-builder/blob/master/docs/DevelopGuide/ChangeLog/changelog.md) + - [Error messages](https://github.com/baidubce/app-builder/blob/master/docs/DevelopGuide/ErrorMessage/error_message.md) + - [Environmental parameters](https://github.com/baidubce/app-builder/blob/master/docs/DevelopGuide/EnvironmentalParameters/env.md) ## Open source community and activities
diff --git a/docs/README_ja.md b/docs/README_ja.md index bfac2b37d..54c2eca31 100644 --- a/docs/README_ja.md +++ b/docs/README_ja.md @@ -250,54 +250,49 @@ print(answer.content.answer) - 産業実践アプリケーション例: - [SDK使用例](https://github.com/baidubce/app-builder/blob/master/docs/QuickStart/ExamplesOfIndustrialPracticeApplications/README.md) - [現在SDKがサポートしているプログラミング言語](https://github.com/baidubce/app-builder/blob/master/docs/QuickStart/CurrentlySupportedProgrammingLanguages/README.md) - - 基本: - - モデル: - - [モデルリストの取得](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Model/get_model_list.md) - - [コンポーネント](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Components/Components.md) - - 監視: - - [TRACE基本機能](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Trace/basic.md) - - [TRACE拡張機能](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Trace/phoenix_method.md) - - [Debug機能](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Trace/Debug.md) - - デプロイ: - - [インタラクティブなフロントエンドデプロイ](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Deployment/AgentChainlit.md) - - [パブリッククラウドデプロイ](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Deployment/cloud.md) - - [API アクセス](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Deployment/flask.md) - - [AgentRuntime](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Deployment/agentruntime.md) - - [UserSession](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Deployment/usersession.md) - - プラットフォーム: - - アプリケーション: - - [AppBuilderClientコンポーネント](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Platform/Application/appbuilder_client.md) - - [AppBuilderで公開されたアプリケーションリストの取得](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Platform/Application/get_app_list.md) - - ナレッジベース: - - [ナレッジベースコンポーネント](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Platform/KnowledgeBase/knowledgebase.md) - - カスタムコンポーネント: - - [基本機能コンポーネント](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Platform/CustomComponents/components.md) - - アプリケーション: - - エージェント: - - [基本知識](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) - - [公式コンポーネントの使用](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) - - [ToolCall](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) - - [ToolChoice](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) - - [非同期およびストリーミングを使用してクライアント呼び出しを加速する](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) - - RAG: - - [基本知識](https://github.com/baidubce/app-builder/blob/master/docs/Application/RAG/BasicKnowledge/rag.md) - - [ナレッジベース管理](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) - - [Reference情報処理](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) - - ワークフロー: - - [基本知識](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) - - [Workflowを使ってRAGアプリケーションをゼロから組み立てる](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) - - [Workflowを使ってAgentアプリケーションをゼロから組み立てる](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) - - 開発者ガイド: - - [コードの貢献方法](https://github.com/baidubce/app-builder/blob/master/docs/DevelopGuide/HowToContributeCode/README.md) - - [バージョンアップログ](https://github.com/baidubce/app-builder/blob/master/docs/DevelopGuide/ChangeLog/changelog.md) - - [よくある質問FAQ](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) - - [ログ管理](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) - - [エラーメッセージ](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) - - [環境パラメータ](https://github.com/baidubce/app-builder/blob/master/docs/DevelopGuide/EnvironmentalParameters/env.md) - - APIリファレンス: - - [Python APIリファレンス](https://github.com/baidubce/app-builder/blob/master/docs/API-Reference/Python/PythonAPI.md) - - [Java APIリファレンス](https://github.com/baidubce/app-builder/blob/master/docs/API-Reference/Java/JavaAPI.md) - - [Go APIリファレンス](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) + - 基本: + - モデル: + - [モデルリストの取得](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Model/get_model_list.md) + - [コンポーネント](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Components/Components.md) + - 監視: + - [TRACE基本機能](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Trace/basic.md) + - [TRACE拡張機能](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Trace/phoenix_method.md) + - [Debug機能](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Trace/Debug.md) + - デプロイ: + - [インタラクティブなフロントエンドデプロイ](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Deployment/AgentChainlit.md) + - [パブリッククラウドデプロイ](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Deployment/cloud.md) + - [API アクセス](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Deployment/flask.md) + - [AgentRuntime](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Deployment/agentruntime.md) + - [UserSession](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Deployment/usersession.md) + - プラットフォーム: + - アプリケーション: + - [AppBuilderClientコンポーネント](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Platform/Application/appbuilder_client.md) + - [AppBuilderで公開されたアプリケーションリストの取得](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Platform/Application/get_app_list.md) + - ナレッジベース: + - [ナレッジベースコンポーネント](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Platform/KnowledgeBase/knowledgebase.md) + - カスタムコンポーネント: + - [基本機能コンポーネント](https://github.com/baidubce/app-builder/blob/master/docs/BasisModule/Platform/CustomComponents/components.md) + - アプリケーション: + - エージェント: + - [基本知識](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) + - [公式コンポーネントの使用](https://github.com/baidubce/app-builder/blob/master/docs/Application/Agent/UseOfficialComponents/use_official_components.md) + - [ToolCall](https://github.com/baidubce/app-builder/blob/master/docs/Application/Agent/ToolCall/tool_call.md) + - [ToolChoice](https://github.com/baidubce/app-builder/blob/master/docs/Application/Agent/ToolChoice/tool_choice.md) + - [非同期およびストリーミングを使用してクライアント呼び出しを加速する](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) + - RAG: + - [基本知識](https://github.com/baidubce/app-builder/blob/master/docs/Application/RAG/BasicKnowledge/rag.md) + - [ナレッジベース管理](https://github.com/baidubce/app-builder/blob/master/docs/Application/RAG/DatasetManage/dataset_manage.md) + - [Reference情報処理](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) + - ワークフロー: + - [基本知識](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) + - [Workflowを使ってRAGアプリケーションをゼロから組み立てる](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) + - [Workflowを使ってAgentアプリケーションをゼロから組み立てる](https://github.com/baidubce/app-builder/blob/master/docs/Tools/DocPass/DocPass.md) + - 開発者ガイド: + - [コードの貢献方法](https://github.com/baidubce/app-builder/blob/master/docs/DevelopGuide/HowToContributeCode/README.md) + - [にじかいせっか](https://github.com/baidubce/app-builder/blob/master/docs/DevelopGuide/AdvancedDevelopment/README.md) + - [バージョンアップログ](https://github.com/baidubce/app-builder/blob/master/docs/DevelopGuide/ChangeLog/changelog.md) + - [エラーメッセージ](https://github.com/baidubce/app-builder/blob/master/docs/DevelopGuide/ErrorMessage/error_message.md) + - [環境パラメータ](https://github.com/baidubce/app-builder/blob/master/docs/DevelopGuide/EnvironmentalParameters/env.md) ## オープンソースコミュニティと活動 diff --git a/mkdocs.yml b/mkdocs.yml index 044ab306a..7311aa4c1 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -82,15 +82,15 @@ nav: - 自定义组件: - 基础能力组件: BasisModule/Platform/CustomComponents/components.md - 应用: - # - Agent: - # - 基础知识: - # - 使用官方组件: - # - ToolCall: - # - ToolChoice: + - Agent: + - 基础知识: Application/Agent/BasicKnowledge/agent.md + - 使用官方组件: Application/Agent/UseOfficialComponents/use_official_components.md + - ToolCall: Application/Agent/ToolCall/tool_call.md + - ToolChoice: Application/Agent/ToolChoice/tool_choice.md # - 使用异步和流式加速客户端调用: - RAG: - 基础知识: Application/RAG/BasicKnowledge/rag.md - # - 知识库管理: + - 知识库管理: Application/RAG/DatasetManage/dataset_manage.md # - Reference信息处理: # - Workflow: # - 基础知识: @@ -98,10 +98,9 @@ nav: # - 从零使用Workflow组装一个Agent应用: - 开发者指南: - 如何贡献代码: DevelopGuide/HowToContributeCode/README.md + - 二次开发: DevelopGuide/AdvancedDevelopment/README.md - 版本升级日志: DevelopGuide/ChangeLog/changelog.md - # - 常见问题FAQ: - # - 日志管理: - # - 错误信息: + - 错误信息: DevelopGuide/ErrorMessage/error_message.md - 环境参数: DevelopGuide/EnvironmentalParameters/env.md - API Reference: - Python API Reference: API-Reference/Python/PythonAPI.md