Ollama4j
A Java library (wrapper/binding) for Ollama server.
Loading...
Searching...
No Matches
OllamaResultStream.java
Go to the documentation of this file.
1/*
2 * Ollama4j - Java library for interacting with Ollama server.
3 * Copyright (c) 2025 Amith Koujalgi and contributors.
4 *
5 * Licensed under the MIT License (the "License");
6 * you may not use this file except in compliance with the License.
7 *
8*/
9package io.github.ollama4j.models.response;
10
11import java.util.Iterator;
12import java.util.LinkedList;
13import java.util.Queue;
14
15public class OllamaResultStream extends LinkedList<String> implements Queue<String> {
16 @Override
17 public String poll() {
18 StringBuilder tokens = new StringBuilder();
19 Iterator<String> iterator = this.listIterator();
20 while (iterator.hasNext()) {
21 tokens.append(iterator.next());
22 iterator.remove();
23 }
24 return tokens.toString();
25 }
26}