277 Commits

Author SHA1 Message Date
Amith Koujalgi
64c629775a Refactor OllamaChatRequest and OllamaGenerateRequest to remove builder classes, implement builder-like methods directly in the request classes, and enhance request handling with additional options and image support. Update integration tests to reflect these changes.
Some checks failed
Mark stale issues / stale (push) Failing after 11s
Mark stale issues and PRs / stale (push) Failing after 7s
CodeQL / Analyze (java) (push) Failing after 10s
CodeQL / Analyze (javascript) (push) Failing after 8s
2025-10-07 18:33:22 +05:30
amithkoujalgi
501c35fa44
Refactor integration test targets in Makefile and update workflow
- Renamed integration test targets in the Makefile for clarity: `integration-tests` to `integration-tests-all` and added `integration-tests-basic`.
- Updated GitHub Actions workflow to run the new `integration-tests-basic` target.
- Cleaned up the `WithAuth` test class by removing unused imports and simplifying method signatures.
2025-09-29 10:36:13 +05:30
amithkoujalgi
f114181fe2
Update documentation and refactor code to replace OllamaAPI with Ollama
- Replaced all instances of `OllamaAPI` with `Ollama` in documentation and code examples for consistency.
- Enhanced the configuration for handling broken markdown links in Docusaurus.
- Updated integration tests and example code snippets to reflect the new class structure.
2025-09-29 09:31:32 +05:30
amithkoujalgi
35bf3de62a
Refactor OllamaAPI to Ollama class and update documentation
- Replaced instances of `OllamaAPI` with `Ollama` across the codebase for consistency.
- Updated example code snippets in documentation to reflect the new class name.
- Enhanced metrics collection setup in the documentation.
- Added integration tests for the new `Ollama` class to ensure functionality remains intact.
2025-09-28 23:30:02 +05:30
amithkoujalgi
61fe8b2b56
Refactor model response classes and update API methods
- Renamed `ModelProcessesResponse` to `ModelProcessesResult` and updated all related references in the codebase.
- Introduced `OllamaEmbedResult` class to replace `OllamaEmbedResponse`, ensuring consistency across the API.
- Updated method signatures in `OllamaAPI` to reflect the new class names and adjusted integration tests accordingly.
2025-09-28 22:52:24 +05:30
amithkoujalgi
dd1022a990
Add Javadoc generation to Makefile and refactor model classes
- Introduced a new `javadoc` target in the Makefile to generate Javadocs.
- Refactored model classes: renamed `ModelsProcessResponse` to `ModelProcessesResponse` and updated related references.
- Updated `OllamaEmbedRequestModel` and `OllamaEmbedResponseModel` to `OllamaEmbedRequest` and `OllamaEmbedResponse`, respectively, across the codebase.
- Added new classes for `OllamaEmbedRequest` and `OllamaEmbedResponse` to improve clarity and maintainability.
2025-09-28 22:46:37 +05:30
amithkoujalgi
36f7d14c68
Refactor OllamaAPI exception handling to properly manage InterruptedException and improve logging. Remove unused Logback Classic dependency from pom.xml and clean up commented-out code in integration tests. 2025-09-28 22:28:48 +05:30
amithkoujalgi
e9a4599714
Refactor exception handling by replacing OllamaBaseException with OllamaException across the codebase. Update relevant method signatures and import statements accordingly. 2025-09-28 22:01:17 +05:30
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
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
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
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
e437ba8128
Update OllamaAPIIntegrationTest.java 2025-09-17 21:10:48 +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
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
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
Amith Koujalgi
656802b343 refactor: clean up and deprecate unused methods in OllamaAPI and related classes
- Removed deprecated methods and unused imports from `OllamaAPI`.
- Updated method signatures to improve clarity and consistency.
- Refactored embedding request handling to utilize `OllamaEmbedRequestModel`.
- Adjusted integration tests to reflect changes in method usage and removed obsolete tests.
- Enhanced code readability by standardizing formatting and comments across various classes.
2025-09-16 00:27:11 +05:30
Amith Koujalgi
44c6236243 refactor: rename generateAsync method to generate and update image handling in OllamaAPI
- Renamed `generateAsync` to `generate` for clarity.
- Consolidated image handling in `generateWithImages` to accept multiple image types (File, byte[], String).
- Updated request format handling in `OllamaCommonRequest` and related classes to use a more flexible format property.
- Adjusted integration and unit tests to reflect changes in method signatures and functionality.
2025-09-15 23:35:53 +05:30
twosom
7bd3bed5e4 feat: add client-side tool handling option 2025-09-13 21:21:00 +09:00
amithkoujalgi
fdc2e39646
Refactor logging in OllamaAPI and ConsoleOutputStreamHandler
- Changed logger variable names from 'logger' to 'LOG' for consistency.
- Updated logging statements in OllamaAPI to use the new 'LOG' variable.
- Modified ConsoleOutputStreamHandler to log messages using 'LOG' instead of printing directly to the console.
2025-09-10 18:08:01 +05:30
amithkoujalgi
773cb4af78
Refactor verbosity handling in OllamaAPI
- Removed the verbose logging feature from the OllamaAPI class and related classes.
- Updated logging statements to use debug level instead of info for model requests and responses.
- Cleaned up related test cases to reflect the removal of verbosity settings.
2025-09-10 18:02:28 +05:30
amithkoujalgi
9036d9e7c6
Add unit tests for annotations, serialization, and tool functions
- Introduced TestAnnotations.java to validate OllamaToolService and ToolProperty annotations.
- Added TestBooleanToJsonFormatFlagSerializer.java to test serialization of Boolean values.
- Created TestFileToBase64Serializer.java for testing byte array serialization to Base64.
- Implemented TestOllamaChatMessage.java to ensure correct JSON representation of chat messages.
- Developed TestOllamaChatMessageRole.java to verify role registration and custom role creation.
- Added TestOllamaChatRequestBuilder.java to test message handling and request building.
- Created TestOllamaRequestBody.java to validate request body serialization.
- Implemented TestOllamaToolsResult.java to ensure correct transformation of tool results.
- Added TestOptionsAndUtils.java to test options builder and utility functions.
- Created TestReflectionalToolFunction.java to validate method invocation and argument handling.
- Implemented TestToolRegistry.java to ensure tool registration and retrieval functionality.
- Developed TestToolsPromptBuilder.java to verify prompt builder includes tools and prompts correctly.
- Added serialization tests in TestChatRequestSerialization.java and TestEmbedRequestSerialization.java.
2025-09-10 17:31:41 +05:30