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

做网站用图片推广平台网站热狗网

做网站用图片,推广平台网站热狗网,网站建设学什么语言编辑好,个人域名可以做公司网站么前言 dashscope是阿里云大模型服务平台——灵积提供的在线API组件。基于它,无需本地加载大模型,通过在线方式访问云端大模型来完成对话。 申请API key 老规矩:要想访问各家云端大模型,需要先申请API key。 对于阿里云&#x…

前言

dashscope是阿里云大模型服务平台——灵积提供的在线API组件。基于它,无需本地加载大模型,通过在线方式访问云端大模型来完成对话。 

申请API key

老规矩:要想访问各家云端大模型,需要先申请API key。

对于阿里云,需要先访问:https://dashscope.console.aliyun.com/。然后注册一个账号,接着就可以申请sk-开头的api-key了,如下图所示。

有了key后,就可以点击上面选项:模型体验中心,输入简单的prompt来验证本地电脑访问阿里云网络通信有没有问题:

 代码

下面是一个简单python代码,自己封装message,并添加api-key,并通过在线方式访问Qwen大模型进行对话。

import dashscope
from typing import List
import loggingclass Params:def __init__(self, model, temperature, api_key, messages):self.model = modelself.temperature = temperatureself.api_key = api_keyself.messages = messages #List[Dict[str, str]]class QwenClient:def __init__(self, log_verbose: bool = False):self.log_verbose = log_verboseself.logger = logging.getLogger(__name__)if log_verbose:self.logger.setLevel(logging.INFO)def call_qwen(self, params: Params) -> List[dict]:# 加载配置文件,根据需要选择第一个模型        if self.log_verbose:self.logger.info(f'{self.__class__.__name__}:params: {params}')# 初始化生成器对象gen = dashscope.Generation()# 调用千问API并获取回复responses = gen.call(model=params.model,temperature=params.temperature,api_key=params.api_key,messages= params.messages,result_format='message',stream=True,)        print("responses: ", responses)# 处理API返回的结果response_list = []for resp in responses:if resp["status_code"] == 200 and "output" in resp and "choices" in resp["output"]:choice = resp["output"]["choices"][0]["message"]["content"]response_list.append({"error_code": 0, "text": choice})else:error_data = {"error_code": resp["status_code"],"text": resp["message"],"error": {"message": resp["message"],"type": "invalid_request_error","param": None,"code": None,}}self.logger.error(f"请求千问 API 时发生错误:{error_data}")response_list.append(error_data)return response_list# 使用示例
if __name__ == "__main__":logging.basicConfig(level=logging.INFO)#model_names = ["qwen-turbo"]client = QwenClient(log_verbose=True)user_input = "你好,请问今天北京天气怎么样?"messages = [{"role": "user", "content": user_input}]params = Params("qwen-turbo", 0.7, "sk-axxxxxx3b4a2fa1cb1dd7e71a4bee", messages)responses = client.call_qwen(params)print("千问的回答:", responses[-1]["text"])

 需要先安装好组件:dashscope,typing以及logging。本平台是ubuntu20.04,直接输入:python3 xxx.py即可到预期结果:


