互联网排名前十的公司/天津关键词优化平台

互联网排名前十的公司,天津关键词优化平台,WordPress对接易支付,ipv6网站如何做🎉🎉🎉🎉🎉🎉 欢迎访问的个人博客:https://swzbk.site/,加好友,拉你入福利群 🎉🎉🎉🎉🎉🎉 1、de…

🎉🎉🎉🎉🎉🎉
欢迎访问的个人博客:https://swzbk.site/,加好友,拉你入福利群
🎉🎉🎉🎉🎉🎉

1、deepseek介绍

DeepSeek(深度求索)是一家成立于2023年7月的中国人工智能公司,由量化资管巨头幻方量化创立,专注于开发高性能大语言模型(LLM)及相关技术。今年年初以其模型高性能能力而备受关注,目前国内企业正在广泛接入使用。

2、vue前端界面

  • 加了一个nav页签:深度探索
    在这里插入图片描述

  • 页面代码如下:

<template><div class="chat-wrapper"><div class="chat-container"><div class="chat-header"><h2>DeepSeek 对话</h2></div><div class="chat-messages" ref="chatMessages"><div v-for="(message, index) in chatMessages" :key="index" :class="['message', message.includes('你:') ? 'user-message' : 'bot-message']"><span>{{ message }}</span></div></div><div class="input-container"><input v-model="userInput" type="text" placeholder="输入你的问题" @keydown.enter="sendMessage"><button @click="sendMessage">发送</button></div></div></div>
</template><script>
export default {data() {return {userInput: '',chatMessages: []};},methods: {async sendMessage() {if (this.userInput.trim() === '') return;// 显示用户消息this.chatMessages.push(`你: ${this.userInput}`);try {//这里后面换成服务器ipconst response = await fetch('http://localhost:8090/deepseek', {method: 'POST',headers: {'Content-Type': 'application/json'},body: JSON.stringify({ prompt: this.userInput })});const data = await response.json();const answer = data.answer;// 显示 DeepSeek 的回答this.chatMessages.push(`DeepSeek: ${answer}`);} catch (error) {console.error('请求出错:', error);this.chatMessages.push('请求出错,请稍后再试');}// 清空输入框this.userInput = '';this.$nextTick(() => {this.$refs.chatMessages.scrollTop = this.$refs.chatMessages.scrollHeight;});}}
};
</script><style scoped>
.chat-wrapper {display: flex;justify-content: center;align-items: center;min-height: 100vh;background-color: #f4f4f9;
}.chat-container {width: 80%;height: 80vh;border-radius: 12px;box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);background-color: #fff;overflow: hidden;display: flex;flex-direction: column;
}.chat-header {background-color: #007bff;color: #fff;padding: 15px 20px;text-align: center;flex-shrink: 0;
}.chat-header h2 {margin: 0;font-size: 1.3rem;
}.chat-messages {flex-grow: 1;overflow-y: auto;padding: 20px;display: flex;flex-direction: column;
}.message {padding: 10px 15px;border-radius: 8px;margin-bottom: 10px;max-width: 80%;word-wrap: break-word;
}.user-message {background-color: #e0f7fa;align-self: flex-end;color: #212121;
}.bot-message {background-color: #f1f8e9;align-self: flex-start;color: #212121;
}.input-container {display: flex;padding: 15px 20px;border-top: 1px solid #e0e0e0;flex-shrink: 0;
}.input-container input {flex: 1;padding: 10px;border: 1px solid #ccc;border-radius: 6px;margin-right: 10px;font-size: 1rem;
}.input-container button {padding: 10px 20px;background-color: #007bff;color: #fff;border: none;border-radius: 6px;cursor: pointer;font-size: 1rem;transition: background-color 0.2s ease;
}.input-container button:hover {background-color: #0056b3;
}
</style>

3、deepseek api申请

deepseek api
申请完之后,需要充值使用,有的新人会有免费使用次数,我这里充值了5米,测试用够了。

4、springboot接口增加

  • DeepSeekController接口
package top.naccl.controller;
import com.fasterxml.jackson.databind.JsonNode;
import okhttp3.*;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import top.naccl.model.dto.DeepSeekRequest;
import top.naccl.model.dto.DeepSeekResponse;
import com.fasterxml.jackson.databind.ObjectMapper;import java.io.IOException;
import java.util.concurrent.TimeUnit;@RestController
public class DeepseekController {private static final ObjectMapper objectMapper = new ObjectMapper();//换成自己的deepseek apiprivate static final String DEEPSEEK_API_KEY = "sk-xxxx";private static final String DEEPSEEK_API_URL = "https://api.deepseek.com/v1/chat/completions";@PostMapping("/deepseek")public DeepSeekResponse handleDeepSeekRequest(@RequestBody DeepSeekRequest request) throws IOException {OkHttpClient client = new OkHttpClient.Builder().readTimeout(100, TimeUnit.SECONDS)  // 增加读取超时时间.build();MediaType JSON = MediaType.get("application/json; charset=utf-8");String json = "{\"model\": \"deepseek-chat\", \"messages\": [{\"role\": \"user\", \"content\": \"" + request.getPrompt() + "\"}]}";// 使用 okhttp3.RequestBody 创建请求体okhttp3.RequestBody body = okhttp3.RequestBody.create(JSON, json.getBytes());Request apiRequest = new Request.Builder().url(DEEPSEEK_API_URL).post(body).addHeader("Authorization", "Bearer " + DEEPSEEK_API_KEY).addHeader("Content-Type", "application/json").build();try (Response response = client.newCall(apiRequest).execute()) {if (!response.isSuccessful()) {return new DeepSeekResponse("请求失败:" + response.code());}return handleNormalResponse(response);} catch (IOException e) {return new DeepSeekResponse("请求异常:" + e.getMessage());}}private DeepSeekResponse handleNormalResponse(Response response) throws IOException {try (ResponseBody body = response.body()) {if (body == null) {return new DeepSeekResponse("空响应");}String responseData = body.string();JsonNode jsonNode = objectMapper.readTree(responseData);if (jsonNode.has("choices") && !jsonNode.get("choices").isEmpty()) {JsonNode messageNode = jsonNode.get("choices").get(0).get("message");if (messageNode != null && messageNode.has("content")) {return new DeepSeekResponse(messageNode.get("content").asText());}}return new DeepSeekResponse("未找到有效回答");}}}
  • DeepSeekRequest请求类
package top.naccl.model.dto;import com.fasterxml.jackson.annotation.JsonProperty;// 请求类,用于接收前端传来的用户问题
public class DeepSeekRequest {@JsonProperty("prompt")private String prompt;public String getPrompt() {return prompt;}public void setPrompt(String prompt) {this.prompt = prompt;}
}
  • DeepSeekResponse响应类
package top.naccl.model.dto;// 响应类,用于返回 DeepSeek 的回答给前端
public class DeepSeekResponse {private String answer;public DeepSeekResponse(String answer) {this.answer = answer;}public String getAnswer() {return answer;}public void setAnswer(String answer) {this.answer = answer;}
}

5、pom.xml引入

    <!-- deepseek --><dependency><groupId>com.squareup.okhttp3</groupId><artifactId>okhttp</artifactId><version>4.11.0</version></dependency><dependency><groupId>com.fasterxml.jackson.core</groupId><artifactId>jackson-databind</artifactId></dependency>

6、问题总结

  • 调用比较慢,上面的读取时间需要设置长点
  • 目前不支持记忆问答,每次刷新之前的问答就会清空
  • 目前使用的是非流式响应,具体后面在研究流式响应,据说比较快,所以推荐
  • 测试使用调用api 30次左右,花费0.05
  • 界面还需待优化

🎉🎉🎉🎉🎉🎉
欢迎访问的个人博客:https://swzbk.site/,加好友,拉你入福利群
🎉🎉🎉🎉🎉🎉

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/pingmian/72403.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Kubernetes 单节点集群搭建

Kubernetes 单节点集群搭建教程 本人尝试基于Ubuntu搭建一个单节点K8S集群&#xff0c;其中遇到各种问题&#xff0c;最大的问题就是网络&#xff0c;各种镜像源下载不下来&#xff0c;特此记录&#xff01;注意&#xff1a;文中使用了几个镜像&#xff0c;将看来可能失效导致安…

专题三0~n-1中缺失的数字

1.题目 给一个数组&#xff0c;单调性是递增的&#xff0c;需要找到缺失的数字&#xff0c;加上这个数字就变为等差数组了。 2.算法原理 这里用二分来解决&#xff0c;而二段性是根据下标区分&#xff0c;临界值前的数字于下标相对应&#xff0c;临界值后的于下标相差1&#x…

【图像处理】ISP(Image Signal Processor) 图像处理器的用途和工作原理?

ISP&#xff08;图像信号处理器&#xff09;是数字影像设备的“视觉大脑”&#xff0c;负责将传感器捕获的原始电信号转化为我们看到的高清图像。以下从用途和工作原理两方面通俗解析&#xff1a; 一、ISP的核心用途&#xff1a;让照片“更像眼睛看到的” 提升画质&#xff1a…

python学习笔记-mysql数据库操作

现有一个需求&#xff0c;调用高德api获取全国县级以上行政区数据并保存为json文件&#xff0c;使用python获取&#xff1a; import requests import json# 高德API Key api_key "your_api_key"# 调用行政区域查询API def fetch_districts():url f"https://r…

Redisson 实现分布式锁源码浅析

大家好&#xff0c;我是此林。 今天来分享Redisson分布式锁源码。还是一样&#xff0c;我们用 问题驱动 的方式展开讲述。 1. redis 中如何使用 lua 脚本&#xff1f; Redis内置了lua解释器&#xff0c;lua脚本有两个好处&#xff1a; 1. 减少多次Redis命令的网络传输开销。…

【软件】免费的PDF全文翻译软件,能保留公式图表的样式

转载请注明出处&#xff1a;小锋学长生活大爆炸[xfxuezhagn.cn] 如果本文帮助到了你&#xff0c;欢迎[点赞、收藏、关注]哦~ 很多PDF全文翻译软件都是收费的&#xff0c;而划线翻译看着又很累。这个开源的PDF全文翻译软件非常好用&#xff0c;并且能够保留公式、图表、目录和注…

PentestGPT 下载

PentestGPT 下载 PentestGPT 介绍 PentestGPT&#xff08;Penetration Testing GPT&#xff09;是一个基于大语言模型&#xff08;LLM&#xff09;的智能渗透测试助手。它结合了 ChatGPT&#xff08;或其他 GPT 模型&#xff09;与渗透测试工具&#xff0c;帮助安全研究人员自…

防火墙虚拟系统实验

一实验拓扑 二实验过程 配置资源 创建虚拟系统 配置管理员 创建安全策略

Linux与深入HTTP序列化和反序列化

深入HTTP序列化和反序列化 本篇介绍 在上一节已经完成了客户端和服务端基本的HTTP通信&#xff0c;但是前面的传递并没有完全体现出HTTP的序列化和反序列化&#xff0c;为了更好得理解其工作流程&#xff0c;在本节会以更加具体的方式分析到HTTP序列化和反序列化 本节会在介绍…

基于Python+SQLite实现(Web)验室设备管理系统

实验室设备管理系统 应用背景 为方便实验室进行设备管理&#xff0c;某大学拟开发实验室设备管理系统 来管理所有实验室里的各种设备。系统可实现管理员登录&#xff0c;查看现有的所有设备&#xff0c; 增加设备等功能。 开发环境 Mac OSPyCharm IDEPython3Flask&#xff…

深拷贝and浅拷贝!

一、什么是拷贝&#xff1f;什么是深拷贝和浅拷贝&#xff1f; &#xff08;1&#xff09;拷贝&#xff1a;拷贝就是为了复用原对象的部分or全部数据&#xff0c;在原对象的基础上通过复制的方式创建一个新的对象。 拷贝对象可以分为三种类型&#xff1a;直接赋值、浅拷贝和深拷…

高频面试题(含笔试高频算法整理)基本总结回顾43

干货分享&#xff0c;感谢您的阅读&#xff01; &#xff08;暂存篇---后续会删除&#xff0c;完整版和持续更新见高频面试题基本总结回顾&#xff08;含笔试高频算法整理&#xff09;&#xff09; 备注&#xff1a;引用请标注出处&#xff0c;同时存在的问题请在相关博客留言…

网络爬虫【简介】

我叫补三补四&#xff0c;很高兴见到大家&#xff0c;欢迎一起学习交流和进步 今天来讲一讲视图 一、网络爬虫的定义 网络爬虫&#xff08;Web Crawler&#xff09;&#xff0c;又称为网络蜘蛛、网络机器人等&#xff0c;是一种按照一定规则自动抓取互联网信息的程序或脚本。它…

​AI时代到来,对电商来说是效率跃升,还是温水煮青蛙

​凌晨三点的义乌商贸城&#xff0c;95后创业者小王&#xff0c;静静地盯着屏幕上的AI工具&#xff0c;竟露出了笑容。这个月他的跨境玩具店销量提升了不少&#xff0c;从之前的状态翻了3倍&#xff1b;而且团队人数有所变化&#xff0c;从5人缩减到了2人&#xff08;其中包括他…

PDF文件密码保护破解:安全解密的步骤与技巧

PDF文件加密后&#xff0c;需要特定的密码才能访问内容。以下是一些常见的方法来解密PDF文件&#xff1a; 方法一&#xff1a;使用Adobe Acrobat 如果你有Adobe Acrobat Pro&#xff0c;可以使用它来解密PDF文件。 打开Adobe Acrobat Pro&#xff1a; 启动Adobe Acrobat Pro…

qt 自带虚拟键盘的编译使用记录

一、windows 下编译 使用vs 命令窗口&#xff0c;分别执行&#xff1a; qmake CONFIG"lang-en_GB lang-zh_CN" nmake nmake install 如果事先没有 指定需要使用的输入法语言就进行过编译&#xff0c;则需要先 执行 nmake distclean 清理后执行 qmake 才能生效。 …

C++刷题(二):栈 + 队列

&#x1f4dd;前言说明&#xff1a; 本专栏主要记录本人的基础算法学习以及刷题记录&#xff0c;使用语言为C。 每道题我会给出LeetCode上的题号&#xff08;如果有题号&#xff09;&#xff0c;题目&#xff0c;以及最后通过的代码。没有题号的题目大多来自牛客网。对于题目的…

精通游戏测试笔记(持续更新)

第一章、游戏测试的两条规则 不要恐慌 不要将这次发布当作最后一次发布 不要相信任何人 把每次发布当作最后一次发布 第二章&#xff1a;成为一名游戏测试工程师

Windows功能之FTP服务器搭建

一、创作背景 之前有用linux系统搭建过ftp服务器&#xff0c;最近想着用windows系统也顺便搭建一个&#xff0c;看网上有第三方服务软件一键部署&#xff0c;记得windows可以不借助第三方软件就可以搭建&#xff0c;就想顺便操作试试&#xff0c;结果老是连接不上&#xff0c;费…

星型组网模块的两种交互方式优缺点解析

星型组网模块简介 星型组网模块工作在433MHz频段&#xff1b;星型组网模块集主机&#xff08;协调器&#xff09;、终端为一体&#xff0c;星型组网模块具有长距离、高速率两种传输模式&#xff0c;一个主机&#xff08;协调器&#xff09;支持多达200个节点与其通讯&#xff0…