Skip to content

Commit

Permalink
增加异步生成接口定义
Browse files Browse the repository at this point in the history
  • Loading branch information
lingjue@ubuntu committed Sep 11, 2023
1 parent d08c153 commit 15125e4
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -60,5 +62,9 @@ default BaseMessage predictMessages(List<BaseMessage> messages) {
*/
BaseMessage predictMessages(List<BaseMessage> messages, List<String> stop);

/**
* Take in a list of prompt values and return an Flux&lt;AsyncLLMResult&gt; for every PromptValue.
*/
List<Flux<AsyncLLMResult>> asyncGeneratePrompt(List<PromptValue> prompts, List<String> stop);

}
Original file line number Diff line number Diff line change
@@ -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<List<Generation>> because each input could have multiple generations.
*/
private List<? extends Generation> generations;

/**
* For arbitrary LLM provider specific output.
*/
private Map<String, Object> llmOutput;

public AsyncLLMResult(List<? extends Generation> generations, Map<String, Object> llmOutput) {
this.generations = generations;
this.llmOutput = llmOutput;
}

}

0 comments on commit 15125e4

Please sign in to comment.