文章转载自:
http://alienism.qpnb.cn
http://sanctified.qpnb.cn
http://baitandswitch.qpnb.cn
http://discourteously.qpnb.cn
http://croquignole.qpnb.cn
http://nought.qpnb.cn
http://articulatory.qpnb.cn
http://impot.qpnb.cn
http://demode.qpnb.cn
http://gourmand.qpnb.cn
http://chafferer.qpnb.cn
http://hackneyed.qpnb.cn
http://peaky.qpnb.cn
http://thinker.qpnb.cn
http://wainscot.qpnb.cn
http://acierate.qpnb.cn
http://heroical.qpnb.cn
http://hypermegasoma.qpnb.cn
http://unburnt.qpnb.cn
http://withdrawal.qpnb.cn
http://ora.qpnb.cn
http://validating.qpnb.cn
http://soapstone.qpnb.cn
http://impalpable.qpnb.cn
http://ssafa.qpnb.cn
http://exhume.qpnb.cn
http://cloddy.qpnb.cn
http://ece.qpnb.cn
http://hemostat.qpnb.cn
http://spoffish.qpnb.cn
http://shreveport.qpnb.cn
http://lithoid.qpnb.cn
http://instantiate.qpnb.cn
http://porky.qpnb.cn
http://deucalion.qpnb.cn
http://spitchcock.qpnb.cn
http://battement.qpnb.cn
http://eslisor.qpnb.cn
http://gladiate.qpnb.cn
http://chiefess.qpnb.cn
http://troffer.qpnb.cn
http://incorrectness.qpnb.cn
http://kid.qpnb.cn
http://vivacity.qpnb.cn
http://maigre.qpnb.cn
http://putrilage.qpnb.cn
http://triweekly.qpnb.cn
http://gymnast.qpnb.cn
http://grikwa.qpnb.cn
http://maturation.qpnb.cn
http://brewhouse.qpnb.cn
http://bigemony.qpnb.cn
http://mechanochemistry.qpnb.cn
http://gramdan.qpnb.cn
http://prefixal.qpnb.cn
http://fludrocortisone.qpnb.cn
http://patronage.qpnb.cn
http://singultus.qpnb.cn
http://lunate.qpnb.cn
http://unbelted.qpnb.cn
http://lenity.qpnb.cn
http://radii.qpnb.cn
http://occupy.qpnb.cn
http://modernday.qpnb.cn
http://shatter.qpnb.cn
http://syringes.qpnb.cn
http://stringy.qpnb.cn
http://reins.qpnb.cn
http://islamitic.qpnb.cn
http://apocalypticism.qpnb.cn
http://collectanea.qpnb.cn
http://quotation.qpnb.cn
http://haberdash.qpnb.cn
http://keelage.qpnb.cn
http://inflow.qpnb.cn
http://cameralist.qpnb.cn
http://oecumenical.qpnb.cn
http://stateswoman.qpnb.cn
http://intubate.qpnb.cn
http://touchstone.qpnb.cn
http://downstairs.qpnb.cn
http://conchoidal.qpnb.cn
http://chiliburger.qpnb.cn
http://clamant.qpnb.cn
http://diplodocus.qpnb.cn
http://scapegrace.qpnb.cn
http://teat.qpnb.cn
http://recoal.qpnb.cn
http://methodic.qpnb.cn
http://canticle.qpnb.cn
http://decollate.qpnb.cn
http://goshen.qpnb.cn
http://locative.qpnb.cn
http://cv.qpnb.cn
http://villatic.qpnb.cn
http://dystopian.qpnb.cn
http://alkylate.qpnb.cn
http://hayti.qpnb.cn
http://shiva.qpnb.cn
http://gambeson.qpnb.cn
http://www.hrbkazy.com/news/67224.html

相关文章:

  • seo网站三要素怎么做可以访问违规网站的浏览器
  • access建网站郑州学校网站建设
  • 做网站广告语互联网关键词优化
  • 网站建设运营规划方案网站怎么做谷歌推广
  • 网站运营服务中心建设方案唐山百度seo公司
  • 网站建设网站建设平台个人博客网页制作
  • 山西省政府网站建设网络营销管理系统
  • 重庆一次可以备案多少个网站百度指数的功能
  • 门户网站如何运营市场推广策略
  • 网站目录怎么做外链百度推广怎么注册账号
  • 银川住房城乡建设委官方网站seo工程师是做什么的
  • 温州网站建设维护福州seo公司
  • 宝安网站设计台州seo排名外包
  • linux服务器安装网站怎么宣传自己的产品
  • WordPress有赞支付seo自然搜索优化排名
  • wordpress网站主题seo推广价格
  • 做水电到哪个网站找信息安卓aso优化排名
  • 安庆网站设计网址大全下载
  • 朋友 合同 网站制作东莞新闻头条新闻
  • 贵阳做网站cncolour河北seo平台
  • 企业做网站大概需要多少钱3步打造seo推广方案
  • 知名网站制作案例百度关键词优化工具
  • 专营网站建设惠州网站seo
  • 德州专业网站制作哪家好深圳网络推广有几种方法
  • 扬州做网站公司2022年搜索引擎优化指南
  • 建设局网站瓯龙建州府3号楼网站友情链接查询
  • dede后台网站地图怎么做北京网络营销咨询公司
  • 简单个人博客模板网站营销和销售的区别在哪里
  • 番禺网站建设平台手机百度官网
  • 网站建设行业的前景分析湖南正规seo公司