Skip to content

Commit 19711a7

Browse files
committed
merge: resolve lockfile conflict with main
2 parents 10944ed + e52a76e commit 19711a7

18 files changed

Lines changed: 2863 additions & 211 deletions

graphile/graphile-llm/CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Change Log
2+
3+
All notable changes to this project will be documented in this file.
4+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5+
6+
# 0.2.0 (2026-04-19)
7+
8+
### Bug Fixes
9+
10+
- address Devin Review findings ([1be6d54](https://github.com/constructive-io/constructive/commit/1be6d54d1441371cbb5975f238b957afb061cb8b))
11+
12+
### Features
13+
14+
- add graphile-llm plugin — server-side text-to-vector embedding for PostGraphile ([976f626](https://github.com/constructive-io/constructive/commit/976f626b57ddf574feb7ce617a7c3b1ae51e6d55)), closes [constructive-io/constructive-planning#743](https://github.com/constructive-io/constructive-planning/issues/743)
15+
- add RAG plugin, chat completion provider, and resolve-time embedding ([3224ff7](https://github.com/constructive-io/constructive/commit/3224ff790e272ac35fbd1b8e0aebdeca0f5a5ddb))

graphile/graphile-llm/README.md

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
# graphile-llm
2+
3+
<p align="center" width="100%">
4+
<img height="250" src="https://raw.githubusercontent.com/constructive-io/constructive/refs/heads/main/assets/outline-logo.svg" />
5+
</p>
6+
7+
<p align="center" width="100%">
8+
<a href="https://github.com/constructive-io/constructive/actions/workflows/run-tests.yaml">
9+
<img height="20" src="https://github.com/constructive-io/constructive/actions/workflows/run-tests.yaml/badge.svg" />
10+
</a>
11+
<a href="https://github.com/constructive-io/constructive/blob/main/LICENSE"><img height="20" src="https://img.shields.io/badge/license-MIT-blue.svg"/></a>
12+
<a href="https://www.npmjs.com/package/graphile-llm"><img height="20" src="https://img.shields.io/github/package-json/v/constructive-io/constructive?filename=graphile%2Fgraphile-llm%2Fpackage.json"/></a>
13+
</p>
14+
15+
LLM integration plugin for PostGraphile v5 — server-side text-to-vector embedding, resolve-time vector injection, and RAG (Retrieval-Augmented Generation) for pgvector columns using `@agentic-kit/ollama`.
16+
17+
## Table of contents
18+
19+
- [Installation](#installation)
20+
- [Usage](#usage)
21+
- [Features](#features)
22+
- [Plugins](#plugins)
23+
- [Configuration](#configuration)
24+
- [RAG queries](#rag-queries)
25+
- [License](#license)
26+
27+
## Installation
28+
29+
```bash
30+
npm install graphile-llm
31+
```
32+
33+
## Usage
34+
35+
```typescript
36+
import { GraphileLlmPreset } from 'graphile-llm';
37+
38+
const preset = {
39+
extends: [
40+
GraphileLlmPreset({
41+
defaultEmbedder: {
42+
provider: 'ollama',
43+
model: 'nomic-embed-text',
44+
baseUrl: 'http://localhost:11434',
45+
},
46+
}),
47+
],
48+
};
49+
```
50+
51+
The preset bundles all plugins listed below. You can also import each plugin individually (`createLlmModulePlugin`, `createLlmTextSearchPlugin`, `createLlmTextMutationPlugin`, `createLlmRagPlugin`) if you prefer a-la-carte.
52+
53+
## Features
54+
55+
- **Text-based vector search** — adds `text: String` field to `VectorNearbyInput`; clients pass natural language instead of raw float vectors
56+
- **Text mutation fields** — adds `{column}Text: String` companion fields on create/update inputs for vector columns
57+
- **RAG queries** — adds `ragQuery` and `embedText` root query fields; detects `@hasChunks` smart tags for chunk-aware retrieval
58+
- **Pluggable providers** — provider-based architecture for both embedding and chat completion (Ollama via `@agentic-kit/ollama`, extensible to OpenAI, etc.)
59+
- **Per-database configuration** — reads `llm_module` from `services_public.api_modules` for per-API provider config
60+
- **Toggleable** — each capability (`enableTextSearch`, `enableTextMutations`, `enableRag`) can be independently enabled or disabled
61+
- **Plugin-conditional** — fields only appear in the schema when the plugin is loaded
62+
63+
## Plugins
64+
65+
| Plugin | Description | Toggle |
66+
|--------|-------------|--------|
67+
| `LlmModulePlugin` | Resolves embedder and chat completer from config; stores on build context | Always included |
68+
| `LlmTextSearchPlugin` | Adds `text: String` to `VectorNearbyInput` with resolve-time embedding | `enableTextSearch` (default: `true`) |
69+
| `LlmTextMutationPlugin` | Adds `{column}Text` companion fields on mutation inputs | `enableTextMutations` (default: `true`) |
70+
| `LlmRagPlugin` | Adds `ragQuery` and `embedText` root query fields | `enableRag` (default: `false`) |
71+
72+
## Configuration
73+
74+
```typescript
75+
GraphileLlmPreset({
76+
// Embedding provider (required for text fields and RAG)
77+
defaultEmbedder: {
78+
provider: 'ollama',
79+
model: 'nomic-embed-text',
80+
baseUrl: 'http://localhost:11434',
81+
},
82+
83+
// Chat completion provider (required for RAG)
84+
defaultChatCompleter: {
85+
provider: 'ollama',
86+
model: 'llama3',
87+
baseUrl: 'http://localhost:11434',
88+
},
89+
90+
// Toggle individual capabilities
91+
enableTextSearch: true, // text field on VectorNearbyInput
92+
enableTextMutations: true, // *Text companion fields on mutations
93+
enableRag: false, // ragQuery + embedText root fields
94+
95+
// RAG defaults (overridable per-query)
96+
ragDefaults: {
97+
contextLimit: 10,
98+
maxTokens: 4000,
99+
minSimilarity: 0.3,
100+
},
101+
})
102+
```
103+
104+
Providers can also be configured via environment variables (`EMBEDDER_PROVIDER`, `EMBEDDER_MODEL`, `EMBEDDER_BASE_URL`, `CHAT_PROVIDER`, `CHAT_MODEL`, `CHAT_BASE_URL`).
105+
106+
## RAG queries
107+
108+
When `enableRag: true` and tables have `@hasChunks` smart tags, the plugin adds:
109+
110+
```graphql
111+
# Full RAG: embed prompt, search chunks, assemble context, call chat LLM
112+
query {
113+
ragQuery(
114+
prompt: "What is machine learning?"
115+
contextLimit: 5
116+
minSimilarity: 0.3
117+
) {
118+
answer
119+
sources { content similarity tableName parentId }
120+
tokensUsed
121+
}
122+
}
123+
124+
# Standalone embedding
125+
query {
126+
embedText(text: "machine learning concepts") {
127+
vector
128+
dimensions
129+
}
130+
}
131+
```
132+
133+
## License
134+
135+
MIT
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/** @type {import('ts-jest').JestConfigWithTsJest} */
2+
module.exports = {
3+
preset: 'ts-jest',
4+
testEnvironment: 'node',
5+
testTimeout: 60000,
6+
transform: {
7+
'^.+\\.tsx?$': [
8+
'ts-jest',
9+
{
10+
babelConfig: false,
11+
tsconfig: 'tsconfig.json'
12+
}
13+
]
14+
},
15+
transformIgnorePatterns: [`/node_modules/*`],
16+
testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$',
17+
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
18+
modulePathIgnorePatterns: ['dist/*']
19+
};

graphile/graphile-llm/package.json

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
{
2+
"name": "graphile-llm",
3+
"version": "0.2.0",
4+
"description": "LLM integration plugin for PostGraphile v5 — server-side text-to-vector embedding and text companion fields for pgvector columns",
5+
"author": "Constructive <developers@constructive.io>",
6+
"homepage": "https://github.com/constructive-io/constructive",
7+
"license": "MIT",
8+
"main": "index.js",
9+
"module": "esm/index.js",
10+
"types": "index.d.ts",
11+
"scripts": {
12+
"clean": "makage clean",
13+
"prepack": "npm run build",
14+
"build": "makage build",
15+
"build:dev": "makage build --dev",
16+
"lint": "eslint . --fix",
17+
"test": "jest --forceExit",
18+
"test:watch": "jest --watch"
19+
},
20+
"publishConfig": {
21+
"access": "public",
22+
"directory": "dist"
23+
},
24+
"repository": {
25+
"type": "git",
26+
"url": "https://github.com/constructive-io/constructive"
27+
},
28+
"bugs": {
29+
"url": "https://github.com/constructive-io/constructive/issues"
30+
},
31+
"dependencies": {
32+
"@agentic-kit/ollama": "^1.0.3"
33+
},
34+
"peerDependencies": {
35+
"@dataplan/pg": "1.0.0",
36+
"grafast": "1.0.0",
37+
"graphile-build": "5.0.0",
38+
"graphile-build-pg": "5.0.0",
39+
"graphile-config": "1.0.0",
40+
"graphile-search": "workspace:^",
41+
"graphile-utils": "5.0.0",
42+
"graphql": "16.13.0",
43+
"pg-sql2": "5.0.0",
44+
"postgraphile": "5.0.0"
45+
},
46+
"peerDependenciesMeta": {
47+
"graphile-search": {
48+
"optional": true
49+
},
50+
"graphile-utils": {
51+
"optional": true
52+
}
53+
},
54+
"devDependencies": {
55+
"@types/node": "^22.19.11",
56+
"graphile-connection-filter": "workspace:^",
57+
"graphile-search": "workspace:^",
58+
"graphile-test": "workspace:^",
59+
"makage": "^0.3.0",
60+
"pgsql-test": "workspace:^"
61+
},
62+
"keywords": [
63+
"postgraphile",
64+
"graphile",
65+
"constructive",
66+
"plugin",
67+
"llm",
68+
"embedding",
69+
"pgvector",
70+
"rag",
71+
"agentic-kit",
72+
"ollama",
73+
"openai"
74+
]
75+
}

0 commit comments

Comments
 (0)