230 Commits

Author SHA1 Message Date
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
amithkoujalgi
fddd753a48
Add unit tests for authentication, options, tool registry, and prompt builder
- Created TestAuth.java to validate BasicAuth and BearerAuth header generation.
- Added TestOptionsAndUtils.java to test OptionsBuilder and utility functions.
- Implemented TestToolRegistry.java to ensure tool registration and retrieval functionality.
- Developed TestToolsPromptBuilder.java to verify prompt builder includes tools and prompts correctly.
2025-09-10 17:06:47 +05:30
amithkoujalgi
a093be5581
Update OllamaAPI.java 2025-08-31 22:02:43 +05:30
amithkoujalgi
b216d1b647
Refactor imports and add fields to OllamaStructuredResult
Reorders and deduplicates import statements across multiple files for consistency and clarity. Adds additional fields to OllamaStructuredResult and ensures OllamaResult is populated with these fields. Updates tests and minor code style improvements throughout the codebase.
2025-08-31 16:46:32 +05:30
amithkoujalgi
6fa5c323b8
Refactor stream handler and update test model usage
Simplified ConsoleOutputStreamHandler to print messages directly without substring logic. Updated WithAuth integration test to use the THINKING_MODEL ('gpt-oss:20b') instead of GENERAL_PURPOSE_MODEL ('gemma3:270m') for model pulling and generation.
2025-08-31 15:56:40 +05:30
amithkoujalgi
c754bd11da
Refactor OllamaAPI for improved async handling and response streaming
Updated OllamaAPI to support separate thinking and response stream handlers, enhancing the asynchronous generation of responses. Adjusted related models and observers to accommodate new streaming logic. Improved the handling of response data in OllamaResult and OllamaGenerateResponseModel, adding new properties for better tracking of response metrics. Refined integration tests to reflect changes in method signatures and ensure proper logging of streamed responses.
2025-08-31 14:02:42 +05:30
amithkoujalgi
5f5fa8ecae
Deprecate findModelTagFromLibrary and simplify WeatherTool
Marked findModelTagFromLibrary as deprecated in OllamaAPI due to reliance on unstable HTML structure. Simplified WeatherTool by removing external API calls and returning a static weather response for demonstration purposes.
2025-08-31 01:33:57 +05:30
amithkoujalgi
6b69284497
Update workflow job names and refine integration tests
Added descriptive names to jobs in the GitHub Actions workflow for better clarity. In integration tests, replaced GENERAL_PURPOSE_MODEL with TOOLS_MODEL in relevant tests and adjusted logging within lambda expressions for improved output handling.
2025-08-30 21:30:16 +05:30
amithkoujalgi
8e50bc8d75
Update OllamaAPIIntegrationTest.java 2025-08-30 20:54:18 +05:30
amithkoujalgi
be5b77c4ac
Refactor tool tests and improve tool argument handling
Refactored integration tests to use a reusable employeeFinderTool method and improved assertions for tool call results. Updated tool argument formatting in OllamaAPI for clearer output. Modified AnnotatedTool to use 'numberOfHearts' instead of 'amountOfHearts' and simplified the sayHello method signature and output. Removed redundant and duplicate test code for tool streaming.
2025-08-30 20:53:14 +05:30
amithkoujalgi
97f457575d
Remove sample prompt utilities and update integration tests
Deleted SamplePrompts.java and sample-db-prompt-template.txt as they are no longer needed. Updated OllamaAPIIntegrationTest to use a new TOOLS_MODEL constant, refactored tool registration and prompt descriptions for employee details, and improved test assertions for tool-based chat interactions.
2025-08-30 20:01:35 +05:30
amithkoujalgi
621004e6d8
Fix logging for model pull retry 2025-08-30 18:10:33 +05:30
amithkoujalgi
0ec20d14b0
Enhance CI workflow and refactor integration tests
- Added setup step for Ollama installation in the GitHub Actions workflow.
- Updated environment variables for integration tests to utilize an external Ollama host.
- Refactored test method names in OllamaAPIIntegrationTest for clarity and consistency, changing 'testAskModel' to 'testGenerate'.
- Introduced new tests for image processing from URLs and files, while removing outdated tests for improved test suite relevance.
2025-08-30 18:00:04 +05:30
amithkoujalgi
c705432510
Increase model pull retry delay and attempts
Raised the base delay for model pull retries from 1s to 3s and updated log output to show seconds instead of milliseconds. Also increased the number of retries for model pull in integration tests from 3 to 5 to improve robustness.
2025-08-30 17:04:02 +05:30
amithkoujalgi
de379d73b2
Refactor OllamaAPI for readability and add EqualsAndHashCode to BearerAuth
Reformatted method signatures, chained calls, and comments in OllamaAPI for improved readability and maintainability. Added @EqualsAndHashCode(callSuper = false) to BearerAuth to ensure proper equality checks, and reformatted its code for consistency.
2025-08-30 16:59:05 +05:30
amithkoujalgi
ad1bf658a9
Enhance OllamaAPI with improved timeout and retry mechanisms
- Updated request timeout default to 10 seconds for API calls.
- Added verbose logging option with default set to true.
- Introduced maxChatToolCallRetries to control retry attempts during chat interactions.
- Implemented numberOfRetriesForModelPull with exponential backoff for model retrieval failures.
- Refactored pullModel method to include retry logic and improved error handling.
2025-08-30 16:49:43 +05:30
amithkoujalgi
ab9b95dbed
Update THINKING_TOOL_MODEL constant in OllamaAPIIntegrationTest to gpt-oss:20b 2025-08-30 15:50:08 +05:30
amithkoujalgi
7f37233c72
Update THINKING_TOOL_MODEL constant in OllamaAPIIntegrationTest to version 1.7b 2025-08-30 15:45:08 +05:30
amithkoujalgi
77aa3b85d1
Refactor WithAuth integration test for improved structure and functionality
- Restored the WithAuth class and updated it to include a new general-purpose model.
- Enhanced the setup method to initialize the OllamaAPI with bearer authentication.
- Added tests to validate the API's behavior with correct and incorrect authentication tokens.
- Updated the structured output test to reflect changes in the model and prompt.
- Improved logging for better traceability during test execution.
2025-08-30 15:07:32 +05:30
amithkoujalgi
863c978d12
Refactor OllamaAPIIntegrationTest and AnnotatedTool for improved clarity and consistency
- Updated model constants in OllamaAPIIntegrationTest to enhance readability and maintainability.
- Changed method visibility from public to package-private where appropriate.
- Refactored assertions in testListModelsAPI for better validation.
- Cleaned up formatting in AnnotatedTool methods for consistency.
- Added a new image resource (roses.jpg) for testing purposes.
2025-08-30 15:02:51 +05:30
amithkoujalgi
cc950b893e
Refactor OllamaAPI to use Constants for HTTP headers and improve logging format
- Introduced a new Constants class to centralize HTTP header values.
- Updated OllamaAPI methods to utilize Constants for "Content-Type" and "Accept" headers.
- Enhanced logging statements to use parameterized messages for better performance and readability.
- Added a test for the ping method in OllamaAPIIntegrationTest to ensure connectivity.
2025-08-30 13:01:01 +05:30
amithkoujalgi
f085b633af
Update OllamaAPIIntegrationTest.java 2025-08-30 12:14:09 +05:30
amithkoujalgi
3d0b3eeb7f
Add tool deregistration and update integration tests
Introduces a method to deregister all tools in OllamaAPI and ToolRegistry. Updates integration tests to use new models, refactors prompts and assertions, and removes the TimeOfDay class. The WithAuth test is now fully commented out.
2025-08-30 12:01:32 +05:30
Amith Koujalgi
4a69df4476 remove unused model pull in testListModelsAPI 2025-08-29 17:08:48 +05:30
amithkoujalgi
8d9ee006ee
Refactor OllamaAPI and chat models to support 'thinking' responses
- Introduced a 'thinking' field in OllamaChatMessage to capture intermediate reasoning.
- Updated OllamaChatRequest to include a 'think' parameter for chat requests.
- Modified OllamaChatRequestBuilder to facilitate setting the 'think' parameter.
- Enhanced response handling in OllamaChatStreamObserver and OllamaGenerateStreamObserver to manage 'thinking' content.
- Updated integration tests to validate the new 'thinking' functionality in chat and generation methods.
2025-08-28 12:44:43 +05:30
amithkoujalgi
14642e9856
Enhance OllamaAPI with 'think' parameter and response handling
- Added 'think' parameter to the generate methods in OllamaAPI to enable step-by-step reasoning for model responses.
- Updated OllamaGenerateRequest and OllamaGenerateResponseModel to include 'thinking' field.
- Modified response handling in OllamaGenerateStreamObserver to incorporate 'thinking' responses.
- Updated integration tests to validate the new functionality, including tests for generating responses with thinking enabled.
- Refactored related methods and classes for consistency and clarity.
2025-08-28 10:03:07 +05:30
Amith Koujalgi
3efd7712be
Merge pull request #143 from ollama4j/small-fixes
All checks were successful
Mark stale issues / stale (push) Successful in 33s
Small fixes
2025-08-27 21:18:15 +05:30
Travis Lyons
bae903f8ca
fix: handle ollama error responses
fixes: #138

