Die Ollamaservice -Schnittstelle bietet die Interaktion mit dem OLLAMA -Webdienst.
public interface OllamaService {
CompletionResponse completion ( CompletionRequest completionRequest );
TagsResponse getTags ();
ShowResponse show ( ShowRequest showRequest );
void copy ( CopyRequest copyRequest );
void delete ( String modelName );
void streamingCompletion ( CompletionRequest completionRequest , StreamResponseProcessor < String > handler );
EmbeddingResponse embed ( EmbeddingRequest embeddingRequest );
} Die OllamaserviceFactory -Klasse ist dafür verantwortlich, Instanzen des OllamaService zu erstellen. Es bietet Builder -Methoden, um eine Instanz des Dienstes mit der angegebenen Konfiguration zu erstellen.
public class OllamaServiceFactory {
public static OllamaService create ( OllamaProperties properties ) { // ...
}
public static OllamaService create ( OllamaProperties properties , Gson gson ) { // ...
}
}Die StreamResponseProcessor -Schnittstelle bietet Methoden zur Verarbeitung von Reaktionen für Streaming -Abschlüsse.
public interface StreamResponseProcessor < T > {
void processStreamItem ( T item );
void processCompletion ( T fullResponse );
void processError ( Throwable throwable );
} Erstellen Sie einfach eine Instanz des OllamaService mit der Fabrik und verwenden Sie sie.
Schauen Sie sich hier an
Oder schauen Sie sich das Projekt für Spring-Boot-Wiederhola-Proben an.
https://github.com/jmorganca/ollama/blob/main/docs/api.md
https://github.com/jmorganca/ollama/blob/main/docs/linux.md
$ curl https://ollama.ai/install.sh | sh
>>> Installing ollama to /usr/local/bin...
>>> Creating ollama user...
>>> Adding current user to ollama group...
>>> Creating ollama systemd service...
>>> Enabling and starting ollama service...
Created symlink /etc/systemd/system/default.target.wants/ollama.service → /etc/systemd/system/ollama.service.
>>> NVIDIA GPU installed. # open http://localhost:11434/
# or via curl
$ curl http://localhost:11434/api/tags
$ ollama run mistralUm die Protokolle von Ollama anzuzeigen, die als Startservice ausgeführt werden, laufen Sie aus:
$ journalctl -u ollamaEntfernen Sie den Ollama -Service:
sudo systemctl stop ollama
sudo systemctl disable ollama
sudo rm /etc/systemd/system/ollama.serviceEntfernen Sie das Ollama -Binärding aus Ihrem Bin -Verzeichnis (entweder /usr /local /bin, /usr /bin oder /bin):
sudo rm $( which ollama )Entfernen Sie die heruntergeladenen Modelle und den Ollama -Service -Benutzer:
sudo rm -r /usr/share/ollama
sudo userdel ollama