|
豆包python大语言模型库安装指令:pipinstallvolcengine-python-sdk报错:note:Thiserrororiginatesfromasubprocess,andislikelynotaproblemwithpip.ERROR:Failedbuildingwheelforvolcengine-python-sdkRunningsetup.pycleanforvolcengine-python-sdkFailedtobuildvolcengine-python-sdkERROR:ERROR:Failedtobuildinstallablewheelsforsomepyproject.tomlbasedprojects(volcengine-python-sdk)联系官方,官方说自己那边可以正常安装 。这不就奇怪了吗?!然后想了一下,直接手动下载安装吧!打开pypi.org,搜索:volcengine-python-sd 下载到本地,解压缩,放到pycharm的虚拟环境下面,路径:venv/Lib/site-packages 当我们去调用官方给的示例的时候会出错,提示有些库没有安装,这个时候,我们再在pycharm中执行一下下面的安装库方法。 pipinstallvolcengine-python-sdk豆包SDK依赖的库会自动安装上。上面解决了依赖库的问题,下面我们还需要在头条大模型后台设置几个内容。 先设置一下api访问密钥,访问下面网址:https://console.volcengine.com/iam/keymanage/获取到 Access_Key_ID,Secret_Access_Key访问下面网址,获取apikey:https://console.volcengine.com/ark/region:ark+cn-beijing/apiKey 获取到apikey。访问下面网址获取model:https://console.volcengine.com/ark/region:ark+cn-beijing/endpoint?current=1&pageSize=10新建推理模型,获取到调用模型,model我们还需要开通一下,我们调用的模型: 访问下面网址:https://console.volcengine.com/ark/region:ark+cn-beijing/openManagementpython调用示例代码方法:fromvolcenginesdkarkruntimeimportArkdefget_doubao_api(api_key,Access_Key_ID,Secret_Access_Key,prompt):try:client=Ark(api_key=api_key,ak=Access_Key_ID,sk=Secret_Access_Key)completion=client.chat.completions.create(model="ep-20240624053151-fj4hp",messages=[{"role":"system","content":"你是豆包,是由字节跳动开发的AI人工智能助手"},{"role":"user","content":prompt},],)returncompletion.choices[0].message.contentexceptExceptionase:returne官方的pythonapi文档入口:PythonSDK--火山方舟大模型服务平台-火山引擎
|
|