|
@@ -3,6 +3,7 @@ package com.yw.master1.eu.ai.service;
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
import com.yw.eu.base.message.model.Message;
|
|
import com.yw.eu.base.message.model.Message;
|
|
|
import com.yw.master1.eu.ai.model.AiMessage;
|
|
import com.yw.master1.eu.ai.model.AiMessage;
|
|
@@ -91,7 +92,7 @@ public class AiApi {
|
|
|
return response.body().string();
|
|
return response.body().string();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- //deepseek
|
|
|
|
|
|
|
+ //deepseek 百度
|
|
|
public static String deepseek(String str) throws IOException {
|
|
public static String deepseek(String str) throws IOException {
|
|
|
OkHttpClient HTTP_CLIENT = new OkHttpClient().newBuilder().build();
|
|
OkHttpClient HTTP_CLIENT = new OkHttpClient().newBuilder().build();
|
|
|
MediaType mediaType = MediaType.parse("application/json");
|
|
MediaType mediaType = MediaType.parse("application/json");
|
|
@@ -105,6 +106,25 @@ public class AiApi {
|
|
|
Response response = HTTP_CLIENT.newCall(request).execute();
|
|
Response response = HTTP_CLIENT.newCall(request).execute();
|
|
|
return response.body().string();
|
|
return response.body().string();
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ //deepseek 硅基流动
|
|
|
|
|
+ public static String deepseek3(String str) throws IOException {
|
|
|
|
|
+ OkHttpClient HTTP_CLIENT = new OkHttpClient().newBuilder()
|
|
|
|
|
+ .connectTimeout(5, TimeUnit.SECONDS)
|
|
|
|
|
+ .readTimeout(30, TimeUnit.SECONDS)
|
|
|
|
|
+ .writeTimeout(30, TimeUnit.SECONDS)
|
|
|
|
|
+ .build();
|
|
|
|
|
+ MediaType mediaType = MediaType.parse("application/json");
|
|
|
|
|
+ RequestBody body = RequestBody.create(mediaType, "{\"model\": \"deepseek-ai/DeepSeek-V3\",\"stream\": false,\"messages\": [{\"role\": \"user\",\"content\": \""+str+"\"}]}");
|
|
|
|
|
+ Request request = new Request.Builder()
|
|
|
|
|
+ .url("https://api.siliconflow.cn/v1/chat/completions")
|
|
|
|
|
+ .method("POST", body)
|
|
|
|
|
+ .addHeader("Content-Type", "application/json")
|
|
|
|
|
+ .addHeader("Authorization", "Bearer sk-wsrxuoufnunjxyyzlwuhryqnsqtbxqlxrujzadvtmqtbhfnj")
|
|
|
|
|
+ .build();
|
|
|
|
|
+ Response response = HTTP_CLIENT.newCall(request).execute();
|
|
|
|
|
+ return response.body().string();
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
public static void main(String []args) throws IOException{
|
|
public static void main(String []args) throws IOException{
|
|
|
System.out.println(sendAsk("请说出你的名字"));
|
|
System.out.println(sendAsk("请说出你的名字"));
|