当前位置:   article > 正文

今日头条豆包大语言模型api接入python SDK,安装官方库报错,解决方法_error: error: failed to build installable wheels f

error: error: failed to build installable wheels for some pyproject.toml bas

豆包python大语言模型库安装指令:

pip install volcengine-python-sdk

报错:

  1. note: This error originates from a subprocess, and is likely not a problem with pip.
  2. ERROR: Failed building wheel for volcengine-python-sdk
  3. Running setup.py clean for volcengine-python-sdk
  4. Failed to build volcengine-python-sdk
  5. ERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (volcengine-python-sdk)

联系官方,官方说自己那边可以正常安装 。

这不就奇怪了吗?!

然后想了一下,直接手动下载安装吧!

打开pypi.org,搜索:volcengine-python-sd

 

下载到本地,解压缩,放到pycharm的虚拟环境下面,路径:venv/Lib/site-packages

 

当我们去调用官方给的示例的时候会出错,提示有些库没有安装,这个时候,我们再在pycharm中执行一下下面的安装库方法。

 

pip install volcengine-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/openManagement

python 调用示例代码方法:

  1. from volcenginesdkarkruntime import Ark
  2. def get_doubao_api(api_key, Access_Key_ID, Secret_Access_Key, prompt):
  3. try:
  4. client = Ark(api_key=api_key, ak=Access_Key_ID, sk=Secret_Access_Key)
  5. completion = client.chat.completions.create(
  6. model="ep-20240624053151-fj4hp",
  7. messages=[
  8. {"role": "system", "content": "你是豆包,是由字节跳动开发的 AI 人工智能助手"},
  9. {"role": "user", "content": prompt},
  10. ],
  11. )
  12. return completion.choices[0].message.content
  13. except Exception as e:
  14. return e

官方的python api文档入口:

Python SDK--火山方舟大模型服务平台-火山引擎

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/神奇cpp/article/detail/925946
推荐阅读
相关标签
  

闽ICP备14008679号