Compare commits

..

40 Commits
1.1.2 ... main

Author SHA1 Message Date
Amith Koujalgi
b456feda64 Merge pull request #225 from ollama4j/fix-docs-build
Some checks failed
Mark stale issues / stale (push) Failing after 19s
Mark stale issues and PRs / stale (push) Failing after 51s
CodeQL / Analyze (java) (push) Failing after 12s
CodeQL / Analyze (javascript) (push) Failing after 10s
Update Docs Build GHA
2025-10-23 12:11:35 +05:30
amithkoujalgi
1c1452836d Merge branch 'main' into fix-docs-build 2025-10-23 11:56:56 +05:30
amithkoujalgi
1bca07ecb8 Add workflow_dispatch trigger to build-on-pull-request.yml for manual execution 2025-10-23 11:51:20 +05:30
amithkoujalgi
47c5943137 Update dependencies in package.json and package-lock.json to version 3.9.2 for various Docusaurus packages, including @docusaurus/core, @docusaurus/preset-classic, and @docusaurus/theme-mermaid. Also, upgrade @ai-sdk/gateway to version 2.0.0 and @algolia packages to version 5.41.0. Add @vercel/oidc package version 3.0.3. 2025-10-23 11:44:31 +05:30
amithkoujalgi
3061b2d8ef Merge branch 'main' into fix-docs-build 2025-10-23 11:19:56 +05:30
Amith Koujalgi
531f063cc9 Merge pull request #212 from ollama4j/dependabot/npm_and_yarn/docs/docsearch/js-4.2.0
Bump @docsearch/js from 4.1.0 to 4.2.0 in /docs
2025-10-23 11:19:36 +05:30
Amith Koujalgi
887a9e1bfc Merge pull request #213 from ollama4j/dependabot/maven/org.projectlombok-lombok-1.18.42
Bump org.projectlombok:lombok from 1.18.40 to 1.18.42
2025-10-23 11:19:12 +05:30
Amith Koujalgi
10e2a606b5 Merge pull request #219 from ollama4j/dependabot/npm_and_yarn/docs/docusaurus/preset-classic-3.9.2
Bump @docusaurus/preset-classic from 3.9.1 to 3.9.2 in /docs
2025-10-23 11:18:59 +05:30
Amith Koujalgi
d589315d23 Merge pull request #218 from ollama4j/dependabot/github_actions/actions/setup-node-6
Bump actions/setup-node from 5 to 6
2025-10-23 11:18:47 +05:30
Amith Koujalgi
95cc2164d3 Merge pull request #214 from ollama4j/dependabot/maven/org.junit.jupiter-junit-jupiter-api-6.0.0
Bump org.junit.jupiter:junit-jupiter-api from 5.13.4 to 6.0.0
2025-10-23 11:18:36 +05:30
Amith Koujalgi
970d54bcb5 Merge pull request #217 from ollama4j/dependabot/maven/org.sonatype.central-central-publishing-maven-plugin-0.9.0
Bump org.sonatype.central:central-publishing-maven-plugin from 0.8.0 to 0.9.0
2025-10-23 11:18:26 +05:30
Amith Koujalgi
e326936d3d Merge pull request #211 from ollama4j/dependabot/github_actions/github/codeql-action-4
Bump github/codeql-action from 3 to 4
2025-10-23 11:18:08 +05:30
Amith Koujalgi
9b916480b2 Merge pull request #216 from ollama4j/dependabot/maven/org.jacoco-jacoco-maven-plugin-0.8.14
Bump org.jacoco:jacoco-maven-plugin from 0.8.13 to 0.8.14
2025-10-23 11:17:56 +05:30
Amith Koujalgi
83d292671a Merge pull request #210 from ollama4j/snyk-upgrade-8a0a753719bdd0b263a1412cd892d136
[Snyk] Upgrade org.projectlombok:lombok from 1.18.40 to 1.18.42
2025-10-23 11:17:39 +05:30
amithkoujalgi
dcf2a0fdb6 Merge branch 'main' into fix-docs-build 2025-10-23 11:16:29 +05:30
dependabot[bot]
1ba0f02af6 Bump @docusaurus/preset-classic from 3.9.1 to 3.9.2 in /docs
Bumps [@docusaurus/preset-classic](https://github.com/facebook/docusaurus/tree/HEAD/packages/docusaurus-preset-classic) from 3.9.1 to 3.9.2.
- [Release notes](https://github.com/facebook/docusaurus/releases)
- [Changelog](https://github.com/facebook/docusaurus/blob/main/CHANGELOG.md)
- [Commits](https://github.com/facebook/docusaurus/commits/v3.9.2/packages/docusaurus-preset-classic)

---
updated-dependencies:
- dependency-name: "@docusaurus/preset-classic"
  dependency-version: 3.9.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-10-23 05:46:28 +00:00
dependabot[bot]
74e6777b7c Bump @docsearch/js from 4.1.0 to 4.2.0 in /docs
Bumps [@docsearch/js](https://github.com/algolia/docsearch/tree/HEAD/packages/docsearch-js) from 4.1.0 to 4.2.0.
- [Release notes](https://github.com/algolia/docsearch/releases)
- [Changelog](https://github.com/algolia/docsearch/blob/main/CHANGELOG.md)
- [Commits](https://github.com/algolia/docsearch/commits/v4.2.0/packages/docsearch-js)

---
updated-dependencies:
- dependency-name: "@docsearch/js"
  dependency-version: 4.2.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-10-23 05:46:15 +00:00
Amith Koujalgi
849ae77712 Merge pull request #220 from ollama4j/dependabot/maven/ch.qos.logback-logback-classic-1.5.20
Bump ch.qos.logback:logback-classic from 1.5.18 to 1.5.20
2025-10-23 11:16:07 +05:30
Amith Koujalgi
fcd0fbe4b3 Merge pull request #221 from ollama4j/dependabot/npm_and_yarn/docs/docusaurus/plugin-google-gtag-3.9.2
Bump @docusaurus/plugin-google-gtag from 3.9.1 to 3.9.2 in /docs
2025-10-23 11:13:56 +05:30
amithkoujalgi
066df6b369 Enhance agent documentation by refining the definition and benefits of agents, improving clarity on YAML configuration parameters, and updating the sample interaction. Additionally, modify the Agent class to pull the model during initialization, ensuring proper setup for agent functionality. 2025-10-23 11:10:06 +05:30
dependabot[bot]
1fbfe8a18c Bump @docusaurus/plugin-google-gtag from 3.9.1 to 3.9.2 in /docs
Bumps [@docusaurus/plugin-google-gtag](https://github.com/facebook/docusaurus/tree/HEAD/packages/docusaurus-plugin-google-gtag) from 3.9.1 to 3.9.2.
- [Release notes](https://github.com/facebook/docusaurus/releases)
- [Changelog](https://github.com/facebook/docusaurus/blob/main/CHANGELOG.md)
- [Commits](https://github.com/facebook/docusaurus/commits/v3.9.2/packages/docusaurus-plugin-google-gtag)

---
updated-dependencies:
- dependency-name: "@docusaurus/plugin-google-gtag"
  dependency-version: 3.9.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-10-22 12:04:31 +00:00
Amith Koujalgi
23785bb5b7 Merge pull request #222 from ollama4j/dependabot/npm_and_yarn/docs/docusaurus/core-3.9.2
Some checks failed
CodeQL / Analyze (java) (push) Failing after 11s
CodeQL / Analyze (javascript) (push) Failing after 8s
Mark stale issues / stale (push) Failing after 12s
Mark stale issues and PRs / stale (push) Failing after 10s
Bump @docusaurus/core from 3.9.1 to 3.9.2 in /docs
2025-10-22 17:33:09 +05:30
dependabot[bot]
00cd2a0adf Bump @docusaurus/core from 3.9.1 to 3.9.2 in /docs
Bumps [@docusaurus/core](https://github.com/facebook/docusaurus/tree/HEAD/packages/docusaurus) from 3.9.1 to 3.9.2.
- [Release notes](https://github.com/facebook/docusaurus/releases)
- [Changelog](https://github.com/facebook/docusaurus/blob/main/CHANGELOG.md)
- [Commits](https://github.com/facebook/docusaurus/commits/v3.9.2/packages/docusaurus)

---
updated-dependencies:
- dependency-name: "@docusaurus/core"
  dependency-version: 3.9.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-10-22 07:34:56 +00:00
Amith Koujalgi
49fac9d2cf Merge pull request #223 from ollama4j/dependabot/npm_and_yarn/docs/docusaurus/module-type-aliases-3.9.2
Some checks failed
CodeQL / Analyze (java) (push) Failing after 8s
CodeQL / Analyze (javascript) (push) Failing after 6s
Bump @docusaurus/module-type-aliases from 3.9.1 to 3.9.2 in /docs
2025-10-22 13:03:22 +05:30
amithkoujalgi
ca1a73fa76 Improved agent documentation 2025-10-22 13:01:19 +05:30
amithkoujalgi
adbf6a8185 Enhance agent documentation by adding interactive examples using the TypewriterTextarea component. Update the content to demonstrate sample interactions, improving clarity and user engagement. 2025-10-22 12:08:52 +05:30
amithkoujalgi
57adaafb42 Refactor Javadoc comments in Agent class for consistency and clarity, consolidating multi-line comments into single-line format. Update interact method to return chat history instead of a string response, enhancing functionality and documentation. 2025-10-21 10:35:06 +05:30
amithkoujalgi
ad03c784e5 Clarify Tool Functions section in agent documentation by removing redundant text in YAML registration instructions for Java classes. 2025-10-20 23:37:53 +05:30
amithkoujalgi
2e245a0e16 Implement Tool Functions section in agent documentation, detailing how to register Java classes for agent functionality. Update YAML configuration instructions accordingly. 2025-10-20 23:36:29 +05:30
amithkoujalgi
7c0c4e38ed Update Maven configuration to disable error failures and modify GitHub Actions workflow to skip GPG signing and tests during the build process. 2025-10-20 22:57:42 +05:30
amithkoujalgi
a0c1184e7b Merge remote-tracking branch 'origin/main'
Some checks failed
CodeQL / Analyze (javascript) (push) Failing after 8s
CodeQL / Analyze (java) (push) Failing after 10s
Mark stale issues / stale (push) Failing after 12s
Mark stale issues and PRs / stale (push) Failing after 29s
2025-10-20 22:49:45 +05:30
dependabot[bot]
f49c6d162a Bump @docusaurus/module-type-aliases from 3.9.1 to 3.9.2 in /docs
Bumps [@docusaurus/module-type-aliases](https://github.com/facebook/docusaurus/tree/HEAD/packages/docusaurus-module-type-aliases) from 3.9.1 to 3.9.2.
- [Release notes](https://github.com/facebook/docusaurus/releases)
- [Changelog](https://github.com/facebook/docusaurus/blob/main/CHANGELOG.md)
- [Commits](https://github.com/facebook/docusaurus/commits/v3.9.2/packages/docusaurus-module-type-aliases)

---
updated-dependencies:
- dependency-name: "@docusaurus/module-type-aliases"
  dependency-version: 3.9.2
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-10-20 00:50:44 +00:00
dependabot[bot]
751f2585b4 Bump ch.qos.logback:logback-classic from 1.5.18 to 1.5.20
Bumps [ch.qos.logback:logback-classic](https://github.com/qos-ch/logback) from 1.5.18 to 1.5.20.
- [Release notes](https://github.com/qos-ch/logback/releases)
- [Commits](https://github.com/qos-ch/logback/compare/v_1.5.18...v_1.5.20)

---
updated-dependencies:
- dependency-name: ch.qos.logback:logback-classic
  dependency-version: 1.5.20
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-10-20 00:48:33 +00:00
dependabot[bot]
a4edcf4e43 Bump actions/setup-node from 5 to 6
Bumps [actions/setup-node](https://github.com/actions/setup-node) from 5 to 6.
- [Release notes](https://github.com/actions/setup-node/releases)
- [Commits](https://github.com/actions/setup-node/compare/v5...v6)

---
updated-dependencies:
- dependency-name: actions/setup-node
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-10-20 00:47:32 +00:00
dependabot[bot]
eee8fe5755 Bump org.sonatype.central:central-publishing-maven-plugin
Bumps [org.sonatype.central:central-publishing-maven-plugin](https://github.com/sonatype/central-publishing-maven-plugin) from 0.8.0 to 0.9.0.
- [Commits](https://github.com/sonatype/central-publishing-maven-plugin/commits)

---
updated-dependencies:
- dependency-name: org.sonatype.central:central-publishing-maven-plugin
  dependency-version: 0.9.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-10-13 00:42:34 +00:00
dependabot[bot]
a7a030b9b0 Bump org.jacoco:jacoco-maven-plugin from 0.8.13 to 0.8.14
Bumps [org.jacoco:jacoco-maven-plugin](https://github.com/jacoco/jacoco) from 0.8.13 to 0.8.14.
- [Release notes](https://github.com/jacoco/jacoco/releases)
- [Commits](https://github.com/jacoco/jacoco/compare/v0.8.13...v0.8.14)

---
updated-dependencies:
- dependency-name: org.jacoco:jacoco-maven-plugin
  dependency-version: 0.8.14
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-10-13 00:42:20 +00:00
dependabot[bot]
e793320f7c Bump org.junit.jupiter:junit-jupiter-api from 5.13.4 to 6.0.0
Bumps [org.junit.jupiter:junit-jupiter-api](https://github.com/junit-team/junit-framework) from 5.13.4 to 6.0.0.
- [Release notes](https://github.com/junit-team/junit-framework/releases)
- [Commits](https://github.com/junit-team/junit-framework/compare/r5.13.4...r6.0.0)

---
updated-dependencies:
- dependency-name: org.junit.jupiter:junit-jupiter-api
  dependency-version: 6.0.0
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-10-13 00:41:21 +00:00
dependabot[bot]
4c3cf3b335 Bump org.projectlombok:lombok from 1.18.40 to 1.18.42
Bumps [org.projectlombok:lombok](https://github.com/projectlombok/lombok) from 1.18.40 to 1.18.42.
- [Changelog](https://github.com/projectlombok/lombok/blob/master/doc/changelog.markdown)
- [Commits](https://github.com/projectlombok/lombok/compare/v1.18.40...v1.18.42)

---
updated-dependencies:
- dependency-name: org.projectlombok:lombok
  dependency-version: 1.18.42
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-10-13 00:40:58 +00:00
dependabot[bot]
ecfbc1b394 Bump github/codeql-action from 3 to 4
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3 to 4.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/v3...v4)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: '4'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-10-13 00:32:45 +00:00
snyk-bot
ceb1e6f338 fix: upgrade org.projectlombok:lombok from 1.18.40 to 1.18.42
Snyk has created this PR to upgrade org.projectlombok:lombok from 1.18.40 to 1.18.42.

See this package in maven:
org.projectlombok:lombok

See this project in Snyk:
https://app.snyk.io/org/koujalgi.amith/project/e4176cf5-c6db-4650-af21-3778aa308d33?utm_source=github&utm_medium=referral&page=upgrade-pr
2025-10-11 08:36:43 +00:00
9 changed files with 464 additions and 442 deletions

View File

@@ -8,6 +8,8 @@ on:
paths:
- 'src/**'
- 'pom.xml'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
@@ -52,7 +54,7 @@ jobs:
steps:
- uses: actions/checkout@v5
- name: Use Node.js
uses: actions/setup-node@v5
uses: actions/setup-node@v6
with:
node-version: '20.x'
- run: cd docs && npm ci

View File

@@ -32,13 +32,13 @@ jobs:
java-version: '21'
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
uses: github/codeql-action/init@v4
with:
languages: ${{ matrix.language }}
- name: Autobuild
uses: github/codeql-action/autobuild@v3
uses: github/codeql-action/autobuild@v4
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
uses: github/codeql-action/analyze@v4

View File

@@ -40,7 +40,7 @@ jobs:
- uses: actions/checkout@v5
- name: Use Node.js
uses: actions/setup-node@v5
uses: actions/setup-node@v6
with:
node-version: '20.x'
- run: cd docs && npm ci
@@ -54,7 +54,7 @@ jobs:
regex: false
- name: Build with Maven
run: mvn --file pom.xml -U clean package && cp -r ./target/apidocs/. ./docs/build/apidocs
run: mvn --file pom.xml -U clean package -Dgpg.skip=true -DskipTests && cp -r ./target/apidocs/. ./docs/build/apidocs
- name: Doxygen Action
uses: mattnotmitt/doxygen-action@v1.12.0

View File

@@ -1,43 +1,50 @@
---
sidebar_position: 4
title: Agents
title: Agents 🆕
---
import CodeEmbed from '@site/src/components/CodeEmbed';
import TypewriterTextarea from '@site/src/components/TypewriterTextarea';
# Agents
Build powerful, flexible agents—backed by LLMs and tools—in a few minutes.
An **agent** is an intelligent assistant that understands user requests, communicates using LLMs, and performs actions by invoking appropriate tools (exposed as code).
Ollama4js agent system lets you bring together the best of LLM reasoning and external tool-use using a simple, declarative YAML configuration. No framework bloat, no complicated setup—just describe your agent, plug in your logic, and go.
With agents, you can:
- Orchestrate multi-step reasoning and tool use (e.g., answering questions, looking up data, making reservations, sending emails, and more)
- Automatically select and execute the right tools or actions based on user intent
- Maintain conversation context to support dynamic, interactive problem solving
- Adapt behavior, persona, or expertise by simply changing configuration—without changing your Java code
Agents help by acting as an intelligent bridge between users, LLMs, and your application's capabilities. They can automate tasks, provide personalized assistance, and extend what LLMs can do by calling your Java methods or integrating with external systems.
With Ollama4j, creating an agent is as simple as describing its purpose, available tools, behavior, and preferred language model—all defined in a single YAML file.
**Why consider building agents using Ollama4j?**
- **Seamless Customization:** Effortlessly fine-tune your agent's personality, expertise, or workflow by editing the YAML—no need to recompile or modify your Java code.
- **Plug-and-Play Extensibility:** Add new tools or swap out existing logic classes without wrestling with framework internals or glue code.
- **Rapid Iteration:** Experiment freely. Try different models, instructions, and toolsets to try new behaviors or orchestrations in minutes.
- **Clear Separation of Concerns:** Keep your core business logic (Java) and conversational configuration (YAML) distinct, promoting clarity, maintainability, and collaboration.
---
**Why use agents in Ollama4j?**
- **Effortless Customization:** Instantly adjust your agents persona, reasoning strategies, or domain by tweaking YAML. No need to touch your compiled Java code.
- **Easy Extensibility:** Want new capabilities? Just add or change tools and logic classes—no framework glue or plumbing required.
- **Fast Experimentation:** Mix-and-match models, instructions, and tools—prototype sophisticated behaviors or orchestrators in minutes.
- **Clean Separation:** Keep business logic (Java) and agent personality/configuration (YAML) separate for maintainability and clarity.
---
## Define an Agent in YAML
### Define an Agent in YAML
Specify everything about your agent—what LLM it uses, its “personality,” and all callable tools—in a single YAML file.
**Agent YAML keys:**
**Agent configuration parameters:**
| Field | Description |
|-------------------------|-----------------------------------------------------------------------------------------------------------------------|
| `name` | Name of your agent. |
| `host` | The base URL for your Ollama server (e.g., `http://localhost:11434`). |
| `model` | The LLM backing your agent (e.g., `llama2`, `mistral`, `mixtral`, etc). |
| `customPrompt` | _(optional)_ System prompt—instructions or persona for your agent. |
| `tools` | List of tools the agent can use. Each tool entry describes the name, function, and parameters. |
| `toolFunctionFQCN` | Fully qualified Java class name implementing the tool logic. Must be present on classpath. |
| `requestTimeoutSeconds` | _(optional)_ How long (seconds) to wait for agent replies. |
| Field | Description |
|-------------------------|------------------------------------------------------------------------------------------------|
| `name` | Name of your agent. |
| `host` | The base URL for your Ollama server (e.g., `http://localhost:11434`). |
| `model` | The LLM backing your agent (e.g., `llama3`, `gemma`, `mistral`, etc). |
| `customPrompt` | _(optional)_ System prompt—instructions or persona for your agent. |
| `tools` | List of tools the agent can use. Each tool entry describes the name, function, and parameters. |
| `toolFunctionFQCN` | Fully qualified Java class name implementing the tool logic. Must be present on classpath. |
| `requestTimeoutSeconds` | _(optional)_ How long (seconds) to wait for agent replies. |
YAML makes it effortless to configure and tweak your agents powers and behavior—no code changes needed!
@@ -47,14 +54,42 @@ YAML makes it effortless to configure and tweak your agents powers and behavi
---
## Instantiating and Running Agents in Java
### Implement Tool Functions
Your agent calls out to Java classes (Tool Functions). Put these implementations on your classpath, register them in YAML.
<CodeEmbed src="https://raw.githubusercontent.com/ollama4j/ollama4j-examples/refs/heads/main/src/main/java/io/github/ollama4j/examples/tools/toolfunctions/HotelBookingLookupToolFunction.java"/>
<CodeEmbed src="https://raw.githubusercontent.com/ollama4j/ollama4j-examples/refs/heads/main/src/main/java/io/github/ollama4j/examples/tools/toolfunctions/HotelBookingToolFunction.java"/>
---
### Instantiating and Running Agents
Once your agent is described in YAML, bringing it to life in Java takes only a couple of lines:
<CodeEmbed src="https://raw.githubusercontent.com/ollama4j/ollama4j-examples/refs/heads/main/src/main/java/io/github/ollama4j/examples/AgentExample.java"/>
- **No boilerplate.** Just load and start chatting or calling tools.
- The API takes care of wiring up LLMs, tool invocation, and instruction handling.
The API takes care of wiring up LLMs, tool invocation, and instruction handling.
Ready to build your own AI-powered assistant? Just write your YAML, implement the tool logic in Java, and go!
Here's a sample interaction:
<TypewriterTextarea
textContent='[You]: Book a hotel in Mysuru for two guests, from July 20 to July 22.
Alright, I have booked the hotel! Room number 10 booked for 2 guests in Mysuru from July 20th to July 22nd. Here is your booking ID: HB-123'
typingSpeed={30}
pauseBetweenSentences={1200}
height='110px'
width='100%'
/>
Here's another one:
<TypewriterTextarea
textContent='[You]: Give me details of booking ID - HB-123.
I found a booking for HB-123. Looks like the hotel is booked for 2 guests. Enjoy your stay!'
typingSpeed={30}
pauseBetweenSentences={1200}
height='90px'
width='100%'
/>

View File

@@ -1,7 +1,7 @@
---
sidebar_position: 6
title: Metrics
title: Metrics 🆕
---
import CodeEmbed from '@site/src/components/CodeEmbed';

695
docs/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -15,10 +15,11 @@
},
"dependencies": {
"@docsearch/js": "^4.1.0",
"@docusaurus/core": "^3.9.0",
"@docusaurus/plugin-google-gtag": "^3.9.1",
"@docusaurus/preset-classic": "^3.9.1",
"@docusaurus/theme-mermaid": "^3.9.1",
"@docusaurus/core": "^3.9.2",
"@docusaurus/plugin-google-gtag": "^3.9.2",
"@docusaurus/preset-classic": "^3.9.2",
"@docusaurus/theme-mermaid": "^3.9.2",
"@docusaurus/plugin-content-docs": "^3.9.2",
"@iconify/react": "^6.0.2",
"@mdx-js/react": "^3.1.1",
"clsx": "^2.1.1",
@@ -30,8 +31,8 @@
"react-image-gallery": "^1.4.0"
},
"devDependencies": {
"@docusaurus/module-type-aliases": "^3.9.1",
"@docusaurus/types": "^3.4.0"
"@docusaurus/module-type-aliases": "^3.9.2",
"@docusaurus/types": "^3.9.2"
},
"browserslist": {
"production": [

13
pom.xml
View File

@@ -19,7 +19,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven-surefire-plugin.version>3.5.4</maven-surefire-plugin.version>
<maven-failsafe-plugin.version>3.5.4</maven-failsafe-plugin.version>
<lombok.version>1.18.40</lombok.version>
<lombok.version>1.18.42</lombok.version>
</properties>
<developers>
@@ -80,6 +80,7 @@
<configuration>
<!-- to disable the "missing" warnings. Remove the doclint to enable warnings-->
<doclint>all,-missing</doclint>
<failOnError>false</failOnError>
</configuration>
<executions>
<execution>
@@ -272,7 +273,7 @@
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.5.18</version>
<version>1.5.20</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -283,7 +284,7 @@
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.13.4</version>
<version>6.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -346,7 +347,7 @@
<plugin>
<groupId>org.sonatype.central</groupId>
<artifactId>central-publishing-maven-plugin</artifactId>
<version>0.8.0</version>
<version>0.9.0</version>
<extensions>true</extensions>
<configuration>
<publishingServerId>mvn-repo-id</publishingServerId>
@@ -372,7 +373,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.13</version>
<version>0.8.14</version>
<executions>
<execution>
<goals>
@@ -483,7 +484,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.13</version>
<version>0.8.14</version>
<executions>
<execution>
<goals>

View File

@@ -38,44 +38,32 @@ import lombok.*;
* </ul>
*/
public class Agent {
/**
* The agent's display name
*/
/** The agent's display name */
private final String name;
/**
* List of supported tools for this agent
*/
/** List of supported tools for this agent */
private final List<Tools.Tool> tools;
/**
* Ollama client instance for communication with the API
*/
/** Ollama client instance for communication with the API */
private final Ollama ollamaClient;
/**
* The model name used for chat completions
*/
/** The model name used for chat completions */
private final String model;
/**
* Persists chat message history across rounds
*/
/** Persists chat message history across rounds */
private final List<OllamaChatMessage> chatHistory;
/**
* Optional custom system prompt for the agent
*/
/** Optional custom system prompt for the agent */
private final String customPrompt;
/**
* Constructs a new Agent.
*
* @param name The agent's given name.
* @param name The agent's given name.
* @param ollamaClient The Ollama API client instance to use.
* @param model The model name to use for chat completion.
* @param model The model name to use for chat completion.
* @param customPrompt A custom prompt to prepend to all conversations (may be null).
* @param tools List of available tools for function calling.
* @param tools List of available tools for function calling.
*/
public Agent(
String name,
@@ -149,6 +137,7 @@ public class Agent {
}
Ollama ollama = new Ollama(agentSpec.getHost());
ollama.setRequestTimeoutSeconds(120);
ollama.pullModel(agentSpec.getModel());
return new Agent(
agentSpec.getName(),
ollama,
@@ -161,21 +150,17 @@ public class Agent {
}
/**
* Facilitates a single round of chat for the agent:
* Conducts a conversational interaction with the agent.
*
* <ul>
* <li>Builds/promotes the system prompt on the first turn if necessary
* <li>Adds the user's input to chat history
* <li>Submits the chat turn to the Ollama model (with tool/function support)
* <li>Updates internal chat history in accordance with the Ollama chat result
* </ul>
*
* @param userInput The user's message or question for the agent.
* @return The model's response as a string.
* @throws OllamaException If there is a problem with the Ollama API.
* @param userInput the user's question, instruction, or message for the agent.
* @param chatTokenHandler an optional handler for receiving streaming token updates from the model as it generates a reply.
* Can be {@code null} if streaming output is not needed.
* @return Updated chat history, as a list of {@link OllamaChatMessage} objects representing the complete conversation so far.
* This includes system, user, assistant, and any tool/function calls/results.
* @throws OllamaException if an error occurs communicating with the Ollama API or running tools.
*/
public String interact(String userInput, OllamaChatStreamObserver chatTokenHandler)
throws OllamaException {
public List<OllamaChatMessage> interact(
String userInput, OllamaChatStreamObserver chatTokenHandler) throws OllamaException {
// Build a concise and readable description of available tools
String availableToolsDescription =
tools.isEmpty()
@@ -217,11 +202,10 @@ public class Agent {
.build();
OllamaChatResult response = ollamaClient.chat(request, chatTokenHandler);
// Update chat history for continuity
chatHistory.clear();
chatHistory.addAll(response.getChatHistory());
return response.getResponseModel().getMessage().getResponse();
return response.getChatHistory();
}
/**
@@ -279,35 +263,23 @@ public class Agent {
@Getter
@EqualsAndHashCode(callSuper = false)
private static class AgentToolSpec extends Tools.ToolSpec {
/**
* Fully qualified class name of the tool's {@link ToolFunction} implementation
*/
/** Fully qualified class name of the tool's {@link ToolFunction} implementation */
private String toolFunctionFQCN = null;
/**
* Instance of the {@link ToolFunction} to invoke
*/
/** Instance of the {@link ToolFunction} to invoke */
private ToolFunction toolFunctionInstance = null;
}
/**
* Bean for describing a tool function parameter for use in agent YAML definitions.
*/
/** Bean for describing a tool function parameter for use in agent YAML definitions. */
@Data
public class AgentToolParameter {
/**
* The parameter's type (e.g., string, number, etc.)
*/
/** The parameter's type (e.g., string, number, etc.) */
private String type;
/**
* Description of the parameter
*/
/** Description of the parameter */
private String description;
/**
* Whether this parameter is required
*/
/** Whether this parameter is required */
private boolean required;
/**