|
1 | 1 | --- |
2 | 2 | name: constructive-ai |
3 | | -description: "AI and vector search capabilities — pgvector RAG pipelines (embeddings, similarity search, agentic kits), and Ollama CI/CD workflows for running LLM models in GitHub Actions. Use when building RAG pipelines, working with embeddings, running Ollama in CI, or implementing AI-powered search." |
| 3 | +description: "AI and vector search on the Constructive platform — provision pgvector columns and indexes via SDK, query embeddings via codegen'd ORM, build RAG pipelines with Ollama, and run LLM models in GitHub Actions CI/CD. Use when building RAG pipelines, working with embeddings, running Ollama in CI, or implementing AI-powered search within a Constructive application." |
4 | 4 | metadata: |
5 | 5 | author: constructive-io |
6 | | - version: "1.0.0" |
| 6 | + version: "2.0.0" |
7 | 7 | --- |
8 | 8 |
|
9 | 9 | # Constructive AI |
10 | 10 |
|
11 | | -Build AI-powered features with pgvector RAG pipelines and Ollama CI/CD workflows. |
| 11 | +Build AI-powered features on the Constructive platform: provision vector storage via SDK, query via codegen'd ORM, and integrate Ollama for embeddings and generation. |
12 | 12 |
|
13 | 13 | ## When to Apply |
14 | 14 |
|
15 | 15 | Use this skill when: |
16 | | -- Building RAG (Retrieval-Augmented Generation) pipelines |
17 | | -- Working with vector embeddings and similarity search |
18 | | -- Setting up Ollama LLM models in CI/CD |
19 | | -- Implementing AI-powered search or agentic workflows |
| 16 | +- Adding pgvector columns and indexes to a Constructive database |
| 17 | +- Querying vector embeddings via the generated TypeScript ORM |
| 18 | +- Building RAG (Retrieval-Augmented Generation) pipelines on Constructive |
| 19 | +- Running Ollama LLM models in CI/CD |
| 20 | +- Implementing AI-powered search alongside other search strategies (tsvector, BM25, trgm) |
20 | 21 |
|
21 | | -## pgvector RAG |
| 22 | +## The Constructive AI Flow |
22 | 23 |
|
23 | | -Build end-to-end RAG pipelines: embed documents → store in pgvector → similarity search → feed to LLM. |
| 24 | +``` |
| 25 | +1. Provision → SDK creates vector(N) column + HNSW index on your table |
| 26 | +2. Codegen → @constructive-io/graphql-codegen generates typed ORM (see constructive-graphql skill) |
| 27 | +3. Embed → Application code generates embeddings (Ollama, OpenAI, etc.) |
| 28 | +4. Store → ORM or SDK inserts embeddings into the vector column |
| 29 | +5. Query → ORM queries with vectorEmbedding filter + distance ordering |
| 30 | +6. RAG → Retrieve context via ORM → feed to LLM for generation |
| 31 | +``` |
24 | 32 |
|
25 | | -See [pgvector-rag.md](./references/pgvector-rag.md) for the full RAG pipeline guide. |
| 33 | +> **Important:** For vector *querying* via ORM, see the `constructive-graphql` skill ([search-pgvector.md](../constructive-graphql/references/search-pgvector.md)). This skill covers the AI/RAG layer on top. |
26 | 34 |
|
27 | | -## Ollama CI/CD |
| 35 | +## Quick Start: Provision + Query |
| 36 | + |
| 37 | +### 1. Create a vector field via SDK |
| 38 | + |
| 39 | +```typescript |
| 40 | +const vecField = await db.field.create({ |
| 41 | + data: { |
| 42 | + databaseId, |
| 43 | + tableId: documentsTableId, |
| 44 | + name: 'embedding', |
| 45 | + type: 'vector(768)', |
| 46 | + }, |
| 47 | + select: { id: true, name: true }, |
| 48 | +}).execute(); |
| 49 | +``` |
| 50 | + |
| 51 | +### 2. Create an HNSW index |
| 52 | + |
| 53 | +```typescript |
| 54 | +await db.index.create({ |
| 55 | + data: { |
| 56 | + databaseId, |
| 57 | + tableId: documentsTableId, |
| 58 | + name: 'idx_documents_embedding_hnsw', |
| 59 | + fieldIds: [vecField.data.createField.field.id], |
| 60 | + accessMethod: 'hnsw', |
| 61 | + options: { m: 16, ef_construction: 64 }, |
| 62 | + opClasses: ['vector_cosine_ops'], |
| 63 | + }, |
| 64 | + select: { id: true }, |
| 65 | +}).execute(); |
| 66 | +``` |
| 67 | + |
| 68 | +### 3. Query via codegen'd ORM |
| 69 | + |
| 70 | +```typescript |
| 71 | +const result = await db.document.findMany({ |
| 72 | + where: { |
| 73 | + vectorEmbedding: { |
| 74 | + vector: queryVector, |
| 75 | + metric: 'COSINE', |
| 76 | + distance: 0.5, |
| 77 | + }, |
| 78 | + }, |
| 79 | + orderBy: 'EMBEDDING_VECTOR_DISTANCE_ASC', |
| 80 | + first: 5, |
| 81 | + select: { |
| 82 | + id: true, |
| 83 | + title: true, |
| 84 | + content: true, |
| 85 | + embeddingVectorDistance: true, |
| 86 | + }, |
| 87 | +}).execute(); |
| 88 | +``` |
28 | 89 |
|
29 | | -Run Ollama LLM models in GitHub Actions for testing and validation. |
| 90 | +### 4. Feed to LLM for RAG |
| 91 | + |
| 92 | +```typescript |
| 93 | +const context = result.data.documents.nodes |
| 94 | + .map(d => d.content) |
| 95 | + .join('\n\n'); |
| 96 | + |
| 97 | +const answer = await ollama.generateResponse(question, context); |
| 98 | +``` |
| 99 | + |
| 100 | +## Ollama Integration |
| 101 | + |
| 102 | +Use Ollama for local embedding generation and LLM inference. See [ollama.md](./references/ollama.md) for the full OllamaClient implementation, model selection, and API reference. |
| 103 | + |
| 104 | +```typescript |
| 105 | +const ollama = new OllamaClient(); |
| 106 | +const embedding = await ollama.generateEmbedding('document text'); |
| 107 | +const response = await ollama.generateResponse(question, context); |
| 108 | +``` |
| 109 | + |
| 110 | +## Ollama CI/CD |
30 | 111 |
|
31 | | -See [ollama-ci.md](./references/ollama-ci.md) for CI workflow configuration. |
| 112 | +Run Ollama in GitHub Actions for testing RAG pipelines. See [ollama-ci.md](./references/ollama-ci.md) for workflow templates. |
32 | 113 |
|
33 | 114 | ## Reference Guide |
34 | 115 |
|
35 | 116 | | Reference | Topic | Consult When | |
36 | 117 | |-----------|-------|--------------| |
37 | | -| [pgvector-rag.md](./references/pgvector-rag.md) | RAG pipeline overview | Building end-to-end RAG systems | |
38 | | -| [rag-embeddings.md](./references/rag-embeddings.md) | Embedding generation | Creating and storing vector embeddings | |
39 | | -| [rag-similarity-search.md](./references/rag-similarity-search.md) | Similarity search | Querying vectors, distance metrics | |
40 | | -| [rag-rag-pipeline.md](./references/rag-rag-pipeline.md) | Full RAG pipeline | Document ingestion → retrieval → generation | |
41 | | -| [rag-setup.md](./references/rag-setup.md) | pgvector setup | Installing pgvector, creating indexes | |
42 | | -| [rag-ollama.md](./references/rag-ollama.md) | Ollama integration | Using Ollama for local LLM inference | |
43 | | -| [rag-agentic-kit.md](./references/rag-agentic-kit.md) | Agentic kit patterns | Building AI agents with RAG | |
| 118 | +| [rag-pipeline.md](./references/rag-pipeline.md) | RAG pipeline on Constructive | Building end-to-end RAG (embed → store → retrieve → generate) | |
| 119 | +| [ollama.md](./references/ollama.md) | Ollama client & models | Generating embeddings, LLM inference, streaming, model selection | |
44 | 120 | | [ollama-ci.md](./references/ollama-ci.md) | Ollama GitHub Actions | Running LLM models in CI/CD | |
| 121 | +| [pgvector-sql.md](./references/pgvector-sql.md) | pgvector SQL reference | Raw SQL for vector tables, indexes, similarity functions (SQL-level) | |
| 122 | +| [agentic-kit.md](./references/agentic-kit.md) | Agentic kit (multi-provider) | Multi-provider LLM abstraction (Ollama, Anthropic, OpenAI), streaming, embeddings, RAG patterns | |
45 | 123 |
|
46 | 124 | ## Cross-References |
47 | 125 |
|
48 | | -- `graphile-search` — Unified search plugin (includes pgvector adapter) |
49 | | -- `constructive-graphql` — Search via codegen SDK (pgvector queries) |
50 | | -- `pgpm` — Database migrations for vector tables |
| 126 | +- `constructive-graphql` — [search-pgvector.md](../constructive-graphql/references/search-pgvector.md): ORM query patterns for vector search (distance filters, metrics, ordering) |
| 127 | +- `constructive-graphql` — [search-rag.md](../constructive-graphql/references/search-rag.md): RAG patterns with codegen'd ORM (single-table, multi-table, hybrid, embedding ingestion) |
| 128 | +- `constructive-graphql` — [search-composite.md](../constructive-graphql/references/search-composite.md): Combining pgvector with tsvector/BM25/trgm in unified `searchScore` |
| 129 | +- `graphile-search` — Plugin internals for the unified search system (team-level) |
| 130 | +- `pgpm` — Database migrations for vector-enabled modules |
0 commit comments