baidubce / app-builder Goto Github PK
View Code? Open in Web Editor NEWappbuilder-sdk, 千帆AppBuilder-SDK帮助开发者灵活、快速的搭建AI原生应用
Home Page: https://appbuilder.cloud.baidu.com/
License: Apache License 2.0
appbuilder-sdk, 千帆AppBuilder-SDK帮助开发者灵活、快速的搭建AI原生应用
Home Page: https://appbuilder.cloud.baidu.com/
License: Apache License 2.0
使用的是txt文本文档
设置的参数如下
splitter = DocSplitter(splitter_type="split_by_chunk", max_segment_length=50, overlap=0,
separators=["。", "!", "?", ".", "!", "?", "……", "|\n", "\\n", "\n", ";"])
最终返回结果始终只有一段,且超过设置的50字
当前appbuilder依赖了一个非常早期的pydantic版本(https://github.com/baidubce/app-builder/blob/master/requirements.txt#L3 )
当前很多三方组件不兼容此版本,建议升级到2.x版本。
使用打包pyinstaller死活打不进去appbuilder
文档解析在使用手册中是免费使用的,但我使用示例代码进行文档解析,返回权限错误。这是什么原因呢?而我使用同样的API KEY进行TTS是可以正常返回结果的。
以下是具体报错信息:
Traceback (most recent call last):
File "/home/yxliu56/code/work/app-builder/docprase.py", line 42, in
parse_result = parser(msg, return_raw=True)
File "/home/yxliu56/code/work/app-builder/appbuilder/core/component.py", line 94, in call
return self.run(*inputs, **kwargs)
File "/home/yxliu56/code/work/app-builder/appbuilder/core/components/doc_parser/doc_parser.py", line 126, in run
self.check_response_header(response)
File "/home/yxliu56/code/work/app-builder/appbuilder/core/component.py", line 149, in check_response_header
raise BaseRPCException(message)
appbuilder.core._exception.BaseRPCException: request_id=30d05399-ea69-4b10-93be-0dcebb70e255 , http status code is 401, body is {"requestId":"30d05399-ea69-4b10-93be-0dcebb70e255","code":216003,"message":"Authentication error: ( Unsupported authorization header type )"}
以下是我的调用代码
`import os
os.environ["APPBUILDER_TOKEN"] = "我的百度apikey,是复制的SDK密钥中的API KEY"
from appbuilder.core.components.doc_parser.doc_parser import DocParser
from appbuilder.core.components.doc_splitter.doc_splitter import DocSplitter
from appbuilder.core.message import Message
file_path = "text.pptx" # 待解析的文件路径
msg = Message(file_path)
parser = DocParser()
parse_result = parser(msg)
print(parse_result.content)`
你好,请问是否有langchain适配appbuilder接口的示例呢?由于appbuilder和百度其它模型调用方式不同,似乎目前的langchain.community中的QianfanChatEndpoint无法直接使用?
import appbuilder
import os
# 设置环境中的TOKEN,以下TOKEN为访问和QPS受限的试用TOKEN,正式使用请替换为您的个人TOKEN
os.environ["APPBUILDER_TOKEN"] = "bce-v3/ALTAK-n5AYUIUJMarF7F7iFXVeK/1bf65eed7c8c7efef9b11388524fa1087f90ea58"
# 从AppBuilder网页获取并传入应用ID,以下为地理小达人应用ID
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, "**的首都在哪里?春季天气怎么样?有什么适合玩的景点?")
print(answer.content)
输出:
c:\ATemp>python test.py
Traceback (most recent call last):
File "c:\ATemp\test.py", line 2, in
import appbuilder
File "C:\Python39\lib\site-packages\appbuilder_init_.py", line 60, in
from .core.components.rag_with_baidu_search_pro import RagWithBaiduSearchPro
File "C:\Python39\lib\site-packages\appbuilder\core\components\rag_with_baidu_search_pro_init_.py", line 20, in
from .component import RagWithBaiduSearchPro
File "C:\Python39\lib\site-packages\appbuilder\core\components\rag_with_baidu_search_pro\component.py", line 21, in
from appbuilder.core.components.rag_with_baidu_search_pro.parse_rag_pro_response import ParseRagProResponse
File "C:\Python39\lib\site-packages\appbuilder\core\components\rag_with_baidu_search_pro\parse_rag_pro_response.py", line 16, in
from appbuilder.core.components.llms.base import CompletionResponse
File "C:\Python39\lib\site-packages\appbuilder\core\components\llms\base.py", line 69, in
class ModelArgsConfig(BaseModel):
File "C:\Python39\lib\site-packages\appbuilder\core\components\llms\base.py", line 71, in ModelArgsConfig
temperature: confloat(gt=0.0, le=1.0) = Field(default=1e-10, description="模型的温度参数,范围从 0.0 到 1.0。")
File "C:\Python39\lib\site-packages\pydantic\types.py", line 475, in confloat
annotated_types.Interval(gt=gt, ge=ge, lt=lt, le=le),
TypeError: Interval() takes no arguments
GBI是否可以引用知识库检索进行问题的优化
期望:百度云正式登陆环境
import appbuilder
os.environ["APPBUILDER_TOKEN"] = "bce-YOURTOKEN"
print(appbuilder.show_model_list())
期望结果
当前可以使用的模型列表如下:
Erniebot4-8k
Llama2-13b
...
针对需要RAG原子能力的典型客户,提供一个能快速找到相关能力的页面
ERNIE Speed-AppBuilder用不了,ERNIE-Bot 4.0调用太慢,ERNIE-Bot和ERNIE-Bot-turbo效果差,所以GBI什么时候能升级一下
目前千帆推出了很多API来操作appbuilder,是否有计划实现自定义ui,打造自己专属的agent应用?
像调用MB一样直接调用大模型,需要playground组件给个例子来说明。
代码实现上述选项,应该传哪个值?
查看以了以下代码,没有找到头绪:
class CustomProcessRule(BaseModel):
separators: list[str] = Field(..., description="分段符号列表", example=[",", "?"])
target_length: int = Field(..., description="分段最大长度", ge=300, le=1200)
overlap_rate: float = Field(
..., description="分段重叠最大字数占比,推荐值0.25", ge=0, le=0.3, example=0.2
)
class DocumentChunker(BaseModel):
choices: list[str] = Field(..., description="选择项") # 这里有个枚举值吗?
prependInfo: list[str] = Field(
...,
description="chunker关联元数据,可选值为title (增加标题), filename(增加文件名)",
)
separator: Optional[DocumentSeparator] = Field(..., description="分段符号")
pattern: Optional[DocumentPattern] = Field(None, description="正则表达式")
class MRC(CompletionBaseComponent):
"""
阅读理解问答组件,基于大模型进行阅读理解问答,支持拒答、澄清、重点强调、友好性提升、溯源等多种功能,可用于回答用户提出的问题。
Examples:
.. code-block:: python
import appbuilder
os.environ["APPBUILDER_TOKEN"] = '...'
mrc_component = appbuilder.MRC()
# 获取功能说明
instructions = mrc_component.get_instruction_set()
# 输出功能说明
for key, value in instructions.items():
print(f"{key}: {value}")
# 模拟运行MRC组件,开启澄清和友好性提升功能
result = mrc_component.run(appbuilder.Message("什么是人工智能?"), clarify=True, friendly=True)
# 输出运行结果
print(result)
目前版本SDK导入Excel模板文档会将其当作普通文档进行处理,从AppBuilder控制台上传就是正常的处理方式,请问什么时候可以支持该功能
instruction为None时会报错,需要设置个值。
from appbuilder import RagWithBaiduSearchPro
from appbuilder import Message
tool = RagWithBaiduSearchPro(model="ERNIE-Bot")
result = tool.run(Message(query), stream=False, instruction=Message(""))
/home/bjadks/.conda/envs/rag/lib/python3.10/site-packages/appbuilder/core/constants.py
AppBuilderClientAnswer(answer='由于工具执行失败,我无法直接读取音频文件内容。', events=[Event(code=0, message='', status='running', event_type='ChatAgent', content_type='text', detail={'text': '由于工具执行失败,我无法直接读取音频文件内容。'}, usage=Usage(prompt_tokens=370, completion_tokens=2, total_tokens=372, name='ERNIE Speed-AppBuilder'))])
当前面向开发者提供开放的数据结构,包括Message和Component,方便开发者融入个人已有的大模型应用程序。此部分仍在不断建设中。
消息(Message)
构建大模型应用的统一数据结构,基于Pydantic构建,在不同的Component之间流动。Message几类的默认字段是content,类型是Any。
https://github.com/baidubce/app-builder/blob/master/cookbooks/console_rag.ipynb
appbuilder.core._exception.AppBuilderServerException: request_id=3a2f2a81-d557-47d1-96f7-9aa6c13330c7, code=1039, message=应用服务已下线,请前往应用中心创建新应用(跳转URL:https://console.bce.baidu.com/ai_apaas/appCenter), service_err_code=, service_err_message=
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.