976 Commits

Author SHA1 Message Date
amithkoujalgi
031076b498
Update readme 2025-09-26 23:35:46 +05:30
amithkoujalgi
305bab9819
Refactor OllamaAPI and related classes for improved embedding model support and tool registration
This update modifies the OllamaAPI class to enhance support for embedding models by renaming related classes and introducing new request and response models. The OllamaEmbedRequestModel and OllamaEmbedResponseModel classes have been added, along with their corresponding builder class. Additionally, the tool registration process has been improved with the introduction of annotations for automatic tool discovery. Deprecated methods and commented-out code have been removed for clarity, and Javadoc comments have been updated for consistency across the API.
2025-09-26 22:13:55 +05:30
amithkoujalgi
f5ca5bdca3
Refactor OllamaAPI and related classes to enhance tool management and request handling
This update modifies the OllamaAPI class and associated request classes to improve the handling of tools. The ToolRegistry now manages a list of Tools.Tool objects instead of ToolSpecification, streamlining tool registration and retrieval. The OllamaGenerateRequest and OllamaChatRequest classes have been updated to reflect this change, ensuring consistency across the API. Additionally, several deprecated methods and commented-out code have been removed for clarity. Integration tests have been adjusted to accommodate these changes, enhancing overall test reliability.
2025-09-26 01:26:22 +05:30
amithkoujalgi
fe82550637
Refactor OllamaAPI and related classes for improved functionality and code clarity
This update removes deprecated methods from the OllamaAPI class, enhancing the overall structure and readability. The OllamaGenerateRequest class has been updated to include a list of tools, and the generate methods have been refactored to streamline request handling. Additionally, the WeatherTool class has been removed, and a new sample tool specification has been added for demonstration purposes. Changes in pom.xml include commented-out dependencies for better clarity.
2025-09-25 18:10:18 +05:30
amithkoujalgi
53e4b413ec
Refactor unloadModel test in OllamaAPIIntegrationTest for improved exception handling
Updated the shouldUnloadModel test to use a constant for the model name and assert that no exceptions are thrown during the unload operation. This change enhances the clarity and reliability of the test by focusing on exception handling rather than checking the model's presence in the process list.
2025-09-24 00:57:05 +05:30
amithkoujalgi
07878ddf36
Refactor OllamaAPI and related classes for improved request handling and builder pattern integration
This update refactors the OllamaAPI class and its associated request builders to enhance the handling of generate requests and chat requests. The OllamaGenerateRequest and OllamaChatRequest classes now utilize builder patterns for better readability and maintainability. Additionally, deprecated methods have been removed or marked, and integration tests have been updated to reflect these changes, ensuring consistent usage of the new request structures.
2025-09-24 00:54:09 +05:30
amithkoujalgi
cc232c1383
Refactor OllamaAPI and endpoint callers for improved error handling and metrics recording
Refactor OllamaAPI and endpoint callers for improved error handling and metrics recording

Enhanced the OllamaAPI class by adding detailed error handling and metrics recording for API calls. Updated the OllamaChatEndpointCaller and OllamaGenerateEndpointCaller to use static endpoint constants instead of method suffixes, improving code clarity. Adjusted Javadoc comments for consistency and readability across the classes.
2025-09-23 19:00:44 +05:30
amithkoujalgi
52c60d9d18
Update OllamaAPI.java
Refactor OllamaAPI documentation for clarity and consistency

