{"id":26893469,"url":"https://github.com/oalles/ollama-java","last_synced_at":"2025-05-12T16:12:46.560Z","repository":{"id":206053234,"uuid":"715709675","full_name":"oalles/ollama-java","owner":"oalles","description":"A java client for Ollama","archived":false,"fork":false,"pushed_at":"2025-03-24T08:16:25.000Z","size":3569,"stargazers_count":22,"open_issues_count":0,"forks_count":5,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-31T23:58:00.864Z","etag":null,"topics":["client","java","language-model","llm","llm-inference","localdevelopment","ollama","spring-boot"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/oalles.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-11-07T17:14:57.000Z","updated_at":"2025-03-29T18:57:11.000Z","dependencies_parsed_at":"2023-11-08T06:43:28.845Z","dependency_job_id":"612219db-cd18-4a0f-a994-4d703ad6e178","html_url":"https://github.com/oalles/ollama-java","commit_stats":null,"previous_names":["oalles/ollama-java-client","oalles/ollama-java"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oalles%2Follama-java","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oalles%2Follama-java/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oalles%2Follama-java/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oalles%2Follama-java/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oalles","download_url":"https://codeload.github.com/oalles/ollama-java/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253774007,"owners_count":21962198,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["client","java","language-model","llm","llm-inference","localdevelopment","ollama","spring-boot"],"created_at":"2025-03-31T23:58:04.458Z","updated_at":"2025-05-12T16:12:46.526Z","avatar_url":"https://github.com/oalles.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OLLAMA Java Client\n\n## Modules\n\n* [ollama-java-client](ollama-java-client) - The Ollama Java Client library\n* [ollama-java-client-starter](ollama-java-client-starter) - The Ollama Java Client Spring Boot 3 Starter\n* [spring-boot-ollama-sample](spring-boot-ollama-sample) - A sample Spring Boot 3 application using the Ollama Java\n  Client Spring Boot 3 Starter\n\n## Model Description\n\n### OllamaService\n\nThe [OllamaService](src/main/java/es/omarall/ollama/OllamaService.java) interface provide the interaction with the\nollama web service.\n\n```java\npublic interface OllamaService {\n    CompletionResponse completion(CompletionRequest completionRequest);\n\n    TagsResponse getTags();\n\n    ShowResponse show(ShowRequest showRequest);\n\n    void copy(CopyRequest copyRequest);\n\n    void delete(String modelName);\n\n    void streamingCompletion(CompletionRequest completionRequest, StreamResponseProcessor\u003cString\u003e handler);\n\n    EmbeddingResponse embed(EmbeddingRequest embeddingRequest);\n}\n```\n\n### OllamaServiceFactory\n\nThe [OllamaServiceFactory](src/main/java/es/omarall/ollama/OllamaServiceFactory.java) class is responsible for creating\ninstances of the `OllamaService`. It provides builder methods\nto create an instance of the service with the specified configuration.\n\n```java\npublic class OllamaServiceFactory {\n    public static OllamaService create(OllamaProperties properties) { // ...\n    }\n\n    public static OllamaService create(OllamaProperties properties, Gson gson) { // ...\n    }\n}\n```\n\n### StreamResponseProcessor\n\nThe [StreamResponseProcessor](src/main/java/es/omarall/ollama/StreamResponseProcessor.java) interface provides methods\nto process streaming completion responses.\n\n```java\npublic interface StreamResponseProcessor\u003cT\u003e {\n    void processStreamItem(T item);\n\n    void processCompletion(T fullResponse);\n\n    void processError(Throwable throwable);\n}\n```\n\n### How to use\n\nJust create an instance of the `OllamaService` with the factory and use it.\n\nHave a look at [here](./ollama-java-client/src/test/java/es/omarall/ollama/HowToUse.java)\n\nor have a look at the [spring-boot-ollama-sample](spring-boot-ollama-sample) project.\n\n## Useful Resources\n\n### API DOC\n\nhttps://github.com/jmorganca/ollama/blob/main/docs/api.md\n\n### Linux install\n\nhttps://github.com/jmorganca/ollama/blob/main/docs/linux.md\n\n```bash\n$ curl https://ollama.ai/install.sh | sh\n\u003e\u003e\u003e Installing ollama to /usr/local/bin...\n\u003e\u003e\u003e Creating ollama user...\n\u003e\u003e\u003e Adding current user to ollama group...\n\u003e\u003e\u003e Creating ollama systemd service...\n\u003e\u003e\u003e Enabling and starting ollama service...\nCreated symlink /etc/systemd/system/default.target.wants/ollama.service → /etc/systemd/system/ollama.service.\n\u003e\u003e\u003e NVIDIA GPU installed.\n```\n\n#### Test URL\n\n```text\n# open http://localhost:11434/ \n# or via curl    \n$ curl http://localhost:11434/api/tags\n```\n\n#### Instal Mistral 7B model\n\n```bash\n$ ollama run mistral\n```\n\n#### Viewing logs\n\nTo view logs of Ollama running as a startup service, run:\n\n``` bash\n$ journalctl -u ollama\n```\n\n### Uninstall\n\nRemove the ollama service:\n\n```bash\nsudo systemctl stop ollama\nsudo systemctl disable ollama\nsudo rm /etc/systemd/system/ollama.service\n```\n\nRemove the ollama binary from your bin directory (either /usr/local/bin, /usr/bin, or /bin):\n\n```bash\nsudo rm $(which ollama)\n```\n\nRemove the downloaded models and Ollama service user:\n\n```bash\nsudo rm -r /usr/share/ollama\nsudo userdel ollama\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foalles%2Follama-java","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foalles%2Follama-java","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foalles%2Follama-java/lists"}