mirror of
https://github.com/CodePhiliaX/Chat2DB.git
synced 2025-07-30 03:03:13 +08:00
embedding query
This commit is contained in:
@ -542,20 +542,27 @@ public class ChatController {
|
||||
TableSchemaRequest tableSchemaRequest = new TableSchemaRequest();
|
||||
tableSchemaRequest.setSchemaVector(contentVector);
|
||||
tableSchemaRequest.setDataSourceId(queryRequest.getDataSourceId());
|
||||
String databaseName = StringUtils.isNotBlank(queryRequest.getDatabaseName()) ? queryRequest.getDatabaseName() : queryRequest.getSchemaName();
|
||||
if (Objects.isNull(databaseName)) {
|
||||
databaseName = "";
|
||||
tableSchemaRequest.setDatabaseName(queryRequest.getDatabaseName());
|
||||
tableSchemaRequest.setDataSourceSchema(queryRequest.getSchemaName());
|
||||
ConfigService configService = ApplicationContextUtil.getBean(ConfigService.class);
|
||||
Config keyConfig = configService.find(Chat2dbAIClient.CHAT2DB_OPENAI_KEY).getData();
|
||||
if (Objects.isNull(keyConfig) || StringUtils.isBlank(keyConfig.getContent())) {
|
||||
return "";
|
||||
}
|
||||
tableSchemaRequest.setDatabaseName(databaseName);
|
||||
DataResult<TableSchemaResponse> result = gatewayClientService.schemaVectorSearch(tableSchemaRequest);
|
||||
|
||||
List<String> schemas = Lists.newArrayList();
|
||||
if (CollectionUtils.isNotEmpty(result.getData().getTableSchemas())) {
|
||||
for(TableSchema data: result.getData().getTableSchemas()){
|
||||
schemas.add(data.getTableSchema());
|
||||
tableSchemaRequest.setApiKey(keyConfig.getContent());
|
||||
try {
|
||||
DataResult<TableSchemaResponse> result = gatewayClientService.schemaVectorSearch(tableSchemaRequest);
|
||||
List<String> schemas = Lists.newArrayList();
|
||||
if (Objects.nonNull(result.getData()) && CollectionUtils.isNotEmpty(result.getData().getTableSchemas())) {
|
||||
for(TableSchema data: result.getData().getTableSchemas()){
|
||||
schemas.add(data.getTableSchema());
|
||||
}
|
||||
}
|
||||
return JSON.toJSONString(schemas);
|
||||
} catch (Exception exception) {
|
||||
log.error("query table error, do nothing");
|
||||
return "";
|
||||
}
|
||||
return JSON.toJSONString(schemas);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -79,8 +79,8 @@ public interface GatewayClientService {
|
||||
* @param searchVectors
|
||||
* @return
|
||||
*/
|
||||
@Get("/api/client/milvus/knowledge/search")
|
||||
DataResult<KnowledgeResponse> knowledgeVectorSearch(@Query KnowledgeRequest searchVectors);
|
||||
@Post(url = "/api/client/milvus/knowledge/search", contentType = "application/json")
|
||||
DataResult<KnowledgeResponse> knowledgeVectorSearch(@Body KnowledgeRequest searchVectors);
|
||||
|
||||
/**
|
||||
* save table schema vector
|
||||
@ -88,8 +88,8 @@ public interface GatewayClientService {
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@Get("/api/client/milvus/schema/search")
|
||||
DataResult<TableSchemaResponse> schemaVectorSearch(@Query TableSchemaRequest request);
|
||||
@Post(url = "/api/client/milvus/schema/search", contentType = "application/json")
|
||||
DataResult<TableSchemaResponse> schemaVectorSearch(@Body TableSchemaRequest request);
|
||||
|
||||
/**
|
||||
* check in white list
|
||||
|
@ -26,5 +26,5 @@ public class TableSchemaRequest {
|
||||
|
||||
private List<String> schemaList;
|
||||
|
||||
private Boolean deleteBeforeInsert;
|
||||
private Boolean deleteBeforeInsert = false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user