HamaWhiteGG / langchain-java

Java version of LangChain, while empowering LLM for Big Data.
Apache License 2.0
551 stars 107 forks source link

可以流式输出吗,直接等待完成太长时间了? #104

Closed mumengmeng closed 1 year ago

mumengmeng commented 1 year ago

可以流式输出吗,直接等待完成太长时间了?

HamaWhiteGG commented 1 year ago

supported, see StreamOpenAIExample

@RunnableExample
public class StreamOpenAIExample {

    public static void main(String[] args) {

        var llm = OpenAI.builder()
                .maxTokens(1000)
                .temperature(0)
                .requestTimeout(120)
                .build()
                .init();

        var result = llm.asyncPredict("Introduce West Lake in Hangzhou, China.");
        result.doOnNext(System.out::print).blockLast();
    }
}
mumengmeng commented 1 year ago

niubility!