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

星火大模型接入及文本生成HTTP流式、非流式接口(JAVA)

文章目录

  • 一、接入星火大模型
  • 二、基于JAVA实现HTTP非流式接口
    • 1.配置
    • 2.接口实现
      • (1)分析接口请求
      • (2)代码实现
    • 3.功能测试
      • (1)测试对话功能
      • (2)测试记住上下文功能
  • 三、基于JAVA实现HTTP流式接口
    • 1.接口实现
      • (1)分析接口请求
      • (2)代码实现
    • 2.功能测试
      • (1)测试对话功能
      • (2)测试记住上下文功能

一、接入星火大模型

首先,需要在讯飞开放平台(https://passport.xfyun.cn/login)进行登录:

在这里插入图片描述

  • 点击这个+创建应用:
    在这里插入图片描述

  • 创建应用:
    在这里插入图片描述

  • 查看创建好的应用:

在这里插入图片描述

点击创建的应用可以查看各种鉴权信息,如调用http接口需要的APIPassword。

二、基于JAVA实现HTTP非流式接口

非流式,即一次性返回生成的内容,返回为一个接口;流式,即一边生成一边返回,会返回多个接口,所有接口的文本内容拼接起来构成完整的回答。

本文以模型Spark Lite为例,重要信息(APIPassword、接口地址)在这个页面查看:https://console.xfyun.cn/services/cbm
接口文档在这个地址查看:https://www.xfyun.cn/doc/spark/HTTP%E8%B0%83%E7%94%A8%E6%96%87%E6%A1%A3.html#_1-%E6%8E%A5%E5%8F%A3%E8%AF%B4%E6%98%8E

1.配置

  • 需要先创建好Spring Boot项目,配置applicaiton.yml如下:
port: 9000# 星火大模型相关配置
spark:# http鉴权相关配置http:httpApiPassword: ""# 模型相关配置,参考https://console.xfyun.cn/services/cbmmodel:temperature: 0.5 #核采样阈值,用于决定结果随机性,取值越高随机性越强,即相同的问题得到的不同答案的可能性越高。取值范围 (0,1],默认为0.5topK: 4 # 平衡生成文本的质量和多样性,较小的 k 值会减少随机性,使得输出更加稳定;而较大的 k 值会增加随机性,产生更多新颖的输出。取值范围[1, 6],默认为4max_tokens: 1024 # 允许回复的最大tokens数量modelName: "lite"apiHttpUrl: "https://spark-api-open.xf-yun.com/v1/chat/completions"historyRememberCount: 100 # 记录的上下文条数,为0则表示单轮问答不记住上下文
  • pom.xml如下:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>org.example</groupId><artifactId>spark</artifactId><version>1.0-SNAPSHOT</version><properties><maven.compiler.source>8</maven.compiler.source><maven.compiler.target>8</maven.compiler.target><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding></properties><dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId><version>2.7.6</version></dependency><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><version>1.18.30</version></dependency><dependency><groupId>com.alibaba</groupId><artifactId>fastjson</artifactId><version>2.0.43</version></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><version>2.7.18</version><scope>test</scope></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-websocket</artifactId><version>2.7.18</version></dependency></dependencies></project>

2.接口实现

(1)分析接口请求

  • 请求头:
Content-Type: application/json
Authorization: Bearer 123456
  • 请求体:
{"model": "generalv3.5","user": "用户唯一id","messages": [{"role": "system","content": "你是知识渊博的助理"},{"role": "user","content": "你好,讯飞星火"}],// 下面是可选参数"temperature": 0.5,"top_k": 4,"stream": false,"max_tokens": 1024
}
  • 正常响应:
{"code": 0,"message": "Success","sid": "cha000b0003@dx1905cd86d6bb86d552","choices": [{"message": {"role": "assistant","content": "你好,我是由科大讯飞构建的星火认知智能模型。\n如果你有任何问题或者需要帮助的地方,请随时告诉我!我会尽力为你提供解答和支持。请问有什么可以帮到你的吗?"},"index": 0}],"usage": {"prompt_tokens": 6,"completion_tokens": 42,"total_tokens": 48}
}
  • 错误响应:
{"error": {"message": "invalid user","type": "api_error","param": null,"code": null}
}

(2)代码实现

  • 主方法:
	//从application.yml中引入一些必要的配置@Value("${spark.http.httpApiPassword}")private String httpApiPassword;@Value("${spark.model.apiHttpUrl}")private String apiUrl;@Value("${spark.model.temperature}")private float temperature;@Value("${spark.model.topK}")private int topK;@Value("${spark.model.modelName}")private String model;@Value("${spark.model.max_tokens}")private int maxTokens;@Value("${spark.model.historyRememberCount}")private int historyRememberCount;private final ObjectMapper objectMapper = new ObjectMapper();public SparkResponse completions(String systemContent, String userContent, String userId) throws IOException {URL url = new URL(apiUrl);HttpURLConnection connection = (HttpURLConnection) url.openConnection();connection.setRequestMethod("POST");// 设置请求头connection.setRequestProperty("Authorization", "Bearer " + httpApiPassword);connection.setRequestProperty("Content-Type", "application/json");// 设置请求体,发起请求connection.setDoOutput(true);connection.getOutputStream().write(buildRequestBody(systemContent, userContent, userId,false).toJSONString().getBytes());// 获取响应SparkResponse res = parseResponse(connection);// 将响应加到上下文中if(historyRememberCount>0){rememberCompletionsAnswer(userId,res);}return res;}
  • 构建请求体:
private JSONObject buildRequestBody(String systemContent, String userContent, String userId, boolean isStreaming) {// 加入一些大模型参数JSONObject requestBody = new JSONObject();requestBody.put("model", model);requestBody.put("temperature", temperature);requestBody.put("top_k", topK);requestBody.put("max_tokens", maxTokens);requestBody.put("stream", isStreaming);JSONArray messages = new JSONArray();// 将历史上下文加入请求中if (historyRememberCount > 0&&!historyDialoguesMap.isEmpty()&&historyDialoguesMap.containsKey(userId)) {messages.addAll(historyDialoguesMap.get(userId));}// 构建此轮dialogue并加入到上下文中Dialogue messageSystem = null;if (StringUtils.isNotEmpty(systemContent)) {messageSystem = new Dialogue("system", systemContent);messages.add(messageSystem);}Dialogue messageUser = new Dialogue("user", userContent);messages.add(messageUser);if(historyRememberCount > 0){historyInsert(userId,messageSystem);historyInsert(userId,messageUser);}requestBody.put("messages", messages);return requestBody;}/*** 上下文添加方法*/public void historyInsert(String userId, Dialogue dialogue) {if(dialogue == null){return;}if (historyDialoguesMap.containsKey(userId)) {List<Dialogue> historyDialogues = historyDialoguesMap.get(userId);historyDialogues.add(dialogue);if (historyDialogues.size() > historyRememberCount) {historyDialogues.remove(0);}}else{List<Dialogue> historyDialogues = new ArrayList<>();historyDialogues.add(dialogue);historyDialoguesMap.put(userId,historyDialogues);if (historyDialogues.size() > historyRememberCount) {historyDialogues.remove(0);}}}
  • 定义响应体类:
/*** 星火大模型返回类型封装*/
@AllArgsConstructor
@NoArgsConstructor
@Data
public class SparkResponse implements Serializable {private static final long serialVersionUID = 1L;private Integer code;private String message;private String sid;private String id;private Long created;private List<Choices> choices;private JSONObject usage;private JSONObject error;
}
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Choices implements Serializable {private static final long serialVersionUID = 1L;private Dialogue message;private Dialogue delta;private int index;
}
/*** 与大模型的会话*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Dialogue {/*** 角色:system  user  assistant*/private String role;private String content;private int index;public Dialogue(String role, String content) {this.role=role;this.content=content;}
}
  • 获取响应:
    private SparkResponse parseResponse(HttpURLConnection connection) throws IOException {int responseCode = connection.getResponseCode();log.info("SparkHttpAPI completions responseCode:{}", responseCode);if (responseCode == HttpURLConnection.HTTP_OK) {try (InputStream inputStream = connection.getInputStream()) {return objectMapper.readValue(inputStream, SparkResponse.class);}} else {throw new SparkResponseParseException("NonStreaming Completions Result Parse Error");}}
  • 将响应加到上下文中:
 public void rememberCompletionsAnswer(String userId, SparkResponse res){historyInsert(userId, res.getChoices().get(0).getMessage());}

3.功能测试

(1)测试对话功能

 @Autowiredprivate SparkHttpAPI sparkHttpAPITest;@Testvoid completions() {String systemContent = "你是知识渊博的助理";String userContent = "告诉我讯飞星火认知大模型的应用场景有哪些?";try{SparkResponse ans= sparkHttpAPITest.completions(systemContent,userContent,"111");System.out.println(ans);}catch (Exception e){log.error("测试不通过",e);}}

在这里插入图片描述

(2)测试记住上下文功能

 @Testvoid historyTest() {String systemContent = "你是知识渊博的律师";String userContent = "小王偷了小李门口的鞋子,小王犯法吗?";try {SparkResponse ans = sparkHttpAPITest.completions(systemContent, userContent, "111");System.out.println(ans);userContent = "小王犯了什么罪";ans = sparkHttpAPITest.completions(null, userContent, "111");System.out.println(ans);} catch (Exception e) {log.error("测试不通过", e);}}

在这里插入图片描述

三、基于JAVA实现HTTP流式接口

接口文档也在这个地址查看:https://www.xfyun.cn/doc/spark/HTTP%E8%B0%83%E7%94%A8%E6%96%87%E6%A1%A3.html#_1-%E6%8E%A5%E5%8F%A3%E8%AF%B4%E6%98%8E

1.接口实现

(1)分析接口请求

  • 响应格式:

相比非流式略微有一些不同,响应分成了多次,最后一个data:[DONE]为结束标志。

data:{"code":0,"message":"Success","sid":"cha000b000c@dx1905cf38fc8b86d552","id":"cha000b000c@dx1905cf38fc8b86d552","created":1719546385,"choices":[{"delta":{"role":"assistant","content":"你好"},"index":0}]}data:{"code":0,"message":"Success","sid":"cha000b000c@dx1905cf38fc8b86d552","id":"cha000b000c@dx1905cf38fc8b86d552","created":1719546385,"choices":[{"delta":{"role":"assistant","content":",很高兴"},"index":0}]}data:{"code":0,"message":"Success","sid":"cha000b000c@dx1905cf38fc8b86d552","id":"cha000b000c@dx1905cf38fc8b86d552","created":1719546385,"choices":[{"delta":{"role":"assistant","content":"为你解答问题"},"index":0}]}data:{"code":0,"message":"Success","sid":"cha000b000c@dx1905cf38fc8b86d552","id":"cha000b000c@dx1905cf38fc8b86d552","created":1719546385,"choices":[{"delta":{"role":"assistant","content":"。\n"},"index":0}]}data:{"code":0,"message":"Success","sid":"cha000b000c@dx1905cf38fc8b86d552","id":"cha000b000c@dx1905cf38fc8b86d552","created":1719546387,"choices":[{"delta":{"role":"assistant","content":"我是讯飞星火认知大模型,由科大讯飞构建的认知智能系统。"},"index":0}]}data:{"code":0,"message":"Success","sid":"cha000b000c@dx1905cf38fc8b86d552","id":"cha000b000c@dx1905cf38fc8b86d552","created":1719546388,"choices":[{"delta":{"role":"assistant","content":"我具备与人类进行自然交流的能力,可以高效地满足各领域的认知智能需求。"},"index":0}]}data:{"code":0,"message":"Success","sid":"cha000b000c@dx1905cf38fc8b86d552","id":"cha000b000c@dx1905cf38fc8b86d552","created":1719546389,"choices":[{"delta":{"role":"assistant","content":"无论你有什么问题或者需要帮助的地方,我都将尽我所能提供支持和解决方案。请随时告诉我你的需求!"},"index":0}]}data:{"code":0,"message":"Success","sid":"cha000b000c@dx1905cf38fc8b86d552","id":"cha000b000c@dx1905cf38fc8b86d552","created":1719546389,"choices":[{"delta":{"role":"assistant","content":""},"index":0}],"usage":{"prompt_tokens":6,"completion_tokens":68,"total_tokens":74}}data:[DONE]

(2)代码实现

  • 主方法:
    public void streamingCompletions(String systemContent, String userContent, Consumer<SparkResponse> responseConsumer, String userId) throws IOException {URL url = new URL(apiUrl);HttpURLConnection connection = (HttpURLConnection) url.openConnection();connection.setRequestMethod("POST");// 设置请求头connection.setRequestProperty("Authorization", "Bearer " + httpApiPassword);connection.setRequestProperty("Content-Type", "application/json");// 设置请求体connection.setDoOutput(true);connection.getOutputStream().write(buildRequestBody(systemContent, userContent, userId,true).toJSONString().getBytes());// 获取响应parseResponseStreaming(connection, responseConsumer, userId);}
  • 解析响应:
private void parseResponseStreaming(HttpURLConnection connection, Consumer<SparkResponse> responseConsumer, String userId) throws IOException {int responseCode = connection.getResponseCode();log.info("SparkHttpAPI completions responseCode:{}", responseCode);if (responseCode == HttpURLConnection.HTTP_OK) {try (InputStream inputStream = connection.getInputStream();BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))) {String line;while ((line = reader.readLine()) != null) {if (!line.trim().isEmpty()) {line = line.replaceFirst("data: ", "");if (line.equals("[DONE]")) {return;}try {SparkResponse response = objectMapper.readValue(line, SparkResponse.class);if(historyRememberCount>0){rememberStreamingAnswer(userId,response);}responseConsumer.accept(response); // 将解析的响应传递给调用方} catch (Exception e) {log.error("Failed to parse response line: {}", line, e);}}}}} else {throw new SparkResponseParseException("Streaming Completions Result Parse Error");}}
  • 记住响应到上下文中:
public void rememberStreamingAnswer(String userId, SparkResponse res){historyInsert(userId, res.getChoices().get(0).getDelta());}

2.功能测试

(1)测试对话功能

    @Testvoid streamingCompletions() {String systemContent = "你是知识渊博的助理";String userContent = "告诉我讯飞星火认知大模型的应用场景有哪些?";try {sparkHttpAPITest.streamingCompletions(systemContent, userContent, SparkHttpResponseHandler::handleResponse, "111");} catch (Exception e) {log.error("测试不通过", e);}}
  • 其中的SparkHttpResponseHandler用于处理流式响应
/*** 处理流式接口响应*/
public class SparkHttpResponseHandler {public static void handleResponse(SparkResponse response) {System.out.println("Received response: " + response);}
}
  • 执行结果:
2025-01-24 10:21:29.901  INFO 25120 --- [           main] org.example.llm.SparkHttpAPI             : SparkHttpAPI completions responseCode:200
Received response: SparkResponse(code=0, message=Success, sid=cha000beda5@dx194961d49a99a4b532, id=cha000beda5@dx194961d49a99a4b532, created=1737685289, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=我是科大讯飞研发, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000beda5@dx194961d49a99a4b532, id=cha000beda5@dx194961d49a99a4b532, created=1737685289, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=的以中文为核心的, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000beda5@dx194961d49a99a4b532, id=cha000beda5@dx194961d49a99a4b532, created=1737685290, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=新一代认知智能大, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000beda5@dx194961d49a99a4b532, id=cha000beda5@dx194961d49a99a4b532, created=1737685290, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=模型,我能够在与, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000beda5@dx194961d49a99a4b532, id=cha000beda5@dx194961d49a99a4b532, created=1737685290, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=人自然的对话互动, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000beda5@dx194961d49a99a4b532, id=cha000beda5@dx194961d49a99a4b532, created=1737685290, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=的过程中,同时提, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000beda5@dx194961d49a99a4b532, id=cha000beda5@dx194961d49a99a4b532, created=1737685290, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=供以下多种能力:, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000beda5@dx194961d49a99a4b532, id=cha000beda5@dx194961d49a99a4b532, created=1737685290, choices=[Choices(message=null, delta=Dialogue(role=assistant, content= 1. 内容生成, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000beda5@dx194961d49a99a4b532, id=cha000beda5@dx194961d49a99a4b532, created=1737685290, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=能力:我可以生成, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000beda5@dx194961d49a99a4b532, id=cha000beda5@dx194961d49a99a4b532, created=1737685290, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=多种类型多种风格, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000beda5@dx194961d49a99a4b532, id=cha000beda5@dx194961d49a99a4b532, created=1737685290, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=的内容,例如邮件, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000beda5@dx194961d49a99a4b532, id=cha000beda5@dx194961d49a99a4b532, created=1737685290, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=、文案、公文、作, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000beda5@dx194961d49a99a4b532, id=cha000beda5@dx194961d49a99a4b532, created=1737685291, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=文、对话等; 2, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000beda5@dx194961d49a99a4b532, id=cha000beda5@dx194961d49a99a4b532, created=1737685291, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=. 自然语言理解, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000beda5@dx194961d49a99a4b532, id=cha000beda5@dx194961d49a99a4b532, created=1737685291, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=能力:我可以理解, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000beda5@dx194961d49a99a4b532, id=cha000beda5@dx194961d49a99a4b532, created=1737685291, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=对话和篇章,并可, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000beda5@dx194961d49a99a4b532, id=cha000beda5@dx194961d49a99a4b532, created=1737685291, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=以实现文本摘要、, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000beda5@dx194961d49a99a4b532, id=cha000beda5@dx194961d49a99a4b532, created=1737685291, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=信息抽取、多语言, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000beda5@dx194961d49a99a4b532, id=cha000beda5@dx194961d49a99a4b532, created=1737685291, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=翻译、阅读理解、, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000beda5@dx194961d49a99a4b532, id=cha000beda5@dx194961d49a99a4b532, created=1737685291, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=情感分析等能力;, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000beda5@dx194961d49a99a4b532, id=cha000beda5@dx194961d49a99a4b532, created=1737685291, choices=[Choices(message=null, delta=Dialogue(role=assistant, content= 3. 知识问答, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000beda5@dx194961d49a99a4b532, id=cha000beda5@dx194961d49a99a4b532, created=1737685292, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=能力:我可以回答, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000beda5@dx194961d49a99a4b532, id=cha000beda5@dx194961d49a99a4b532, created=1737685292, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=各种各样的问题,, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000beda5@dx194961d49a99a4b532, id=cha000beda5@dx194961d49a99a4b532, created=1737685292, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=包括医学知识、百, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000beda5@dx194961d49a99a4b532, id=cha000beda5@dx194961d49a99a4b532, created=1737685292, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=科知识、天文地理, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000beda5@dx194961d49a99a4b532, id=cha000beda5@dx194961d49a99a4b532, created=1737685292, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=等; 4. 推理, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000beda5@dx194961d49a99a4b532, id=cha000beda5@dx194961d49a99a4b532, created=1737685292, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=能力:我拥有基于, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000beda5@dx194961d49a99a4b532, id=cha000beda5@dx194961d49a99a4b532, created=1737685292, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=思维链的推理能力, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000beda5@dx194961d49a99a4b532, id=cha000beda5@dx194961d49a99a4b532, created=1737685292, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=,能够进行科学推, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000beda5@dx194961d49a99a4b532, id=cha000beda5@dx194961d49a99a4b532, created=1737685292, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=理、常识推理等;, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000beda5@dx194961d49a99a4b532, id=cha000beda5@dx194961d49a99a4b532, created=1737685292, choices=[Choices(message=null, delta=Dialogue(role=assistant, content= 5. 数学能力, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000beda5@dx194961d49a99a4b532, id=cha000beda5@dx194961d49a99a4b532, created=1737685293, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=:我具备数学思维, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000beda5@dx194961d49a99a4b532, id=cha000beda5@dx194961d49a99a4b532, created=1737685293, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=,能理解数学问题, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000beda5@dx194961d49a99a4b532, id=cha000beda5@dx194961d49a99a4b532, created=1737685293, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=,进行计算、推理, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000beda5@dx194961d49a99a4b532, id=cha000beda5@dx194961d49a99a4b532, created=1737685293, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=、证明,并能给出, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000beda5@dx194961d49a99a4b532, id=cha000beda5@dx194961d49a99a4b532, created=1737685293, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=解题步骤。 6., index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000beda5@dx194961d49a99a4b532, id=cha000beda5@dx194961d49a99a4b532, created=1737685293, choices=[Choices(message=null, delta=Dialogue(role=assistant, content= 代码理解与生成, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000beda5@dx194961d49a99a4b532, id=cha000beda5@dx194961d49a99a4b532, created=1737685293, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=能力:我可以进行, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000beda5@dx194961d49a99a4b532, id=cha000beda5@dx194961d49a99a4b532, created=1737685293, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=代码理解、代码修, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000beda5@dx194961d49a99a4b532, id=cha000beda5@dx194961d49a99a4b532, created=1737685293, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=改以及代码生成等, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000beda5@dx194961d49a99a4b532, id=cha000beda5@dx194961d49a99a4b532, created=1737685293, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=工作; 此外,我, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000beda5@dx194961d49a99a4b532, id=cha000beda5@dx194961d49a99a4b532, created=1737685294, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=还具备对话游戏、, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000beda5@dx194961d49a99a4b532, id=cha000beda5@dx194961d49a99a4b532, created=1737685294, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=角色扮演等特色能, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000beda5@dx194961d49a99a4b532, id=cha000beda5@dx194961d49a99a4b532, created=1737685294, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=力,等待你的探索, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000beda5@dx194961d49a99a4b532, id=cha000beda5@dx194961d49a99a4b532, created=1737685294, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=。 我可以对多元, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000beda5@dx194961d49a99a4b532, id=cha000beda5@dx194961d49a99a4b532, created=1737685294, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=能力实现融合统一, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000beda5@dx194961d49a99a4b532, id=cha000beda5@dx194961d49a99a4b532, created=1737685294, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=,对真实场景下的, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000beda5@dx194961d49a99a4b532, id=cha000beda5@dx194961d49a99a4b532, created=1737685294, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=需求,我具备提出, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000beda5@dx194961d49a99a4b532, id=cha000beda5@dx194961d49a99a4b532, created=1737685294, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=问题、规划问题、, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000beda5@dx194961d49a99a4b532, id=cha000beda5@dx194961d49a99a4b532, created=1737685294, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=解决问题的闭环能, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000beda5@dx194961d49a99a4b532, id=cha000beda5@dx194961d49a99a4b532, created=1737685294, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=力。进一步地,我, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000beda5@dx194961d49a99a4b532, id=cha000beda5@dx194961d49a99a4b532, created=1737685295, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=可以持续从海量数, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000beda5@dx194961d49a99a4b532, id=cha000beda5@dx194961d49a99a4b532, created=1737685295, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=据和大规模知识中, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000beda5@dx194961d49a99a4b532, id=cha000beda5@dx194961d49a99a4b532, created=1737685295, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=不断学习进化,这, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000beda5@dx194961d49a99a4b532, id=cha000beda5@dx194961d49a99a4b532, created=1737685295, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=些能力使得我能够, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000beda5@dx194961d49a99a4b532, id=cha000beda5@dx194961d49a99a4b532, created=1737685295, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=在多个行业和领域, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000beda5@dx194961d49a99a4b532, id=cha000beda5@dx194961d49a99a4b532, created=1737685295, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=发挥越来越重要的, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000beda5@dx194961d49a99a4b532, id=cha000beda5@dx194961d49a99a4b532, created=1737685295, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=作用。 同时基于, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000beda5@dx194961d49a99a4b532, id=cha000beda5@dx194961d49a99a4b532, created=1737685295, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=我的能力,我将结, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000beda5@dx194961d49a99a4b532, id=cha000beda5@dx194961d49a99a4b532, created=1737685295, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=合科大讯飞以及行, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000beda5@dx194961d49a99a4b532, id=cha000beda5@dx194961d49a99a4b532, created=1737685295, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=业生态伙伴的相关, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000beda5@dx194961d49a99a4b532, id=cha000beda5@dx194961d49a99a4b532, created=1737685296, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=产品,完成多模态, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000beda5@dx194961d49a99a4b532, id=cha000beda5@dx194961d49a99a4b532, created=1737685296, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=理解和生成等相关, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000beda5@dx194961d49a99a4b532, id=cha000beda5@dx194961d49a99a4b532, created=1737685296, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=工作。, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000beda5@dx194961d49a99a4b532, id=cha000beda5@dx194961d49a99a4b532, created=1737685296, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=null, index=0), index=0)], usage={"prompt_tokens":12,"completion_tokens":304,"total_tokens":316}, error=null)

(2)测试记住上下文功能

    @Testvoid historyTest() {String systemContent = "你是知识渊博的律师";String userContent = "小王偷了小李门口的鞋子,小王犯法吗?";try {sparkHttpAPITest.streamingCompletions(systemContent, userContent, SparkHttpResponseHandler::handleResponse,"111");userContent = "小王犯了什么罪";sparkHttpAPITest.streamingCompletions(null, userContent, SparkHttpResponseHandler::handleResponse,"111");} catch (Exception e) {log.error("测试不通过", e);}}
  • 执行结果:
2025-01-24 10:24:38.667  INFO 33000 --- [           main] org.example.llm.SparkHttpAPI             : SparkHttpAPI completions responseCode:200
Received response: SparkResponse(code=0, message=Success, sid=cha000bf839@dx19496202bdeb8f2532, id=cha000bf839@dx19496202bdeb8f2532, created=1737685478, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000bf839@dx19496202bdeb8f2532, id=cha000bf839@dx19496202bdeb8f2532, created=1737685478, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=王的行为, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000bf839@dx19496202bdeb8f2532, id=cha000bf839@dx19496202bdeb8f2532, created=1737685478, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=是否构成犯罪, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000bf839@dx19496202bdeb8f2532, id=cha000bf839@dx19496202bdeb8f2532, created=1737685478, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=,取决于具体的法律, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000bf839@dx19496202bdeb8f2532, id=cha000bf839@dx19496202bdeb8f2532, created=1737685478, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=条文和司法解释, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000bf839@dx19496202bdeb8f2532, id=cha000bf839@dx19496202bdeb8f2532, created=1737685479, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000bf839@dx19496202bdeb8f2532, id=cha000bf839@dx19496202bdeb8f2532, created=1737685479, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=在大多数情况下,偷窃是一种违法行为,因为它侵犯了他人的财产权。然而,如果小王只是出于好奇或者误认为鞋子属于他而拿走,那么这种行为可能不会被视为犯罪。, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000bf839@dx19496202bdeb8f2532, id=cha000bf839@dx19496202bdeb8f2532, created=1737685480, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=此外,如果小王的行为是出于善意,例如他误以为鞋子是自己的,那么这种行为可能不会被认定为犯罪。但是,如果他的行为导致了小李的财产损失,那么他可能需要承担相应的赔偿责任。, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000bf839@dx19496202bdeb8f2532, id=cha000bf839@dx19496202bdeb8f2532, created=1737685480, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=总之,小王是否犯法需要根据具体情况来判断。如果您有关于这个问题的疑问,建议您咨询专业的律师以获取准确的法律建议。, index=0), index=0)], usage={"prompt_tokens":35,"completion_tokens":129,"total_tokens":164}, error=null)
2025-01-24 10:24:41.009  INFO 33000 --- [           main] org.example.llm.SparkHttpAPI             : SparkHttpAPI completions responseCode:200
Received response: SparkResponse(code=0, message=Success, sid=cha000bf847@dx194962034c8b8f2532, id=cha000bf847@dx194962034c8b8f2532, created=1737685481, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000bf847@dx194962034c8b8f2532, id=cha000bf847@dx194962034c8b8f2532, created=1737685481, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=王的行为, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000bf847@dx194962034c8b8f2532, id=cha000bf847@dx194962034c8b8f2532, created=1737685481, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=可能构成盗窃, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000bf847@dx194962034c8b8f2532, id=cha000bf847@dx194962034c8b8f2532, created=1737685481, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=罪。, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000bf847@dx194962034c8b8f2532, id=cha000bf847@dx194962034c8b8f2532, created=1737685482, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=根据《中华人民共和国刑法》第二百六十四条,盗窃公私财物,数额较大或者多次盗窃的,处三年以下有期徒刑、拘役或者管制,并处或者单处罚金;数额巨大或者有其他严重情节的,处三年以上十年以下有期徒刑,并处罚金;, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000bf847@dx194962034c8b8f2532, id=cha000bf847@dx194962034c8b8f2532, created=1737685482, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=数额特别巨大或者有其他特别严重情节的,处十年以上有期徒刑或者无期徒刑,并处罚金或者没收财产。然而,如果小王是出于好奇或者误认为鞋子属于他而拿走,那么这种行为可能不会被视为犯罪。, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000bf847@dx194962034c8b8f2532, id=cha000bf847@dx194962034c8b8f2532, created=1737685483, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=此外,如果小王的行为导致了小李的财产损失,那么他可能需要承担相应的赔偿责任。请注意,这只是一般情况下的法律解释,具体情况需要根据案件的具体事实和证据来判断。, index=0), index=0)], usage=null, error=null)
Received response: SparkResponse(code=0, message=Success, sid=cha000bf847@dx194962034c8b8f2532, id=cha000bf847@dx194962034c8b8f2532, created=1737685483, choices=[Choices(message=null, delta=Dialogue(role=assistant, content=如果您有关于这个问题的疑问,建议您咨询专业的律师以获取准确的法律建议。, index=0), index=0)], usage={"prompt_tokens":218,"completion_tokens":175,"total_tokens":393}, error=null)

相关文章:

星火大模型接入及文本生成HTTP流式、非流式接口(JAVA)

文章目录 一、接入星火大模型二、基于JAVA实现HTTP非流式接口1.配置2.接口实现&#xff08;1&#xff09;分析接口请求&#xff08;2&#xff09;代码实现 3.功能测试&#xff08;1&#xff09;测试对话功能&#xff08;2&#xff09;测试记住上下文功能 三、基于JAVA实现HTTP流…...

21.Word:小赵-毕业论文排版❗【39】

目录 题目​ NO1.2 NO3.4 NO5.6 NO7.8.9 NO10.11.12 题目 NO1.2 自己的论文当中接收老师的修改&#xff1a;审阅→比较→源文档&#xff1a;考生文件夹&#xff1a;Word.docx→修订的文档&#xff1a;考生文件夹&#xff1a;教师修改→确定→接收→接收所有修订将合并之…...

Python中的函数(上)

Python中的函数是非常重要的编程概念&#xff0c;以下是详细的介绍&#xff1a; 函数定义基础 在Python中&#xff0c;函数是组织好的、可重复使用的代码块&#xff0c;用于执行特定任务。通过函数&#xff0c;我们可以将复杂的程序分解为较小的、更易管理的部分&#xff0c…...

Windows11 安装poetry

使用powershell安装 (Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | py - 如果使用py运行失败则替换为python即可 终端运行结果如下 D:\AI\A_Share_investment_Agent> (Invoke-WebRequest -Uri https://install.python-poetry.…...

浅谈Linux 权限、压缩、进程与服务

概述 放假回家&#xff0c;对Linux系统的一些知识进行重新的整理&#xff0c;做到温故而知新&#xff0c;对用户权限管理、文件赋权、压缩文件、进程与服务的知识进行了一次梳理和总结。 权限管理 Linux最基础的权限是用户和文件&#xff0c;先了解基础的用户权限和文件权限…...

006 LocalStorage和SessionStorage

JWT存储在LocalStorage与SessionStorage里的区别和共同点如下&#xff1a; 区别 数据有效期&#xff1a; • LocalStorage&#xff1a;始终有效&#xff0c;存储的数据会一直保留在浏览器中&#xff0c;即使窗口或浏览器关闭也一直保存&#xff0c;因此常用作持久数据。 • Se…...

AJAX RSS Reader:技术解析与应用场景

AJAX RSS Reader:技术解析与应用场景 引言 随着互联网的快速发展,信息量呈爆炸式增长。为了方便用户快速获取感兴趣的信息,RSS(Really Simple Syndication)技术应运而生。AJAX RSS Reader作为一种基于AJAX技术的信息读取工具,在用户体验和信息获取方面具有显著优势。本…...

Go优雅实现redis分布式锁

前言 系统为了保证高可用&#xff0c;通常会部署多实例&#xff0c;并且会存在同时对共享资源并发读写&#xff0c;这时候为了保证读写的安全&#xff0c;常规手段是会引入分布式锁&#xff0c;本文将介绍如何使用redis设计一个优雅的Go分布式锁。 设计 redis分布式锁是借助…...

本地部署deepseek模型步骤

文章目录 0.deepseek简介1.安装ollama软件2.配置合适的deepseek模型3.安装chatbox可视化 0.deepseek简介 DeepSeek 是一家专注于人工智能技术研发的公司&#xff0c;致力于打造高性能、低成本的 AI 模型&#xff0c;其目标是让 AI 技术更加普惠&#xff0c;让更多人能够用上强…...

(2025 年最新)MacOS Redis Desktop Manager中文版下载,附详细图文

MacOS Redis Desktop Manager中文版下载 大家好&#xff0c;今天给大家带来一款非常实用的 Redis 可视化工具——Redis Desktop Manager&#xff08;简称 RDM&#xff09;。相信很多开发者都用过 Redis 数据库&#xff0c;但如果你想要更高效、更方便地管理 Redis 数据&#x…...

C++ 写一个简单的加减法计算器

************* C topic&#xff1a;结构 ************* Structure is a very intersting issue. I really dont like concepts as it is boring. I would like to cases instead. If I want to learn something, donot hesitate to make shits. Like building a house. Wh…...

计算机网络基础 - 链路层(3)

计算机网络基础 链路层和局域网交换局域网链路层寻址地址解析协议 ARP以太网物理拓扑以太网帧结构以太网提供的服务以太网标准 链路层交换机交换机转发和过滤自学习交换机优点交换机和路由器比较 大家好呀&#xff01;我是小笙&#xff0c;本章我主要分享计算机网络基础 - 链路…...

ray.rllib 入门实践-5: 训练算法

前面的博客介绍了ray.rllib中算法的配置和构建&#xff0c;也包含了算法训练的代码。 但是rllib中实现算法训练的方式不止一种&#xff0c;本博客对此进行介绍。很多教程使用 PPOTrainer 进行训练&#xff0c;但是 PPOTrainer 在最近的 ray 版本中已经取消了。 环境配置&#x…...

FPGA 使用 CLOCK_LOW_FANOUT 约束

使用 CLOCK_LOW_FANOUT 约束 您可以使用 CLOCK_LOW_FANOUT 约束在单个时钟区域中包含时钟缓存负载。在由全局时钟缓存直接驱动的时钟网段 上对 CLOCK_LOW_FANOUT 进行设置&#xff0c;而且全局时钟缓存扇出必须低于 2000 个负载。 注释&#xff1a; 当与其他时钟约束配合…...

选择的阶段性质疑

条条大路通罗马&#xff0c;每个人选择的道路&#xff0c;方向并不一样&#xff0c;但不妨碍都可以到达终点&#xff0c;而往往大家会更推崇自己走过的路径。 自己靠什么走向成功&#xff0c;自己用了什么方法&#xff0c;奉行什么原则或者理念&#xff0c;也会尽可能传播这种&…...

固有频率与模态分析

目录 引言 1. 固有频率&#xff1a;物体的“天生节奏” 1.1 定义 1.2 关键特点 1.3 实际意义 2. 有限元中的模态分析&#xff1a;给结构“体检振动” 2.1 模态分析的意义 2.2 实际案例 2.2.1 桥梁模态分析 2.2.2 飞机机翼模态分析 2.2.3 具体事例 3. 模态分析的工具…...

数科OFD证照生成原理剖析与平替方案实现

一、 引言 近年来&#xff0c;随着电子发票的普及&#xff0c;OFD格式作为我国电子发票的标准格式&#xff0c;其应用范围日益广泛。然而&#xff0c;由于不同软件生成的OFD文件存在差异&#xff0c;以及用户对OFD文件处理需求的多样化&#xff0c;OFD套餐转换工具应运而生。本…...

CAN总线数据采集与分析

CAN总线数据采集与分析 目录 CAN总线数据采集与分析1. 引言2. 数据采集2.1 数据采集简介2.2 数据采集实现3. 数据分析3.1 数据分析简介3.2 数据分析实现4. 数据可视化4.1 数据可视化简介4.2 数据可视化实现5. 案例说明5.1 案例1:数据采集实现5.2 案例2:数据分析实现5.3 案例3…...

SpringSecurity:There is no PasswordEncoder mapped for the id “null“

文章目录 一、情景说明二、分析三、解决 一、情景说明 在整合SpringSecurity功能的时候 我先是去实现认证功能 也就是&#xff0c;去数据库比对用户名和密码 相关的类&#xff1a; UserDetailsServiceImpl implements UserDetailsService 用于SpringSecurity查询数据库 Logi…...

ResNet 残差网络

目录 网络结构 残差块&#xff08;Residual Block&#xff09; ResNet网络结构示意图 残差块&#xff08;Residual Block&#xff09;细节 基本残差块&#xff08;ResNet-18/34&#xff09; Bottleneck残差块&#xff08;ResNet-50/101/152&#xff09; 残差连接类型对比 变体网…...

CAPL编程常见问题与解决方案深度解析

CAPL编程常见问题与解决方案深度解析 目录 CAPL编程常见问题与解决方案深度解析引言1. CAPL编程核心难点剖析1.1 典型问题分类2. 六大典型问题场景解析案例1:定时器资源竞争导致逻辑错乱2.1.1 问题现象2.1.2 根因分析2.1.3 解决方案案例2:大数据量报文处理引发性能瓶颈2.2.1 …...

信号处理以及队列

下面是一个使用C和POSIX信号处理以及队列的简单示例。这个示例展示了如何使用信号处理程序将信号放入队列中&#xff0c;并在主循环中处理这些信号。 #include <iostream> #include <csignal> #include <queue> #include <mutex> #include <thread…...

Linux pkill 命令使用详解

简介 pkill 命令用于根据进程名称、用户、组或其他属性终止进程。它是 procps-ng 包的一部分&#xff0c;通常比 kill 更受欢迎&#xff0c;因为它无需查找进程 ID (PID)。 常用选项 -<signal>, --signal <signal>&#xff1a;定义要发送给每个匹配进程的信号&am…...

react注意事项

1.状态的定义以及修改 2.排序用lodash进行排序 import _ from lodassh 3.利用className插件进行动态类名的使用 4.表单使用 5.react中获取dom...

【开源免费】基于SpringBoot+Vue.JS在线考试学习交流网页平台(JAVA毕业设计)

本文项目编号 T 158 &#xff0c;文末自助获取源码 \color{red}{T158&#xff0c;文末自助获取源码} T158&#xff0c;文末自助获取源码 目录 一、系统介绍二、数据库设计三、配套教程3.1 启动教程3.2 讲解视频3.3 二次开发教程 四、功能截图五、文案资料5.1 选题背景5.2 国内…...

怎样在PPT中启用演讲者视图功能?

怎样在PPT中启用演讲者视图功能&#xff1f; 如果你曾经参加过重要的会议或者演讲&#xff0c;你就会知道&#xff0c;演讲者视图&#xff08;Presenter View&#xff09;对PPT展示至关重要。它不仅能帮助演讲者更好地掌控演讲节奏&#xff0c;还能提供额外的提示和支持&#…...

UE AController

定义和功能 AController是一种特定于游戏的控制器&#xff0c;在UE框架中用于定义玩家和AI的控制逻辑。AController负责处理玩家输入&#xff0c;并根据这些输入驱动游戏中的角色或其他实体的行为。设计理念 AController设计用于分离控制逻辑与游戏角色&#xff0c;增强游戏设计…...

H264原始码流格式分析

1.H264码流结构组成 H.264裸码流&#xff08;Raw Bitstream&#xff09;数据主要由一系列的NALU&#xff08;网络抽象层单元&#xff09;组成。每个NALU包含一个NAL头和一个RBSP&#xff08;原始字节序列载荷&#xff09;。 1.1 H.264码流层次 H.264码流的结构可以分为两个层…...

JAVA 接口、抽象类的关系和用处 详细解析

接口 - Java教程 - 廖雪峰的官方网站 一个 抽象类 如果实现了一个接口&#xff0c;可以只选择实现接口中的 部分方法&#xff08;所有的方法都要有&#xff0c;可以一部分已经写具体&#xff0c;另一部分继续保留抽象&#xff09;&#xff0c;原因在于&#xff1a; 抽象类本身…...

反向代理模块b

1 概念 1.1 反向代理概念 反向代理是指以代理服务器来接收客户端的请求&#xff0c;然后将请求转发给内部网络上的服务器&#xff0c;将从服务器上得到的结果返回给客户端&#xff0c;此时代理服务器对外表现为一个反向代理服务器。 对于客户端来说&#xff0c;反向代理就相当于…...