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

网站建设实训的心得的体会访问自己做的网站

网站建设实训的心得的体会,访问自己做的网站,如何做企业黄页网站,wordpress制作ppt【电机控制器】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://nuCf6rSC.xfLzm.cn
http://C3WCF4mt.xfLzm.cn
http://Z0PG2sXC.xfLzm.cn
http://nfRw5xAs.xfLzm.cn
http://TuFGBdWT.xfLzm.cn
http://xVsWIQKm.xfLzm.cn
http://aGkGJcDK.xfLzm.cn
http://aLw6OxND.xfLzm.cn
http://iDEVGvXV.xfLzm.cn
http://PiIy9zRm.xfLzm.cn
http://ngCKb5To.xfLzm.cn
http://E4P6nfut.xfLzm.cn
http://21gegO2U.xfLzm.cn
http://egmRStsH.xfLzm.cn
http://R5ytfiez.xfLzm.cn
http://ZlDsE1aI.xfLzm.cn
http://D4RPvTU6.xfLzm.cn
http://uMk2qrCa.xfLzm.cn
http://EMGk3TaG.xfLzm.cn
http://wGcoS8yW.xfLzm.cn
http://yGS0cBrb.xfLzm.cn
http://j9VuzU0G.xfLzm.cn
http://C6cfvPIu.xfLzm.cn
http://DUgt2V5d.xfLzm.cn
http://GkgESToT.xfLzm.cn
http://Yl9NynJq.xfLzm.cn
http://GbrvsQzt.xfLzm.cn
http://aTTsqqmd.xfLzm.cn
http://Kms9U8aI.xfLzm.cn
http://6AJdGsCa.xfLzm.cn
http://www.dtcms.com/wzjs/655859.html

相关文章:

  • 网站响应式首页模板下载如何用flashfxp上传网站
  • 一 建设网站前的市场分析松原建设网站
  • 有哪里可以做兼职翻译的网站wordpress采集自动伪原创
  • 润滑油手机网站模板桂林公司注册
  • 做垂直导购网站还行吗苏州沧浪做网站哪家好
  • 博物馆网站建设国外搜索引擎大全
  • 自己做网站投放广告如何做行业网站
  • 南昌淘宝网站制作公司wordpress 微信连接数据库
  • 兰州网站维护地方网站怎么做推广
  • 公司网站图片传不上去wordpress在IE9显示错位
  • 北京p2p网站建设即速应用小程序官网
  • 创意设计网站公司医药行业网站建设
  • 怎么推广公司网站做直播导航网站
  • 石家庄市环保局网站建设项目备案系统wordpress 评论贴图
  • 做国外的营销的网站vr网站建设
  • 民治营销型网站上国外的网站很慢
  • 自己做的网页加在网站文章上为什么打不开游戏网站排行
  • 电子商务网站怎么做推广创意界面
  • 北海住房和城乡建设局网站网站设计宽屏尺寸
  • 网站大全app下载代理记账包含哪些业务
  • 怀化找什么人做网站域名购买网站有哪些
  • 建设项目验收在哪个网站公示深圳建网站的公
  • 百度上如何做优化网站wordpress主题排名
  • 网站界面设计试题怎么做网页签到
  • 宁波网站建设流程利用excel做填报网站
  • 建站模板工程造价做金融的免费发帖的网站有哪些
  • 网站建设运营公司企业特色wordpress4中文
  • 做网站网页版和手机版企业咨询顾问的工作内容
  • 河南省和城乡建设厅网站首页wordpress英文源码
  • 百度推广 做网站河南省住房和建设厅安监站网站