Interface ChatClient.ChatClientRequestSpec
- All Known Implementing Classes:
DefaultChatClient.DefaultChatClientRequestSpec
- Enclosing interface:
- ChatClient
public static interface ChatClient.ChatClientRequestSpec
-
Method Summary
Modifier and TypeMethodDescriptionadvisors(Consumer<ChatClient.AdvisorSpec> consumer) call()mutate()Return aChatClient.Builderto create a newChatClientwhose settings are replicated from thisChatClientRequest.<B extends ChatOptions.Builder<?>>
ChatClient.ChatClientRequestSpecoptions(B customizer) stream()system(Consumer<ChatClient.PromptSystemSpec> consumer) system(org.springframework.core.io.Resource text) templateRenderer(TemplateRenderer templateRenderer) toolCallbacks(List<ToolCallback> toolCallbacks) Deprecated, for removal: This API element is subject to removal in a future version.toolCallbacks(ToolCallback... toolCallbacks) Deprecated, for removal: This API element is subject to removal in a future version.as of 2.0.0, in favor oftools(Object...).toolCallbacks(ToolCallbackProvider... toolCallbackProviders) Deprecated, for removal: This API element is subject to removal in a future version.as of 2.0.0, in favor oftools(Object...).toolContext(Map<String, Object> toolContext) Register one or more tools for this chat request.user(Consumer<ChatClient.PromptUserSpec> consumer) user(org.springframework.core.io.Resource text)
-
Method Details
-
mutate
ChatClient.Builder mutate()Return aChatClient.Builderto create a newChatClientwhose settings are replicated from thisChatClientRequest. -
advisors
-
advisors
-
advisors
-
messages
-
messages
-
options
-
tools
Register one or more tools for this chat request. The method accepts a heterogeneous mix of tool representations and routes each element to the appropriate internal list automatically:ToolCallback— registered directly as a callback.ToolCallbackProvider— registered directly as a provider; its callbacks are resolved lazily at request time.ToolCallback[]orToolCallbackProvider[]— every element of the array is registered as above.Collection— iterated and each element is dispatched by the same rules.- Any other object — treated as a
@Tool-annotated POJO; aToolCallbackis generated for eachTool-annotated method it contains.
Mixed calls are fully supported:
chatClient.prompt() .tools(new DateTimeTools(), existingCallback, myProvider) .toolContext(Map.of("tenantId", "acme")) .call().content();Tools registered here are available only for this specific request. Use
ChatClient.Builder.defaultTools(Object...)to register tools that apply to every request built from the sameChatClient.Builder.- Parameters:
tools- tool objects to register; must not benulland must not containnullelements- Returns:
- this spec for chaining
- Throws:
IllegalArgumentException- iftoolsisnull, containsnullelements, or if a POJO argument has noTool-annotated methods
-
toolCallbacks
@Deprecated(since="2.0.0", forRemoval=true) ChatClient.ChatClientRequestSpec toolCallbacks(ToolCallback... toolCallbacks) Deprecated, for removal: This API element is subject to removal in a future version.as of 2.0.0, in favor oftools(Object...). To be removed in 3.0.0. -
toolCallbacks
@Deprecated(since="2.0.0", forRemoval=true) ChatClient.ChatClientRequestSpec toolCallbacks(List<ToolCallback> toolCallbacks) Deprecated, for removal: This API element is subject to removal in a future version.as of 2.0.0, in favor oftools(Object...). To be removed in 3.0.0. -
toolCallbacks
@Deprecated(since="2.0.0", forRemoval=true) ChatClient.ChatClientRequestSpec toolCallbacks(ToolCallbackProvider... toolCallbackProviders) Deprecated, for removal: This API element is subject to removal in a future version.as of 2.0.0, in favor oftools(Object...). To be removed in 3.0.0. -
toolContext
-
system
-
system
ChatClient.ChatClientRequestSpec system(org.springframework.core.io.Resource textResource, Charset charset) -
system
-
system
-
user
-
user
-
user
-
user
-
templateRenderer
-
call
ChatClient.CallResponseSpec call() -
stream
ChatClient.StreamResponseSpec stream()
-
tools(Object...).