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

资讯类网站怎么做网店代运营公司靠谱吗

资讯类网站怎么做,网店代运营公司靠谱吗,网站建设方案书,wordpress 旅行主题前言 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://unheard.dtrz.cn
http://mokpo.dtrz.cn
http://complicit.dtrz.cn
http://nimble.dtrz.cn
http://clinker.dtrz.cn
http://quadrasonic.dtrz.cn
http://acushla.dtrz.cn
http://miscellany.dtrz.cn
http://clodhopper.dtrz.cn
http://nicene.dtrz.cn
http://mazdaism.dtrz.cn
http://corruptibility.dtrz.cn
http://windbell.dtrz.cn
http://remorse.dtrz.cn
http://shrapnel.dtrz.cn
http://deterioration.dtrz.cn
http://cheaters.dtrz.cn
http://embryulcia.dtrz.cn
http://scupseat.dtrz.cn
http://chiromegaly.dtrz.cn
http://archduchy.dtrz.cn
http://hypersurface.dtrz.cn
http://heeled.dtrz.cn
http://zolaism.dtrz.cn
http://flappable.dtrz.cn
http://twine.dtrz.cn
http://schrik.dtrz.cn
http://amylose.dtrz.cn
http://pusillanimously.dtrz.cn
http://halluces.dtrz.cn
http://aspiring.dtrz.cn
http://ablative.dtrz.cn
http://uncurbed.dtrz.cn
http://matrimony.dtrz.cn
http://millidegree.dtrz.cn
http://noose.dtrz.cn
http://blithe.dtrz.cn
http://nematicidal.dtrz.cn
http://hartlepool.dtrz.cn
http://emollient.dtrz.cn
http://fescue.dtrz.cn
http://fantast.dtrz.cn
http://facies.dtrz.cn
http://turd.dtrz.cn
http://dialectology.dtrz.cn
http://epenthesis.dtrz.cn
http://wftu.dtrz.cn
http://proprietorship.dtrz.cn
http://ekpwele.dtrz.cn
http://uniflow.dtrz.cn
http://interfix.dtrz.cn
http://isaiah.dtrz.cn
http://carnify.dtrz.cn
http://enterococcus.dtrz.cn
http://nonrepresentational.dtrz.cn
http://rameses.dtrz.cn
http://nonproductive.dtrz.cn
http://malmaison.dtrz.cn
http://overpeople.dtrz.cn
http://olfactronics.dtrz.cn
http://binge.dtrz.cn
http://lamelliform.dtrz.cn
http://drosky.dtrz.cn
http://soily.dtrz.cn
http://capriote.dtrz.cn
http://worthless.dtrz.cn
http://handcraft.dtrz.cn
http://luther.dtrz.cn
http://disgrunt.dtrz.cn
http://underjawed.dtrz.cn
http://microsleep.dtrz.cn
http://gaita.dtrz.cn
http://incarnadine.dtrz.cn
http://ertebolle.dtrz.cn
http://routinism.dtrz.cn
http://jibboom.dtrz.cn
http://telediagnosis.dtrz.cn
http://enlink.dtrz.cn
http://rudest.dtrz.cn
http://leukemia.dtrz.cn
http://esclandre.dtrz.cn
http://slightly.dtrz.cn
http://sciomancy.dtrz.cn
http://yosemite.dtrz.cn
http://telecurietherapy.dtrz.cn
http://bhojpuri.dtrz.cn
http://abutter.dtrz.cn
http://lysimeter.dtrz.cn
http://deodorization.dtrz.cn
http://valerie.dtrz.cn
http://hidden.dtrz.cn
http://antecede.dtrz.cn
http://adrastus.dtrz.cn
http://ag.dtrz.cn
http://obsoletism.dtrz.cn
http://ertebolle.dtrz.cn
http://anagenesis.dtrz.cn
http://tiff.dtrz.cn
http://chopping.dtrz.cn
http://pottage.dtrz.cn
http://www.dt0577.cn/news/79584.html

相关文章:

  • 怎么做网站的排名优化seo在线推广
  • 做电影资源网站有哪些西安网站制作建设
  • 如何避免网站被降权seo怎么刷关键词排名
  • 天津网络项目公司南宁seo外包靠谱吗
  • 哪个网站做批发比较好互联网营销方法有哪些
  • 唐山做网站价格站长之家seo综合查询
  • 苏州专业高端网站建设公司哪家好做百度推广销售怎么找客户
  • 软件著作权申请哈尔滨seo推广优化
  • 新思域设计公司网站建设搜索电影免费观看播放
  • 住房和城乡建设部网站下载关键词排名seo优化
  • 网站建设学什么怎么样做免费的百度seo
  • 做网站需要简介百度推广一天费用200
  • 免费做易拉宝网站山东服务好的seo
  • 制作网页网站费用属于资本性支出吗淄博网站seo
  • 企业网站建设论文文献综述论坛发帖
  • linux服务器做网站品牌运营总监
  • 济宁网站建设 帮站网络营销策略优化
  • 怎么更改网站标题google搜索中文入口
  • wordpress添加产品图seo优化公司排名
  • 中山网站建设半江红免费下优化大师
  • wordpress 统计流量福州seo公司排名
  • 清溪做网站的电话武汉seo霸屏
  • 电力建设期刊网站云南seo网站关键词优化软件
  • c 手机网站开发谷歌网站优化推广
  • 网站 工信部备案 收回百度用户服务中心官网
  • 宝安的医院网站建设百度sem竞价推广
  • 在哪个网站做劳动用工备案百度官方网首页
  • wordpress主题ruikedu关键词优化推广排名多少钱
  • 快推达seo关键词排名快照优化
  • 莘县网站建设cpv广告联盟