Antarmuka Ollamaservice menyediakan interaksi dengan layanan web Ollama.
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 );
} Kelas Ollamaservicefactory bertanggung jawab untuk menciptakan contoh OllamaService . Ini menyediakan metode pembangun untuk membuat instance layanan dengan konfigurasi yang ditentukan.
public class OllamaServiceFactory {
public static OllamaService create ( OllamaProperties properties ) { // ...
}
public static OllamaService create ( OllamaProperties properties , Gson gson ) { // ...
}
}Antarmuka StreamResponseprocessor menyediakan metode untuk memproses respons penyelesaian streaming.
public interface StreamResponseProcessor < T > {
void processStreamItem ( T item );
void processCompletion ( T fullResponse );
void processError ( Throwable throwable );
} Cukup buat instance OllamaService dengan pabrik dan gunakan.
Lihat di sini
atau lihat proyek sampel spring-boot-ollama.
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 mistralUntuk melihat log Ollama berjalan sebagai layanan startup, jalankan:
$ journalctl -u ollamaHapus Layanan Ollama:
sudo systemctl stop ollama
sudo systemctl disable ollama
sudo rm /etc/systemd/system/ollama.serviceHapus biner ollama dari direktori bin Anda (salah satu /usr /lokal /bin, /usr /bin, atau /bin):
sudo rm $( which ollama )Hapus model yang diunduh dan pengguna layanan ollama:
sudo rm -r /usr/share/ollama
sudo userdel ollama