
dev.langchain4j.retriever.Retriever Maven / Gradle / Ivy
package dev.langchain4j.retriever;
import dev.langchain4j.data.segment.TextSegment;
import dev.langchain4j.rag.content.Content;
import dev.langchain4j.rag.content.retriever.ContentRetriever;
import java.util.List;
import static java.util.stream.Collectors.toList;
/**
* Interface for retrieving relevant items.
*
* @param the type of the items.
* @deprecated Please use {@link ContentRetriever} instead.
*/
@Deprecated(forRemoval = true)
public interface Retriever {
/**
* Find relevant items for the given text.
*
* @param text the text to search for.
* @return the list of relevant items.
*/
List findRelevant(String text);
/**
* Find relevant items for the given text and memoryId.
*
* Default implementation throws an exception.
*
* @param memoryId the memoryId to search for.
* @param text the text to search for.
* @return the list of relevant items.
*/
default List findRelevant(
@SuppressWarnings("unused") Object memoryId,
@SuppressWarnings("unused") String text) {
throw new RuntimeException("Not implemented");
}
default ContentRetriever toContentRetriever() {
return (query) -> {
List relevant = (List) findRelevant(query.text());
return relevant.stream()
.map(Content::from)
.collect(toList());
};
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy