L'interface Ollamaservice fournit l'interaction avec le service 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 );
} La classe OllamaserviceFactory est responsable de la création d'instances de l' OllamaService . Il fournit des méthodes de constructeur pour créer une instance du service avec la configuration spécifiée.
public class OllamaServiceFactory {
public static OllamaService create ( OllamaProperties properties ) { // ...
}
public static OllamaService create ( OllamaProperties properties , Gson gson ) { // ...
}
}L'interface StreamResponseProcessor fournit des méthodes pour traiter les réponses de réalisation de streaming.
public interface StreamResponseProcessor < T > {
void processStreamItem ( T item );
void processCompletion ( T fullResponse );
void processError ( Throwable throwable );
} Créez simplement une instance du OllamaService avec l'usine et utilisez-la.
Jetez un œil ici
Ou jetez un œil au projet Spring-Boot-Elma-échantillon.
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 mistralPour afficher les journaux d'Olllama en cours de service de démarrage, exécutez:
$ journalctl -u ollamaSupprimer le service Olllama:
sudo systemctl stop ollama
sudo systemctl disable ollama
sudo rm /etc/systemd/system/ollama.serviceRetirez le binaire Olllama de votre répertoire bac (soit / usr / local / bin, / usr / bin, ou / bin):
sudo rm $( which ollama )Supprimer les modèles téléchargés et l'utilisateur du service Olllama:
sudo rm -r /usr/share/ollama
sudo userdel ollama