From 8f45a5d432df2d1cf072b94468513e891c8ea290 Mon Sep 17 00:00:00 2001 From: Chengmo Date: Fri, 27 Dec 2024 19:27:07 -0800 Subject: [PATCH 1/3] add base code (#691) Co-authored-by: chengmo --- python/core/component.py | 7 +++++ python/tests/test_component_is_async.py | 37 +++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 python/tests/test_component_is_async.py diff --git a/python/core/component.py b/python/core/component.py index 5628ed9f..b62d9262 100644 --- a/python/core/component.py +++ b/python/core/component.py @@ -236,6 +236,13 @@ def set_secret_key_and_gateway(self, secret_key: Optional[str] = None, gateway: """ self.secret_key = secret_key self.gateway = gateway + # 因为子类可能重载init方法,导致没有is_async属性,所以此处需要判断一下 + try: + self.is_async + except AttributeError: + # 目前async仅在AppBuilderClient中使用,所以没有async属性的组件都可以设置为False + self.is_async = False + if self.is_async: self._http_client = AsyncHTTPClient(self.secret_key, self.gateway) else: diff --git a/python/tests/test_component_is_async.py b/python/tests/test_component_is_async.py new file mode 100644 index 00000000..c7bfb8fa --- /dev/null +++ b/python/tests/test_component_is_async.py @@ -0,0 +1,37 @@ +# Copyright (c) 2024 Baidu, Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +import json +import os +import unittest +from appbuilder.core.component import Component + +class MockComponent(Component): + + def __init__(self, *args, **kwargs): + pass + + def tool_eval(self, *args, **kwargs): + print("Success") + + +class TestComponentInit(unittest.TestCase): + def test_component_init(self): + component = MockComponent() + os.environ["APPBUILDER_TOKEN"] = "abc" + component.set_secret_key_and_gateway() + component.tool_eval() + +if __name__ == '__main__': + unittest.main() + From 09a112c9065dfe3c4f39855eff947def3f46d0bc Mon Sep 17 00:00:00 2001 From: C9luster <138663536+C9luster@users.noreply.github.com> Date: Thu, 2 Jan 2025 10:21:01 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=9B=B4=E6=96=B0SDK=E6=A8=A1=E5=9E=8B?= =?UTF-8?q?=E5=90=8D=E7=A7=B0=20(#696)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 更新SDK模型名称 * 更新update * update --------- Co-authored-by: yinjiaqi --- README.md | 2 +- cookbooks/components/agent_runtime.ipynb | 2 +- cookbooks/components/rag_with_baidusearch.ipynb | 4 ++-- cookbooks/components/text_generation.ipynb | 8 ++++---- cookbooks/end2end_application/rag/rag.ipynb | 4 ++-- docs/BasisModule/Components/gbi/nl2sql/README.md | 2 +- .../BasisModule/Components/gbi/select_table/README.md | 2 +- .../Components/llms/dialog_summary/README.md | 2 +- .../Components/llms/hallucination_detection/README.md | 6 +++--- .../Components/llms/is_complex_query/README.md | 4 ++-- docs/BasisModule/Components/llms/mrc/README.md | 6 +++--- docs/BasisModule/Components/llms/nl2pandas/README.md | 2 +- .../Components/llms/oral_query_generation/README.md | 6 +++--- docs/BasisModule/Components/llms/playground/README.md | 2 +- .../Components/llms/qa_pair_mining/README.md | 4 ++-- .../Components/llms/query_decomposition/README.md | 4 ++-- .../Components/llms/query_rewrite/README.md | 2 +- .../Components/llms/similar_question/README.md | 2 +- .../Components/llms/style_rewrite/README.md | 2 +- .../Components/llms/style_writing/README.md | 2 +- .../Components/llms/tag_extraction/README.md | 2 +- .../Components/rag_with_baidu_search/README.md | 4 ++-- .../Components/rag_with_baidu_search_pro/README.md | 4 ++-- docs/BasisModule/Deployment/agentruntime.md | 2 +- docs/DevelopGuide/HowToContributeCode/README.md | 4 ++-- .../README.md | 8 ++++---- .../StartFirstAINativeApplication/README.md | 8 ++++---- docs/README_en.md | 2 +- docs/README_ja.md | 2 +- python/core/agent.py | 2 +- python/core/components/gbi/nl2sql/README.md | 2 +- python/core/components/gbi/nl2sql/component.py | 2 +- python/core/components/gbi/select_table/README.md | 2 +- python/core/components/gbi/select_table/component.py | 2 +- python/core/components/llms/dialog_summary/README.md | 2 +- .../core/components/llms/dialog_summary/component.py | 2 +- .../components/llms/hallucination_detection/README.md | 6 +++--- .../llms/hallucination_detection/component.py | 4 ++-- .../core/components/llms/is_complex_query/README.md | 4 ++-- .../components/llms/is_complex_query/component.py | 2 +- python/core/components/llms/mrc/README.md | 6 +++--- python/core/components/llms/nl2pandas/README.md | 2 +- python/core/components/llms/nl2pandas/component.py | 2 +- .../components/llms/oral_query_generation/README.md | 6 +++--- .../llms/oral_query_generation/component.py | 6 +++--- python/core/components/llms/playground/README.md | 2 +- python/core/components/llms/playground/component.py | 2 +- python/core/components/llms/qa_pair_mining/README.md | 4 ++-- .../core/components/llms/qa_pair_mining/component.py | 2 +- .../components/llms/query_decomposition/README.md | 4 ++-- .../components/llms/query_decomposition/component.py | 2 +- python/core/components/llms/query_rewrite/README.md | 2 +- .../core/components/llms/query_rewrite/component.py | 2 +- .../core/components/llms/similar_question/README.md | 2 +- .../components/llms/similar_question/component.py | 2 +- python/core/components/llms/style_rewrite/README.md | 2 +- .../core/components/llms/style_rewrite/component.py | 2 +- python/core/components/llms/style_writing/README.md | 2 +- .../core/components/llms/style_writing/component.py | 2 +- python/core/components/llms/tag_extraction/README.md | 2 +- .../core/components/llms/tag_extraction/component.py | 2 +- .../core/components/rag_with_baidu_search/README.md | 4 ++-- .../components/rag_with_baidu_search_pro/README.md | 4 ++-- .../v2/llms/hallucination_detection/component.py | 4 ++-- .../v2/llms/oral_query_generation/component.py | 4 ++-- .../components/v2/llms/similar_question/component.py | 2 +- .../components/v2/llms/style_rewrite/component.py | 2 +- .../components/v2/llms/style_writing/component.py | 2 +- python/tests/component_tool_eval_cases.py | 11 ++++++++++- python/tests/test_appbuilder_sentry_trace_on.py | 6 +++--- python/tests/test_rag_baidu_search.py | 2 +- python/tests/test_v2_component_trace.py | 2 +- python/tests/test_v2_hallucination_detection.py | 2 +- python/tests/test_v2_oral_query_generat.py | 2 +- python/tests/test_v2_similar_question.py | 2 +- python/tests/test_v2_style_rewrite.py | 2 +- python/utils/model_util.py | 4 ++-- 77 files changed, 128 insertions(+), 119 deletions(-) diff --git a/README.md b/README.md index ef7addf9..28cef058 100644 --- a/README.md +++ b/README.md @@ -111,7 +111,7 @@ template_str = "你扮演{role}, 请回答我的问题。\n\n问题:{question} # 定义输入,调用playground组件 input = appbuilder.Message({"role": "java工程师", "question": "请简要回答java语言的内存回收机制是什么,要求100字以内"}) -playground = appbuilder.Playground(prompt_template=template_str, model="Qianfan-Agent-Speed-8k") +playground = appbuilder.Playground(prompt_template=template_str, model="Qianfan-Agent-Speed-8K") # 以打字机的方式,流式展示大模型回答内容 output = playground(input, stream=True, temperature=1e-10) diff --git a/cookbooks/components/agent_runtime.ipynb b/cookbooks/components/agent_runtime.ipynb index b222c6e2..bb73547e 100644 --- a/cookbooks/components/agent_runtime.ipynb +++ b/cookbooks/components/agent_runtime.ipynb @@ -429,7 +429,7 @@ "class PlaygroundWithHistory(Component):\n", " def __init__(self):\n", " super().__init__()\n", - " self.query_rewrite = QueryRewrite(model=\"Qianfan-Agent-Speed-8k\")\n", + " self.query_rewrite = QueryRewrite(model=\"Qianfan-Agent-Speed-8K\")\n", " self.playground = Playground(\n", " prompt_template=\"{query}\",\n", " model=\"ERNIE-Bot\"\n", diff --git a/cookbooks/components/rag_with_baidusearch.ipynb b/cookbooks/components/rag_with_baidusearch.ipynb index 477729bc..0fafa836 100644 --- a/cookbooks/components/rag_with_baidusearch.ipynb +++ b/cookbooks/components/rag_with_baidusearch.ipynb @@ -82,8 +82,8 @@ "friendly = False # 友好度提升\n", "cite = True # 溯源\n", "\n", - "# 使用 Qianfan-Agent-Speed-8k 模型\n", - "component = appbuilder.RAGWithBaiduSearch(model=\"Qianfan-Agent-Speed-8k\")\n", + "# 使用 Qianfan-Agent-Speed-8K 模型\n", + "component = appbuilder.RAGWithBaiduSearch(model=\"Qianfan-Agent-Speed-8K\")\n", "query = appbuilder.Message(\"海淀区的面积是多少\")\n", "\n", "answer = component.run(\n", diff --git a/cookbooks/components/text_generation.ipynb b/cookbooks/components/text_generation.ipynb index 17b2319c..84fdf10a 100644 --- a/cookbooks/components/text_generation.ipynb +++ b/cookbooks/components/text_generation.ipynb @@ -101,7 +101,7 @@ "商品信息:\n", "'''\n", "# 创建商品信息生成组件\n", - "product_information_generation = Playground(prompt_template=prompt_template, model='Qianfan-Agent-Speed-8k')\n", + "product_information_generation = Playground(prompt_template=prompt_template, model='Qianfan-Agent-Speed-8K')\n", "\n", "# 获取商品信息\n", "# 填充prompt_template参数的参数映射表,需要与prompt_template对应\n", @@ -152,7 +152,7 @@ "from appbuilder import QAPairMining\n", "\n", "# 初始化问答对生成组件\n", - "qa_pair_mining = QAPairMining(model='Qianfan-Agent-Speed-8k')\n", + "qa_pair_mining = QAPairMining(model='Qianfan-Agent-Speed-8K')\n", "\n", "# 获取问答对\n", "response = qa_pair_mining(Message(product_information), stream=False, temperature=1e-10)\n", @@ -210,7 +210,7 @@ "'''\n", "\n", "# 初始化风格写作组件\n", - "style_writing = StyleWriting(model='Qianfan-Agent-Speed-8k')\n", + "style_writing = StyleWriting(model='Qianfan-Agent-Speed-8K')\n", "\n", "# 获取小红书文案\n", "response = style_writing(Message(query), style_query='小红书', length=300)\n", @@ -260,7 +260,7 @@ "from appbuilder import TagExtraction\n", "\n", "# 初始化标签抽取组件\n", - "tag_extraction = TagExtraction(model='Qianfan-Agent-Speed-8k')\n", + "tag_extraction = TagExtraction(model='Qianfan-Agent-Speed-8K')\n", "\n", "# 获取标签\n", "response = tag_extraction(Message(copywriting), stream=False, temperature=1e-10)\n", diff --git a/cookbooks/end2end_application/rag/rag.ipynb b/cookbooks/end2end_application/rag/rag.ipynb index 3eef0c47..6d25e230 100644 --- a/cookbooks/end2end_application/rag/rag.ipynb +++ b/cookbooks/end2end_application/rag/rag.ipynb @@ -171,7 +171,7 @@ "具备团队协作精神,能够与团队成员有效沟通,共同推进项目进展。'''\n", "\n", "# 标签抽取的组件\n", - "tagger = appbuilder.TagExtraction(model=\"Qianfan-Agent-Speed-8k\")\n", + "tagger = appbuilder.TagExtraction(model=\"Qianfan-Agent-Speed-8K\")\n", "\n", "# 从JD抽取标签并打印\n", "tags = tagger(appbuilder.Message(job_desc))\n", @@ -234,7 +234,7 @@ "\n", "play = appbuilder.Playground(\n", " prompt_template=\"基于候选人姓名、职责描述和简历内容,概括一下{name}的推荐理由。\\n候选人姓名: {name}\\n职责描述: {JD}\\n简历内容: {resume}\\n推荐理由: \",\n", - " model=\"Qianfan-Agent-Speed-8k\"\n", + " model=\"Qianfan-Agent-Speed-8K\"\n", ")\n", "\n", "resume_summary = play(appbuilder.Message({\"JD\": job_desc, \"name\": sorted_resumes[0][0], \"resume\": \"\\n\".join(list(resume_content[sorted_resumes[0][0]]))}))\n", diff --git a/docs/BasisModule/Components/gbi/nl2sql/README.md b/docs/BasisModule/Components/gbi/nl2sql/README.md index 050a9fca..7156bfce 100644 --- a/docs/BasisModule/Components/gbi/nl2sql/README.md +++ b/docs/BasisModule/Components/gbi/nl2sql/README.md @@ -59,7 +59,7 @@ print(f"llm result: {nl2sql_result_message.content.llm_result}") ## 参数说明 ### 初始化参数 -- model_name: 支持的模型名字 ERNIE-Bot 4.0, ERNIE-Bot, ERNIE-Bot-turbo, Qianfan-Agent-Speed-8k +- model_name: 支持的模型名字 ERNIE-Bot 4.0, ERNIE-Bot, ERNIE-Bot-turbo, Qianfan-Agent-Speed-8K - table_schemas: 表的 schema,例如: ``` diff --git a/docs/BasisModule/Components/gbi/select_table/README.md b/docs/BasisModule/Components/gbi/select_table/README.md index 4d173b79..3146a304 100644 --- a/docs/BasisModule/Components/gbi/select_table/README.md +++ b/docs/BasisModule/Components/gbi/select_table/README.md @@ -51,7 +51,7 @@ print(f"选的表是: {select_table_result_message.content}") ## 参数说明 ### 初始化参数 -- model_name: 支持的模型名字 ERNIE-Bot 4.0, ERNIE-Bot, ERNIE-Bot-turbo, Qianfan-Agent-Speed-8k +- model_name: 支持的模型名字 ERNIE-Bot 4.0, ERNIE-Bot, ERNIE-Bot-turbo, Qianfan-Agent-Speed-8K - table_descriptions: 表的描述是个字典,key: 是表的名字, value: 是表的描述,例如: ``` diff --git a/docs/BasisModule/Components/llms/dialog_summary/README.md b/docs/BasisModule/Components/llms/dialog_summary/README.md index 2ef9b066..95dfeb14 100644 --- a/docs/BasisModule/Components/llms/dialog_summary/README.md +++ b/docs/BasisModule/Components/llms/dialog_summary/README.md @@ -23,7 +23,7 @@ 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"] = "bce-YOURTOKEN" -dialog_summary = appbuilder.DialogSummary("Qianfan-Agent-Speed-8k") +dialog_summary = appbuilder.DialogSummary("Qianfan-Agent-Speed-8K") text = "用户:喂我想查一下我的话费\n坐席:好的女士您话费余的话还有87.49元钱\n用户:好的知道了谢谢\n坐席:嗯不客气祝您生活愉快再见" answer = dialog_summary(appbuilder.Message(text)) print(answer) diff --git a/docs/BasisModule/Components/llms/hallucination_detection/README.md b/docs/BasisModule/Components/llms/hallucination_detection/README.md index 528cb681..541fd019 100644 --- a/docs/BasisModule/Components/llms/hallucination_detection/README.md +++ b/docs/BasisModule/Components/llms/hallucination_detection/README.md @@ -37,8 +37,8 @@ context = \ 很多怕胖的女生看到猪皮就怕怕,但其实猪皮含有大量胶原蛋白,营养价值很高呢!这里红通通的猪皮还经过韩国秘制酱汁处理过,会有一点点辣味。烤猪皮的时候也需特别注意火侯,这样吃起来才会有外脆内Q的口感!''' answer = '澳门新麻蒲烤肉店并不是每天开门。' -#! 该组件推荐使用Qianfan-Agent-Speed-8k模型。 -hallucination_detection = appbuilder.HallucinationDetection('Qianfan-Agent-Speed-8k') +#! 该组件推荐使用Qianfan-Agent-Speed-8K模型。 +hallucination_detection = appbuilder.HallucinationDetection('Qianfan-Agent-Speed-8K') inputs = {'query': query, 'context': context, 'answer': answer} msg = appbuilder.Message(inputs) result = hallucination_detection.run(msg) @@ -58,7 +58,7 @@ os.environ["APPBUILDER_TOKEN"] = "bce-YOURTOKEN" ### 初始化参数 | 参数名称 | 参数类型 | 是否必须 | 描述 | 示例值 | | ------- | ------- | -------- | -------- | -------- | -| `model` | str | 是 | 模型名称,用于指定要使用的千帆模型。推荐使用Qianfan-Agent-Speed-8k模型。 | Qianfan-Agent-Speed-8k | +| `model` | str | 是 | 模型名称,用于指定要使用的千帆模型。推荐使用Qianfan-Agent-Speed-8K模型。 | Qianfan-Agent-Speed-8K | | `secret_key` | str | 否 | 用户鉴权token,默认从环境变量中获取: `os.getenv("APPBUILDER_TOKEN", "")` | bce-v3/XXX | | `gateway` | str | 否 | 后端网关服务地址,默认从环境变量中获取: `os.getenv("GATEWAY_URL", "")` | https://appbuilder.baidu.com | | `lazy_certification` | bool | 否 | 延迟认证,为True时在第一次运行时认证。默认为False。 | False | diff --git a/docs/BasisModule/Components/llms/is_complex_query/README.md b/docs/BasisModule/Components/llms/is_complex_query/README.md index a3bab947..c14a252a 100644 --- a/docs/BasisModule/Components/llms/is_complex_query/README.md +++ b/docs/BasisModule/Components/llms/is_complex_query/README.md @@ -21,7 +21,7 @@ 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"] = "..." -is_complex_query = appbuilder.IsComplexQuery(model="Qianfan-Agent-Speed-8k") +is_complex_query = appbuilder.IsComplexQuery(model="Qianfan-Agent-Speed-8K") msg = "吸塑包装盒在工业化生产和物流运输中分别有什么重要性?" msg = appbuilder.Message(msg) @@ -42,7 +42,7 @@ os.environ["APPBUILDER_TOKEN"] = "bce-YOURTOKEN" ### 初始化参数 |参数名称 |参数类型 |是否必须 |描述 |示例值| |--------|--------|--------|----|------| -|model |str |是 |模型名称,用于指定要使用的千帆模型|Qianfan-Agent-Speed-8k| +|model |str |是 |模型名称,用于指定要使用的千帆模型|Qianfan-Agent-Speed-8K| ### 调用参数 |参数名称 |参数类型 |是否必须 |描述 |示例值| diff --git a/docs/BasisModule/Components/llms/mrc/README.md b/docs/BasisModule/Components/llms/mrc/README.md index eaf152be..19da449d 100644 --- a/docs/BasisModule/Components/llms/mrc/README.md +++ b/docs/BasisModule/Components/llms/mrc/README.md @@ -9,7 +9,7 @@ MRC(阅读理解问答模块)是一项先进的自然语言处理功能, ### 特色优势 我们的MRC模块,基于百度自研的先进语言模型文新一言,提供了一系列强大的阅读理解问答功能。在保持文本理解和问题回答的高精度的同时, 我们特别强调了答案的质量和交互体验。以下是我们MRC模块的几个主要功能特色: - - 1.多版本模型支持:我们的MRC模块包括不同版本的文新一言大模型,Erniebot 4.0、Qianfan-Agent-Speed-8k等,每个版本都针对特定的应用场景进行了优化。 用户可以根据自己的需求选择最适合的模型版本,以获得最佳的性能。 + - 1.多版本模型支持:我们的MRC模块包括不同版本的文新一言大模型,Erniebot 4.0、Qianfan-Agent-Speed-8K等,每个版本都针对特定的应用场景进行了优化。 用户可以根据自己的需求选择最适合的模型版本,以获得最佳的性能。 - 2.答案格式的多样性: - 拒答功能:当问题超出模型知识范围或不具体时,模型可以选择不回答,避免提供误导性信息。 - 澄清功能:对于模棱两可或含糊的问题,模型可以请求更多信息或对问题进行澄清,以确保答案的准确性。 @@ -41,7 +41,7 @@ import os os.environ["APPBUILDER_TOKEN"] = "..." # 创建MRC对象 -mrc_component = appbuilder.MRC(model="Qianfan-Agent-Speed-8k") +mrc_component = appbuilder.MRC(model="Qianfan-Agent-Speed-8K") # 初始化参数 msg = "残疾人怎么办相关证件" @@ -119,7 +119,7 @@ import os os.environ["APPBUILDER_TOKEN"] = '...' # 创建MRC对象 -mrc_component = appbuilder.MRC(model="Qianfan-Agent-Speed-8k") +mrc_component = appbuilder.MRC(model="Qianfan-Agent-Speed-8K") # 初始化参数 msg = "残疾人怎么办相关证件" diff --git a/docs/BasisModule/Components/llms/nl2pandas/README.md b/docs/BasisModule/Components/llms/nl2pandas/README.md index a6828200..a107b4f7 100644 --- a/docs/BasisModule/Components/llms/nl2pandas/README.md +++ b/docs/BasisModule/Components/llms/nl2pandas/README.md @@ -30,7 +30,7 @@ query = "海淀区有哪些学校" query = appbuilder.Message(query) #定义并运行Nl2pandas实例,得到结果 -nl2pandas = appbuilder.Nl2pandasComponent(model="Qianfan-Agent-Speed-8k") +nl2pandas = appbuilder.Nl2pandasComponent(model="Qianfan-Agent-Speed-8K") answer = nl2pandas(query, table_info = table_info) ``` diff --git a/docs/BasisModule/Components/llms/oral_query_generation/README.md b/docs/BasisModule/Components/llms/oral_query_generation/README.md index 4a796b11..b64b8ada 100644 --- a/docs/BasisModule/Components/llms/oral_query_generation/README.md +++ b/docs/BasisModule/Components/llms/oral_query_generation/README.md @@ -28,8 +28,8 @@ text = ('文档标题:在OPPO Reno5上使用视频超级防抖\n' '防抖后手机屏幕将出现超级防抖Pro开关,点击即可开启或关闭。 除此之外,前置视频同样加持防抖算法,边走边拍也能稳定聚焦脸部' ',实时视频分享您的生活。') -#! 该组件推荐使用Qianfan-Agent-Speed-8k模型。 -oral_query_generation = appbuilder.OralQueryGeneration(model='Qianfan-Agent-Speed-8k') +#! 该组件推荐使用Qianfan-Agent-Speed-8K模型。 +oral_query_generation = appbuilder.OralQueryGeneration(model='Qianfan-Agent-Speed-8K') result = oral_query_generation(appbuilder.Message(text), query_type='全部', output_format='str') print(result) @@ -47,7 +47,7 @@ os.environ["APPBUILDER_TOKEN"] = "bce-YOURTOKEN" | 参数名称 | 参数类型 | 是否必须 | 描述 | 示例值 | | ------- | ------- | -------- | -------- | -------- | -| `model` | str | 是 | 模型名称,用于指定要使用的千帆模型。推荐使用Qianfan-Agent-Speed-8k模型。 | Qianfan-Agent-Speed-8k | +| `model` | str | 是 | 模型名称,用于指定要使用的千帆模型。推荐使用Qianfan-Agent-Speed-8K模型。 | Qianfan-Agent-Speed-8K | | `secret_key` | str | 否 | 用户鉴权token,默认从环境变量中获取: `os.getenv("APPBUILDER_TOKEN", "")` | bce-v3/XXX | | `gateway` | str | 否 | 后端网关服务地址,默认从环境变量中获取: `os.getenv("GATEWAY_URL", "")` | https://appbuilder.baidu.com | | `lazy_certification` | bool | 否 | 延迟认证,为True时在第一次运行时认证。默认为False。 | False | diff --git a/docs/BasisModule/Components/llms/playground/README.md b/docs/BasisModule/Components/llms/playground/README.md index 73c59859..ad3baaf7 100644 --- a/docs/BasisModule/Components/llms/playground/README.md +++ b/docs/BasisModule/Components/llms/playground/README.md @@ -26,7 +26,7 @@ os.environ["APPBUILDER_TOKEN"] = "..." play = appbuilder.Playground( prompt_template="你好,{name},我是{bot_name},{bot_name}是一个{bot_type},我可以{bot_function},你可以问我{bot_question}。", - model="Qianfan-Agent-Speed-8k" + model="Qianfan-Agent-Speed-8K" ) play(appbuilder.Message({"name": "小明", "bot_name": "小红", "bot_type": "聊天机器人", "bot_function": "聊天", "bot_question": "你好吗?"}), stream=False) ``` diff --git a/docs/BasisModule/Components/llms/qa_pair_mining/README.md b/docs/BasisModule/Components/llms/qa_pair_mining/README.md index 8fcfa6e5..f1c00c82 100644 --- a/docs/BasisModule/Components/llms/qa_pair_mining/README.md +++ b/docs/BasisModule/Components/llms/qa_pair_mining/README.md @@ -23,7 +23,7 @@ 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"] = "..." -qa_mining = appbuilder.QAPairMining(model="Qianfan-Agent-Speed-8k") +qa_mining = appbuilder.QAPairMining(model="Qianfan-Agent-Speed-8K") # 输入文本(对此文本挖掘问答对) msg = '2017年,工商银行根据外部宏观环境变化,及时调整业务策略,优化资产负债结构,' + \ '保持存贷款业务协调发展,提升资产负债配置效率。' + \ @@ -110,7 +110,7 @@ split_result = splitter(parse_result) # 每个段落抽取问答对,并返回结果 for doc_segment in split_result.content["paragraphs"]: - qa_mining = QAPairMining(model="Qianfan-Agent-Speed-8k") + qa_mining = QAPairMining(model="Qianfan-Agent-Speed-8K") text = doc_segment.get("text", "") if text == "": logger.error("Text is null. break") diff --git a/docs/BasisModule/Components/llms/query_decomposition/README.md b/docs/BasisModule/Components/llms/query_decomposition/README.md index d1b7f06b..2629c103 100644 --- a/docs/BasisModule/Components/llms/query_decomposition/README.md +++ b/docs/BasisModule/Components/llms/query_decomposition/README.md @@ -21,7 +21,7 @@ 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"] = "..." -query_decomposition = appbuilder.QueryDecomposition(model="Qianfan-Agent-Speed-8k") +query_decomposition = appbuilder.QueryDecomposition(model="Qianfan-Agent-Speed-8K") msg = "吸塑包装盒在工业化生产和物流运输中分别有什么重要性?" msg = appbuilder.Message(msg) @@ -42,7 +42,7 @@ os.environ["APPBUILDER_TOKEN"] = "bce-YOURTOKEN" ### 初始化参数 |参数名称 |参数类型 |是否必须 |描述 |示例值| |--------|--------|--------|----|------| -|model |str |是 |模型名称,用于指定要使用的千帆模型|Qianfan-Agent-Speed-8k| +|model |str |是 |模型名称,用于指定要使用的千帆模型|Qianfan-Agent-Speed-8K| ### 调用参数 |参数名称 |参数类型 |是否必须 |描述 |示例值| diff --git a/docs/BasisModule/Components/llms/query_rewrite/README.md b/docs/BasisModule/Components/llms/query_rewrite/README.md index ca568cf0..9e951413 100644 --- a/docs/BasisModule/Components/llms/query_rewrite/README.md +++ b/docs/BasisModule/Components/llms/query_rewrite/README.md @@ -24,7 +24,7 @@ import appbuilder os.environ["APPBUILDER_TOKEN"] = '...' # 初始化并使用 QueryRewrite 组件 -query_rewrite = appbuilder.QueryRewrite(model="Qianfan-Agent-Speed-8k") +query_rewrite = appbuilder.QueryRewrite(model="Qianfan-Agent-Speed-8K") answer = query_rewrite(appbuilder.Message(['我应该怎么办理护照?', '您可以查询官网或人工咨询', '我需要准备哪些材料?', '身份证、免冠照片一张以及填写完整的《中国公民因私出国(境)申请表》', '在哪里办']), rewrite_type="带机器人回复") print(answer) ``` diff --git a/docs/BasisModule/Components/llms/similar_question/README.md b/docs/BasisModule/Components/llms/similar_question/README.md index ca5b1129..4a7db172 100644 --- a/docs/BasisModule/Components/llms/similar_question/README.md +++ b/docs/BasisModule/Components/llms/similar_question/README.md @@ -23,7 +23,7 @@ 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"] = "..." -similar_question = appbuilder.SimilarQuestion(model="Qianfan-Agent-Speed-8k") +similar_question = appbuilder.SimilarQuestion(model="Qianfan-Agent-Speed-8K") msg = "我想吃冰淇淋,哪里的冰淇淋比较好吃?" msg = appbuilder.Message(msg) diff --git a/docs/BasisModule/Components/llms/style_rewrite/README.md b/docs/BasisModule/Components/llms/style_rewrite/README.md index f694e376..ff482a92 100644 --- a/docs/BasisModule/Components/llms/style_rewrite/README.md +++ b/docs/BasisModule/Components/llms/style_rewrite/README.md @@ -33,7 +33,7 @@ import appbuilder os.environ["APPBUILDER_TOKEN"] = "..." # 初始化并使用 StyleRewrite 组件 -style_rewrite = appbuilder.StyleRewrite(model="Qianfan-Agent-Speed-8k") +style_rewrite = appbuilder.StyleRewrite(model="Qianfan-Agent-Speed-8K") answer = style_rewrite(appbuilder.Message("文心大模型发布新版"), style="激励话术") ``` diff --git a/docs/BasisModule/Components/llms/style_writing/README.md b/docs/BasisModule/Components/llms/style_writing/README.md index 9ae42933..c5d07f1e 100644 --- a/docs/BasisModule/Components/llms/style_writing/README.md +++ b/docs/BasisModule/Components/llms/style_writing/README.md @@ -26,7 +26,7 @@ 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"] = "..." -model = "Qianfan-Agent-Speed-8k" +model = "Qianfan-Agent-Speed-8K" style_writing = appbuilder.StyleWriting(model) query = "帮我写一篇关于人体工学椅的文案" diff --git a/docs/BasisModule/Components/llms/tag_extraction/README.md b/docs/BasisModule/Components/llms/tag_extraction/README.md index 313541a7..8d84f3fc 100644 --- a/docs/BasisModule/Components/llms/tag_extraction/README.md +++ b/docs/BasisModule/Components/llms/tag_extraction/README.md @@ -31,7 +31,7 @@ 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"] = '...' -tag_extraction = appbuilder.TagExtraction(model="Qianfan-Agent-Speed-8k") +tag_extraction = appbuilder.TagExtraction(model="Qianfan-Agent-Speed-8K") result = tag_extraction(appbuilder.Message("从这段文本中抽取关键标签")) ``` diff --git a/docs/BasisModule/Components/rag_with_baidu_search/README.md b/docs/BasisModule/Components/rag_with_baidu_search/README.md index 8196d888..a6df5e05 100644 --- a/docs/BasisModule/Components/rag_with_baidu_search/README.md +++ b/docs/BasisModule/Components/rag_with_baidu_search/README.md @@ -38,7 +38,7 @@ import os os.environ["APPBUILDER_TOKEN"] = '...' # 创建rag_with_baidusearch对象 -rag_with_baidusearch_component = appbuilder.RAGWithBaiduSearch(model="Qianfan-Agent-Speed-8k") +rag_with_baidusearch_component = appbuilder.RAGWithBaiduSearch(model="Qianfan-Agent-Speed-8K") # 运行rag_with_baidusearch基本组件 msg = appbuilder.Message("残疾人怎么办相关证件") @@ -111,7 +111,7 @@ os.environ["APPBUILDER_TOKEN"] = '...' # 创建rag_with_baidusearch对象, 并初始化人设指令 rag_with_baidusearch_component = appbuilder.RAGWithBaiduSearch( - model="Qianfan-Agent-Speed-8k", + model="Qianfan-Agent-Speed-8K", instruction=appbuilder.Message("你是问答助手,在回答问题前需要加上: 很高兴为您解答")) diff --git a/docs/BasisModule/Components/rag_with_baidu_search_pro/README.md b/docs/BasisModule/Components/rag_with_baidu_search_pro/README.md index 816a26c8..245db73a 100644 --- a/docs/BasisModule/Components/rag_with_baidu_search_pro/README.md +++ b/docs/BasisModule/Components/rag_with_baidu_search_pro/README.md @@ -26,7 +26,7 @@ import os os.environ["APPBUILDER_TOKEN"] = '...' # 创建rag_with_baidusearch_pro对象 -rag_with_baidu_search_pro = appbuilder.RagWithBaiduSearchPro(model="Qianfan-Agent-Speed-8k") +rag_with_baidu_search_pro = appbuilder.RagWithBaiduSearchPro(model="Qianfan-Agent-Speed-8K") # 运行rag_with_baidusearch基本组件 msg = appbuilder.Message("残疾人怎么办相关证件") @@ -88,7 +88,7 @@ os.environ["APPBUILDER_TOKEN"] = '...' # 创建rag_with_baidusearch对象, 并初始化人设指令 rag_with_baidusearch_pro = appbuilder.RagWithBaiduSearchPro( - model="Qianfan-Agent-Speed-8k", + model="Qianfan-Agent-Speed-8K", instruction=appbuilder.Message("你是问答助手,在回答问题前需要加上: 很高兴为您解答")) diff --git a/docs/BasisModule/Deployment/agentruntime.md b/docs/BasisModule/Deployment/agentruntime.md index 84759e5f..decf0296 100644 --- a/docs/BasisModule/Deployment/agentruntime.md +++ b/docs/BasisModule/Deployment/agentruntime.md @@ -120,7 +120,7 @@ os.environ["APPBUILDER_TOKEN"] = 'YOUR_APPBUILDER_TOKEN' class PlaygroundWithHistory(Component): def __init__(self): super().__init__() - self.query_rewrite = QueryRewrite(model="Qianfan-Agent-Speed-8k") + self.query_rewrite = QueryRewrite(model="Qianfan-Agent-Speed-8K") self.play = Playground( prompt_template="{query}", model="eb-4" diff --git a/docs/DevelopGuide/HowToContributeCode/README.md b/docs/DevelopGuide/HowToContributeCode/README.md index 46433c91..89304664 100644 --- a/docs/DevelopGuide/HowToContributeCode/README.md +++ b/docs/DevelopGuide/HowToContributeCode/README.md @@ -51,7 +51,7 @@ class SimilarQuestion(CompletionBaseComponent): os.environ["APPBUILDER_TOKEN"] = "..." - qa_mining = appbuilder.SimilarQuestion(model="Qianfan-Agent-Speed-8k") + qa_mining = appbuilder.SimilarQuestion(model="Qianfan-Agent-Speed-8K") msg = "我想吃冰淇淋,哪里的冰淇淋比较好吃?" msg = appbuilder.Message(msg) @@ -150,7 +150,7 @@ class SimilarQuestion(CompletionBaseComponent): os.environ["APPBUILDER_TOKEN"] = "..." - qa_mining = appbuilder.SimilarQuestion(model="Qianfan-Agent-Speed-8k") + qa_mining = appbuilder.SimilarQuestion(model="Qianfan-Agent-Speed-8K") msg = "我想吃冰淇淋,哪里的冰淇淋比较好吃?" msg = appbuilder.Message(msg) diff --git a/docs/QuickStart/ExamplesOfIndustrialPracticeApplications/README.md b/docs/QuickStart/ExamplesOfIndustrialPracticeApplications/README.md index 431f2446..6174398a 100644 --- a/docs/QuickStart/ExamplesOfIndustrialPracticeApplications/README.md +++ b/docs/QuickStart/ExamplesOfIndustrialPracticeApplications/README.md @@ -38,7 +38,7 @@ ERNIE-Bot 4.0, ERNIE-Bot, ERNIE-3.5-4K-0205, ERNIE-3.5-8K-0205, ERNIE-3.5-8K-122 | ERNIE-Bot | eb | | ERNIE-Bot-turbo | eb-turbo | | EB-turbo-AppBuilder专用版 | ernie_speed_appbuilder | -| Qianfan-Agent-Speed-8k | ernie_speed_appbuilder | +| Qianfan-Agent-Speed-8K | ernie_speed_appbuilder | @@ -52,7 +52,7 @@ os.environ["APPBUILDER_TOKEN"] = "bce-v3/ALTAK-n5AYUIUJMarF7F7iFXVeK/1bf65eed7c8 # 空模版组件 template_str = "你扮演{role}, 请回答我的问题。\n\n问题:{question}。\n\n回答:" -playground = appbuilder.Playground(prompt_template=template_str, model="Qianfan-Agent-Speed-8k") +playground = appbuilder.Playground(prompt_template=template_str, model="Qianfan-Agent-Speed-8K") # 定义输入,调用空模版组件 input = appbuilder.Message({"role": "java工程师", "question": "java语言的内存回收机制是什么"}) @@ -69,7 +69,7 @@ import os os.environ["APPBUILDER_TOKEN"] = "bce-v3/ALTAK-n5AYUIUJMarF7F7iFXVeK/1bf65eed7c8c7efef9b11388524fa1087f90ea58" # 相似问生成组件 -similar_q = appbuilder.SimilarQuestion(model="Qianfan-Agent-Speed-8k") +similar_q = appbuilder.SimilarQuestion(model="Qianfan-Agent-Speed-8K") # 定义输入,调用相似问生成 input = appbuilder.Message("我想吃冰淇淋,哪里的冰淇淋比较好吃?") @@ -114,7 +114,7 @@ import appbuilder # 空模版组件 playground = appbuilder.Playground( prompt_template="{query}", - model="Qianfan-Agent-Speed-8k" + model="Qianfan-Agent-Speed-8K" ) # 使用 AgentRuntime 来服务化playground组件 diff --git a/docs/QuickStart/StartFirstAINativeApplication/README.md b/docs/QuickStart/StartFirstAINativeApplication/README.md index 9da4edee..7d75e55b 100644 --- a/docs/QuickStart/StartFirstAINativeApplication/README.md +++ b/docs/QuickStart/StartFirstAINativeApplication/README.md @@ -42,7 +42,7 @@ ERNIE-Bot 4.0, ERNIE-Bot, ERNIE-3.5-4K-0205, ERNIE-3.5-8K-0205, ERNIE-3.5-8K-122 | ERNIE-Bot | eb | | ERNIE-Bot-turbo | eb-turbo | | EB-turbo-AppBuilder专用版 | ernie_speed_appbuilder | -| Qianfan-Agent-Speed-8k | ernie_speed_appbuilder | +| Qianfan-Agent-Speed-8K | ernie_speed_appbuilder | @@ -56,7 +56,7 @@ os.environ["APPBUILDER_TOKEN"] = "bce-v3/ALTAK-n5AYUIUJMarF7F7iFXVeK/1bf65eed7c8 # 空模版组件 template_str = "你扮演{role}, 请回答我的问题。\n\n问题:{question}。\n\n回答:" -playground = appbuilder.Playground(prompt_template=template_str, model="Qianfan-Agent-Speed-8k") +playground = appbuilder.Playground(prompt_template=template_str, model="Qianfan-Agent-Speed-8K") # 定义输入,调用空模版组件 input = appbuilder.Message({"role": "java工程师", "question": "java语言的内存回收机制是什么"}) @@ -73,7 +73,7 @@ import os os.environ["APPBUILDER_TOKEN"] = "bce-v3/ALTAK-n5AYUIUJMarF7F7iFXVeK/1bf65eed7c8c7efef9b11388524fa1087f90ea58" # 相似问生成组件 -similar_q = appbuilder.SimilarQuestion(model="Qianfan-Agent-Speed-8k") +similar_q = appbuilder.SimilarQuestion(model="Qianfan-Agent-Speed-8K") # 定义输入,调用相似问生成 input = appbuilder.Message("我想吃冰淇淋,哪里的冰淇淋比较好吃?") @@ -118,7 +118,7 @@ import appbuilder # 空模版组件 playground = appbuilder.Playground( prompt_template="{query}", - model="Qianfan-Agent-Speed-8k" + model="Qianfan-Agent-Speed-8K" ) # 使用 AgentRuntime 来服务化playground组件 diff --git a/docs/README_en.md b/docs/README_en.md index 88a1a559..13cd91ce 100644 --- a/docs/README_en.md +++ b/docs/README_en.md @@ -82,7 +82,7 @@ template_str = "你扮演{role}, 请回答我的问题。\n\n问题:{question} # 定义输入,调用playground组件 input = appbuilder.Message({"role": "java工程师", "question": "请简要回答java语言的内存回收机制是什么,要求100字以内"}) -playground = appbuilder.Playground(prompt_template=template_str, model="Qianfan-Agent-Speed-8k") +playground = appbuilder.Playground(prompt_template=template_str, model="Qianfan-Agent-Speed-8K") # 以打字机的方式,流式展示大模型回答内容 output = playground(input, stream=True, temperature=1e-10) diff --git a/docs/README_ja.md b/docs/README_ja.md index 54c2eca3..2df5b7e0 100644 --- a/docs/README_ja.md +++ b/docs/README_ja.md @@ -79,7 +79,7 @@ template_str = "あなたは{role}の役割を果たします。私の質問に # 入力を定義し、playgroundコンポーネントを呼び出します。 input = appbuilder.Message({"role": "Javaエンジニア", "question": "Java言語のメモリ回収メカニズムについて簡単に説明してください。100文字以内でお願いします。"}) -playground = appbuilder.Playground(prompt_template=template_str, model="Qianfan-Agent-Speed-8k") +playground = appbuilder.Playground(prompt_template=template_str, model="Qianfan-Agent-Speed-8K") # タイプライターのように、ストリーム形式で大規模モデルの回答内容を表示します。 output = playground(input, stream=True, temperature=1e-10) diff --git a/python/core/agent.py b/python/core/agent.py index d6d1df80..fbc0ad41 100644 --- a/python/core/agent.py +++ b/python/core/agent.py @@ -108,7 +108,7 @@ class AgentRuntime(BaseModel): class PlaygroundWithHistory(Component): def __init__(self): super().__init__() - self.query_rewrite = QueryRewrite(model="Qianfan-Agent-Speed-8k") + self.query_rewrite = QueryRewrite(model="Qianfan-Agent-Speed-8K") self.play = Playground( prompt_template="{query}", model="eb-4" diff --git a/python/core/components/gbi/nl2sql/README.md b/python/core/components/gbi/nl2sql/README.md index 050a9fca..7156bfce 100644 --- a/python/core/components/gbi/nl2sql/README.md +++ b/python/core/components/gbi/nl2sql/README.md @@ -59,7 +59,7 @@ print(f"llm result: {nl2sql_result_message.content.llm_result}") ## 参数说明 ### 初始化参数 -- model_name: 支持的模型名字 ERNIE-Bot 4.0, ERNIE-Bot, ERNIE-Bot-turbo, Qianfan-Agent-Speed-8k +- model_name: 支持的模型名字 ERNIE-Bot 4.0, ERNIE-Bot, ERNIE-Bot-turbo, Qianfan-Agent-Speed-8K - table_schemas: 表的 schema,例如: ``` diff --git a/python/core/components/gbi/nl2sql/component.py b/python/core/components/gbi/nl2sql/component.py index 9d3d6c70..32f73038 100644 --- a/python/core/components/gbi/nl2sql/component.py +++ b/python/core/components/gbi/nl2sql/component.py @@ -38,7 +38,7 @@ def __init__(self, model_name: str, table_schemas: List[str], knowledge: Dict = 创建 gbi nl2sql 对象 Args: - model_name: 支持的模型名字 ERNIE-Bot 4.0, ERNIE-Bot, ERNIE-Bot-turbo, Qianfan-Agent-Speed-8k + model_name: 支持的模型名字 ERNIE-Bot 4.0, ERNIE-Bot, ERNIE-Bot-turbo, Qianfan-Agent-Speed-8K table_schemas: 表的 schema 列表,例如: ``` CREATE TABLE `mytable` ( `d_year` COMMENT '年度,2019,2020..2022..', diff --git a/python/core/components/gbi/select_table/README.md b/python/core/components/gbi/select_table/README.md index 4d173b79..3146a304 100644 --- a/python/core/components/gbi/select_table/README.md +++ b/python/core/components/gbi/select_table/README.md @@ -51,7 +51,7 @@ print(f"选的表是: {select_table_result_message.content}") ## 参数说明 ### 初始化参数 -- model_name: 支持的模型名字 ERNIE-Bot 4.0, ERNIE-Bot, ERNIE-Bot-turbo, Qianfan-Agent-Speed-8k +- model_name: 支持的模型名字 ERNIE-Bot 4.0, ERNIE-Bot, ERNIE-Bot-turbo, Qianfan-Agent-Speed-8K - table_descriptions: 表的描述是个字典,key: 是表的名字, value: 是表的描述,例如: ``` diff --git a/python/core/components/gbi/select_table/component.py b/python/core/components/gbi/select_table/component.py index ceb4cdca..fc710a69 100644 --- a/python/core/components/gbi/select_table/component.py +++ b/python/core/components/gbi/select_table/component.py @@ -36,7 +36,7 @@ def __init__(self, model_name: str, table_descriptions: Dict[str, str], 创建 GBI 选表对象 Args: - model_name: 支持的模型名字 ERNIE-Bot 4.0, ERNIE-Bot, ERNIE-Bot-turbo, Qianfan-Agent-Speed-8k + model_name: 支持的模型名字 ERNIE-Bot 4.0, ERNIE-Bot, ERNIE-Bot-turbo, Qianfan-Agent-Speed-8K table_descriptions: 表的描述是个字典,key: 是表的名字, value: 是表的描述,例如: { "超市营收明细表": "超市营收明细表,包含超市各种信息等", diff --git a/python/core/components/llms/dialog_summary/README.md b/python/core/components/llms/dialog_summary/README.md index 2ef9b066..95dfeb14 100644 --- a/python/core/components/llms/dialog_summary/README.md +++ b/python/core/components/llms/dialog_summary/README.md @@ -23,7 +23,7 @@ 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"] = "bce-YOURTOKEN" -dialog_summary = appbuilder.DialogSummary("Qianfan-Agent-Speed-8k") +dialog_summary = appbuilder.DialogSummary("Qianfan-Agent-Speed-8K") text = "用户:喂我想查一下我的话费\n坐席:好的女士您话费余的话还有87.49元钱\n用户:好的知道了谢谢\n坐席:嗯不客气祝您生活愉快再见" answer = dialog_summary(appbuilder.Message(text)) print(answer) diff --git a/python/core/components/llms/dialog_summary/component.py b/python/core/components/llms/dialog_summary/component.py index 6b5b62d8..125bc61d 100644 --- a/python/core/components/llms/dialog_summary/component.py +++ b/python/core/components/llms/dialog_summary/component.py @@ -32,7 +32,7 @@ class DialogSummary(CompletionBaseComponent): # 请前往千帆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"] = '...' - dialog_summary = appbuilder.DialogSummary("Qianfan-Agent-Speed-8k") + dialog_summary = appbuilder.DialogSummary("Qianfan-Agent-Speed-8K") text = "用户:喂我想查一下我的话费\n坐席:好的女士您话费余的话还有87.49元钱\n用户:好的知道了谢谢\n坐席:嗯不客气祝您生活愉快再见" answer = dialog_summary(appbuilder.Message(text)) print(answer) diff --git a/python/core/components/llms/hallucination_detection/README.md b/python/core/components/llms/hallucination_detection/README.md index 528cb681..541fd019 100644 --- a/python/core/components/llms/hallucination_detection/README.md +++ b/python/core/components/llms/hallucination_detection/README.md @@ -37,8 +37,8 @@ context = \ 很多怕胖的女生看到猪皮就怕怕,但其实猪皮含有大量胶原蛋白,营养价值很高呢!这里红通通的猪皮还经过韩国秘制酱汁处理过,会有一点点辣味。烤猪皮的时候也需特别注意火侯,这样吃起来才会有外脆内Q的口感!''' answer = '澳门新麻蒲烤肉店并不是每天开门。' -#! 该组件推荐使用Qianfan-Agent-Speed-8k模型。 -hallucination_detection = appbuilder.HallucinationDetection('Qianfan-Agent-Speed-8k') +#! 该组件推荐使用Qianfan-Agent-Speed-8K模型。 +hallucination_detection = appbuilder.HallucinationDetection('Qianfan-Agent-Speed-8K') inputs = {'query': query, 'context': context, 'answer': answer} msg = appbuilder.Message(inputs) result = hallucination_detection.run(msg) @@ -58,7 +58,7 @@ os.environ["APPBUILDER_TOKEN"] = "bce-YOURTOKEN" ### 初始化参数 | 参数名称 | 参数类型 | 是否必须 | 描述 | 示例值 | | ------- | ------- | -------- | -------- | -------- | -| `model` | str | 是 | 模型名称,用于指定要使用的千帆模型。推荐使用Qianfan-Agent-Speed-8k模型。 | Qianfan-Agent-Speed-8k | +| `model` | str | 是 | 模型名称,用于指定要使用的千帆模型。推荐使用Qianfan-Agent-Speed-8K模型。 | Qianfan-Agent-Speed-8K | | `secret_key` | str | 否 | 用户鉴权token,默认从环境变量中获取: `os.getenv("APPBUILDER_TOKEN", "")` | bce-v3/XXX | | `gateway` | str | 否 | 后端网关服务地址,默认从环境变量中获取: `os.getenv("GATEWAY_URL", "")` | https://appbuilder.baidu.com | | `lazy_certification` | bool | 否 | 延迟认证,为True时在第一次运行时认证。默认为False。 | False | diff --git a/python/core/components/llms/hallucination_detection/component.py b/python/core/components/llms/hallucination_detection/component.py index afd53c20..fcc47de1 100644 --- a/python/core/components/llms/hallucination_detection/component.py +++ b/python/core/components/llms/hallucination_detection/component.py @@ -26,7 +26,7 @@ class HallucinationDetection(CompletionBaseComponent): """ 幻觉检测。输入,判断answer中是否存在幻觉。 - *注:该组件推荐使用Qianfan-Agent-Speed-8k模型。* + *注:该组件推荐使用Qianfan-Agent-Speed-8K模型。* Examples: @@ -103,7 +103,7 @@ def __init__( """初始化幻觉检测组件。 Args: - model (str|None): 模型名称,用于指定要使用的千帆模型。推荐使用Qianfan-Agent-Speed-8k模型。 + model (str|None): 模型名称,用于指定要使用的千帆模型。推荐使用Qianfan-Agent-Speed-8K模型。 secret_key (str, 可选): 用户鉴权token, 默认从环境变量中获取: os.getenv("APPBUILDER_TOKEN", ""). gateway (str, 可选): 后端网关服务地址,默认从环境变量中获取: os.getenv("GATEWAY_URL", "") lazy_certification (bool, 可选): 延迟认证,为True时在第一次运行时认证. Defaults to False. diff --git a/python/core/components/llms/is_complex_query/README.md b/python/core/components/llms/is_complex_query/README.md index a3bab947..c14a252a 100644 --- a/python/core/components/llms/is_complex_query/README.md +++ b/python/core/components/llms/is_complex_query/README.md @@ -21,7 +21,7 @@ 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"] = "..." -is_complex_query = appbuilder.IsComplexQuery(model="Qianfan-Agent-Speed-8k") +is_complex_query = appbuilder.IsComplexQuery(model="Qianfan-Agent-Speed-8K") msg = "吸塑包装盒在工业化生产和物流运输中分别有什么重要性?" msg = appbuilder.Message(msg) @@ -42,7 +42,7 @@ os.environ["APPBUILDER_TOKEN"] = "bce-YOURTOKEN" ### 初始化参数 |参数名称 |参数类型 |是否必须 |描述 |示例值| |--------|--------|--------|----|------| -|model |str |是 |模型名称,用于指定要使用的千帆模型|Qianfan-Agent-Speed-8k| +|model |str |是 |模型名称,用于指定要使用的千帆模型|Qianfan-Agent-Speed-8K| ### 调用参数 |参数名称 |参数类型 |是否必须 |描述 |示例值| diff --git a/python/core/components/llms/is_complex_query/component.py b/python/core/components/llms/is_complex_query/component.py index f0191b7d..7f12e9fb 100644 --- a/python/core/components/llms/is_complex_query/component.py +++ b/python/core/components/llms/is_complex_query/component.py @@ -38,7 +38,7 @@ class IsComplexQuery(CompletionBaseComponent): # 请前往千帆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"] = "..." - is_complex_query = appbuilder.IsComplexQuery(model="Qianfan-Agent-Speed-8k") + is_complex_query = appbuilder.IsComplexQuery(model="Qianfan-Agent-Speed-8K") msg = "吸塑包装盒在工业化生产和物流运输中分别有什么重要性?" msg = appbuilder.Message(msg) diff --git a/python/core/components/llms/mrc/README.md b/python/core/components/llms/mrc/README.md index eaf152be..19da449d 100644 --- a/python/core/components/llms/mrc/README.md +++ b/python/core/components/llms/mrc/README.md @@ -9,7 +9,7 @@ MRC(阅读理解问答模块)是一项先进的自然语言处理功能, ### 特色优势 我们的MRC模块,基于百度自研的先进语言模型文新一言,提供了一系列强大的阅读理解问答功能。在保持文本理解和问题回答的高精度的同时, 我们特别强调了答案的质量和交互体验。以下是我们MRC模块的几个主要功能特色: - - 1.多版本模型支持:我们的MRC模块包括不同版本的文新一言大模型,Erniebot 4.0、Qianfan-Agent-Speed-8k等,每个版本都针对特定的应用场景进行了优化。 用户可以根据自己的需求选择最适合的模型版本,以获得最佳的性能。 + - 1.多版本模型支持:我们的MRC模块包括不同版本的文新一言大模型,Erniebot 4.0、Qianfan-Agent-Speed-8K等,每个版本都针对特定的应用场景进行了优化。 用户可以根据自己的需求选择最适合的模型版本,以获得最佳的性能。 - 2.答案格式的多样性: - 拒答功能:当问题超出模型知识范围或不具体时,模型可以选择不回答,避免提供误导性信息。 - 澄清功能:对于模棱两可或含糊的问题,模型可以请求更多信息或对问题进行澄清,以确保答案的准确性。 @@ -41,7 +41,7 @@ import os os.environ["APPBUILDER_TOKEN"] = "..." # 创建MRC对象 -mrc_component = appbuilder.MRC(model="Qianfan-Agent-Speed-8k") +mrc_component = appbuilder.MRC(model="Qianfan-Agent-Speed-8K") # 初始化参数 msg = "残疾人怎么办相关证件" @@ -119,7 +119,7 @@ import os os.environ["APPBUILDER_TOKEN"] = '...' # 创建MRC对象 -mrc_component = appbuilder.MRC(model="Qianfan-Agent-Speed-8k") +mrc_component = appbuilder.MRC(model="Qianfan-Agent-Speed-8K") # 初始化参数 msg = "残疾人怎么办相关证件" diff --git a/python/core/components/llms/nl2pandas/README.md b/python/core/components/llms/nl2pandas/README.md index a6828200..a107b4f7 100644 --- a/python/core/components/llms/nl2pandas/README.md +++ b/python/core/components/llms/nl2pandas/README.md @@ -30,7 +30,7 @@ query = "海淀区有哪些学校" query = appbuilder.Message(query) #定义并运行Nl2pandas实例,得到结果 -nl2pandas = appbuilder.Nl2pandasComponent(model="Qianfan-Agent-Speed-8k") +nl2pandas = appbuilder.Nl2pandasComponent(model="Qianfan-Agent-Speed-8K") answer = nl2pandas(query, table_info = table_info) ``` diff --git a/python/core/components/llms/nl2pandas/component.py b/python/core/components/llms/nl2pandas/component.py index 95fae213..f311e0db 100644 --- a/python/core/components/llms/nl2pandas/component.py +++ b/python/core/components/llms/nl2pandas/component.py @@ -38,7 +38,7 @@ class Nl2pandasComponent(CompletionBaseComponent): query = "海淀区有哪些学校" query = appbuilder.Message(query) - nl2pandas = appbuilder.Nl2pandasComponent(model="Qianfan-Agent-Speed-8k") + nl2pandas = appbuilder.Nl2pandasComponent(model="Qianfan-Agent-Speed-8K") answer = nl2pandas(query, table_info = table_info) """ name = "nl2pandas" diff --git a/python/core/components/llms/oral_query_generation/README.md b/python/core/components/llms/oral_query_generation/README.md index 4a796b11..b64b8ada 100644 --- a/python/core/components/llms/oral_query_generation/README.md +++ b/python/core/components/llms/oral_query_generation/README.md @@ -28,8 +28,8 @@ text = ('文档标题:在OPPO Reno5上使用视频超级防抖\n' '防抖后手机屏幕将出现超级防抖Pro开关,点击即可开启或关闭。 除此之外,前置视频同样加持防抖算法,边走边拍也能稳定聚焦脸部' ',实时视频分享您的生活。') -#! 该组件推荐使用Qianfan-Agent-Speed-8k模型。 -oral_query_generation = appbuilder.OralQueryGeneration(model='Qianfan-Agent-Speed-8k') +#! 该组件推荐使用Qianfan-Agent-Speed-8K模型。 +oral_query_generation = appbuilder.OralQueryGeneration(model='Qianfan-Agent-Speed-8K') result = oral_query_generation(appbuilder.Message(text), query_type='全部', output_format='str') print(result) @@ -47,7 +47,7 @@ os.environ["APPBUILDER_TOKEN"] = "bce-YOURTOKEN" | 参数名称 | 参数类型 | 是否必须 | 描述 | 示例值 | | ------- | ------- | -------- | -------- | -------- | -| `model` | str | 是 | 模型名称,用于指定要使用的千帆模型。推荐使用Qianfan-Agent-Speed-8k模型。 | Qianfan-Agent-Speed-8k | +| `model` | str | 是 | 模型名称,用于指定要使用的千帆模型。推荐使用Qianfan-Agent-Speed-8K模型。 | Qianfan-Agent-Speed-8K | | `secret_key` | str | 否 | 用户鉴权token,默认从环境变量中获取: `os.getenv("APPBUILDER_TOKEN", "")` | bce-v3/XXX | | `gateway` | str | 否 | 后端网关服务地址,默认从环境变量中获取: `os.getenv("GATEWAY_URL", "")` | https://appbuilder.baidu.com | | `lazy_certification` | bool | 否 | 延迟认证,为True时在第一次运行时认证。默认为False。 | False | diff --git a/python/core/components/llms/oral_query_generation/component.py b/python/core/components/llms/oral_query_generation/component.py index a8f4d3e1..7d14af1a 100644 --- a/python/core/components/llms/oral_query_generation/component.py +++ b/python/core/components/llms/oral_query_generation/component.py @@ -27,7 +27,7 @@ class OralQueryGeneration(CompletionBaseComponent): r""" 口语化Query生成,可用于问答场景下对文档增强索引。 - *注:该组件推荐使用Qianfan-Agent-Speed-8k模型。* + *注:该组件推荐使用Qianfan-Agent-Speed-8K模型。* Examples: @@ -43,7 +43,7 @@ class OralQueryGeneration(CompletionBaseComponent): '防抖 开启路径:打开「相机 > 视频 > 点击屏幕上方的“超级防抖”标识」 后置视频同时支持超级防抖和超级防抖Pro功能,开启超级' '防抖后手机屏幕将出现超级防抖Pro开关,点击即可开启或关闭。 除此之外,前置视频同样加持防抖算法,边走边拍也能稳定聚焦脸部' ',实时视频分享您的生活。') - oral_query_generation = appbuilder.OralQueryGeneration(model='Qianfan-Agent-Speed-8k') + oral_query_generation = appbuilder.OralQueryGeneration(model='Qianfan-Agent-Speed-8K') answer = oral_query_generation(appbuilder.Message(text), query_type='全部', output_format='str') print(answer.content) """ @@ -88,7 +88,7 @@ def __init__( """初始化口语化Query生成模型。 Args: - model (str|None): 模型名称,用于指定要使用的千帆模型。推荐使用Qianfan-Agent-Speed-8k模型。 + model (str|None): 模型名称,用于指定要使用的千帆模型。推荐使用Qianfan-Agent-Speed-8K模型。 secret_key (str, 可选): 用户鉴权token, 默认从环境变量中获取: os.getenv("APPBUILDER_TOKEN", ""). gateway (str, 可选): 后端网关服务地址,默认从环境变量中获取: os.getenv("GATEWAY_URL", "") lazy_certification (bool, 可选): 延迟认证,为True时在第一次运行时认证. Defaults to False. diff --git a/python/core/components/llms/playground/README.md b/python/core/components/llms/playground/README.md index 73c59859..ad3baaf7 100644 --- a/python/core/components/llms/playground/README.md +++ b/python/core/components/llms/playground/README.md @@ -26,7 +26,7 @@ os.environ["APPBUILDER_TOKEN"] = "..." play = appbuilder.Playground( prompt_template="你好,{name},我是{bot_name},{bot_name}是一个{bot_type},我可以{bot_function},你可以问我{bot_question}。", - model="Qianfan-Agent-Speed-8k" + model="Qianfan-Agent-Speed-8K" ) play(appbuilder.Message({"name": "小明", "bot_name": "小红", "bot_type": "聊天机器人", "bot_function": "聊天", "bot_question": "你好吗?"}), stream=False) ``` diff --git a/python/core/components/llms/playground/component.py b/python/core/components/llms/playground/component.py index be0344d7..fea20c90 100644 --- a/python/core/components/llms/playground/component.py +++ b/python/core/components/llms/playground/component.py @@ -31,7 +31,7 @@ class Playground(CompletionBaseComponent): import appbuilder os.environ["APPBUILDER_TOKEN"] = "..." - play = appbuilder.Playground(prompt_template="你好,{name},我是{bot_name},{bot_name}是一个{bot_type},我可以{bot_function},你可以问我{bot_question}。", model="Qianfan-Agent-Speed-8k") + play = appbuilder.Playground(prompt_template="你好,{name},我是{bot_name},{bot_name}是一个{bot_type},我可以{bot_function},你可以问我{bot_question}。", model="Qianfan-Agent-Speed-8K") play(appbuilder.Message({"name": "小明", "bot_name": "小红", "bot_type": "聊天机器人", "bot_function": "聊天", "bot_question": "你好吗?"}), stream=False) """ diff --git a/python/core/components/llms/qa_pair_mining/README.md b/python/core/components/llms/qa_pair_mining/README.md index 8fcfa6e5..f1c00c82 100644 --- a/python/core/components/llms/qa_pair_mining/README.md +++ b/python/core/components/llms/qa_pair_mining/README.md @@ -23,7 +23,7 @@ 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"] = "..." -qa_mining = appbuilder.QAPairMining(model="Qianfan-Agent-Speed-8k") +qa_mining = appbuilder.QAPairMining(model="Qianfan-Agent-Speed-8K") # 输入文本(对此文本挖掘问答对) msg = '2017年,工商银行根据外部宏观环境变化,及时调整业务策略,优化资产负债结构,' + \ '保持存贷款业务协调发展,提升资产负债配置效率。' + \ @@ -110,7 +110,7 @@ split_result = splitter(parse_result) # 每个段落抽取问答对,并返回结果 for doc_segment in split_result.content["paragraphs"]: - qa_mining = QAPairMining(model="Qianfan-Agent-Speed-8k") + qa_mining = QAPairMining(model="Qianfan-Agent-Speed-8K") text = doc_segment.get("text", "") if text == "": logger.error("Text is null. break") diff --git a/python/core/components/llms/qa_pair_mining/component.py b/python/core/components/llms/qa_pair_mining/component.py index d8acb07c..66eed294 100644 --- a/python/core/components/llms/qa_pair_mining/component.py +++ b/python/core/components/llms/qa_pair_mining/component.py @@ -33,7 +33,7 @@ class QAPairMining(CompletionBaseComponent): os.environ["APPBUILDER_TOKEN"] = "..." - qa_mining = appbuilder.QAPairMining(model="Qianfan-Agent-Speed-8k") + qa_mining = appbuilder.QAPairMining(model="Qianfan-Agent-Speed-8K") # 输入文本(对此文本挖掘问答对) msg = '2017年,工商银行根据外部宏观环境变化,及时调整业务策略,优化资产负债结构,' + \ '保持存贷款业务协调发展,提升资产负债配置效率。' + \ diff --git a/python/core/components/llms/query_decomposition/README.md b/python/core/components/llms/query_decomposition/README.md index d1b7f06b..2629c103 100644 --- a/python/core/components/llms/query_decomposition/README.md +++ b/python/core/components/llms/query_decomposition/README.md @@ -21,7 +21,7 @@ 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"] = "..." -query_decomposition = appbuilder.QueryDecomposition(model="Qianfan-Agent-Speed-8k") +query_decomposition = appbuilder.QueryDecomposition(model="Qianfan-Agent-Speed-8K") msg = "吸塑包装盒在工业化生产和物流运输中分别有什么重要性?" msg = appbuilder.Message(msg) @@ -42,7 +42,7 @@ os.environ["APPBUILDER_TOKEN"] = "bce-YOURTOKEN" ### 初始化参数 |参数名称 |参数类型 |是否必须 |描述 |示例值| |--------|--------|--------|----|------| -|model |str |是 |模型名称,用于指定要使用的千帆模型|Qianfan-Agent-Speed-8k| +|model |str |是 |模型名称,用于指定要使用的千帆模型|Qianfan-Agent-Speed-8K| ### 调用参数 |参数名称 |参数类型 |是否必须 |描述 |示例值| diff --git a/python/core/components/llms/query_decomposition/component.py b/python/core/components/llms/query_decomposition/component.py index 067215b2..7632fa0e 100644 --- a/python/core/components/llms/query_decomposition/component.py +++ b/python/core/components/llms/query_decomposition/component.py @@ -33,7 +33,7 @@ class QueryDecomposition(CompletionBaseComponent): # 请前往千帆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"] = "..." - query_decomposition = appbuilder.QueryDecomposition(model="Qianfan-Agent-Speed-8k") + query_decomposition = appbuilder.QueryDecomposition(model="Qianfan-Agent-Speed-8K") msg = "吸塑包装盒在工业化生产和物流运输中分别有什么重要性?" msg = appbuilder.Message(msg) diff --git a/python/core/components/llms/query_rewrite/README.md b/python/core/components/llms/query_rewrite/README.md index ca568cf0..9e951413 100644 --- a/python/core/components/llms/query_rewrite/README.md +++ b/python/core/components/llms/query_rewrite/README.md @@ -24,7 +24,7 @@ import appbuilder os.environ["APPBUILDER_TOKEN"] = '...' # 初始化并使用 QueryRewrite 组件 -query_rewrite = appbuilder.QueryRewrite(model="Qianfan-Agent-Speed-8k") +query_rewrite = appbuilder.QueryRewrite(model="Qianfan-Agent-Speed-8K") answer = query_rewrite(appbuilder.Message(['我应该怎么办理护照?', '您可以查询官网或人工咨询', '我需要准备哪些材料?', '身份证、免冠照片一张以及填写完整的《中国公民因私出国(境)申请表》', '在哪里办']), rewrite_type="带机器人回复") print(answer) ``` diff --git a/python/core/components/llms/query_rewrite/component.py b/python/core/components/llms/query_rewrite/component.py index 964a269b..5fbf7cc1 100644 --- a/python/core/components/llms/query_rewrite/component.py +++ b/python/core/components/llms/query_rewrite/component.py @@ -31,7 +31,7 @@ class QueryRewrite(CompletionBaseComponent): import appbuilder os.environ["APPBUILDER_TOKEN"] = '...' - query_rewrite = appbuilder.QueryRewrite(model="Qianfan-Agent-Speed-8k") + query_rewrite = appbuilder.QueryRewrite(model="Qianfan-Agent-Speed-8K") answer = query_rewrite(appbuilder.Message(['我应该怎么办理护照?', '您可以查询官网或人工咨询', '我需要准备哪些材料?', diff --git a/python/core/components/llms/similar_question/README.md b/python/core/components/llms/similar_question/README.md index ca5b1129..4a7db172 100644 --- a/python/core/components/llms/similar_question/README.md +++ b/python/core/components/llms/similar_question/README.md @@ -23,7 +23,7 @@ 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"] = "..." -similar_question = appbuilder.SimilarQuestion(model="Qianfan-Agent-Speed-8k") +similar_question = appbuilder.SimilarQuestion(model="Qianfan-Agent-Speed-8K") msg = "我想吃冰淇淋,哪里的冰淇淋比较好吃?" msg = appbuilder.Message(msg) diff --git a/python/core/components/llms/similar_question/component.py b/python/core/components/llms/similar_question/component.py index 39f79262..776cb647 100644 --- a/python/core/components/llms/similar_question/component.py +++ b/python/core/components/llms/similar_question/component.py @@ -35,7 +35,7 @@ class SimilarQuestion(CompletionBaseComponent): os.environ["APPBUILDER_TOKEN"] = "..." - qa_mining = appbuilder.SimilarQuestion(model="Qianfan-Agent-Speed-8k") + qa_mining = appbuilder.SimilarQuestion(model="Qianfan-Agent-Speed-8K") msg = "我想吃冰淇淋,哪里的冰淇淋比较好吃?" msg = appbuilder.Message(msg) diff --git a/python/core/components/llms/style_rewrite/README.md b/python/core/components/llms/style_rewrite/README.md index f694e376..ff482a92 100644 --- a/python/core/components/llms/style_rewrite/README.md +++ b/python/core/components/llms/style_rewrite/README.md @@ -33,7 +33,7 @@ import appbuilder os.environ["APPBUILDER_TOKEN"] = "..." # 初始化并使用 StyleRewrite 组件 -style_rewrite = appbuilder.StyleRewrite(model="Qianfan-Agent-Speed-8k") +style_rewrite = appbuilder.StyleRewrite(model="Qianfan-Agent-Speed-8K") answer = style_rewrite(appbuilder.Message("文心大模型发布新版"), style="激励话术") ``` diff --git a/python/core/components/llms/style_rewrite/component.py b/python/core/components/llms/style_rewrite/component.py index dd7bc60d..ee49efe4 100644 --- a/python/core/components/llms/style_rewrite/component.py +++ b/python/core/components/llms/style_rewrite/component.py @@ -31,7 +31,7 @@ class StyleRewrite(CompletionBaseComponent): import appbuilder os.environ["APPBUILDER_TOKEN"] = '...' - style_rewrite = appbuilder.StyleRewrite(model="Qianfan-Agent-Speed-8k") + style_rewrite = appbuilder.StyleRewrite(model="Qianfan-Agent-Speed-8K") answer = style_rewrite(appbuilder.Message("文心大模型发布新版本"), style="激励话术") """ diff --git a/python/core/components/llms/style_writing/README.md b/python/core/components/llms/style_writing/README.md index 9ae42933..c5d07f1e 100644 --- a/python/core/components/llms/style_writing/README.md +++ b/python/core/components/llms/style_writing/README.md @@ -26,7 +26,7 @@ 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"] = "..." -model = "Qianfan-Agent-Speed-8k" +model = "Qianfan-Agent-Speed-8K" style_writing = appbuilder.StyleWriting(model) query = "帮我写一篇关于人体工学椅的文案" diff --git a/python/core/components/llms/style_writing/component.py b/python/core/components/llms/style_writing/component.py index 49994617..9e7bcfd5 100644 --- a/python/core/components/llms/style_writing/component.py +++ b/python/core/components/llms/style_writing/component.py @@ -55,7 +55,7 @@ class StyleWriting(CompletionBaseComponent): # 请前往千帆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"] = '...' - style_writing = appbuilder.StyleWriting(model="Qianfan-Agent-Speed-8k") + style_writing = appbuilder.StyleWriting(model="Qianfan-Agent-Speed-8K") answer = style_writing(appbuilder.Message("帮我写一篇关于人体工学椅的文案"), style_query="小红书", length=100) """ diff --git a/python/core/components/llms/tag_extraction/README.md b/python/core/components/llms/tag_extraction/README.md index 313541a7..8d84f3fc 100644 --- a/python/core/components/llms/tag_extraction/README.md +++ b/python/core/components/llms/tag_extraction/README.md @@ -31,7 +31,7 @@ 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"] = '...' -tag_extraction = appbuilder.TagExtraction(model="Qianfan-Agent-Speed-8k") +tag_extraction = appbuilder.TagExtraction(model="Qianfan-Agent-Speed-8K") result = tag_extraction(appbuilder.Message("从这段文本中抽取关键标签")) ``` diff --git a/python/core/components/llms/tag_extraction/component.py b/python/core/components/llms/tag_extraction/component.py index 69b7eca5..d5527696 100644 --- a/python/core/components/llms/tag_extraction/component.py +++ b/python/core/components/llms/tag_extraction/component.py @@ -29,7 +29,7 @@ class TagExtraction(CompletionBaseComponent): # 请前往千帆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"] = '...' - tag_extraction = appbuilder.TagExtraction(model="Qianfan-Agent-Speed-8k") + tag_extraction = appbuilder.TagExtraction(model="Qianfan-Agent-Speed-8K") answer = tag_extraction(appbuilder.Message("从这段文本中抽取关键标签")) """ diff --git a/python/core/components/rag_with_baidu_search/README.md b/python/core/components/rag_with_baidu_search/README.md index 8196d888..a6df5e05 100644 --- a/python/core/components/rag_with_baidu_search/README.md +++ b/python/core/components/rag_with_baidu_search/README.md @@ -38,7 +38,7 @@ import os os.environ["APPBUILDER_TOKEN"] = '...' # 创建rag_with_baidusearch对象 -rag_with_baidusearch_component = appbuilder.RAGWithBaiduSearch(model="Qianfan-Agent-Speed-8k") +rag_with_baidusearch_component = appbuilder.RAGWithBaiduSearch(model="Qianfan-Agent-Speed-8K") # 运行rag_with_baidusearch基本组件 msg = appbuilder.Message("残疾人怎么办相关证件") @@ -111,7 +111,7 @@ os.environ["APPBUILDER_TOKEN"] = '...' # 创建rag_with_baidusearch对象, 并初始化人设指令 rag_with_baidusearch_component = appbuilder.RAGWithBaiduSearch( - model="Qianfan-Agent-Speed-8k", + model="Qianfan-Agent-Speed-8K", instruction=appbuilder.Message("你是问答助手,在回答问题前需要加上: 很高兴为您解答")) diff --git a/python/core/components/rag_with_baidu_search_pro/README.md b/python/core/components/rag_with_baidu_search_pro/README.md index 816a26c8..245db73a 100644 --- a/python/core/components/rag_with_baidu_search_pro/README.md +++ b/python/core/components/rag_with_baidu_search_pro/README.md @@ -26,7 +26,7 @@ import os os.environ["APPBUILDER_TOKEN"] = '...' # 创建rag_with_baidusearch_pro对象 -rag_with_baidu_search_pro = appbuilder.RagWithBaiduSearchPro(model="Qianfan-Agent-Speed-8k") +rag_with_baidu_search_pro = appbuilder.RagWithBaiduSearchPro(model="Qianfan-Agent-Speed-8K") # 运行rag_with_baidusearch基本组件 msg = appbuilder.Message("残疾人怎么办相关证件") @@ -88,7 +88,7 @@ os.environ["APPBUILDER_TOKEN"] = '...' # 创建rag_with_baidusearch对象, 并初始化人设指令 rag_with_baidusearch_pro = appbuilder.RagWithBaiduSearchPro( - model="Qianfan-Agent-Speed-8k", + model="Qianfan-Agent-Speed-8K", instruction=appbuilder.Message("你是问答助手,在回答问题前需要加上: 很高兴为您解答")) diff --git a/python/core/components/v2/llms/hallucination_detection/component.py b/python/core/components/v2/llms/hallucination_detection/component.py index 9d4f4cbb..cc2e663c 100644 --- a/python/core/components/v2/llms/hallucination_detection/component.py +++ b/python/core/components/v2/llms/hallucination_detection/component.py @@ -26,7 +26,7 @@ class HallucinationDetection(CompletionBaseComponent): """ 幻觉检测。输入,判断answer中是否存在幻觉。 - *注:该组件推荐使用Qianfan-Agent-Speed-8k模型。* + *注:该组件推荐使用Qianfan-Agent-Speed-8K模型。* Examples: @@ -103,7 +103,7 @@ def __init__( """初始化幻觉检测组件。 Args: - model (str|None): 模型名称,用于指定要使用的千帆模型。推荐使用Qianfan-Agent-Speed-8k模型。 + model (str|None): 模型名称,用于指定要使用的千帆模型。推荐使用Qianfan-Agent-Speed-8K模型。 secret_key (str, 可选): 用户鉴权token, 默认从环境变量中获取: os.getenv("APPBUILDER_TOKEN", ""). gateway (str, 可选): 后端网关服务地址,默认从环境变量中获取: os.getenv("GATEWAY_URL", "") lazy_certification (bool, 可选): 延迟认证,为True时在第一次运行时认证. Defaults to False. diff --git a/python/core/components/v2/llms/oral_query_generation/component.py b/python/core/components/v2/llms/oral_query_generation/component.py index 55ca08f5..3fff92e3 100644 --- a/python/core/components/v2/llms/oral_query_generation/component.py +++ b/python/core/components/v2/llms/oral_query_generation/component.py @@ -27,7 +27,7 @@ class OralQueryGeneration(CompletionBaseComponent): r""" 口语化Query生成,可用于问答场景下对文档增强索引。 - *注:该组件推荐使用Qianfan-Agent-Speed-8k模型。* + *注:该组件推荐使用Qianfan-Agent-Speed-8K模型。* Examples: @@ -43,7 +43,7 @@ class OralQueryGeneration(CompletionBaseComponent): '防抖 开启路径:打开「相机 > 视频 > 点击屏幕上方的“超级防抖”标识」 后置视频同时支持超级防抖和超级防抖Pro功能,开启超级' '防抖后手机屏幕将出现超级防抖Pro开关,点击即可开启或关闭。 除此之外,前置视频同样加持防抖算法,边走边拍也能稳定聚焦脸部' ',实时视频分享您的生活。') - oral_query_generation = appbuilder.OralQueryGeneration(model='Qianfan-Agent-Speed-8k') + oral_query_generation = appbuilder.OralQueryGeneration(model='Qianfan-Agent-Speed-8K') answer = oral_query_generation(appbuilder.Message(text), query_type='全部', output_format='str') print(answer.content) """ diff --git a/python/core/components/v2/llms/similar_question/component.py b/python/core/components/v2/llms/similar_question/component.py index fdff32f1..4b200bd3 100644 --- a/python/core/components/v2/llms/similar_question/component.py +++ b/python/core/components/v2/llms/similar_question/component.py @@ -35,7 +35,7 @@ class SimilarQuestion(CompletionBaseComponent): os.environ["APPBUILDER_TOKEN"] = "..." - qa_mining = appbuilder.SimilarQuestion(model="Qianfan-Agent-Speed-8k") + qa_mining = appbuilder.SimilarQuestion(model="Qianfan-Agent-Speed-8K") msg = "我想吃冰淇淋,哪里的冰淇淋比较好吃?" msg = appbuilder.Message(msg) diff --git a/python/core/components/v2/llms/style_rewrite/component.py b/python/core/components/v2/llms/style_rewrite/component.py index f2cfa6eb..051325c1 100644 --- a/python/core/components/v2/llms/style_rewrite/component.py +++ b/python/core/components/v2/llms/style_rewrite/component.py @@ -31,7 +31,7 @@ class StyleRewrite(CompletionBaseComponent): import appbuilder os.environ["APPBUILDER_TOKEN"] = '...' - style_rewrite = appbuilder.StyleRewrite(model="Qianfan-Agent-Speed-8k") + style_rewrite = appbuilder.StyleRewrite(model="Qianfan-Agent-Speed-8K") answer = style_rewrite(appbuilder.Message("文心大模型发布新版本"), style="激励话术") """ diff --git a/python/core/components/v2/llms/style_writing/component.py b/python/core/components/v2/llms/style_writing/component.py index f7fafd3d..573de925 100644 --- a/python/core/components/v2/llms/style_writing/component.py +++ b/python/core/components/v2/llms/style_writing/component.py @@ -55,7 +55,7 @@ class StyleWriting(CompletionBaseComponent): # 请前往千帆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"] = '...' - style_writing = appbuilder.StyleWriting(model="Qianfan-Agent-Speed-8k") + style_writing = appbuilder.StyleWriting(model="Qianfan-Agent-Speed-8K") answer = style_writing(appbuilder.Message("帮我写一篇关于人体工学椅的文案"), style_query="小红书", length=100) """ diff --git a/python/tests/component_tool_eval_cases.py b/python/tests/component_tool_eval_cases.py index 19f999cc..10e68d85 100644 --- a/python/tests/component_tool_eval_cases.py +++ b/python/tests/component_tool_eval_cases.py @@ -90,7 +90,7 @@ def schemas(self): class StyleRewriteCase(Case): def init_args(self): - return {"model": "Qianfan-Agent-Speed-8k"} + return {"model": "ERNIE-3.5-8K"} def inputs(self): return {"query": "文心大模型发布新版"} @@ -116,6 +116,9 @@ def outputs(self): return {"text": ["ocr文字识别"]} class HallucinationDetectionCase(Case): + def init_args(self): + return {"model": "ERNIE-3.5-8K"} + def inputs(self): return { "query": '澳门新麻蒲烤肉店每天开门吗?', @@ -307,6 +310,9 @@ def outputs(self): return {"text": ["苹果"]} class SimilarQuestionCase(Case): + def init_args(self): + return {"model": "ERNIE-3.5-8K"} + def inputs(self): return { "query": "我想吃冰淇淋,哪里的冰淇淋比较好吃?" @@ -319,6 +325,9 @@ def outputs(self): return {"text": ["冰淇淋"]} class OralQueryGenerationCase(Case): + def init_args(self): + return {"model": "ERNIE-3.5-8K"} + def inputs(self): text = ('文档标题:在OPPO Reno5上使用视频超级防抖\n' '文档摘要:OPPO Reno5上的视频超级防抖,视频超级防抖3.0,多代视频防抖算法积累,这一代依旧超级防抖超级稳。 开启视频超级' diff --git a/python/tests/test_appbuilder_sentry_trace_on.py b/python/tests/test_appbuilder_sentry_trace_on.py index b8639523..1f27f284 100644 --- a/python/tests/test_appbuilder_sentry_trace_on.py +++ b/python/tests/test_appbuilder_sentry_trace_on.py @@ -70,19 +70,19 @@ def test_sentry_normal(self): # 启动事务 with sentry_sdk.start_transaction(op="task", name="UT-Components-trace-test"): # test Components run - sr = StyleRewrite(model="Qianfan-Agent-Speed-8k") + sr = StyleRewrite(model="ERNIE-3.5-8K") text = "成都是个包容的城市" style = "直播话术" msg = appbuilder.Message(content=text) run_out = sr.run(message=msg, style=style) print(run_out) - sr = StyleRewrite(model="Qianfan-Agent-Speed-8k") + sr = StyleRewrite(model="ERNIE-3.5-8K") tool_eval_out = sr.tool_eval(name="name", query=text, style=style, streaming=True) for res in tool_eval_out: print(res) # test Components v2 tool_eval - sr_v2 = StyleRewriteV2(model="Qianfan-Agent-Speed-8k") + sr_v2 = StyleRewriteV2(model="ERNIE-3.5-8K") text = "成都是个包容的城市" style = "直播话术" tool_eval_out = sr_v2.tool_eval(query=text, style=style) diff --git a/python/tests/test_rag_baidu_search.py b/python/tests/test_rag_baidu_search.py index 144cacb0..9efee5ac 100644 --- a/python/tests/test_rag_baidu_search.py +++ b/python/tests/test_rag_baidu_search.py @@ -11,7 +11,7 @@ def setUp(self): return rag_with_baidu_search class """ # 设置环境变量和初始化TestMRCComponent实例 - self.model_name = "Qianfan-Agent-Speed-8k" + self.model_name = "Qianfan-Agent-Speed-8K" self.rag_with_baidu_search = appbuilder.RAGWithBaiduSearch(model=self.model_name) def test_rag_with_baidu_search(self): diff --git a/python/tests/test_v2_component_trace.py b/python/tests/test_v2_component_trace.py index f48361b9..fe46503d 100644 --- a/python/tests/test_v2_component_trace.py +++ b/python/tests/test_v2_component_trace.py @@ -21,7 +21,7 @@ @unittest.skipUnless(os.getenv("TEST_CASE", "UNKNOWN") == "CPU_PARALLEL", "") class TestStyleRewrite(unittest.TestCase): def setUp(self) -> None: - self.com = StyleRewrite(model="Qianfan-Agent-Speed-8k") + self.com = StyleRewrite(model="ERNIE-3.5-8K") self.tracer = AppBuilderTracer( enable_phoenix = False, enable_console = True diff --git a/python/tests/test_v2_hallucination_detection.py b/python/tests/test_v2_hallucination_detection.py index 3aff6254..2bc63d4c 100644 --- a/python/tests/test_v2_hallucination_detection.py +++ b/python/tests/test_v2_hallucination_detection.py @@ -51,7 +51,7 @@ def setUp(self): 无返回值,方法中执行了环境变量的赋值操作。 """ - self.hallucination_detection = HallucinationDetection() + self.hallucination_detection = HallucinationDetection(model="ERNIE-3.5-8K") def test_run_with_default_params(self): """测试 run 方法使用默认参数 diff --git a/python/tests/test_v2_oral_query_generat.py b/python/tests/test_v2_oral_query_generat.py index 91a7b187..84c5f34c 100644 --- a/python/tests/test_v2_oral_query_generat.py +++ b/python/tests/test_v2_oral_query_generat.py @@ -22,7 +22,7 @@ @unittest.skipUnless(os.getenv("TEST_CASE", "UNKNOWN") == "CPU_PARALLEL", "") class TestOralQueryGeneration(unittest.TestCase): def setUp(self): - self.com = OralQueryGeneration() + self.com = OralQueryGeneration(model="ERNIE-3.5-8K") self.text = ('文档标题:在OPPO Reno5上使用视频超级防抖\n' '文档摘要:OPPO Reno5上的视频超级防抖,视频超级防抖3.0,多代视频防抖算法积累,这一代依旧超级防抖超级稳。 开启视频超级' '防抖 开启路径:打开「相机 > 视频 > 点击屏幕上方的“超级防抖”标识」 后置视频同时支持超级防抖和超级防抖Pro功能,开启超级' diff --git a/python/tests/test_v2_similar_question.py b/python/tests/test_v2_similar_question.py index 52e9a930..a19202cf 100644 --- a/python/tests/test_v2_similar_question.py +++ b/python/tests/test_v2_similar_question.py @@ -24,7 +24,7 @@ @unittest.skipUnless(os.getenv("TEST_CASE", "UNKNOWN") == "CPU_PARALLEL", "") class TestSimilarQuestion(unittest.TestCase): def setUp(self): - self.com = SimilarQuestion() + self.com = SimilarQuestion(model="ERNIE-3.5-8K") def test_run(self): query = "我想吃冰淇淋,哪里的冰淇淋比较好吃?" diff --git a/python/tests/test_v2_style_rewrite.py b/python/tests/test_v2_style_rewrite.py index f41fa475..51927251 100644 --- a/python/tests/test_v2_style_rewrite.py +++ b/python/tests/test_v2_style_rewrite.py @@ -21,7 +21,7 @@ @unittest.skipUnless(os.getenv("TEST_CASE", "UNKNOWN") == "CPU_PARALLEL", "") class TestStyleRewrite(unittest.TestCase): def setUp(self) -> None: - self.com = StyleRewrite(model="Qianfan-Agent-Speed-8k") + self.com = StyleRewrite(model="ERNIE-3.5-8K") def test_normal_case(self): time.sleep(2) diff --git a/python/utils/model_util.py b/python/utils/model_util.py index c2116e96..9d16d500 100644 --- a/python/utils/model_util.py +++ b/python/utils/model_util.py @@ -30,7 +30,7 @@ ("ERNIE-Bot-turbo", "eb-turbo"), ("EB-turbo-AppBuilder专用版", "eb-turbo-appbuilder"), ("EB-turbo-AppBuilder专用版", "ernie_speed_appbuilder"), - ("EB-turbo-AppBuilder专用版", "Qianfan-Agent-Speed-8k"), + ("EB-turbo-AppBuilder专用版", "Qianfan-Agent-Speed-8K"), ] class RemoteModel(object): @@ -62,7 +62,7 @@ def get_remote_name_by_short_name(self, short_name: str) -> Optional[str]: """ # TODO(chengmo): 使用logging 替换 print,解决print多次的问题 if short_name == "eb-turbo-appbuilder": - print("Deprecate warning: model [eb-turbo-appbuilder] is deprecated, please use [Qianfan-Agent-Speed-8k]") + print("Deprecate warning: model [eb-turbo-appbuilder] is deprecated, please use [Qianfan-Agent-Speed-8K]") if short_name in self.short_names: return self.remote_name From c2e7a3858ea31e0fbae51e53958b3954417d4e30 Mon Sep 17 00:00:00 2001 From: userpj Date: Thu, 2 Jan 2025 11:40:38 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E7=9F=A5=E8=AF=86=E5=BA=93=E5=AF=BC?= =?UTF-8?q?=E5=85=A5=E6=96=87=E6=A1=A3separator=E3=80=81prependInfo?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E9=9D=9E=E5=BF=85=E5=A1=AB=20(#689)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/BasisModule/Platform/KnowledgeBase/knowledgebase.md | 4 ++-- python/core/console/knowledge_base/data_class.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/BasisModule/Platform/KnowledgeBase/knowledgebase.md b/docs/BasisModule/Platform/KnowledgeBase/knowledgebase.md index f5503dbc..27cd0569 100644 --- a/docs/BasisModule/Platform/KnowledgeBase/knowledgebase.md +++ b/docs/BasisModule/Platform/KnowledgeBase/knowledgebase.md @@ -300,10 +300,10 @@ class DocumentChoices(BaseModel): class DocumentChunker(BaseModel): choices: list[str] = Field(..., description="使用哪些chunker方法 (separator | pattern | onePage),separator:自定义切片—标识符,pattern:自定义切片—标识符中选择正则表达式,onePage:整文件切片") prependInfo: list[str] = Field( - ..., + None, description="chunker关联元数据,可选值为title (增加标题), filename(增加文件名)", ) - separator: Optional[DocumentSeparator] = Field(..., description="分隔符配置") + separator: Optional[DocumentSeparator] = Field(None, description="分隔符配置") pattern: Optional[DocumentPattern] = Field(None, description="正则表达式") class DocumentSeparator(BaseModel): diff --git a/python/core/console/knowledge_base/data_class.py b/python/core/console/knowledge_base/data_class.py index cc689f96..13924959 100644 --- a/python/core/console/knowledge_base/data_class.py +++ b/python/core/console/knowledge_base/data_class.py @@ -183,10 +183,10 @@ class DocumentChunker(BaseModel): description="使用哪些chunker方法 (separator | pattern | onePage),separator:自定义切片—标识符,pattern:自定义切片—标识符中选择正则表达式,onePage:整文件切片", ) prependInfo: list[str] = Field( - ..., + None, description="chunker关联元数据,可选值为title (增加标题), filename(增加文件名)", ) - separator: Optional[DocumentSeparator] = Field(..., description="分段符号") + separator: Optional[DocumentSeparator] = Field(None, description="分段符号") pattern: Optional[DocumentPattern] = Field(None, description="正则表达式")