AI 提问追问环境demo,以及评分处理
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.vetti.common.ai.gpt;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
@@ -71,11 +72,12 @@ public class ChatGPTClient {
|
||||
*/
|
||||
private String sendMessage(String prompt, String model,ObjectMapper objectMapper,HttpClient client,String role) throws IOException, InterruptedException {
|
||||
// 创建消息列表
|
||||
List<Map<String, String>> messages = new ArrayList<>();
|
||||
Map<String, String> message = new HashMap<>();
|
||||
message.put("role", role);
|
||||
message.put("content", prompt);
|
||||
messages.add(message);
|
||||
List<Map> messages = JSONUtil.toList(prompt, Map.class);
|
||||
|
||||
// Map<String, String> message = new HashMap<>();
|
||||
// message.put("role", role);
|
||||
// message.put("content", prompt);
|
||||
// messages.add(message);
|
||||
|
||||
return sendChatRequest(messages, model, 0.7,objectMapper,client);
|
||||
}
|
||||
@@ -89,7 +91,7 @@ public class ChatGPTClient {
|
||||
* @throws IOException 网络或IO异常
|
||||
* @throws InterruptedException 线程中断异常
|
||||
*/
|
||||
private String sendChatRequest(List<Map<String, String>> messages, String model, double temperature,ObjectMapper objectMapper,HttpClient client)
|
||||
private String sendChatRequest(List<Map> messages, String model, double temperature,ObjectMapper objectMapper,HttpClient client)
|
||||
throws IOException, InterruptedException {
|
||||
// 构建请求体
|
||||
Map<String, Object> requestBody = new HashMap<>();
|
||||
|
||||
Reference in New Issue
Block a user