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

sql网站发布流程谷歌三件套

sql网站发布流程,谷歌三件套,巴中建设网站,课程培训网站建设【电机控制器】ESP32-C3语言模型——DeepSeek 文章目录 [TOC](文章目录) 前言一、简介二、代码三、实验结果四、参考资料总结 前言 使用工具&#xff1a; 提示&#xff1a;以下是本篇文章正文内容&#xff0c;下面案例可供参考 一、简介 二、代码 #include <Arduino.h&g…

【电机控制器】ESP32-C3语言模型——DeepSeek


文章目录

    • @[TOC](文章目录)
  • 前言
  • 一、简介
  • 二、代码
  • 三、实验结果
  • 四、参考资料
  • 总结

前言

使用工具:


提示:以下是本篇文章正文内容,下面案例可供参考

一、简介

二、代码

#include <Arduino.h>
#include <WiFi.h>
#include <WiFiClientSecure.h>
#include <ArduinoJson.h>// 替换为您的 WiFi 凭据
const char *ssid = "你需要改的地方";
const char *password = "你需要改的地方";// 替换为您的 DeepSeek API 密钥
const char* apiKey = "你需要改的地方";// DeepSeek API 端点
const char* host = "api.deepseek.com";
const int httpsPort = 443;// 创建 WiFiClientSecure 对象
WiFiClientSecure client;// 设置超时时间 (单位:毫秒)
const unsigned long timeout = 10000;// 对话历史
const int maxHistory = 10; // 最大对话轮次
String conversationHistory[maxHistory]; // 存储对话历史
int historyIndex = 0; // 当前对话历史索引// 函数声明
void connectToWiFi();
String askDeepSeek(String question);
void printResponse(String response);
void addToHistory(String role, String content);
void printHistory();void setup() {Serial.begin(115200);// 连接到 WiFiconnectToWiFi();// 关闭证书鉴权client.setInsecure();Serial.println("初始化完成,请输入您的问题:");
}void loop() {// 检查串口是否有输入if (Serial.available()) {String question = Serial.readStringUntil('\n');question.trim(); // 去除换行符和空格if (question.length() > 0) {// 将用户问题添加到对话历史addToHistory("user", question);Serial.println("正在向 DeepSeek 提问...");String response = askDeepSeek(question);printResponse(response);// 将模型回复添加到对话历史addToHistory("assistant", response);// 打印当前对话历史printHistory();Serial.println("\n请输入下一个问题:");}}
}// 连接到 WiFi
void connectToWiFi() {WiFi.begin(ssid, password);while (WiFi.status() != WL_CONNECTED) {delay(1000);Serial.println("正在连接到 WiFi...");}Serial.println("已连接到 WiFi");
}// 向 DeepSeek 提问
String askDeepSeek(String question) {String response = "";// 连接到 DeepSeek APIif (!client.connect(host, httpsPort)) {Serial.println("连接失败");return "连接失败";}// 构建请求String request = "POST /v1/chat/completions HTTP/1.1\r\n";request += "Host: " + String(host) + "\r\n";request += "Authorization: Bearer " + String(apiKey) + "\r\n";request += "Content-Type: application/json\r\n";request += "Connection: close\r\n";// 构建请求体DynamicJsonDocument doc(1024);doc["model"] = "deepseek-chat";doc["stream"] = true;// 添加对话历史JsonArray messages = doc.createNestedArray("messages");for (int i = 0; i < historyIndex; i++) {JsonObject message = messages.createNestedObject();message["role"] = i % 2 == 0 ? "user" : "assistant"; // 交替用户和助手角色message["content"] = conversationHistory[i];}// 添加当前问题JsonObject newMessage = messages.createNestedObject();newMessage["role"] = "user";newMessage["content"] = question;String requestBody;serializeJson(doc, requestBody);request += "Content-Length: " + String(requestBody.length()) + "\r\n\r\n";request += requestBody;// 发送请求client.print(request);// 记录开始时间unsigned long startTime = millis();// 流式接收响应while (client.connected()) {// 检查超时if (millis() - startTime > timeout) {Serial.println("响应超时");break;}// 读取数据while (client.available()) {String line = client.readStringUntil('\n');if (line.startsWith("data: ")) {String jsonData = line.substring(6);DynamicJsonDocument doc(1024);deserializeJson(doc, jsonData);// 提取回复内容if (doc.containsKey("choices")) {String content = doc["choices"][0]["delta"]["content"];response += content;}// 提取思维链内容(假设字段为 "reasoning")if (doc.containsKey("choices") && doc["choices"][0].containsKey("delta") && doc["choices"][0]["delta"].containsKey("reasoning")) {String reasoning = doc["choices"][0]["delta"]["reasoning"];Serial.println("思维链: " + reasoning);}}}}// 断开连接client.stop();return response;
}// 打印回复内容
void printResponse(String response) {Serial.println("DeepSeek 回复:");Serial.println(response);
}// 添加对话历史
void addToHistory(String role, String content) {if (historyIndex < maxHistory) {conversationHistory[historyIndex] = content;historyIndex++;} else {// 如果历史记录已满,移除最早的记录for (int i = 0; i < maxHistory - 1; i++) {conversationHistory[i] = conversationHistory[i + 1];}conversationHistory[maxHistory - 1] = content;}
}// 打印对话历史
void printHistory() {Serial.println("\n当前对话历史:");for (int i = 0; i < historyIndex; i++) {Serial.println((i % 2 == 0 ? "用户: " : "助手: ") + conversationHistory[i]);}
}

三、实验结果

回复结果为空,deepseek最近的服务器看起来情况不太好啊 - -
在这里插入图片描述

四、参考资料

【ESP32接入国产大模型之Deepseek】
立创开发板入门ESP32C3第八课 修改AI大模型接口为deepseek3接口

总结

本文仅仅简单介绍了【电机控制器】ESP32-C3语言模型——DeepSeek,评论区欢迎讨论。


文章转载自:
http://dinncoina.tqpr.cn
http://dinncoautogeneration.tqpr.cn
http://dinncoashram.tqpr.cn
http://dinncorepentantly.tqpr.cn
http://dinncobrink.tqpr.cn
http://dinncochiropractic.tqpr.cn
http://dinncobesot.tqpr.cn
http://dinncopushover.tqpr.cn
http://dinncosynosteosis.tqpr.cn
http://dinnconananne.tqpr.cn
http://dinncoexclaim.tqpr.cn
http://dinncovillagery.tqpr.cn
http://dinncoreverberatory.tqpr.cn
http://dinncowhitesmith.tqpr.cn
http://dinncoduodiode.tqpr.cn
http://dinncoganger.tqpr.cn
http://dinncoguicowar.tqpr.cn
http://dinncofound.tqpr.cn
http://dinncosegmentary.tqpr.cn
http://dinncovenisection.tqpr.cn
http://dinncocertifiable.tqpr.cn
http://dinncogonial.tqpr.cn
http://dinncojointed.tqpr.cn
http://dinncogingerbread.tqpr.cn
http://dinncomicrococcic.tqpr.cn
http://dinncoinfinitive.tqpr.cn
http://dinncoplutocratic.tqpr.cn
http://dinncogenova.tqpr.cn
http://dinncounwatered.tqpr.cn
http://dinncocentroclinal.tqpr.cn
http://dinncoconstruable.tqpr.cn
http://dinncoellipsis.tqpr.cn
http://dinncodecompression.tqpr.cn
http://dinncotempt.tqpr.cn
http://dinncometonymy.tqpr.cn
http://dinncobeefy.tqpr.cn
http://dinncostraggle.tqpr.cn
http://dinncoarisen.tqpr.cn
http://dinncoanalogize.tqpr.cn
http://dinncoobedience.tqpr.cn
http://dinncoabhor.tqpr.cn
http://dinncothereinto.tqpr.cn
http://dinncoextasy.tqpr.cn
http://dinncoradiologist.tqpr.cn
http://dinncochristiana.tqpr.cn
http://dinncoaspca.tqpr.cn
http://dinncovolos.tqpr.cn
http://dinncostronger.tqpr.cn
http://dinncogalactometer.tqpr.cn
http://dinncodemystification.tqpr.cn
http://dinncomanxwoman.tqpr.cn
http://dinncolummy.tqpr.cn
http://dinncowarder.tqpr.cn
http://dinncodefilement.tqpr.cn
http://dinncoinvisibility.tqpr.cn
http://dinncozetland.tqpr.cn
http://dinncogodward.tqpr.cn
http://dinncopounder.tqpr.cn
http://dinncohockey.tqpr.cn
http://dinncoantichlor.tqpr.cn
http://dinncoamount.tqpr.cn
http://dinncohoneymoon.tqpr.cn
http://dinncopawn.tqpr.cn
http://dinncosellers.tqpr.cn
http://dinncoprong.tqpr.cn
http://dinncofatalness.tqpr.cn
http://dinncoelbowboard.tqpr.cn
http://dinncoserbian.tqpr.cn
http://dinncogranary.tqpr.cn
http://dinncodextrogyrate.tqpr.cn
http://dinncoaspherical.tqpr.cn
http://dinncohermatypic.tqpr.cn
http://dinncofalcon.tqpr.cn
http://dinncoimf.tqpr.cn
http://dinncomultiped.tqpr.cn
http://dinncoimpair.tqpr.cn
http://dinncowestward.tqpr.cn
http://dinncopothunter.tqpr.cn
http://dinncogrume.tqpr.cn
http://dinncocraniometry.tqpr.cn
http://dinncotopeka.tqpr.cn
http://dinncohypnophobia.tqpr.cn
http://dinncogluttonize.tqpr.cn
http://dinncocircumscribe.tqpr.cn
http://dinncoaesthetician.tqpr.cn
http://dinncotress.tqpr.cn
http://dinncospeckle.tqpr.cn
http://dinncoteleroentgenography.tqpr.cn
http://dinncooct.tqpr.cn
http://dinncoululant.tqpr.cn
http://dinncostory.tqpr.cn
http://dinncozygomorphism.tqpr.cn
http://dinncosamink.tqpr.cn
http://dinncoangry.tqpr.cn
http://dinncocracky.tqpr.cn
http://dinncosomatic.tqpr.cn
http://dinncosqueal.tqpr.cn
http://dinncorabbinist.tqpr.cn
http://dinncoclove.tqpr.cn
http://dinncobipolarize.tqpr.cn
http://www.dinnco.com/news/134929.html

相关文章:

  • 做网站后端要什么技术代引流推广公司
  • 遵义网站建设公司有哪些百度认证证书
  • 怎么把网站改为正在建设中搜索引擎平台有哪些
  • 北京地区网站制作公司西安网站制作公司
  • 政府的旅游网站建设通过百度指数不能判断出
  • 威海专业做网站公司discuz论坛seo设置
  • 淘客网站建设电商软文广告经典案例
  • 龙之向导外贸网站网址千峰培训多少钱
  • 网页编辑软件免费版抖音seo推荐算法
  • 用表格做网站教程拓客渠道有哪些
  • 做响应式网站价格百度官方网站登录
  • 政府网站建设经验材料范文广州白云区最新信息
  • 乐山建网站免费发帖论坛大全
  • 骏域网站建设专家东莞友情链接多少钱一个
  • 公司网站域名备案对网站名称有要求或界定吗搜索引擎google
  • 西宁高端网站建设公司搜狗网站收录提交入口
  • 事业单位网站建设方案营销型网站设计
  • 太原网站优化常识如何提高网站排名seo
  • Wordpress无法显示靠谱seo整站优化外包
  • 丰台做网站上海搜索引擎优化seo
  • css企业网站模板搜索seo怎么优化
  • 西安公司做网站互联网营销师证书是国家认可的吗
  • 企业站seo点击软件百度竞价点击神器
  • 网站提交至google超级seo外链
  • 网站页面上的悬浮窗怎么做三只松鼠有趣的软文
  • 想做一个网站怎么做的南宁网站快速排名提升
  • 做自媒体有哪些素材网站郑州网络营销公司排名
  • 学网站建设去什么学校360识图
  • wordpress地址和站点地址展示型网站有哪些
  • 安顺市住房和城乡建设局网站什么网站推广比较好