https://github.com/patmartin/ai-ops
AI support for Ops4J
https://github.com/patmartin/ai-ops
Last synced: 4 days ago
JSON representation
AI support for Ops4J
- Host: GitHub
- URL: https://github.com/patmartin/ai-ops
- Owner: PatMartin
- License: apache-2.0
- Created: 2024-12-19T16:41:22.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-12-20T22:08:43.000Z (over 1 year ago)
- Last Synced: 2025-08-20T15:53:48.835Z (11 months ago)
- Language: Java
- Size: 13.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ai-ops
AI and LLM operations for Ops4J, powered by [LangChain4j](https://github.com/langchain4j/langchain4j).
This is an optional plugin module. Add it to a project that already depends on `ops4j-core` to bring LLM question answering, image generation, RAG, and prompt-based workflows into your pipelines.
---
## Overview
`ai-ops` integrates large language models into the Ops4J pipeline model. It uses LangChain4j to communicate with OpenAI-compatible APIs and the GitHub Models endpoint. Operations are first-class pipeline stages: a record flows in, the operation invokes the configured model, and an annotated record flows out.
---
## Operations
| Operation | Description |
| --- | --- |
| `ask` (`AskQuestion`) | Sends a question to a configured LLM (ChatGPT or GitHub Models) and writes the response back into the record. |
| `ai-prompt` (`AiPrompt`) | Executes a templated prompt where placeholders are filled from the incoming record's fields. |
| `rag` (`RAG`) | Retrieval-Augmented Generation. Indexes a set of documents using local embeddings, then answers questions by retrieving relevant context before querying the model. |
| `query-image` (`QueryImage`) | Sends an image to a vision-capable model and writes the model's answer about the image back into the record. |
| `gen-image` (`GenImage`) | Generates an image using DALL-E 3 and stores the result URL in the record. |
| `ai-draw` (`AiDraw`) | Wrapper around DALL-E 3 image generation with additional drawing-oriented options. |
All operations extend `AiOp`, which provides shared configuration for the API provider, model name, and API key.
---
## Usage Examples
Ask a single question:
```bash
ask "Explain why the sky is blue"
```
Annotate each record in a stream with an AI-generated summary of its `description` field:
```bash
cat products.json | ai-prompt -t "Summarize this in one sentence: {{description}}"
```
Answer questions against a local document corpus:
```bash
cat questions.json | rag -d ./docs
```
Generate an image based on a prompt stored in the `prompt` field of each record:
```bash
cat prompts.json | gen-image
```
---
## Configuration
`ai-ops` registers itself automatically. API credentials are provided at runtime via options on each operation or through environment variables recognized by LangChain4j (`OPENAI_API_KEY`, `GITHUB_TOKEN`, etc.).
Default provider configuration is located in `src/main/resources/ai.conf`:
```hocon
ai {
provider = openai
}
```
---
## Key Dependencies
| Dependency | Purpose |
| --- | --- |
| [ops4j-core](../ops4j-core/) | Ops4J runtime and base classes |
| LangChain4j (core, OpenAI, GitHub Models) | LLM client and AI service abstraction |
| LangChain4j Easy RAG | Document ingestion and retrieval for RAG workflows |
| LangChain4j BGE embeddings | Local embedding model for RAG document indexing |