diff --git a/go/appbuilder/dataset_test.go b/go/appbuilder/dataset_test.go index 5d7d7ada..17f56a3e 100644 --- a/go/appbuilder/dataset_test.go +++ b/go/appbuilder/dataset_test.go @@ -15,8 +15,8 @@ package appbuilder import ( - "bytes" - "fmt" + // "bytes" + // "fmt" "os" "testing" ) diff --git a/java/src/main/java/com/baidubce/appbuilder/console/knowledgebase/Knowledgebase.java b/java/src/main/java/com/baidubce/appbuilder/console/knowledgebase/Knowledgebase.java index 23b071d1..dc540b27 100644 --- a/java/src/main/java/com/baidubce/appbuilder/console/knowledgebase/Knowledgebase.java +++ b/java/src/main/java/com/baidubce/appbuilder/console/knowledgebase/Knowledgebase.java @@ -736,6 +736,25 @@ public QueryKnowledgeBaseResponse queryKnowledgeBase(QueryKnowledgeBaseRequest r QueryKnowledgeBaseResponse respBody = response.getBody(); return respBody; } + + public QueryKnowledgeBaseResponse queryKnowledgeBase(String query, String type, Integer top, Integer skip, + String[] knowledgebaseIDs, QueryKnowledgeBaseRequest.MetadataFilters filters, + QueryKnowledgeBaseRequest.QueryPipelineConfig pipelineConfig) + throws IOException, AppBuilderServerException { + + float rank_score_threshold = 0.4f; + + String url = AppBuilderConfig.QUERY_KNOWLEDGEBASE_URL; + QueryKnowledgeBaseRequest request = new QueryKnowledgeBaseRequest(query, type, rank_score_threshold, top, skip, knowledgebaseIDs, filters, pipelineConfig); + String jsonBody = JsonUtils.serialize(request); + ClassicHttpRequest postRequest = httpClient.createPostRequestV2(url, + new StringEntity(jsonBody, StandardCharsets.UTF_8)); + postRequest.setHeader("Content-Type", "application/json"); + HttpResponse response = httpClient.execute(postRequest, + QueryKnowledgeBaseResponse.class); + QueryKnowledgeBaseResponse respBody = response.getBody(); + return respBody; + } public QueryKnowledgeBaseResponse queryKnowledgeBase(String query, String type, Float rank_score_threshold, Integer top, Integer skip, String[] knowledgebaseIDs, QueryKnowledgeBaseRequest.MetadataFilters filters, @@ -746,7 +765,7 @@ public QueryKnowledgeBaseResponse queryKnowledgeBase(String query, String type, } String url = AppBuilderConfig.QUERY_KNOWLEDGEBASE_URL; - QueryKnowledgeBaseRequest request = new QueryKnowledgeBaseRequest(query, type, rank_score_threshold,top, skip, knowledgebaseIDs, filters, pipelineConfig); + QueryKnowledgeBaseRequest request = new QueryKnowledgeBaseRequest(query, type, rank_score_threshold, top, skip, knowledgebaseIDs, filters, pipelineConfig); String jsonBody = JsonUtils.serialize(request); ClassicHttpRequest postRequest = httpClient.createPostRequestV2(url, new StringEntity(jsonBody, StandardCharsets.UTF_8));