Skip to content

Commit be646f7

Browse files
feat: ai-assistant
1 parent 63b54df commit be646f7

89 files changed

Lines changed: 6454 additions & 284 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

apps/csk/.env.example

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,10 @@ UNIFORM_PREVIEW_SECRET=hello-world
99
# defaults to localhost:3000 if not set.
1010
#When set, should resolve to the base url of the app.
1111
# This is used to generate the sitemap and robots.txt
12-
BASE_URL=
12+
BASE_URL=
13+
14+
# OpenAI API key
15+
OPENAI_API_KEY=
16+
17+
# Postgres data base url
18+
DATABASE_URL=

apps/csk/README.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,58 @@ This integration brings new parameter types for design and layout control via Un
6262
![Your project](https://res.cloudinary.com/uniform-demos/image/upload/csk-v-next/doc/project_page.png)
6363
1. Navigate to the `Integrations` tab, find the `Design Extensions` integration and install it.
6464

65+
## 🚀 RAG integration
66+
67+
Retrieval-augmented generation (RAG) keeps your assistant grounded in your content: it fetches the most relevant documents from a Postgres-backed vector store and passes them to the LLM, so answers stay on-topic and up-to-date.
68+
69+
### Step 4. Create a Postgres database
70+
71+
You will need a **Postgres** database to complete this tutorial. If you don’t have Postgres locally you can either:
72+
73+
- Spin up a **free Postgres** instance on [Vercel Postgres](https://vercel.com/postgres).
74+
- Follow [this guide](https://www.postgresqltutorial.com/install-postgresql/) to install Postgres locally.
75+
76+
Once your database is ready, copy its connection string – you’ll need it in the next step.
77+
78+
### Step 5. Migrate the database
79+
80+
1. Open `.env` and paste your **database connection string** after the `DATABASE_URL=` key.
81+
1. Run the migration:
82+
83+
```bash
84+
npm run db:migrate
85+
```
86+
87+
The script will:
88+
89+
- Enable the `pgvector` extension.
90+
- Create tables for the `resources` and `embeddings` schema defined in `src/module/chat/rag/schema` with necessary columns.
91+
92+
1. Fill the data to database:
93+
```bash
94+
npm run db:load
95+
```
96+
97+
### Step 6. Add your OpenAI API key
98+
99+
Some starter features – like AI-Assistant and RAG integration – require an **OpenAI API key**.
100+
101+
1. Generate a key in your OpenAI dashboard: <https://platform.openai.com>.
102+
1. Add it to `.env`:
103+
```bash
104+
OPENAI_API_KEY=
105+
```
106+
107+
### Step 7. Add Webhook (Additional)
108+
109+
You can configure a webhook so your external database (e.g. the Postgres layer you added above) stays automatically up‑to‑date whenever content is published or deleted in Uniform.
110+
111+
1. Open Settings → Webhooks
112+
1. Set the Endpoint URL to: `https://your_domain/api/webhook/entry-event`
113+
1. Enable the following events:
114+
- entry.published
115+
- entry.deleted
116+
65117
## How to sync content
66118

67119
The following scripts are created to facilitate sync of content between the `./content` folder and your project.

apps/csk/content/asset/0aafe2e9-468c-43e1-81f3-fda6c02388e7.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
asset:
2-
type: image
2+
type: other
33
_id: 0aafe2e9-468c-43e1-81f3-fda6c02388e7
44
_name: ''
55
fields:
@@ -26,5 +26,5 @@ asset:
2626
value: 1059
2727
type: number
2828
custom: {}
29-
created: '2025-05-20T11:52:45.655676+00:00'
30-
modified: '2025-05-20T11:52:45.655676+00:00'
29+
created: '2025-05-26T08:40:43.349414+00:00'
30+
modified: '2025-05-26T08:40:43.349414+00:00'

apps/csk/content/asset/1697b6ae-aa6f-4bd6-b844-c8fb3c86216c.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
asset:
2-
type: image
2+
type: other
33
_id: 1697b6ae-aa6f-4bd6-b844-c8fb3c86216c
44
_name: ''
55
fields:
@@ -26,5 +26,5 @@ asset:
2626
value: 24
2727
type: number
2828
custom: {}
29-
created: '2025-05-20T11:52:45.084371+00:00'
30-
modified: '2025-05-20T11:52:45.084371+00:00'
29+
created: '2025-05-26T08:40:43.907922+00:00'
30+
modified: '2025-05-26T08:40:43.907922+00:00'

apps/csk/content/asset/4469d093-0095-43fe-a6f1-9ccd66da351c.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
asset:
2-
type: other
2+
type: image
33
_id: 4469d093-0095-43fe-a6f1-9ccd66da351c
44
_name: ''
55
fields:
@@ -26,5 +26,5 @@ asset:
2626
value: 24
2727
type: number
2828
custom: {}
29-
created: '2025-06-05T12:14:52.403835+00:00'
30-
modified: '2025-06-05T13:26:31.639979+00:00'
29+
created: '2025-05-26T08:40:45.988794+00:00'
30+
modified: '2025-06-05T14:41:54.108127+00:00'

apps/csk/content/asset/511356c8-8058-4312-9d7b-6d73218b67c1.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
asset:
2-
type: image
2+
type: other
33
_id: 511356c8-8058-4312-9d7b-6d73218b67c1
44
_name: ''
55
fields:
@@ -26,5 +26,5 @@ asset:
2626
value: 29
2727
type: number
2828
custom: {}
29-
created: '2025-01-29T11:08:52.824037+00:00'
30-
modified: '2025-06-05T13:26:33.548976+00:00'
29+
created: '2025-04-24T10:41:24.913841+00:00'
30+
modified: '2025-06-05T14:41:54.567064+00:00'

apps/csk/content/asset/7770ab14-93dd-46bb-9ef6-7dab66fff401.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
asset:
2-
type: other
2+
type: image
33
_id: 7770ab14-93dd-46bb-9ef6-7dab66fff401
44
_name: ''
55
fields:
@@ -26,5 +26,5 @@ asset:
2626
value: 24
2727
type: number
2828
custom: {}
29-
created: '2025-06-05T12:14:53.976389+00:00'
30-
modified: '2025-06-05T13:26:31.413125+00:00'
29+
created: '2025-05-26T08:40:46.276069+00:00'
30+
modified: '2025-06-05T14:41:53.852796+00:00'

apps/csk/content/asset/c13180f0-750f-4fc7-837e-46ade3070952.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
asset:
2-
type: other
2+
type: image
33
_id: c13180f0-750f-4fc7-837e-46ade3070952
44
_name: ''
55
fields:
@@ -26,5 +26,5 @@ asset:
2626
value: 24
2727
type: number
2828
custom: {}
29-
created: '2025-06-05T12:14:53.862+00:00'
30-
modified: '2025-06-05T13:26:31.696036+00:00'
29+
created: '2025-05-26T08:40:47.459882+00:00'
30+
modified: '2025-06-05T14:41:54.39118+00:00'

apps/csk/content/asset/e69c04dc-5c4f-4951-8102-08d9a8df8913.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
asset:
2-
type: image
2+
type: other
33
_id: e69c04dc-5c4f-4951-8102-08d9a8df8913
44
_name: ''
55
fields:
@@ -26,5 +26,5 @@ asset:
2626
value: 34
2727
type: number
2828
custom: {}
29-
created: '2025-02-05T09:08:07.205461+00:00'
30-
modified: '2025-06-05T13:26:31.921082+00:00'
29+
created: '2025-04-24T10:42:09.850151+00:00'
30+
modified: '2025-06-05T14:41:56.383215+00:00'
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# yaml-language-server: $schema=<https://uniform.app/schemas/json-schema/component-definition/v1.json>
2+
$schema: https://uniform.app/schemas/json-schema/component-definition/v1.json
3+
id: aiAssistant
4+
name: AI Assistant
5+
icon: ghost-character
6+
parameters:
7+
- id: starterPrompts
8+
name: Starter Prompts
9+
type: $block
10+
typeConfig:
11+
allowedTypes:
12+
- starterPrompt
13+
categoryId: 70d03350-bbf9-457d-abc0-cf7d7aa2a3a4
14+
previewImageUrl: >-
15+
https://res.cloudinary.com/uniform-demos/image/upload/csk-v-next/coffee-shop-template/preview-images/ai-assistant.jpg
16+
useTeamPermissions: true
17+
slots: []
18+
canBeComposition: false
19+
created: '2025-04-24T11:11:12.057056+00:00'
20+
updated: '2025-04-24T11:11:12.057056+00:00'

0 commit comments

Comments
 (0)