Remove deprecations from 1.0.0-M8
Remove deprecated DocumentCompressor/Ranker/Selector - These are replaced by the org.springframework.ai.rag.postretrieval.document.DocumentPostProcessor Remove deprecated Chatclient/DefaultChatClient methods In ChatClient: - Remove defaultTools and tools as these are replaced by defaultToolCallbacks and defaultToolNames respectively. In DefaultChatClient: - Remove tools method implementation - Remove unused DefaultCallPromptResponseSpec and DefaultStreamPromptResponseSpec Remove deprecated addMessage from Prompt Remove deprecated isInternalToolExecutionEnabled() from ToolCallingChatOptions - This is replaced by getInternalToolExecutionEnabled() Signed-off-by: Ilayaperumal Gopinathan <ilayaperumal.gopinathan@broadcom.com>
This commit is contained in:
@@ -222,12 +222,6 @@ public interface ChatClient {
|
||||
|
||||
ChatClientRequestSpec toolNames(String... toolNames);
|
||||
|
||||
/**
|
||||
* Use toolNames instead
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "1.0.0-m8")
|
||||
ChatClientRequestSpec tools(String... toolNames);
|
||||
|
||||
ChatClientRequestSpec tools(Object... toolObjects);
|
||||
|
||||
ChatClientRequestSpec toolCallbacks(ToolCallback... toolCallbacks);
|
||||
@@ -295,9 +289,6 @@ public interface ChatClient {
|
||||
|
||||
Builder defaultToolNames(String... toolNames);
|
||||
|
||||
@Deprecated
|
||||
Builder defaultTools(String... tools);
|
||||
|
||||
Builder defaultTools(Object... toolObjects);
|
||||
|
||||
Builder defaultToolCallbacks(ToolCallback... toolCallbacks);
|
||||
|
||||
@@ -51,7 +51,6 @@ import org.springframework.ai.chat.messages.UserMessage;
|
||||
import org.springframework.ai.chat.model.ChatModel;
|
||||
import org.springframework.ai.chat.model.ChatResponse;
|
||||
import org.springframework.ai.chat.model.Generation;
|
||||
import org.springframework.ai.chat.model.StreamingChatModel;
|
||||
import org.springframework.ai.chat.prompt.ChatOptions;
|
||||
import org.springframework.ai.chat.prompt.Prompt;
|
||||
import org.springframework.ai.content.Media;
|
||||
@@ -835,11 +834,6 @@ public class DefaultChatClient implements ChatClient {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChatClientRequestSpec tools(String... toolNames) {
|
||||
return this.toolNames(toolNames);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChatClientRequestSpec toolNames(String... toolNames) {
|
||||
Assert.notNull(toolNames, "toolNames cannot be null");
|
||||
@@ -992,72 +986,4 @@ public class DefaultChatClient implements ChatClient {
|
||||
|
||||
}
|
||||
|
||||
// Prompt
|
||||
|
||||
@Deprecated // never used, to be removed
|
||||
public static class DefaultCallPromptResponseSpec implements CallPromptResponseSpec {
|
||||
|
||||
private final ChatModel chatModel;
|
||||
|
||||
private final Prompt prompt;
|
||||
|
||||
public DefaultCallPromptResponseSpec(ChatModel chatModel, Prompt prompt) {
|
||||
Assert.notNull(chatModel, "chatModel cannot be null");
|
||||
Assert.notNull(prompt, "prompt cannot be null");
|
||||
this.chatModel = chatModel;
|
||||
this.prompt = prompt;
|
||||
}
|
||||
|
||||
public String content() {
|
||||
return doGetChatResponse(this.prompt).getResult().getOutput().getText();
|
||||
}
|
||||
|
||||
public List<String> contents() {
|
||||
return doGetChatResponse(this.prompt).getResults().stream().map(r -> r.getOutput().getText()).toList();
|
||||
}
|
||||
|
||||
public ChatResponse chatResponse() {
|
||||
return doGetChatResponse(this.prompt);
|
||||
}
|
||||
|
||||
private ChatResponse doGetChatResponse(Prompt prompt) {
|
||||
return this.chatModel.call(prompt);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Deprecated // never used, to be removed
|
||||
public static class DefaultStreamPromptResponseSpec implements StreamPromptResponseSpec {
|
||||
|
||||
private final Prompt prompt;
|
||||
|
||||
private final StreamingChatModel chatModel;
|
||||
|
||||
public DefaultStreamPromptResponseSpec(StreamingChatModel streamingChatModel, Prompt prompt) {
|
||||
Assert.notNull(streamingChatModel, "streamingChatModel cannot be null");
|
||||
Assert.notNull(prompt, "prompt cannot be null");
|
||||
this.chatModel = streamingChatModel;
|
||||
this.prompt = prompt;
|
||||
}
|
||||
|
||||
public Flux<ChatResponse> chatResponse() {
|
||||
return doGetFluxChatResponse(this.prompt);
|
||||
}
|
||||
|
||||
private Flux<ChatResponse> doGetFluxChatResponse(Prompt prompt) {
|
||||
return this.chatModel.stream(prompt);
|
||||
}
|
||||
|
||||
public Flux<String> content() {
|
||||
return doGetFluxChatResponse(this.prompt).map(r -> {
|
||||
if (r.getResult() == null || r.getResult().getOutput() == null
|
||||
|| r.getResult().getOutput().getText() == null) {
|
||||
return "";
|
||||
}
|
||||
return r.getResult().getOutput().getText();
|
||||
}).filter(StringUtils::hasLength);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -150,11 +150,6 @@ public class DefaultChatClientBuilder implements Builder {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder defaultTools(String... toolNames) {
|
||||
return defaultToolNames(toolNames);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder defaultToolNames(String... toolNames) {
|
||||
this.defaultRequest.toolNames(toolNames);
|
||||
|
||||
@@ -236,15 +236,6 @@ public class Prompt implements ModelRequest<List<Message>> {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Builder addMessage(Message message) {
|
||||
if (this.messages == null) {
|
||||
this.messages = new ArrayList<>();
|
||||
}
|
||||
this.messages.add(message);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder chatOptions(ChatOptions chatOptions) {
|
||||
this.chatOptions = chatOptions;
|
||||
return this;
|
||||
|
||||
@@ -70,16 +70,6 @@ public interface ToolCallingChatOptions extends ChatOptions {
|
||||
@Nullable
|
||||
Boolean getInternalToolExecutionEnabled();
|
||||
|
||||
/**
|
||||
* Whether the {@link ChatModel} is responsible for executing the tools requested by
|
||||
* the model or if the tools should be executed directly by the caller.
|
||||
*/
|
||||
@Nullable
|
||||
@Deprecated
|
||||
default Boolean isInternalToolExecutionEnabled() {
|
||||
return getInternalToolExecutionEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether the {@link ChatModel} is responsible for executing the tools requested
|
||||
* by the model or if the tools should be executed directly by the caller.
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
* Copyright 2023-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.rag.postretrieval.compression;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
import org.springframework.ai.document.Document;
|
||||
import org.springframework.ai.rag.Query;
|
||||
import org.springframework.ai.rag.postretrieval.document.DocumentPostProcessor;
|
||||
import org.springframework.ai.rag.postretrieval.ranking.DocumentRanker;
|
||||
import org.springframework.ai.rag.postretrieval.selection.DocumentSelector;
|
||||
|
||||
/**
|
||||
* A component for compressing the content of each document to reduce noise and redundancy
|
||||
* in the retrieved information, addressing challenges such as "lost-in-the-middle" and
|
||||
* context length restrictions from the model.
|
||||
* <p>
|
||||
* Unlike {@link DocumentSelector}, this component does not remove entire documents from
|
||||
* the list, but rather alters the content of the documents. Unlike
|
||||
* {@link DocumentRanker}, this component does not change the order/score of the documents
|
||||
* in the list.
|
||||
*
|
||||
* @deprecated in favour of {@link DocumentPostProcessor}.
|
||||
*/
|
||||
@Deprecated
|
||||
public interface DocumentCompressor extends BiFunction<Query, List<Document>, List<Document>> {
|
||||
|
||||
/**
|
||||
* Compresses the content of each document.
|
||||
* @param query the query to compress documents for
|
||||
* @param documents the list of documents whose content should be compressed
|
||||
* @return a list of documents with compressed content
|
||||
*/
|
||||
List<Document> compress(Query query, List<Document> documents);
|
||||
|
||||
default List<Document> apply(Query query, List<Document> documents) {
|
||||
return compress(query, documents);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
/*
|
||||
* Copyright 2023-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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* RAG Sub-Module: Document Compression.
|
||||
*/
|
||||
@NonNullApi
|
||||
@NonNullFields
|
||||
package org.springframework.ai.rag.postretrieval.compression;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
import org.springframework.lang.NonNullFields;
|
||||
@@ -1,54 +0,0 @@
|
||||
/*
|
||||
* Copyright 2023-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.rag.postretrieval.ranking;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
import org.springframework.ai.document.Document;
|
||||
import org.springframework.ai.rag.Query;
|
||||
import org.springframework.ai.rag.postretrieval.compression.DocumentCompressor;
|
||||
import org.springframework.ai.rag.postretrieval.document.DocumentPostProcessor;
|
||||
import org.springframework.ai.rag.postretrieval.selection.DocumentSelector;
|
||||
|
||||
/**
|
||||
* A component for ordering and ranking documents based on their relevance to a query to
|
||||
* bring the most relevant documents to the top of the list, addressing challenges such as
|
||||
* "lost-in-the-middle".
|
||||
* <p>
|
||||
* Unlike {@link DocumentSelector}, this component does not remove entire documents from
|
||||
* the list, but rather changes the order/score of the documents in the list. Unlike
|
||||
* {@link DocumentCompressor}, this component does not alter the content of the documents.
|
||||
*
|
||||
* @deprecated in favour of {@link DocumentPostProcessor}.
|
||||
*/
|
||||
@Deprecated
|
||||
public interface DocumentRanker extends BiFunction<Query, List<Document>, List<Document>> {
|
||||
|
||||
/**
|
||||
* Ranks documents based on their relevance to the given query.
|
||||
* @param query the query to rank documents for
|
||||
* @param documents the list of documents to rank
|
||||
* @return a list of ordered documents based on a ranking algorithm
|
||||
*/
|
||||
List<Document> rank(Query query, List<Document> documents);
|
||||
|
||||
default List<Document> apply(Query query, List<Document> documents) {
|
||||
return rank(query, documents);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
/*
|
||||
* Copyright 2023-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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* RAG Sub-Module: Document Ranking.
|
||||
*/
|
||||
@NonNullApi
|
||||
@NonNullFields
|
||||
package org.springframework.ai.rag.postretrieval.ranking;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
import org.springframework.lang.NonNullFields;
|
||||
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
* Copyright 2023-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.rag.postretrieval.selection;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
import org.springframework.ai.document.Document;
|
||||
import org.springframework.ai.rag.Query;
|
||||
import org.springframework.ai.rag.postretrieval.compression.DocumentCompressor;
|
||||
import org.springframework.ai.rag.postretrieval.document.DocumentPostProcessor;
|
||||
import org.springframework.ai.rag.postretrieval.ranking.DocumentRanker;
|
||||
|
||||
/**
|
||||
* A component for removing irrelevant or redundant documents from a list of retrieved
|
||||
* documents, addressing challenges such as "lost-in-the-middle" and context length
|
||||
* restrictions from the model.
|
||||
* <p>
|
||||
* Unlike {@link DocumentRanker}, this component does not change the order/score of the
|
||||
* documents in the list, but rather removes irrelevant or redundant documents. Unlike
|
||||
* {@link DocumentCompressor}, this component does not alter the content of the documents,
|
||||
* but rather removes entire documents.
|
||||
*
|
||||
* @deprecated in favour of {@link DocumentPostProcessor}.
|
||||
*/
|
||||
@Deprecated
|
||||
public interface DocumentSelector extends BiFunction<Query, List<Document>, List<Document>> {
|
||||
|
||||
/**
|
||||
* Removes irrelevant or redundant documents from a list of retrieved documents.
|
||||
* @param query the query to select documents for
|
||||
* @param documents the list of documents to select from
|
||||
* @return a list of selected documents
|
||||
*/
|
||||
List<Document> select(Query query, List<Document> documents);
|
||||
|
||||
default List<Document> apply(Query query, List<Document> documents) {
|
||||
return select(query, documents);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
/*
|
||||
* Copyright 2023-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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* RAG Sub-Module: Document Selection.
|
||||
*/
|
||||
@NonNullApi
|
||||
@NonNullFields
|
||||
package org.springframework.ai.rag.postretrieval.selection;
|
||||
|
||||
import org.springframework.lang.NonNullApi;
|
||||
import org.springframework.lang.NonNullFields;
|
||||
Reference in New Issue
Block a user