2024-08-27 14:05:52 +02:00
|
|
|
package eu.m724.responsesource;
|
|
|
|
|
2024-08-29 13:22:48 +02:00
|
|
|
import eu.m724.chat.ChatEvent;
|
2024-08-28 15:09:38 +02:00
|
|
|
import eu.m724.chat.ChatMessage;
|
|
|
|
|
|
|
|
import java.util.concurrent.CompletableFuture;
|
2024-08-28 15:48:52 +02:00
|
|
|
import java.util.concurrent.LinkedBlockingQueue;
|
2024-08-28 15:09:38 +02:00
|
|
|
|
2024-08-27 14:05:52 +02:00
|
|
|
public interface ChatResponse {
|
2024-08-28 15:09:38 +02:00
|
|
|
/**
|
|
|
|
* is this response streaming
|
2024-08-28 15:48:52 +02:00
|
|
|
* if it's not, the queue will get one element that is the whole response
|
|
|
|
*
|
2024-08-28 15:09:38 +02:00
|
|
|
* @return is this response streaming
|
|
|
|
*/
|
2024-08-27 14:05:52 +02:00
|
|
|
boolean isStreaming();
|
2024-08-28 15:09:38 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* if streamed, text token by token as it goes (or other splitting depending on the source)
|
|
|
|
* if not, the {@link CompletableFuture} returns just the whole response after it's ready
|
2024-08-28 15:48:52 +02:00
|
|
|
*
|
|
|
|
* @return the fifo queue with each element being a part. null ends the sequence
|
2024-08-28 15:09:38 +02:00
|
|
|
*/
|
2024-08-29 13:22:48 +02:00
|
|
|
LinkedBlockingQueue<ChatEvent> eventQueue();
|
2024-08-28 15:09:38 +02:00
|
|
|
|
|
|
|
/**
|
2024-08-28 15:48:52 +02:00
|
|
|
* gets the resulting {@link ChatMessage} when it's ready
|
|
|
|
*
|
|
|
|
* @return the resulting {@link ChatMessage} as soon as the response is complete
|
2024-08-28 15:09:38 +02:00
|
|
|
*/
|
2024-08-28 15:48:52 +02:00
|
|
|
CompletableFuture<ChatMessage> message();
|
2024-08-27 14:05:52 +02:00
|
|
|
}
|