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

沈阳建设局网站做微信网站公司

沈阳建设局网站,做微信网站公司,专业团队原图,质量好的购物平台一、什么是智谱AI 智谱AI成立于2019年#xff0c;由‌清华大学计算机系知识工程实验室的技术成果转化而来#xff0c;是一家致力于人工智能技术研发和应用的公司。智谱致力于打造新一代认知智能大模型#xff0c;专注于做大模型的中国创新。 二、智谱开放平台API调用 官方文…一、什么是智谱AI 智谱AI成立于2019年由‌清华大学计算机系知识工程实验室的技术成果转化而来是一家致力于人工智能技术研发和应用的公司。智谱致力于打造新一代认知智能大模型专注于做大模型的中国创新。 二、智谱开放平台API调用 官方文档 https://open.bigmodel.cn/dev/api#http_para 创建应用 https://open.bigmodel.cn/usercenter/apikeys Nodejs Http调用示例  cnpm i request --save const request require(request) async function main() { let url https://open.bigmodel.cn/api/paas/v4/chat/completions let body { model: glm-4, // 模型选择 temperature: 0.9, //核采样阈值用于决定结果随机性取值越高随机性越强即相同 的问题得到的不同答案的可能性越高。取值范围 (01) top-k: 4, //平衡生成文本的质量和多样性较小的 k 值会减少随机性使得输 出更加稳定而较大的 k 值会增加随机性产生更多新颖的输出。取值范围[1, 6]默认为4 max_tokens: 1000, //模型回答的tokens的最大长度 messages: [ { role: system, //用于设置对话背景,角色设定 content: 你是一个聪明且富有创造力的小说作家 }, { role: user, content: 你是谁 } ], } header { Authorization: Bearer 8e67b3159ae070a71d71fe97fceb733b.Bf7fRh7Yy7uWxdDp, // 注意此处替换自己的key和 secret Content-Type: application/json } var options { method: POST, url: url, headers: header, body: JSON.stringify(body) }; request(options, function (error, response) { if (error) throw new Error(error); console.log(response.body); }); } main(); Golang Http调用示例  package main import ( bytes encoding/json fmt net/http ) func main() { url : https://open.bigmodel.cn/api/paas/v4/chat/completions body : map[string]interface{}{ model: glm-4, temperature: 0.9, top-k: 4, max_tokens: 100, messages: []map[string]interface{}{ { role: system, content: 你是一个聪明且富有创造力的小说作家, }, { role: user, content: 你是谁, }, }, } jsonBody, err : json.Marshal(body) if err ! nil { fmt.Println(Error marshalling JSON:, err) return } req, err : http.NewRequest(POST, url, bytes.NewBuffer(jsonBody)) if err ! nil { fmt.Println(Error creating request:, err) return } req.Header.Set(Authorization, Bearer 8e67b3159ae070a71d71fe97fceb733b.Bf7fRh7Yy7uWxdDp) req.Header.Set(Content-Type, application/json) client : http.Client{} resp, err : client.Do(req) if err ! nil { fmt.Println(Error sending request:, err) return } defer resp.Body.Close() var result map[string]interface{} err json.NewDecoder(resp.Body).Decode(result) if err ! nil { fmt.Println(Error decoding response:, err) return } fmt.Println(result) } Python Http调用示例 import requests import json # 定义请求的URL url https://open.bigmodel.cn/api/paas/v4/chat/completions # 定义请求的body body { model: glm-4, temperature: 0.9, top-k: 4, max_tokens: 100, messages: [ { role: system, content: 你是一个聪明且富有创造力的小说作家 }, { role: user, content: 你是谁 } ], } # 定义请求的headers headers { Authorization: Bearer 8e67b3159ae070a71d71fe97fceb733b.Bf7fRh7Yy7uWxdDp, Content-Type: application/json } # 发送POST请求 response requests.post(url, headersheaders, datajson.dumps(body)) # 打印响应结果 print(response.json()) OpenAi调用示例   https://github.com/openai/openai-node https://github.com/openai/openai-python https://github.com/sashabaranov/go-openai 官方文档 调用示例 https://www.xfyun.cn/doc/spark/HTTP%E8%B0%83%E7%94%A8%E6%96%87%E6%A1%A3.html#_7 -%E4%BD%BF%E7%94%A8openai-sdk%E8%AF%B7%E6%B1%82%E7%A4%BA%E4%BE%8B Python openAi https://github.com/openai/openai-python 1、安装依赖  pip install openai 2、请求  # https://github.com/openai/openai-python # pip install openai from openai import OpenAI client OpenAI( api_key8e67b3159ae070a71d71fe97fceb733b.Bf7fRh7Yy7uWxdDp, base_urlhttps://open.bigmodel.cn/api/paas/v4/ ) completion client.chat.completions.create( modelglm-4, messages[ {role: system, content: 你是一个聪明且富有创造力的小说作家}, {role: user, content: 请你作为童话故事大王写一篇短篇童话故事故事的主 题是要永远保持一颗善良的心要能够激发儿童的学习兴趣和想象力同时也能够帮助儿童更好地理解和接 受故事中所蕴含的道理和价值观。} ], top_p0.7, temperature0.9 ) print(completion.choices[0].message) Nodejs openAi https://github.com/openai/openai-node 安装依赖 npm install openai --save cnpm install openai --save 使用import 需要在package.json里面需要配置type:module,   { type: module, dependencies: { } } 配置代码   import OpenAI from openai; const client new OpenAI({ apiKey: 8e67b3159ae070a71d71fe97fceb733b.Bf7fRh7Yy7uWxdDp, baseURL: https://open.bigmodel.cn/api/paas/v4/ }); async function main() { const chatCompletion await client.chat.completions.create({ messages: [{ role: user, content: 你好 }], model: GLM-4-Flash, }); console.log(chatCompletion.choices[0].message.content); } main(); 智谱开放平台API调用视频详解 【应用开发】分别用nodejs python golang Opne Ai调用 ChatGLM 智谱AI大模型的Api
http://www.yingshimen.cn/news/59632/

