by baidubce
Provides a client SDK for building AI‑native applications on Baidu Cloud, enabling model calls, component orchestration, knowledge‑base management, workflow composition, monitoring, and flexible deployment options.
AppBuilder SDK equips developers with a unified Python (and Java/Go) client to create, orchestrate, and deploy AI‑native applications. It abstracts large‑model invocation, Baidu ecosystem components, knowledge‑base operations, and workflow management, allowing rapid prototyping of RAG, agent, and tool‑call solutions.
python3 -m pip install --upgrade appbuilder-sdk
.APPBUILDER_TOKEN
with your Baidu API key.appbuilder
and leverage built‑in classes such as Playground
, RagWithBaiduSearchPro
, AppBuilderClient
, KnowledgeBase
, and AgentRuntime
.Message
, Component
, and AgentRuntime
objects, or integrate with external frameworks like LangChain or Flask.appbuilder_bce_deploy
tool for public cloud endpoints.Message
, Component
, AgentRuntime
) for building complex agents and pipelines.appbuilder_bce_deploy
.Q: Which Python versions are supported? A: Python 3.9 and above.
Q: How do I obtain the required token?
A: Generate an API key from Baidu Cloud console and set APPBUILDER_TOKEN
.
Q: Can I use the SDK with other languages? A: Yes, Java and Go versions are provided, and Docker images are available for containerized usage.
Q: How is deployment handled?
A: Use AgentRuntime
with Flask/gunicorn for API services, Chainlit for interactive UI, or appbuilder_bce_deploy
for one‑click public cloud deployment.
Q: Is there built‑in support for tracing and debugging? A: The SDK includes visual tracing dashboards and detailed debug logs to monitor component execution and token usage.
百度智能云千帆AppBuilder-SDK是百度智能云千帆AppBuilder面向AI原生应用开发者提供的一站式开发平台的客户端SDK。
百度智能云千帆AppBuilder-SDK提供了以下AI应用开发者的必备功能:
RAG
应用Message
、Component
、AgentRuntime
多级工作流抽象,实现工作流编排,并可与LangChain、OpenAI等业界生态能力打通AgentRuntime
支持部署为基于Flask
与gunicorn
的API服务AgentRuntime
支持部署为基于Chainlit
的对话框交互前端appbuilder_bce_deploy
工具,可快速部署程序到百度云,提供公网API服务,联动AppBuilder工作流AppBuilder-SDK提供多类型组件,覆盖以下构建产业级RAG
应用的完整步骤:
AppBuilder-SDK不仅提供了百度智能云提供的基础能力组件,同时提供经过深度优化的大模型高级能力组件,可以组合下表提供的原子能力组件,构建个性化的RAG应用RAG 原子能力 CookBook:
阶段 | 组件名称 | 组件类型 | 组件链接 |
---|---|---|---|
文档解析 | 文档矫正增强 (DocCropEnhance) | 基础能力组件 | 链接 |
文档解析 | 文档格式转换 (DocFormatConverter) | 基础能力组件 | 链接 |
文档解析 | 文档解析(DocParser) | 基础能力组件 | 链接 |
文档解析 | 表格抽取组件(ExtractTableFromDoc) | 基础能力组件 | 链接 |
文档解析 | 通用文字识别-高精度版(GeneralOCR) | 基础能力组件 | 链接 |
文档切片 | 文档切分(DocSplitter) | 基础能力组件 | 链接 |
切片向量化 | 向量计算(Embedding) | 基础能力组件 | 链接 |
索引构建及切片召回 | 向量检索-VectorDB(BaiduVectorDBRetriever) | 基础能力组件 | 链接 |
索引构建及切片召回 | 向量检索-BES(BaiduElasticSearchRetriever) | 基础能力组件 | 链接 |
文档切片及答案生成 | 问答对挖掘(QAPairMining) | 高级能力组件 | 链接 |
文档切片及答案生成 | 相似问生成(SimilarQuestion) | 高级能力组件 | 链接 |
答案生成 | 标签抽取(TagExtraction) | 高级能力组件 | 链接 |
答案生成 | 复杂Query判定(IsComplexQuery) | 高级能力组件 | 链接 |
答案生成 | 复杂Query分解(QueryDecomposition) | 高级能力组件 | 链接 |
答案生成 | 多轮改写 (QueryRewrite) | 高级能力组件 | 链接 |
答案生成 | 阅读理解问答(MRC) | 高级能力组件 | 链接 |
答案生成 | 幻觉检测(Hallucination Detection) | 高级能力组件 | 链接 |
百度智能云千帆AppBuilder-SDK 更新记录&最新特性请查阅我们的版本说明
Python
版本安装,要求Python版本 >= 3.9
python3 -m pip install --upgrade appbuilder-sdk
Java
及 Go
版本安装,以及通过Docker
镜像使用,请查阅安装说明
- 请在
>=3.9
的Python环境安装appbuilder-sdk
后使用该端到端应用示例- 示例中使用请替换为您的个人Token
Playground
组件可自由调用,您在百度智能云千帆大模型平台有权限的任何模型,并可自定义prompt
模板 与 模型参数import appbuilder
import os
# 设置环境中的TOKEN,请替换为您的个人TOKEN
os.environ["APPBUILDER_TOKEN"] = "your api key"
# 定义prompt模板
template_str = "你扮演{role}, 请回答我的问题。\n\n问题:{question}。\n\n回答:"
# 定义输入,调用playground组件
input = appbuilder.Message({"role": "java工程师", "question": "请简要回答java语言的内存回收机制是什么,要求100字以内"})
playground = appbuilder.Playground(prompt_template=template_str, model="Qianfan-Agent-Speed-8K")
# 以打字机的方式,流式展示大模型回答内容
output = playground(input, stream=True, temperature=1e-10)
for stream_message in output.content:
print(stream_message)
# 流式输出结束后,可再次打印完整的大模型对话结果,除回答内容外,还包括token的用量情况
print(output.model_dump_json(indent=4))
Java语言的
内存回收机制是通过垃圾回收器(Garbage Collector)来实现的。
垃圾回收器会自动检测不再使用的对象,并释放其占用的内存空间,从而确保系统的内存不会被耗尽。
Java提供了多种垃圾回收器,如串行回收器、并行回收器、CMS回收器和G1回收器等,以满足不同场景下的性能需求
。
{
"content": "Java语言的内存回收机制是通过垃圾回收器(Garbage Collector)来实现的。垃圾回收器会自动检测不再使用的对象,并释放其占用的内存空间,从而确保系统的内存不会被耗尽。Java提供了多种垃圾回收器,如串行回收器、并行回收器、CMS回收器和G1回收器等,以满足不同场景下的性能需求。",
"name": "msg",
"mtype": "dict",
"id": "2bbee989-40e3-45e4-9802-e144cdc829a9",
"extra": {},
"token_usage": {
"prompt_tokens": 35,
"completion_tokens": 70,
"total_tokens": 105
}
}
RAG with Baidu Search增强版
, 结合百度搜索的搜索引擎技术和ERNIE模型的语义理解能力,可以更准确地理解用户的搜索意图,并提供与搜索查询相关性更高的搜索结果import appbuilder
import os
# 设置环境中的TOKEN,使用请替换为您的个人TOKEN
os.environ["APPBUILDER_TOKEN"] = "your api key"
rag_with_baidu_search_pro = appbuilder.RagWithBaiduSearchPro(model="ERNIE-3.5-8K")
input = appbuilder.Message("9.11和9.8哪个大")
result = rag_with_baidu_search_pro.run(
message=input,
instruction=appbuilder.Message("你是专业知识助手"))
# 输出运行结果
print(result.model_dump_json(indent=4))
{
"content": "9.11小于9.8。在比较两个小数的大小时,需要逐位比较它们的数值,包括整数部分和小数部分。对于9.11和9.8,整数部分都是9,所以需要在小数部分进行比较。小数点后的第一位是1和8,显然1小于8,所以9.11小于9.8。",
"name": "msg",
"mtype": "dict",
"id": "eb31b7de-dd6a-485f-adb9-1f7921a6f4bf",
"extra": {
"search_baidu": [
{
"content": "大模型‘智商’受质疑:9.11 vs 9...",
"icon": "https://appbuilder.bj.bcebos.com/baidu-search-rag-pro/icon/souhu.ico",
"url": "https://m.sohu.com/a/793754123_121924584/",
"ref_id": "2",
"site_name": "搜狐网",
"title": "大模型‘智商’受质疑:9.11 vs 9.8的比较揭示AI理解能力的..."
},
{
"content": "究竟|9.11比9.8大?大模型们为何会...",
"icon": "https://appbuilder.bj.bcebos.com/baidu-search-rag-pro/icon/tencent.svg.png",
"url": "https://new.qq.com/rain/a/20240717A07JLV00",
"ref_id": "4",
"site_name": "腾讯网",
"title": "究竟|9.11比9.8大?大模型们为何会在小学数学题上集体..."
},
...
]
},
"token_usage": {
"completion_tokens": 77,
"prompt_tokens": 2008,
"total_tokens": 2085
}
}
import appbuilder
import os
# 设置环境中的TOKEN,请替换为您的个人TOKEN
os.environ["APPBUILDER_TOKEN"] = "your api key"
# 从AppBuilder网页获取并传入应用ID,以下为说唱导师应用ID
app_id = "4678492a-5864-472e-810a-654538d3503c"
app_builder_client = appbuilder.AppBuilderClient(app_id)
conversation_id = app_builder_client.create_conversation()
answer = app_builder_client.run(conversation_id, "以“上班狼狈却又追逐梦想“为主题进行一首说唱创作,保持押韵, 控制在200字以内")
print(answer.content.answer)
好的,我们来以“上班狼狈却又追逐梦想”为主题,进行一段简短的说唱创作。这里是一个简单的示例,你可以根据自己的感觉进行调整:
Intro:
朝九晚五,生活重压,
狼狈上班,却心怀梦想,
每一天,都是新的挑战,
为了那未来,我奋发向前。
Verse 1:
穿上西装,打好领带,
步入人群,去追逐名利,
虽然狼狈,却不曾言败,
因为心中,有梦想在激励。
Hook:
上班狼狈,却不曾放弃,
追逐梦想,是我心中的火炬,
照亮前路,指引我前行,
无论多难,我都要坚持到底。
这首小曲儿以“上班狼狈却又追逐梦想”为主题,通过押韵的方式表达了上班族虽然生活艰辛,但依然怀揣梦想,勇往直前的精神。希望你喜欢!
应用类型 | 应用链接 | 推荐理由 |
---|---|---|
基础能力组件 | 通用文字识别 | 体验百度AI开放平台提供的通用文字识别-高精度版的精准识别结果 |
基础能力组件 | 基础组件服务化 | 基础组件可通过flask实现服务化部署 或 通过chainlit实现可交互的前端部署,集成到您的系统中 |
流程编排 | Assistant SDK | 学习如何纯代码态搭建一个Agent应用,并实现自定义工作流程及FunctionCall |
端到端应用 | AppBuilder Client SDK | 使用AppBuilder网页端创建并发布一个Agent应用后,通过AppBuilderClient SDK集成到你的系统中 |
端到端应用 | Agent应用-工作流Agent | 使用AppBuilder网页端创建并发布一个工作流Agent应用后,通过AppBuilderClient SDK集成到你的系统中 |
端到端应用 | 通过AppBuilder-ToolCall功能实现端云组件联动的Agent | 学习Agent、FunctionCall的知识,并构造调用本地组件的Agent |
端到端应用 | 简历筛选小助手 | 通过对本地简历库的简历进行解析、切片、创建索引,实现基于JD进行简历筛选,并对筛选的Top1简历进行总结 |
端到端应用 | 企业级问答系统 | 学习如何通过SDK与网页平台搭配,实现离线知识库生产与在线问答 |
进阶应用 | 使用appbuilder_bce_deploy部署公有云服务 | 一键将自己的服务部署到百度智能云,部署后可以自动生成公网ip,联动工作流的API节点 |
进阶应用 | 使用appbuilder_trace_server实现对使用状态的跟踪 | 使用Appbuilder-SDK Trace功能实现对组件、应用调用情况的追踪 |
Github Issue: 提交安装/使用问题、报告bug、建议新特性、沟通开发计划等
AppBuilder-SDK遵循Apache-2.0开源协议。
Please log in to share your review and rating for this MCP.
Explore related MCPs that share similar capabilities and solve comparable challenges
by modelcontextprotocol
An MCP server implementation that provides a tool for dynamic and reflective problem-solving through a structured thinking process.
by danny-avila
Provides a self‑hosted ChatGPT‑style interface supporting numerous AI models, agents, code interpreter, image generation, multimodal interactions, and secure multi‑user authentication.
by block
Automates engineering tasks on local machines, executing code, building projects, debugging, orchestrating workflows, and interacting with external APIs using any LLM.
by RooCodeInc
Provides an autonomous AI coding partner inside the editor that can understand natural language, manipulate files, run commands, browse the web, and be customized via modes and instructions.
by pydantic
A Python framework that enables seamless integration of Pydantic validation with large language models, providing type‑safe agent construction, dependency injection, and structured output handling.
by lastmile-ai
Build effective agents using Model Context Protocol and simple, composable workflow patterns.
by mcp-use
A Python SDK that simplifies interaction with MCP servers and enables developers to create custom agents with tool‑calling capabilities.
by nanbingxyz
A cross‑platform desktop AI assistant that connects to major LLM providers, supports a local knowledge base, and enables tool integration via MCP servers.
by gptme
Provides a personal AI assistant that runs directly in the terminal, capable of executing code, manipulating files, browsing the web, using vision, and interfacing with various LLM providers.