feat(config): 新增异步线程池与WebMvc异步配置并扩展emoji字段支持
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.yolo.keyborad.controller;
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.yolo.keyborad.common.BaseResponse;
|
||||
import com.yolo.keyborad.common.ResultUtils;
|
||||
@@ -18,11 +19,13 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.ai.chat.client.ChatClient;
|
||||
import org.springframework.ai.embedding.Embedding;
|
||||
import org.springframework.ai.embedding.EmbeddingResponse;
|
||||
import org.springframework.ai.openai.OpenAiChatOptions;
|
||||
import org.springframework.ai.openai.OpenAiEmbeddingModel;
|
||||
import org.springframework.boot.context.properties.bind.DefaultValue;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import reactor.core.publisher.Flux;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/*
|
||||
@@ -59,15 +62,34 @@ public class DemoController {
|
||||
@Operation(summary = "测试聊天接口", description = "测试接口")
|
||||
@Parameter(name = "userInput",required = true,description = "测试聊天接口",example = "talk to something")
|
||||
public Flux<String> testTalk(@DefaultValue("you are so cute!") String userInput){
|
||||
String delimiter = "/t";
|
||||
|
||||
return client
|
||||
.prompt("You're a 25-year-old guy—witty and laid-back, always replying in English.\n" +
|
||||
"Read the user's last message, then write three short and funny replies that sound like something a guy would say. Go easy on the emojis.\n" +
|
||||
"Keep each under 20 words. Use '/t' to separate them—no numbers or extra labels.")
|
||||
.prompt("""
|
||||
You're a 25-year-old guy—witty and laid-back, always replying in English.
|
||||
|
||||
Read the user's last message, then write three short and funny replies that sound like something a guy would say.
|
||||
Go easy on the emojis.
|
||||
Keep each under 20 words.
|
||||
|
||||
User message: %s
|
||||
""".formatted(userInput))
|
||||
.system("""
|
||||
Format rules (very important):
|
||||
- Return EXACTLY 3 replies.
|
||||
- Use "<SPLIT>" as the separator between replies.
|
||||
- Output format: reply1<SPLIT>reply2<SPLIT>reply3
|
||||
- Do NOT use "<SPLIT>" inside any reply.
|
||||
""")
|
||||
.user(userInput)
|
||||
.options(OpenAiChatOptions.builder()
|
||||
.user(StpUtil.getLoginIdAsString()) // ✅ 这里每次请求都会重新取当前登录用户
|
||||
.build())
|
||||
.stream()
|
||||
.content();
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/embed")
|
||||
@Operation(summary = "测试向量接口", description = "测试向量接口")
|
||||
@Parameter(name = "userInput",required = true,description = "测试向量接口",example = "you are so cute!")
|
||||
|
||||
Reference in New Issue
Block a user