相关文章:

  • 毕业设计做视频网站网站正在建设中 手机版
  • 怎样修改网站的主页内容wordpress分类下文章置顶
  • 网站建设费和网站维护费的区别自做网站多少钱
  • 昌邑市住房和建设局网站太原app定制
  • 南昌网站建设渠道wordpress 个人博客 主题
  • 假网站网站怎么做广西百度推广
  • 湖北网站推广公司技巧数据做图网站
  • 营销型网站的建设与推广辅导记录优猫券网站怎么做
  • 公司建设网站有什么好处外贸网站后台
  • 北京网站建设龙鹏印度软件外包产业
  • 微信公众 号平台官网网站优化招商
  • 猎上网登陆官方网站福建省龙岩市新罗区建设局网站
  • 做网站域名的好处是什么网站信息推广途径包括哪些
  • 外贸网站建站那家公司好电子报 网站开发
  • 岳阳建设局网站seo对网站的重要性
  • 苏州建材装修网站建设上海工程造价咨询公司
  • 记事本做网站怎么改字体wordpress如何销售卡密
  • 网站建设公司兴田德润优惠搭建本地网站环境
  • 建设网站都要学些什么iis搭建网站怎么做前端
  • 电子商务类网站建设的网站后台会自动退出是正常的
  • 洪山网站建设公司软件开发工资一般多少大专
  • 网站开发培训排名.net 网站开发视频
  • 全网营销网站怎么做织梦招商加盟网站源码
  • 齐河网站建设电话wordpress博客怎么访问不了
  • 怎样才能建设一歌网站api接口开放平台
  • 网站死链接怎么提交深圳公司注册电话
  • 门户网站建设一般多少钱旗袍网站架构
  • 企业网站推广渠道有哪些沈阳建设工程信息网中介
  • 奉贤做网站的沧州网站建设的公司
  • 网站建设市场报告做 网络网站