mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-13 13:07:32 +00:00
[feature][chat]Add API to get ChatModelType list.#1739
This commit is contained in:
@@ -0,0 +1,16 @@
|
|||||||
|
package com.tencent.supersonic.chat.api.pojo.response;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class ChatModelTypeResp {
|
||||||
|
private String type;
|
||||||
|
private String name;
|
||||||
|
private String description;
|
||||||
|
}
|
||||||
@@ -5,14 +5,18 @@ import javax.servlet.http.HttpServletResponse;
|
|||||||
|
|
||||||
import com.tencent.supersonic.auth.api.authentication.pojo.User;
|
import com.tencent.supersonic.auth.api.authentication.pojo.User;
|
||||||
import com.tencent.supersonic.auth.api.authentication.utils.UserHolder;
|
import com.tencent.supersonic.auth.api.authentication.utils.UserHolder;
|
||||||
|
import com.tencent.supersonic.chat.api.pojo.response.ChatModelTypeResp;
|
||||||
import com.tencent.supersonic.chat.server.pojo.ChatModel;
|
import com.tencent.supersonic.chat.server.pojo.ChatModel;
|
||||||
import com.tencent.supersonic.chat.server.service.ChatModelService;
|
import com.tencent.supersonic.chat.server.service.ChatModelService;
|
||||||
import com.tencent.supersonic.chat.server.util.ModelConfigHelper;
|
import com.tencent.supersonic.chat.server.util.ModelConfigHelper;
|
||||||
import com.tencent.supersonic.common.pojo.ChatModelConfig;
|
import com.tencent.supersonic.common.pojo.ChatModelConfig;
|
||||||
|
import com.tencent.supersonic.common.pojo.enums.ChatModelType;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping({"/api/chat/model", "/openapi/chat/model"})
|
@RequestMapping({"/api/chat/model", "/openapi/chat/model"})
|
||||||
@@ -45,6 +49,13 @@ public class ChatModelController {
|
|||||||
return chatModelService.getChatModels();
|
return chatModelService.getChatModels();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/getModelTypeList")
|
||||||
|
public List<ChatModelTypeResp> getModelTypeList() {
|
||||||
|
return Arrays.stream(ChatModelType.values()).map(t -> ChatModelTypeResp.builder()
|
||||||
|
.type(t.toString()).name(t.getName()).description(t.getDescription()).build())
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
@PostMapping("/testConnection")
|
@PostMapping("/testConnection")
|
||||||
public boolean testConnection(@RequestBody ChatModelConfig modelConfig) {
|
public boolean testConnection(@RequestBody ChatModelConfig modelConfig) {
|
||||||
return ModelConfigHelper.testConnection(modelConfig);
|
return ModelConfigHelper.testConnection(modelConfig);
|
||||||
|
|||||||
@@ -1,14 +1,19 @@
|
|||||||
package com.tencent.supersonic.common.pojo.enums;
|
package com.tencent.supersonic.common.pojo.enums;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
public enum ChatModelType {
|
public enum ChatModelType {
|
||||||
TEXT_TO_SQL("Convert text query to SQL statement"), MULTI_TURN_REWRITE(
|
TEXT_TO_SQL("SQL生成", "Convert text query to SQL statement"), MULTI_TURN_REWRITE("多轮改写",
|
||||||
"Rewrite text query for multi-turn conversation"), MEMORY_REVIEW(
|
"Rewrite text query for multi-turn conversation"), MEMORY_REVIEW("记忆评估",
|
||||||
"Review memory in order to add few-shot examples"), RESPONSE_GENERATE(
|
"Review memory in order to add few-shot examples"), RESPONSE_GENERATE("回复生成",
|
||||||
"Generate readable response to the end user");
|
"Generate readable response to the end user");
|
||||||
|
|
||||||
private String description;
|
private String description;
|
||||||
|
private String name;
|
||||||
|
|
||||||
ChatModelType(String description) {
|
ChatModelType(String name, String description) {
|
||||||
|
this.name = name;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user