diff --git a/langchain-core/src/main/java/com/hw/langchain/base/language/BaseLanguageModel.java b/langchain-core/src/main/java/com/hw/langchain/base/language/BaseLanguageModel.java index ed35fd0e2..4c23ea892 100644 --- a/langchain-core/src/main/java/com/hw/langchain/base/language/BaseLanguageModel.java +++ b/langchain-core/src/main/java/com/hw/langchain/base/language/BaseLanguageModel.java @@ -18,9 +18,11 @@ package com.hw.langchain.base.language; +import com.hw.langchain.schema.AsyncLLMResult; import com.hw.langchain.schema.BaseMessage; import com.hw.langchain.schema.LLMResult; import com.hw.langchain.schema.PromptValue; +import reactor.core.publisher.Flux; import java.util.List; @@ -60,5 +62,9 @@ default BaseMessage predictMessages(List messages) { */ BaseMessage predictMessages(List messages, List stop); + /** + * Take in a list of prompt values and return an Flux<AsyncLLMResult> for every PromptValue. + */ + List> asyncGeneratePrompt(List prompts, List stop); } diff --git a/langchain-core/src/main/java/com/hw/langchain/schema/AsyncLLMResult.java b/langchain-core/src/main/java/com/hw/langchain/schema/AsyncLLMResult.java new file mode 100644 index 000000000..214e50df0 --- /dev/null +++ b/langchain-core/src/main/java/com/hw/langchain/schema/AsyncLLMResult.java @@ -0,0 +1,30 @@ +package com.hw.langchain.schema; + +import lombok.Data; + +import java.util.List; +import java.util.Map; + +/** + * @author lingjue@ubuntu + * @since 8/1/23 7:01 PM + */ +@Data +public class AsyncLLMResult { + + /** + * List of the things generated. This is List> because each input could have multiple generations. + */ + private List generations; + + /** + * For arbitrary LLM provider specific output. + */ + private Map llmOutput; + + public AsyncLLMResult(List generations, Map llmOutput) { + this.generations = generations; + this.llmOutput = llmOutput; + } + +}