
---desc: ERNIE 4.0 Turbo是百度自研的旗舰级超大规模⼤语⾔模型,综合效果表现出色,广泛适用于各领域复杂任务场景;支持自动对接百度搜索插件,保障问答信息时效。 support_training: 1 tasks:- 文心大模型- 大语言模型 license: other base_model: aistudio/ERNIE-Bot-turbo dev_type:- notebook- sft_gui deploy_type:- fast_deploy---<div align="center"><img src="https://ai-studio-static-online.cdn.bcebos.com/fc3d615dbfee41b79d4149be75edaa5b261eca1032f74bd7bbbb8464c86ad8e8" width = "450",caption='' /></div>## 模型描述ERNIE 4.0 Turbo是百度自研的旗舰级超大规模⼤语⾔模型,综合效果表现出色,广泛适用于各领域复杂任务场景;支持自动对接百度搜索插件,保障问答信息时效。相较于ERNIE 4.0在性能表现上更优秀。## 模型开发体验更多文心大模型使用方法,详见[大模型开发文档](https://ai.baidu.com/ai-doc/AISTUDIO/rm344erns)### 使用星河社区提供的大模型API服务```import osfrom openai import OpenAIclient = OpenAI( api_key=os.environ.get("AI_STUDIO_API_KEY"), # 含有 AI Studio 访问令牌的环境变量,https://aistudio.baidu.com/account/accessToken, base_url="https://aistudio.baidu.com/llm/lmapi/v3", # aistudio 大模型 api 服务域名)chat_completion = client.chat.completions.create( messages=[ {'role': 'system', 'content': '你是 AI Studio 实训AI开发平台的开发者助理,你精通开发相关的知识,负责给开发者提供搜索帮助建议。'}, {'role': 'user', 'content': '你好,请介绍一下AI Studio'} ], model="ernie-4.0-turbo-8k",)print(chat_completion.choices[0].message.content)```### 流式输出```import osfrom openai import OpenAIclient = OpenAI( api_key=os.environ.get("AI_STUDIO_API_KEY"), # 含有 AI Studio 访问令牌的环境变量,https://aistudio.baidu.com/account/accessToken, base_url="https://aistudio.baidu.com/llm/lmapi/v3", # aistudio 大模型 api 服务域名)completion = client.chat.completions.create( model="ernie-4.0-turbo-8k", messages=[ {'role': 'system', 'content': '你是 AI Studio 实训AI开发平台的开发者助理,你精通开发相关的知识,负责给开发者提供搜索帮助建议。'}, {'role': 'user', 'content': '你好,请介绍一下AI Studio'} ], stream=True,)for chunk in completion: print(chunk.choices[0].delta.content or "", end="")```