Add ChatClient.Builder auto-configuraiton support

- add ChatClinetCustomizer support.
  - add enable/disable property - enabled by default.
  - add ITs.

* Update README.md
This commit is contained in:
Christian Tzolov
2024-05-23 20:55:20 +02:00
committed by Mark Pollack
parent 5f887b3eb6
commit 0571aac44c
8 changed files with 385 additions and 58 deletions

View File

@@ -0,0 +1,40 @@
/*
* Copyright 2024-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.ai.chat.client;
import org.springframework.ai.chat.ChatClient;
/**
* Callback interface that can be used to customize a {@link ChatClient.Builder
* ChatClient.Builder}.
*
* @author Christian Tzolov
* @author Mark Pollack
* @author Josh Long
* @author Arjen Poutsma
* @since 1.0.0 M1
*/
@FunctionalInterface
public interface ChatClientCustomizer {
/**
* Callback to customize a {@link ChatClient.Builder ChatClient.Builder} instance.
* @param chatClientBuilder the client builder to customize
*/
void customize(ChatClient.Builder chatClientBuilder);
}

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.ai.chat;
package org.springframework.ai.chat.client;
import java.net.MalformedURLException;
import java.net.URL;
@@ -29,6 +29,11 @@ import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import reactor.core.publisher.Flux;
import org.springframework.ai.chat.ChatClient;
import org.springframework.ai.chat.ChatModel;
import org.springframework.ai.chat.ChatResponse;
import org.springframework.ai.chat.Generation;
import org.springframework.ai.chat.StreamingChatModel;
import org.springframework.ai.chat.messages.Message;
import org.springframework.ai.chat.messages.MessageType;
import org.springframework.ai.chat.messages.UserMessage;