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