Updated Javadoc comments throughout the OllamaAPI class to enhance readability and maintain consistency in formatting. Adjusted line breaks and spacing in comments for improved presentation. No functional changes were made to the code.
2025-09-23 18:33:44 +05:30
amithkoujalgi
d400998fa2
Refactor MetricsRecorder and OllamaAPI for improved label handling and documentation clarity 2025-09-23 18:08:57 +05:30
amithkoujalgi
827bedb696
Add Prometheus metrics integration and refactor API error handling
Introduces Prometheus metrics support with a new MetricsRecorder and documentation (METRICS.md). Refactors OllamaAPI methods to improve error handling, reduce checked exceptions, and record metrics for API calls. Updates dependencies in pom.xml to include Prometheus and Guava. Adds MetricsRecorder class and updates tests for metrics integration.
2025-09-23 16:51:26 +05:30
amithkoujalgi
a9f6d4671c
Set keepAlive to 0m in OllamaAPI requests
Added keepAlive parameter with value '0m' to OllamaAPI requests for improved connection handling. Updated integration test to enable tool usage and commented out a test for raw mode and thinking with new model handling.
2025-09-20 23:12:35 +05:30
Amith Koujalgi
5ef1ea906d Remove modelKeepAliveTime property and related code
Eliminated the modelKeepAliveTime field from OllamaAPI and OllamaChatRequest, along with its usage in integration tests and configuration. This streamlines configuration and request handling by removing an unused or deprecated parameter.
2025-09-20 17:48:21 +05:30
Amith Koujalgi
d6f5b5c313 Update workflow and improve test logging
Added environment configuration for GitHub Pages deployment in the build workflow and removed unused environment variable from test workflow. Enhanced logging in OllamaAPIIntegrationTest to include the external host address.
2025-09-20 15:51:31 +05:30
Amith Koujalgi
f0c6ce2b8d Set USE_EXTERNAL_OLLAMA_HOST env in test workflow
Adds USE_EXTERNAL_OLLAMA_HOST environment variable set to 'false' for the run-tests job in the build-on-pull-request workflow. This ensures tests do not use an external Ollama host during pull request builds.
2025-09-20 15:44:47 +05:30
amithkoujalgi
f60491885f
Remove commented pre-commit command from Makefile
Deleted an unused, commented-out pre-commit command from the apply-formatting target to clean up the Makefile.
2025-09-20 15:40:18 +05:30
amithkoujalgi
7a2a307a0a
Add local format-code hook to pre-commit config
Introduces a new local hook 'format-code' that runs 'make apply-formatting' to ensure code formatting is applied automatically during pre-commit. The hook is set to always run.
2025-09-20 15:40:02 +05:30
amithkoujalgi
cac94e0faf
Refactor tool handling and add model unload support
Replaces the 'clientHandlesTools' flag with 'useTools' for tool execution control, defaulting to true. Adds support for model unloading via keep_alive parameter. Updates chat request and builder to use the new flag. Improves integration tests and documentation to reflect these changes. Fixes constructor order in OllamaGenerateStreamObserver and adds ignoreUnknown to ModelsProcessResponse.
2025-09-20 14:46:46 +05:30
amithkoujalgi
6147c7d697
Add Javadoc comments to integration tests
Added detailed Javadoc comments to test methods and utility functions in OllamaAPIIntegrationTest.java to improve documentation and clarify test scenarios, usage, and expected outcomes. No functional changes were made.
2025-09-20 00:54:54 +05:30
amithkoujalgi
751b11881f
Update thinking tool model in integration tests
Replaced the 'deepseek-r1:1.5b' model with 'qwen3:0.6b' for thinking tool tests in OllamaAPIIntegrationTest. Also made minor formatting improvements to comments and string concatenations for better readability.
2025-09-20 00:02:52 +05:30
amithkoujalgi
5da9bc8626
Refactor test method names for clarity
Renamed test methods in OllamaAPIIntegrationTest to use descriptive 'should...' naming conventions, improving readability and clarity of test intent. Removed redundant comments and streamlined assertions for conciseness.
2025-09-19 23:51:32 +05:30
amithkoujalgi
90613c0ec1
Update WithAuth.java 2025-09-19 19:07:42 +05:30
amithkoujalgi
cb0f71ba63
Refactor token handler interfaces and improve streaming
Renamed and refactored token handler interfaces for chat and generate modules to improve clarity and separation. Updated related classes and method signatures to use new handler types. Enhanced error handling and logging in chat and generate request builders. Updated tests and integration code to use new handler classes and configuration properties. Suppressed verbose logs from Docker and Testcontainers in test logging configuration.
2025-09-19 18:05:38 +05:30
amithkoujalgi
d118958ac1
Change logging level from info to debug
Updated OllamaAPI to use LOG.debug instead of LOG.info for model pull status messages. Also changed the root logging level in logback.xml from info to debug to allow debug messages to be displayed during tests.
2025-09-18 02:20:07 +05:30
amithkoujalgi
8df36a9b98
Update GitHub workflows to use JDK 21 (Oracle)
All workflows now use JDK 21 with the Oracle distribution instead of JDK 17 or 11 with Temurin. This ensures consistency and leverages the latest Java features and security updates.
2025-09-18 02:00:55 +05:30
amithkoujalgi
5b71c8eacf
Update OllamaEmbedRequestModel.java 2025-09-18 01:53:28 +05:30
amithkoujalgi
0aeabcc963
Refactor error handling and update tests
Refactored error handling in OllamaChatEndpointCaller by extracting status code checks into a helper method. Improved logging for image loading errors in OllamaChatRequestBuilder. Updated integration and unit tests to relax assertions and clarify comments. Minor documentation formatting fixes and Makefile improvement for reproducible npm installs.
2025-09-18 01:50:23 +05:30
amithkoujalgi
7788f954d6
Improve error handling and code clarity across modules
Enhanced error handling for image URL loading in OllamaChatRequestBuilder, ensuring exceptions are thrown and logged appropriately. Updated test cases to reflect new exception behavior. Improved documentation and code clarity in WeatherTool and test classes. Refactored JSON parsing in response models for conciseness. Minor cleanup in pom.xml and integration test comments for better maintainability.
2025-09-18 01:22:12 +05:30
amithkoujalgi
fe87c4ccc8
Update CI workflows to use JDK 21 with Oracle distribution
Changed Java version from 11 to 21 and switched distribution from 'adopt-hotspot' to 'oracle' in build and documentation publishing workflows for improved compatibility and support.
2025-09-17 21:45:27 +05:30
amithkoujalgi
4f02b299c3
Handle all exceptions when loading image URLs in chat builder
Replaced separate IOException and InterruptedException handling with a single catch for Exception in OllamaChatRequestBuilder, ensuring that any failure when loading image URLs is logged and does not break message building. Updated related unit test to verify builder robustness and usability after invalid image URL input.
2025-09-17 21:41:12 +05:30
amithkoujalgi
274da54d50
Skip unreliable tool call assertions in integration tests
Commented out tool call assertions in OllamaAPIIntegrationTest due to inconsistent model behavior, making the scenario difficult to reproduce reliably. Updated WithAuth test to check for non-null 'isNoon' instead of strict equality.
2025-09-17 21:23:50 +05:30
amithkoujalgi
ca400cfbba
Merge branch 'main' into refactor 2025-09-17 21:11:23 +05:30
amithkoujalgi
e437ba8128
Update OllamaAPIIntegrationTest.java 2025-09-17 21:10:48 +05:30
Amith Koujalgi
5e9f515c66
Merge pull request #182 from ollama4j/dependabot/maven/org.apache.maven.plugins-maven-failsafe-plugin-3.5.4
Some checks failed
CodeQL / Analyze (javascript) (push) Failing after 10s
CodeQL / Analyze (java) (push) Failing after 14s
Mark stale issues / stale (push) Failing after 19s
Mark stale issues and PRs / stale (push) Failing after 1m31s
Bump org.apache.maven.plugins:maven-failsafe-plugin from 3.5.3 to 3.5.4
2025-09-17 21:10:17 +05:30
Amith Koujalgi
5bfdfa2aa1
Merge pull request #181 from ollama4j/dependabot/maven/com.fasterxml.jackson.datatype-jackson-datatype-jsr310-2.20.0
Bump com.fasterxml.jackson.datatype:jackson-datatype-jsr310 from 2.17.1 to 2.20.0
2025-09-17 21:09:57 +05:30
Amith Koujalgi
14666357bd
Merge pull request #180 from ollama4j/dependabot/maven/com.fasterxml.jackson.core-jackson-databind-2.20.0
Bump com.fasterxml.jackson.core:jackson-databind from 2.17.1 to 2.20.0
2025-09-17 21:09:38 +05:30
Amith Koujalgi
b53a391492
Merge pull request #179 from ollama4j/dependabot/maven/org.apache.maven.plugins-maven-javadoc-plugin-3.11.3
Bump org.apache.maven.plugins:maven-javadoc-plugin from 3.11.2 to 3.11.3
2025-09-17 21:09:17 +05:30
Amith Koujalgi
dab2111f10
Merge pull request #178 from ollama4j/dependabot/maven/ch.qos.logback-logback-classic-1.5.18
Bump ch.qos.logback:logback-classic from 1.5.6 to 1.5.18
2025-09-17 21:06:09 +05:30
amithkoujalgi
c15048954c
Update OllamaAPIIntegrationTest.java 2025-09-17 20:54:50 +05:30
amithkoujalgi
ba3d8925f2
Refactor integration tests and update Makefile targets
Refactored OllamaAPIIntegrationTest to simplify stream handlers and remove unused StringBuffer variables. Updated Makefile to ensure formatting is applied before running test targets. Adjusted logback.xml pattern to use full logger name for improved logging clarity.
2025-09-17 20:49:53 +05:30
amithkoujalgi
300f1691e7
Remove hardcoded Ollama host in integration test
Eliminated hardcoded values for 'useExternalOllamaHost' and 'ollamaHost' in OllamaAPIIntegrationTest. The test now relies solely on environment variables for configuration.
2025-09-17 20:38:20 +05:30
amithkoujalgi
a1b5756107
Update Ollama host and clean up integration tests
Changed the remote Ollama host IP in Makefile and test setup to 192.168.29.229. Fixed a typo in a test method name and removed unused StringBuffer variables and related assertions from OllamaAPIIntegrationTest.
2025-09-17 20:28:58 +05:30
amithkoujalgi
b1d3ee54a5
Refactor JSON logging and utility methods
Replaced manual pretty-printing of JSON in OllamaAPI with a new Utils.toJSON method for cleaner logging. Added private constructors to utility classes to prevent instantiation. Updated test and sample code for improved clarity and randomness.
2025-09-17 20:05:18 +05:30
amithkoujalgi
4df4ea1930
Remove deprecated embedding and library model classes
Deleted deprecated classes related to embeddings and library models, including OllamaEmbeddingResponseModel, OllamaEmbeddingsRequestBuilder, OllamaEmbeddingsRequestModel, LibraryModel, LibraryModelDetail, LibraryModelTag, and OllamaModelType. Updated OllamaAPI to remove references to these classes and improve documentation, exception handling, and code clarity.
2025-09-17 19:47:07 +05:30
amithkoujalgi
2f83a5c98c
Improve Makefile output and update pre-commit config
Added colored echo statements to Makefile targets for clearer output and improved developer experience. Updated commitizen hook in .pre-commit-config.yaml to v4.9.1 for latest features and fixes.
2025-09-17 11:56:57 +05:30
Amith Koujalgi
cae8b6e1e4 Update Makefile 2025-09-17 11:17:02 +05:30
Amith Koujalgi
da21bdcf85 Update Makefile 2025-09-17 11:14:01 +05:30
Amith Koujalgi
ac92766c6c Add Spotless plugin and update copyright headers
Introduced the Spotless Maven plugin for code formatting in pom.xml. Updated copyright headers to include 'and contributors' and changed the year to 2025 in all main source files. Minor formatting and import order improvements applied throughout the codebase.
2025-09-17 11:10:55 +05:30
Amith Koujalgi
329381b1ee Refactor and reorganize API docs structure
Moved and renamed several API documentation files for better organization, updated sidebar positions, and merged image generation docs. Added logging documentation and updated Makefile commands for docs build and serve. Improved clarity and consistency in API doc titles and structure.
2025-09-17 10:34:50 +05:30
Amith Koujalgi
fc1f842f6b refactor: enhance generateWithTools method in OllamaAPI
- Updated the generateWithTools method to include a streamHandler parameter for improved response handling.
- Enhanced method documentation to clarify functionality, usage, and error handling.
- Improved the prompt augmentation process by detailing tool invocation based on model output.
2025-09-16 11:00:52 +05:30
Amith Koujalgi
70519e3309 Add configurable timeouts for image URL loading
Introduces connect and read timeout settings for loading images from URLs in OllamaAPI and OllamaChatRequestBuilder. Refactors Utils to use HttpClient for image retrieval with timeout support and improves error handling and logging. Updates unit tests to verify builder robustness against malformed URLs.
2025-09-16 10:31:32 +05:30