当前位置: 首页 > news >正文

甘肃做网站价格网站设建设

甘肃做网站价格,网站设建设,美食网站建设背景介绍,南京网页设计培训班文章目录 关于 DashScope快速上手代码调用http 请求示例Python 调用 关于 DashScope 官方主页:https://dashscope.aliyun.comPYPI : https://pypi.org/project/dashscope/支持模型:https://dashscope.console.aliyun.com/model DashScope灵积模型服务建…

在这里插入图片描述


文章目录

    • 关于 DashScope
    • 快速上手
    • 代码调用
      • http 请求示例
      • Python 调用


关于 DashScope

  • 官方主页:https://dashscope.aliyun.com
  • PYPI : https://pypi.org/project/dashscope/
  • 支持模型:https://dashscope.console.aliyun.com/model

DashScope灵积模型服务建立在“模型即服务”(Model-as-a-Service,MaaS)的理念基础之上,围绕AI各领域模型,通过标准化的API提供包括模型推理、模型微调训练在内的多种模型服务。
通过围绕模型为中心,DashScope灵积模型服务致力于为AI应用开发者提供品类丰富、数量众多的模型选择,并通过API接口为其提供开箱即用、能力卓越、成本经济的模型服务。


在这里插入图片描述


快速上手

参考官方文档:
https://help.aliyun.com/zh/dashscope/create-a-chat-foundation-model

1、开通DashScope并创建API-KEY

https://dashscope.console.aliyun.com/overview


2、安装DashScope SDK

基于 Python 3.8+

pip install dashscope

3、API-KEY设置

1)通过环境变量设置

推荐通过环境变量设置api-key

export DASHSCOPE_API_KEY="YOUR_DASHSCOPE_API_KEY"

2)通过代码设置

通常不推荐将api-key直接写在代码中

import dashscope
dashscope.api_key="YOUR_DASHSCOPE_API_KEY"

3)通过文件设置**

默认会读取~/.dashscope/api_key 作为 DASHSCOPE_API_KEY, 您可以通过环境变量设置api_key保存文件位置。

export DASHSCOPE_API_KEY_FILE_PATH=YOUR_API_KEY_FILE_PATH

代码调用

http 请求示例

curl -X GET 'https://dashscope.aliyuncs.com/api/v1/tasks/73205176-xxxx-xxxx-xxxx-16bd5d902219' \
--header 'Authorization: Bearer <YOUR_API_KEY>'

响应示例:

{"request_id": "45ac7f13-xxxx-xxxx-xxxx-e03c35068d83","output": {"task_id": "73205176-xxxx-xxxx-xxxx-16bd5d902219","task_status": "SUCCEEDED","submit_time": "2023-12-20 21:36:31.896","scheduled_time": "2023-12-20 21:36:39.009","end_time": "2023-12-20 21:36:45.913","results": [{"url": "https://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/xxx1.png"},{"url": "https://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/xxx2.png"},{"url": "https://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/xxx3.png"},{"code": "DataInspectionFailed","message": "Output data may contain inappropriate content.",}],"task_metrics": {"TOTAL": 4,"SUCCEEDED": 3,"FAILED": 1}},"usage": {"image_count": 3}
}

Python 调用

from http import HTTPStatus
import dashscope
from dashscope import Generationdashscope.api_key = 'YOUR-DASHSCOPE-API-KEY'responses = Generation.call(model=Generation.Models.qwen_turbo,prompt='今天天气好吗?')# 方式二
messages = [{'role': 'system', 'content': 'You are a helpful assistant.'},{'role': 'user', 'content': '如何做西红柿鸡蛋?'}]response = Generation.call(model='qwen-turbo',messages=messages,result_format='message',  # set the result to be "message" format.
)if responses.status_code == HTTPStatus.OK:print('Result is: %s' % responses.output)
else:print('Failed request_id: %s, status_code: %s, code: %s, message:%s' %(responses.request_id, responses.status_code, responses.code,responses.message))

def tokenizer():response = dashscope.Tokenization.call(model='qwen-turbo',messages=[{'role': 'user', 'content': '你好?'}],)if response.status_code == HTTPStatus.OK:print('Result is: %s' % response)else:print('Failed request_id: %s, status_code: %s, code: %s, message:%s' %(response.request_id, response.status_code, response.code,response.message))if __name__ == '__main__':tokenizer()
http://www.yayakq.cn/news/321474/

相关文章:

  • 简单网站建设合同模板软件开发模型有几种各有什么特点
  • 做企业网站国内发展网站要素的优化设计
  • 网站备案幕布 下载wordpress 国内教育主题
  • 二元期货交易网站开发地域购物网站
  • 网站建设没有预付款济南百度seo
  • 中国工程建设工程造价管理协会网站建设部工程造价管理网站
  • 昆明网站开发多少钱263企业邮箱登录官网
  • 企业网站建设的具体需求最新网页游戏排行榜2021
  • 小说网站上的广告在哪做会讯通2022官方下载
  • 采摘园网站建设方案诚信通网站怎么做
  • 我做的网站有时打开很慢什么原因成都网站推广公司
  • 开发网站的基本原则做网站的内容资源
  • 如何更新网站微信h5在哪个网站做
  • 网站维护费用包括哪些建筑公司网站电工
  • 关于网站建设中原创文章的一些想法一个公司完整的组织架构
  • 百度小程序如何做网站有没有专业做特产的网站
  • 网站建设整体设计流程windows 安装 wordpress
  • 响应式网站建设免费重庆网站建设服务
  • 吉林天宇建设集团网站初学者网站建设
  • 购物网站答辩ppt怎么做如何推广自己的店铺?
  • 网站开发财务预算制作一个公司网站用vs怎么做
  • asp网站开发人员招聘培训网站欣赏
  • 企业网站带数据库wordpress人才主题
  • 租车网站建设雅虎搜索
  • 深圳网站制作问asp网站模版安装
  • 网站建设实训考试免费微信点餐小程序
  • 商务网站规划与建设心得信息技术初二做网站
  • 酒店类网站开发的策略互联网技术学校
  • 开发工具包seo排名优化软件价格
  • 网站是先备案还是先做网站莱芜金点子广告信息港