Skip to content

Commit

Permalink
重构Readme,调整Docs 及 CookBook目录 (#286)
Browse files Browse the repository at this point in the history
* New Readme
  • Loading branch information
MrChengmo authored Apr 30, 2024
1 parent 81d9eab commit 66aa389
Show file tree
Hide file tree
Showing 70 changed files with 916 additions and 276 deletions.
328 changes: 80 additions & 248 deletions README.md

Large diffs are not rendered by default.

126 changes: 126 additions & 0 deletions README_en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
<div align="center">
<img src='docs/image/logo.png' alt='logo' width='700' >
<br>

[![License](https://img.shields.io/badge/license-Apache%202-blue.svg)](LICENSE)
![Supported Python versions](https://img.shields.io/badge/python-3.9+-orange.svg)
![Supported OSs](https://img.shields.io/badge/os-linux%2C%20win%2C%20mac-yellow.svg)
</div>

[简体中文](./README.md) | English

<br>


## What is AppBuilder SDK?

Baidu AI Cloud Qianfan AppBuilder SDK is a `one-stop development tool` for AI native application developers which contributed by [Baidu AI Cloud Qianfan AppBuilder](https://appbuilder.cloud.baidu.com/).


We provide three types of functions from bottom to top: basic components, process orchestration, and end-to-end applications. With Baidu AI Cloud Qianfan AppBuilder SDK, you can:

- Cooperate with Baidu AI Cloud Qianfan AppBuilder platform [web side](https://console.bce.baidu.com/ai_apaas/app), Build an end-to-end AI native application that includes Baidu's industrial practices at the minute level: Agent / RAG / Workflow application

- Collaborate with basic components and process orchestration to build personalized `Assistant` + `FunctionCall` applications in a modular manner

- Provide two service-oriented deployment methods: API calls and interactive windows, supporting fast cloud deployment


## How to install?

#### The latest version of Baidu AI Cloud Qianfan AppBuilder SDK is 0.7.0 (2024-04-30)

Baidu AI Cloud Qianfan AppBuilder SDK ReleaseNote please refer to our [version description](/docs/quick_start/changelog.md)

- We recommend installing the latest stable version of `Python`

```bash
python3 -m pip install --upgrade appbuilder-sdk
```
- For installation of `Java` and `Go` versions, as well as using `Docker` images, please refer to the [Installation Instructions](/docs/quick_start/install.md)


## Quickly start your first AI native application!

- Please install `appbuilder sdk` in a Python environment with `>=3.9` and use this end-to-end application example
- The example provides a trial token, but access and QPS are restricted. Please replace it with your personal token for official use
- The application in the example is: [Geography expert](https://appbuilder.baidu.com/s/x1tSF), Click on the link to try it out on the web page

#### Code example

```python
import appbuilder
import os

# Set the TOKENs in the environment. The following TOKENs are trial TOKENs with restricted access and QPS. Please replace them with your personal TOKENs for official use
os.environ["APPBUILDER_TOKEN"] = "bce-v3/ALTAK-n5AYUIUJMarF7F7iFXVeK/1bf65eed7c8c7efef9b11388524fa1087f90ea58"

# Obtain and pass in the application ID from the AppBuilder webpage. The following is the application ID of the Geography Expert
app_id = "42eb211a-14b9-43d2-9fae-193c8760ef26"

app_builder_client = appbuilder.AppBuilderClient(app_id)
conversation_id = app_builder_client.create_conversation()

answer = app_builder_client.run(conversation_id, "Where is the capital of the United States and what is the climate like? answer by english")
print(answer.content)
```

#### Answer display

> The capital of the United States is **Washington, D.C.**^[1]^.
>
> The climate of Washington, D.C. is generally mild and wet, with hot summers and cold winters. The city experiences a high level of rainfall, especially in the spring and summer months. However, it also has a high level of sunshine and warm weather in the summer months.^[2]^

**For more examples of AI native application code, please refer to [CookBooks](./bookbooks/README.md)**. We have the following cookbooks that we recommend you to read first:
- Basic Ability Components
- [General Text Recognition Component](/cookbooks/components/general_ocr.ipynb)
- [Basic component service-oriented deployment](/cookbooks/components/agent_runtime.ipynb)
- Process orchestration
- [Assistant SDK](/cookbooks/pipeline/assistant_function_call.ipynb)
- End-to-end applications
- [Agent](/cookbooks/agent_builder.ipynb)
- [RAG](/cookbooks/end2end_application/rag/rag.ipynb)
- [Enterprise level Q&A system](/cookbooks/end2end_application/rag/qa_system_2_dialogue.ipynb)


## Panorama of Baidu AI Cloud Qianfan AppBuilder SDK capability
<div align="center">
<img src='docs/image/structure-en.png' alt='wechat' width='800' >
</div>


## User Documentation

- [Quick start](/docs/quick_start/README.md)
- [Installation instructions](/docs/quick_start/install.md)
- [Release note](/docs/quick_start/changelog.md)
- [Basic components](/docs/basic_module/README.md)
- [Basic Ability Components](/docs/basic_module/components.md)
- [Process orchestration](/docs/basic_module/assistant_sdk.md)
- [End-to-end applications](/docs/basic_module/appbuilder_client.md)
- [Advanced Practice](/docs/advanced_application/README.md)
- [CookBooks](/cookbooks/README.md)
- [Service deployment](/docs/service/README.md)
- [API calls](/docs/service/flask.md)
- [Interactive front-end](/docs/service/chainlit.md)
- [Cloud deployment](/docs/service/cloud.md)
- [Secondary development](/docs/develop_guide/README.md)


## Open source community and activities
<div align="center">
<h3>AppBuilder-SDK WeChat Group QR Code</h3>
<img src='docs/image/wechat_group.png' alt='wechat' width='200' >
</div>

- [Github Issue](https://github.com/baidubce/app-builder/issues): Submit installation/usage issues, report bugs, suggest new features, communicate development plans, etc

- [Baidu AI Cloud Qianfan Community](https://cloud.baidu.com/qianfandev)



## License

AppBuilder SDK follows the Apache 2.0 open source protocol.

26 changes: 26 additions & 0 deletions cookbooks/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# AppBuilder-SDK CookBooks

## CookBook目录

### 基础组件
- [短语音识别组件-asr](/cookbooks/components/asr.ipynb)
- [gbi - 自动选表问表](/cookbooks/components/gbi.ipynb)
- [general_ocr - 通用文字识别](/cookbooks/components/general_ocr.ipynb)
- [object_recognize - 通用物体识别](/cookbooks/components/object_recognize.ipynb)
- [rag_with_baidusearch - 百度搜索](/cookbooks/components/rag_with_baidusearch.ipynb)
- [text_generation - 文本生成](/cookbooks/components/text_generation.ipynb)
- [translate - 文本翻译](/cookbooks/components/translate.ipynb)
- [vdb_retriever - VectorDB向量存储](/cookbooks/components/vdb_retriever.ipynb)


### 流程编排
- [基于AssistantSDK 实现FunctionCall](/cookbooks/pipeline/assistant_function_call.ipynb)


### 端到端应用
- [Agent应用](/cookbooks/end2end_application/agent/appbuilder_client.ipynb)
- [RAG应用-简历筛选小助手](/cookbooks/end2end_application/rag/rag.ipynb)
- [RAG应用-问答助手](/cookbooks/end2end_application/rag/console_rag.ipynb)
- [RAG应用-企业问答系统-离线知识生产](/cookbooks/end2end_application/rag/qa_system_1_dataset.ipynb)
- [RAG应用-企业问答系统-在线问答流程](/cookbooks/end2end_application/rag/qa_system_2_dialogue.ipynb)
- [知识库操作助手](/cookbooks/end2end_application/console_dataset.ipynb)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
205 changes: 205 additions & 0 deletions cookbooks/end2end_application/agent/appbuilder_client.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"id": "42eace26869295fb",
"metadata": {
"collapsed": false
},
"source": [
"# Console AppBuilderClient使用示例\n",
"\n",
"整体使用流程包括以下两个环节:\n",
"\n",
"1. 在[百度智能云千帆AppBuilder官网](https://cloud.baidu.com/product/AppBuilder)创建并发布应用、获取应用ID、获取密钥\n",
"2. 引用AppBuilderSDK代码,初始化AppBuilderClient实例、创建会话、上传文档(可选)、执行对话\n",
"\n",
"以下分别提供三个样例,快递查询小助手、植物识别小助手、篮球教练来说明使用流程,注意以下流程用到的密钥可在图示位置中获取:\n",
"<img src=\"./app_builder_resources/secret.png\" alt=\"drawing\" width=\"1000\"/>\n",
"\n",
"\n",
"## 1. 快递查询小助手\n",
"\n",
"[<span style=\"font-size:1.3em;\"> 快递查询小助手</span>](https://appbuilder.baidu.com/s/KVSXK)一键体验\n",
"\n",
"### 1.1 Console端应用配置与发布\n",
"1 进入[百度智能云千帆AppBuilder官网](https://cloud.baidu.com/product/AppBuilder),配置智能体指令、选择相应的工具组件、发布应用\n",
"\n",
"<img src=\"./app_builder_resources/express_assistant.png\" alt=\"drawing\" width=\"1200\"/>\n",
"\n",
"2 获取应用ID\n",
"<img src=\"./app_builder_resources/app_id.png\" alt=\"drawing\" width=\"1200\"/>\n",
"\n",
"### 1.2 SDK代码调用示例"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a6a9e2ba6159a8e4",
"metadata": {
"collapsed": false,
"is_executing": true
},
"outputs": [],
"source": [
"import appbuilder\n",
"import os\n",
"# 注意以下示例正确运行依赖的条件包括:\n",
"# 1. 在百度智能云千帆AppBuilder官网使用AppBuilderClient创建应用且应用已发布\n",
"# 2. 密钥正确有效\n",
"# 3. 密钥需要与发布应用正确对应,即需要使用发布应用的账户下的密钥\n",
"\n",
"# 配置密钥与应用ID\n",
"os.environ[\"APPBUILDER_TOKEN\"] =\"secret_key\"\n",
"app_id = \"35f4fed3-d530-4dad-bc8e-f2150a4450be\"\n",
"\n",
"# 初始化Agent\n",
"builder = appbuilder.AppBuilderClient(app_id)\n",
"\n",
"# 创建会话ID\n",
"conversation_id = builder.create_conversation()\n",
"\n",
"# 执行对话\n",
"msg = builder.run(conversation_id, \"我的快递单号是:9858485940100; 请查询下此快递的状态\")\n",
"print(\"快递查询助理回答内容:\", msg.content.answer)\n",
"\n",
"# 执行流式对话\n",
"msg = builder.run(conversation_id, \"使用语音播报快递当前状态\", stream=True)\n",
"for content in msg.content:\n",
" for ev in content.events:\n",
" if ev.content_type == \"audio\":\n",
" print(\"快递查询助理生成的音频播放地址:\", ev.detail[\"audio\"])"
]
},
{
"cell_type": "markdown",
"id": "3e462991dab3283d",
"metadata": {
"collapsed": false
},
"source": [
"## 2. 植物识别小助手\n",
"[<span style=\"font-size:1.3em;\">植物识别小助手</span>](https://appbuilder.baidu.com/s/50zyD)一键体验\n",
"\n",
"### 2.1 Console端应用配置与发布\n",
"1 进入[百度智能云千帆AppBuilder官网](https://cloud.baidu.com/product/AppBuilder),配置智能体指令、选择相应的工具组件、发布应用\n",
"<img src=\"./app_builder_resources/plant_recog_assistant.png\" alt=\"drawing\" width=\"1200\"/>\n",
"\n",
"2 获取应用ID, 同1.1\n",
"\n",
"### 2.2 SDK代码调用示例"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4d051395a2aa1d11",
"metadata": {
"collapsed": false,
"is_executing": true
},
"outputs": [],
"source": [
"import os\n",
"import appbuilder\n",
"\n",
"# 注意以下示例正确运行依赖的条件包括:\n",
"# 1. 在百度智能云千帆AppBuilder官网使用AppBuilderClient创建应用且应用已发布\n",
"# 2. 密钥正确有效\n",
"# 3. 密钥需要与发布的应用正确对应,即需要使用发布应用的账户下的密钥\n",
"\n",
"# 配置密钥与应用ID\n",
"os.environ[\"APPBUILDER_TOKEN\"] =\"...\"\n",
"app_id = \"7016e0d3-451b-4a47-a818-dc0a16d4b496\" \n",
"\n",
"# 初始化Agent实例\n",
"builder = appbuilder.AppBuilderClient(app_id)\n",
"\n",
"# 创建会话ID\n",
"conversation_id = builder.create_conversation()\n",
"\n",
"# 上传植物图片\n",
"file_id = builder.upload_local_file(conversation_id, \"./app_builder_resources/tree.png\" )\n",
"\n",
"# 植物识别\n",
"msg = builder.run(conversation_id, \"请识别图中的植物类别\", file_ids=[file_id])\n",
"print(\"植物识别助理回答内容:\", msg.content.answer)"
]
},
{
"cell_type": "markdown",
"id": "c112f09d6ce35d10",
"metadata": {
"collapsed": false
},
"source": [
"## 3. 篮球教练\n",
"[<span style=\"font-size:1.3em;\">篮球教练知识增强检索</span>](https://appbuilder.baidu.com/s/RCVEn)一键体验\n",
"\n",
"### 3.1 Console端应用配置与发布\n",
"1 进入[百度智能云千帆AppBuilder官网](https://cloud.baidu.com/product/AppBuilder),配置智能体指令、上传文档并关联知识库、发布应用\n",
"<img src=\"./app_builder_resources/agent_builder_rag.png\" alt=\"drawing\" width=\"1200\"/>\n",
"\n",
"2 获取应用ID, 同1.1\n",
"\n",
"### 3.2 SDK代码调用示例"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "65e488aa883cf94e",
"metadata": {
"collapsed": false,
"is_executing": true
},
"outputs": [],
"source": [
"import os\n",
"import appbuilder\n",
"\n",
"# 注意以下示例正确运行依赖的条件包括:\n",
"# 1. 在百度智能云千帆AppBuilder官网使用AppBuilderClient创建应用且应用已发布\n",
"# 2. 密钥正确有效\n",
"# 3. 密钥需要与发布的应用正确对应,即需要使用发布应用的账户下的密钥\n",
"\n",
"# 配置密钥与应用ID\n",
"os.environ[\"APPBUILDER_TOKEN\"] =\"...\"\n",
"app_id = \"4316a7cb-b6b2-4448-b6fa-ff131c484ec9\" \n",
"\n",
"# 初始化Agent实例\n",
"builder = appbuilder.AppBuilderClient(app_id)\n",
"\n",
"# 创建会话ID\n",
"conversation_id = builder.create_conversation()\n",
"\n",
"# 执行对话\n",
"msg = builder.run(conversation_id, \"突破技巧中如何运用胯下变向?\", )\n",
"print(\"篮球教练回答内容:\", msg.content.answer)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.8"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"\n",
"示例描述:`你是一个尽职尽责的客服问答助手。你有多个产品使用说明书,根据说明书上的内容回答用户的使用问题。`\n",
"\n",
"<img src=\"./qa_system/magic_instruction.png\" alt=\"drawing\" width=\"1000\"/>\n",
"<img src=\"./qa_system/magic_instruction.jpg\" alt=\"drawing\" width=\"1000\"/>\n",
"\n",
"生成结果示例:\n",
"\n",
Expand Down Expand Up @@ -178,7 +178,7 @@
],
"source": [
"# 初始化Agent实例\n",
"agent = appbuilder.AgentBuilder(app_id)\n",
"agent = appbuilder.AppBuilderClient(app_id)\n",
"\n",
"# 创建会话ID\n",
"conversation_id = agent.create_conversation()\n",
Expand Down
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 66aa389

Please sign in to comment.