Skip to content

Commit f67e796

Browse files
committed
docs: update graphile-llm README with standard header and full documentation
- Add centered logo and badge header matching sibling packages - Add table of contents, installation, plugins table, configuration - Document RAG queries with GraphQL examples - Add toggleable capabilities section
1 parent 955a9dd commit f67e796

1 file changed

Lines changed: 113 additions & 7 deletions

File tree

graphile/graphile-llm/README.md

Lines changed: 113 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,34 @@
11
# graphile-llm
22

3-
LLM integration plugin for PostGraphile v5. Provides server-side text-to-vector embedding for pgvector columns.
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>
46

5-
## Features
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)
626

7-
- **Text-based vector search**: Adds `text: String` field to `VectorNearbyInput` — clients pass natural language instead of raw float vectors
8-
- **Text mutation fields**: Adds `{column}Text: String` companion fields on create/update inputs for vector columns
9-
- **Pluggable embedders**: Provider-based architecture (Ollama via `@agentic-kit/ollama`, with room for OpenAI, etc.)
10-
- **Per-database configuration**: Reads `llm_module` from `services_public.api_modules` for per-API embedder config
11-
- **Plugin-conditional**: Fields only appear in the schema when the plugin is loaded
27+
## Installation
28+
29+
```bash
30+
npm install graphile-llm
31+
```
1232

1333
## Usage
1434

@@ -27,3 +47,89 @@ const preset = {
2747
],
2848
};
2949
```
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

0 commit comments

Comments
 (0)