Class ChatClient
java.lang.Object
io.github.stefanbratanov.jvm.openai.ChatClient
Given a list of messages comprising a conversation, the model will return a response.
Based on Chat
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final HttpClientprotected final com.fasterxml.jackson.databind.ObjectMapper -
Method Summary
Modifier and TypeMethodDescriptionsendRequest(ChatRequest request) Creates a model response for the given chat conversation.sendRequestAsync(ChatRequest request) Same assendRequest(ChatRequest)but returns a response in aCompletableFuturesendStreamRequest(ChatRequest request) Stream model responses back in order to allow partial results for the given request.
-
Field Details
-
httpClient
-
objectMapper
protected final com.fasterxml.jackson.databind.ObjectMapper objectMapper
-
-
Method Details
-
sendRequest
Creates a model response for the given chat conversation.- Throws:
OpenAIException- in case of API errors
-
sendRequestAsync
Same assendRequest(ChatRequest)but returns a response in aCompletableFuture -
sendStreamRequest
Stream model responses back in order to allow partial results for the given request.- Parameters:
request- the request should be configured withChatRequest.Builder.stream(boolean)set to true- Throws:
OpenAIException- in case of API errors
-