- Added error field to ModelPullResponse
  - Enhanced error handling in doPullModel to check for errors in response body and throw OllamaBaseException with the specific error message
2025-08-20 11:51:49 -04:00
amithkoujalgi
cc13a580fa
Update WithAuth.java 2025-08-16 09:27:40 +05:30
amithkoujalgi
54d8cf4cd9
Add WeatherTool and integration test with auth proxy
Introduces WeatherTool for fetching weather data via OpenWeatherMap API and its tool specification. Adds an integration test (WithAuth) using Testcontainers to verify OllamaAPI connectivity through an NGINX proxy with bearer token authentication. Also updates pom.xml to include the testcontainers-nginx dependency and minor improvements to OllamaAPI for request headers and Javadoc formatting. TypewriterTextarea now supports text alignment, with homepage header using center alignment.
2025-08-15 23:16:24 +05:30
p00temkin
03da285d1c
Ignore thinking key to allow gpt-oss replies to be processed 2025-08-12 14:52:31 +02:00
amithkoujalgi
a2d95a052a
- Updated Makefile to add a new remote integration test command.
- Updated docs – Enhanced DBQueryFunction to validate input arguments and throw a RuntimeException if required arguments are missing.
- Updated docs – Refactored tool specifications for fuel price, weather, and employee details to use a unified prompt function structure.  (Addresses #116).
- Improved javadoc for `chatStreaming()` API. (Addresses #115).
- Introduced `ToolInvocationException` to handle errors during tool invocation in OllamaAPI. (Addresses #117).
- Updated integration tests to include `ToolInvocationException` in method signatures for better error handling.
2025-04-06 23:05:26 +05:30
amithkoujalgi
70b4a7961a
Used smaller-sized images for the test cases 2025-03-25 21:56:45 +05:30
amithkoujalgi
0248f21654
Used smaller-sized images for the test cases 2025-03-25 21:34:13 +05:30
Amith Koujalgi
252ea50717 Update OllamaAPIIntegrationTest.java 2025-03-25 20:40:58 +05:30
Benjamin Duffield
bc87d0c7ec add api methods to support passing images as byte[] 2025-03-25 14:00:18 +00:00
amithkoujalgi
be08f11027
Update OllamaAPIIntegrationTest.java 2025-03-25 00:20:25 +05:30
amithkoujalgi
b9b18271a1
Support for structured output
Added support for structured output
2025-03-24 23:45:01 +05:30
Amith Koujalgi
681a692ca9
Updated integration tests 2025-03-18 23:18:42 +05:30
Amith Koujalgi
e245d9633f
Updated integration tests 2025-03-18 22:54:56 +05:30
Amith Koujalgi
bee09aa626
Updated integration tests 2025-03-18 22:03:04 +05:30
Amith Koujalgi
8aa6e3b066
Updated integration tests 2025-03-18 21:41:20 +05:30
Amith Koujalgi
d40912c638
Merge remote-tracking branch 'origin/main' into integration-tests-refactor 2025-03-18 20:54:04 +05:30
Amith Koujalgi
ba0444194f
Merge pull request #98 from csware/bearertoken
Support bearer token
2025-03-18 20:30:08 +05:30
Amith Koujalgi
ac3f505aa6
Switch image model to "moondream" in integration test 2025-03-11 13:12:55 +05:30
amithkoujalgi
fe5078891f
Remove TestRealAPIs and enhance OllamaAPIIntegrationTest 2025-03-11 11:41:51 +05:30
amithkoujalgi
0d091d1826
Update integration test 2025-03-11 00:06:30 +05:30
amithkoujalgi
a9c7f4e5e0
Rename TestAPIsTest to OllamaAPIIntegrationTest 2025-03-10 23:44:18 +05:30