|
3 | 3 |
|
4 | 4 | import com.aliyun.core.http.*; |
5 | 5 | import com.aliyun.sdk.service.gpdb20160503.models.*; |
| 6 | +import darabonba.core.sse.SSEHttpResponseHandler; |
6 | 7 | import darabonba.core.utils.*; |
7 | 8 | import com.aliyun.sdk.gateway.pop.*; |
8 | 9 | import darabonba.core.*; |
@@ -178,6 +179,58 @@ public CompletableFuture<CancelUpsertCollectionDataJobResponse> cancelUpsertColl |
178 | 179 | } |
179 | 180 | } |
180 | 181 |
|
| 182 | + /** |
| 183 | + * <b>description</b> : |
| 184 | + * <p>通过结合知识库和大模型,提供智能问答服务。</p> |
| 185 | + * |
| 186 | + * @param request the request parameters of ChatWithKnowledgeBase ChatWithKnowledgeBaseRequest |
| 187 | + * @return ChatWithKnowledgeBaseResponse |
| 188 | + */ |
| 189 | + @Override |
| 190 | + public CompletableFuture<ChatWithKnowledgeBaseResponse> chatWithKnowledgeBase(ChatWithKnowledgeBaseRequest request) { |
| 191 | + try { |
| 192 | + this.handler.validateRequestModel(request); |
| 193 | + TeaRequest teaRequest = REQUEST.copy().setStyle(RequestStyle.RPC).setAction("ChatWithKnowledgeBase").setMethod(HttpMethod.POST).setPathRegex("/").setBodyType(BodyType.JSON).setBodyIsForm(false).setReqBodyType(BodyType.JSON).formModel(request); |
| 194 | + ClientExecutionParams params = new ClientExecutionParams().withInput(request).withRequest(teaRequest).withOutput(ChatWithKnowledgeBaseResponse.create()); |
| 195 | + return this.handler.execute(params); |
| 196 | + } catch (Exception e) { |
| 197 | + CompletableFuture<ChatWithKnowledgeBaseResponse> future = new CompletableFuture<>(); |
| 198 | + future.completeExceptionally(e); |
| 199 | + return future; |
| 200 | + } |
| 201 | + } |
| 202 | + |
| 203 | + /** |
| 204 | + * <b>description</b> : |
| 205 | + * <p>通过结合知识库和大模型,提供智能问答服务。</p> |
| 206 | + * |
| 207 | + * @param request the request parameters of ChatWithKnowledgeBaseStream ChatWithKnowledgeBaseStreamRequest |
| 208 | + * @return ChatWithKnowledgeBaseStreamResponse |
| 209 | + */ |
| 210 | + @Override |
| 211 | + public CompletableFuture<ChatWithKnowledgeBaseStreamResponse> chatWithKnowledgeBaseStream(ChatWithKnowledgeBaseStreamRequest request) { |
| 212 | + try { |
| 213 | + this.handler.validateRequestModel(request); |
| 214 | + TeaRequest teaRequest = REQUEST.copy().setStyle(RequestStyle.RPC).setAction("ChatWithKnowledgeBaseStream").setMethod(HttpMethod.POST).setPathRegex("/").setBodyType(BodyType.JSON).setBodyIsForm(false).setReqBodyType(BodyType.JSON).formModel(request); |
| 215 | + ClientExecutionParams params = new ClientExecutionParams().withInput(request).withRequest(teaRequest).withOutput(ChatWithKnowledgeBaseStreamResponse.create()); |
| 216 | + return this.handler.execute(params); |
| 217 | + } catch (Exception e) { |
| 218 | + CompletableFuture<ChatWithKnowledgeBaseStreamResponse> future = new CompletableFuture<>(); |
| 219 | + future.completeExceptionally(e); |
| 220 | + return future; |
| 221 | + } |
| 222 | + } |
| 223 | + |
| 224 | + @Override |
| 225 | + public ResponseIterable<ChatWithKnowledgeBaseStreamResponseBody> chatWithKnowledgeBaseStreamWithResponseIterable(ChatWithKnowledgeBaseStreamRequest request) { |
| 226 | + this.handler.validateRequestModel(request); |
| 227 | + TeaRequest teaRequest = REQUEST.copy().setStyle(RequestStyle.SSE).setAction("ChatWithKnowledgeBaseStream").setMethod(HttpMethod.POST).setPathRegex("/").setBodyType(BodyType.JSON).setBodyIsForm(false).setReqBodyType(BodyType.JSON).formModel(request); |
| 228 | + ChatWithKnowledgeBaseStreamResponseBodyIterator iterator = ChatWithKnowledgeBaseStreamResponseBodyIterator.create(); |
| 229 | + ClientExecutionParams params = new ClientExecutionParams().withInput(request).withRequest(teaRequest).withHttpResponseHandler(new SSEHttpResponseHandler(iterator)); |
| 230 | + this.handler.execute(params); |
| 231 | + return new ResponseIterable<>(iterator); |
| 232 | + } |
| 233 | + |
181 | 234 | /** |
182 | 235 | * @param request the request parameters of CheckHadoopDataSource CheckHadoopDataSourceRequest |
183 | 236 | * @return CheckHadoopDataSourceResponse |
|
0 commit comments