[feature][chat]Introduce dedicated LLM management.#1739

This commit is contained in:
jerryjzhang
2024-10-09 12:00:24 +08:00
parent 0654a54c8d
commit 7b9ff2e281
22 changed files with 367 additions and 43 deletions

View File

@@ -5,6 +5,7 @@ import com.tencent.supersonic.chat.api.pojo.request.ChatExecuteReq;
import com.tencent.supersonic.chat.api.pojo.request.ChatParseReq;
import com.tencent.supersonic.chat.api.pojo.response.QueryResult;
import com.tencent.supersonic.chat.server.service.AgentService;
import com.tencent.supersonic.chat.server.service.ChatModelService;
import com.tencent.supersonic.chat.server.service.ChatQueryService;
import com.tencent.supersonic.common.pojo.enums.DatePeriodEnum;
import com.tencent.supersonic.headless.api.pojo.SchemaElement;
@@ -33,6 +34,8 @@ public class BaseTest extends BaseApplication {
protected ChatQueryService chatQueryService;
@Autowired
protected AgentService agentService;
@Autowired
protected ChatModelService chatModelService;
protected QueryResult submitMultiTurnChat(String queryText, Integer agentId, Integer chatId)
throws Exception {

View File

@@ -2,6 +2,8 @@ package com.tencent.supersonic.evaluation;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.tencent.supersonic.auth.api.authentication.pojo.User;
import com.tencent.supersonic.chat.BaseTest;
import com.tencent.supersonic.chat.api.pojo.response.QueryResult;
import com.tencent.supersonic.chat.server.agent.Agent;
@@ -9,12 +11,14 @@ import com.tencent.supersonic.chat.server.agent.AgentConfig;
import com.tencent.supersonic.chat.server.agent.AgentToolType;
import com.tencent.supersonic.chat.server.agent.MultiTurnConfig;
import com.tencent.supersonic.chat.server.agent.RuleParserTool;
import com.tencent.supersonic.chat.server.pojo.ChatModel;
import com.tencent.supersonic.common.pojo.enums.ChatModelType;
import com.tencent.supersonic.util.DataUtils;
import com.tencent.supersonic.util.LLMConfigUtils;
import org.junit.jupiter.api.*;
import java.util.List;
import java.util.stream.Collectors;
import java.util.Map;
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
@Disabled
@@ -133,7 +137,13 @@ public class Text2SQLEval extends BaseTest {
AgentConfig agentConfig = new AgentConfig();
agentConfig.getTools().add(getLLMQueryTool());
agent.setAgentConfig(JSONObject.toJSONString(agentConfig));
agent.setModelConfig(LLMConfigUtils.getLLMConfig(LLMConfigUtils.LLMType.OLLAMA_LLAMA3));
ChatModel chatModel = new ChatModel();
chatModel.setName("Text2SQL LLM");
chatModel.setConfig(LLMConfigUtils.getLLMConfig(LLMConfigUtils.LLMType.OLLAMA_LLAMA3));
chatModel = chatModelService.createChatModel(chatModel, User.getFakeUser());
Map<ChatModelType, Integer> chatModelConfig = Maps.newHashMap();
chatModelConfig.put(ChatModelType.TEXT_TO_SQL, chatModel.getId());
agent.setModelConfig(chatModelConfig);
MultiTurnConfig multiTurnConfig = new MultiTurnConfig();
multiTurnConfig.setEnableMultiTurn(enableMultiturn);
agent.setMultiTurnConfig(multiTurnConfig);

View File

@@ -103,6 +103,21 @@ CREATE TABLE IF NOT EXISTS `s2_chat_memory` (
) ;
COMMENT ON TABLE s2_chat_memory IS 'chat memory table ';
CREATE TABLE IF NOT EXISTS `s2_chat_model`
(
id int AUTO_INCREMENT,
name varchar(100) null,
description varchar(500) null,
`config` varchar(500) NOT NULL ,
`created_at` TIMESTAMP NOT NULL ,
`created_by` varchar(100) NOT NULL ,
`updated_at` TIMESTAMP NOT NULL ,
`updated_by` varchar(100) NOT NULL,
`admin` varchar(500) NOT NULL,
`viewer` varchar(500) DEFAULT NULL,
PRIMARY KEY (`id`)
); COMMENT ON TABLE s2_chat_model IS 'chat model table';
create table IF NOT EXISTS s2_user
(
id INT AUTO_INCREMENT,