Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion apps/csk/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,10 @@ UNIFORM_PREVIEW_SECRET=hello-world
# defaults to localhost:3000 if not set.
#When set, should resolve to the base url of the app.
# This is used to generate the sitemap and robots.txt
BASE_URL=
BASE_URL=

# OpenAI API key
OPENAI_API_KEY=

# Postgres data base url
DATABASE_URL=
52 changes: 52 additions & 0 deletions apps/csk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,58 @@ This integration brings new parameter types for design and layout control via Un
![Your project](https://res.cloudinary.com/uniform-demos/image/upload/csk-v-next/doc/project_page.png)
1. Navigate to the `Integrations` tab, find the `Design Extensions` integration and install it.

## 🚀 RAG integration

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.

### Step 4. Create a Postgres database

You will need a **Postgres** database to complete this tutorial. If you don’t have Postgres locally you can either:

- Spin up a **free Postgres** instance on [Vercel Postgres](https://vercel.com/postgres).
- Follow [this guide](https://www.postgresqltutorial.com/install-postgresql/) to install Postgres locally.

Once your database is ready, copy its connection string – you’ll need it in the next step.

### Step 5. Migrate the database

1. Open `.env` and paste your **database connection string** after the `DATABASE_URL=` key.
1. Run the migration:

```bash
npm run db:migrate
```

The script will:

- Enable the `pgvector` extension.
- Create tables for the `resources` and `embeddings` schema defined in `src/module/chat/rag/schema` with necessary columns.

1. Fill the data to database:
```bash
npm run db:load
```

### Step 6. Add your OpenAI API key

Some starter features – like AI-Assistant and RAG integration – require an **OpenAI API key**.

1. Generate a key in your OpenAI dashboard: <https://platform.openai.com>.
1. Add it to `.env`:
```bash
OPENAI_API_KEY=
```

### Step 7. Add Webhook (Additional)

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.

1. Open Settings → Webhooks
1. Set the Endpoint URL to: `https://your_domain/api/webhook/entry-event`
1. Enable the following events:
- entry.published
- entry.deleted

## How to sync content

The following scripts are created to facilitate sync of content between the `./content` folder and your project.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
asset:
type: image
type: other
_id: 0aafe2e9-468c-43e1-81f3-fda6c02388e7
_name: ''
fields:
Expand All @@ -26,5 +26,5 @@ asset:
value: 1059
type: number
custom: {}
created: '2025-05-20T11:52:45.655676+00:00'
modified: '2025-05-20T11:52:45.655676+00:00'
created: '2025-05-26T08:40:43.349414+00:00'
modified: '2025-05-26T08:40:43.349414+00:00'
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
asset:
type: image
type: other
_id: 1697b6ae-aa6f-4bd6-b844-c8fb3c86216c
_name: ''
fields:
Expand All @@ -26,5 +26,5 @@ asset:
value: 24
type: number
custom: {}
created: '2025-05-20T11:52:45.084371+00:00'
modified: '2025-05-20T11:52:45.084371+00:00'
created: '2025-05-26T08:40:43.907922+00:00'
modified: '2025-05-26T08:40:43.907922+00:00'
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
asset:
type: other
type: image
_id: 4469d093-0095-43fe-a6f1-9ccd66da351c
_name: ''
fields:
Expand All @@ -26,5 +26,5 @@ asset:
value: 24
type: number
custom: {}
created: '2025-06-05T12:14:52.403835+00:00'
modified: '2025-06-05T13:26:31.639979+00:00'
created: '2025-05-26T08:40:45.988794+00:00'
modified: '2025-06-05T14:41:54.108127+00:00'
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
asset:
type: image
type: other
_id: 511356c8-8058-4312-9d7b-6d73218b67c1
_name: ''
fields:
Expand All @@ -26,5 +26,5 @@ asset:
value: 29
type: number
custom: {}
created: '2025-01-29T11:08:52.824037+00:00'
modified: '2025-06-05T13:26:33.548976+00:00'
created: '2025-04-24T10:41:24.913841+00:00'
modified: '2025-06-05T14:41:54.567064+00:00'
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
asset:
type: other
type: image
_id: 7770ab14-93dd-46bb-9ef6-7dab66fff401
_name: ''
fields:
Expand All @@ -26,5 +26,5 @@ asset:
value: 24
type: number
custom: {}
created: '2025-06-05T12:14:53.976389+00:00'
modified: '2025-06-05T13:26:31.413125+00:00'
created: '2025-05-26T08:40:46.276069+00:00'
modified: '2025-06-05T14:41:53.852796+00:00'
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
asset:
type: other
type: image
_id: c13180f0-750f-4fc7-837e-46ade3070952
_name: ''
fields:
Expand All @@ -26,5 +26,5 @@ asset:
value: 24
type: number
custom: {}
created: '2025-06-05T12:14:53.862+00:00'
modified: '2025-06-05T13:26:31.696036+00:00'
created: '2025-05-26T08:40:47.459882+00:00'
modified: '2025-06-05T14:41:54.39118+00:00'
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
asset:
type: image
type: other
_id: e69c04dc-5c4f-4951-8102-08d9a8df8913
_name: ''
fields:
Expand All @@ -26,5 +26,5 @@ asset:
value: 34
type: number
custom: {}
created: '2025-02-05T09:08:07.205461+00:00'
modified: '2025-06-05T13:26:31.921082+00:00'
created: '2025-04-24T10:42:09.850151+00:00'
modified: '2025-06-05T14:41:56.383215+00:00'
20 changes: 20 additions & 0 deletions apps/csk/content/component/aiAssistant.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# yaml-language-server: $schema=<https://uniform.app/schemas/json-schema/component-definition/v1.json>
$schema: https://uniform.app/schemas/json-schema/component-definition/v1.json
id: aiAssistant
name: AI Assistant
icon: ghost-character
parameters:
- id: starterPrompts
name: Starter Prompts
type: $block
typeConfig:
allowedTypes:
- starterPrompt
categoryId: 70d03350-bbf9-457d-abc0-cf7d7aa2a3a4
previewImageUrl: >-
https://res.cloudinary.com/uniform-demos/image/upload/csk-v-next/coffee-shop-template/preview-images/ai-assistant.jpg
useTeamPermissions: true
slots: []
canBeComposition: false
created: '2025-04-24T11:11:12.057056+00:00'
updated: '2025-04-24T11:11:12.057056+00:00'
20 changes: 20 additions & 0 deletions apps/csk/content/component/aiConfiguration.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# yaml-language-server: $schema=<https://uniform.app/schemas/json-schema/component-definition/v1.json>
$schema: https://uniform.app/schemas/json-schema/component-definition/v1.json
id: aiConfiguration
name: AI Configuration
icon: asterisk
parameters: []
categoryId: c7a1d1d9-cc3f-431c-b55e-6c4af1285108
previewImageUrl: >-
https://res.cloudinary.com/uniform-demos/image/upload/csk-v-next/coffee-shop-template/preview-images/ai-configuration.jpg
useTeamPermissions: true
slots:
- id: content
name: Content
allowedComponents: []
allowAllComponents: true
inheritAllowedComponents: false
patternsInAllowedComponents: false
canBeComposition: true
created: '2025-04-24T11:28:17.821117+00:00'
updated: '2025-04-24T11:28:55.575968+00:00'
20 changes: 20 additions & 0 deletions apps/csk/content/component/assistantScrollSection.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# yaml-language-server: $schema=<https://uniform.app/schemas/json-schema/component-definition/v1.json>
$schema: https://uniform.app/schemas/json-schema/component-definition/v1.json
id: assistantScrollSection
name: Assistant Scroll Section
icon: rename
parameters: []
categoryId: 096fd5ed-5e2a-4bfa-834b-fb805d1d1ce9
previewImageUrl: >-
https://res.cloudinary.com/uniform-demos/image/upload/csk-v-next/coffee-shop-template/preview-images/assistant-scroll-section.jpg
useTeamPermissions: true
slots:
- id: content
name: Content
allowedComponents: []
allowAllComponents: true
inheritAllowedComponents: false
patternsInAllowedComponents: false
canBeComposition: false
created: '2025-04-28T12:03:20.971965+00:00'
updated: '2025-04-28T12:03:52.061783+00:00'
2 changes: 1 addition & 1 deletion apps/csk/content/component/header.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ slots:
- navigationLink
- shoppingCartIcon
- favoritesIcon
- aiShoppingAssistantButton
- aiAssistant
allowAllComponents: false
inheritAllowedComponents: false
patternsInAllowedComponents: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,50 @@ composition:
value: contrast-[.1]
_overridability:
hideLockedParameters: true
- _id: 741a47a4-4c3c-4242-bf1a-4c8455fdef37
type: aiAssistant
parameters:
starterPrompts:
type: $block
value:
- _id: 91405084-7665-4771-b7e0-6172a37484c0
type: starterPrompt
fields:
value:
type: text
value: Could you show me what’s in my shopping cart right now?
- _id: 13d4f026-9713-4150-874e-b8b0513da1f2
type: starterPrompt
fields:
value:
type: text
value: >-
Based on what I like, do you have any recommendations for
me?
- _id: 4a765cc7-2cc9-445a-aa7c-eb051b223a51
type: starterPrompt
fields:
value:
type: text
value: >-
Hey, could you take a look at my shopping cart and suggest
a few products that might suit me?
- _id: 010c7d9c-e45e-4f21-9059-a0261002f95b
type: starterPrompt
fields:
value:
type: text
value: Trying to improve bean grinding technique
- _id: f7108251-4567-4387-8306-8c592fdf27ea
type: starterPrompt
fields:
value:
type: text
value: >-
I am looking for an espresso machine that gives me
precision grinding
_overridability:
hideLockedParameters: true
headerCenterContent:
- _id: 5832d439-1459-4a01-b422-fd1e66a71cbb
type: navigationLink
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
composition:
_name: Product Recommendation
_id: 19ea7368-29fc-4e61-b730-b78ee47e74de
type: link
parameters:
link:
type: link
value:
path: /${locale}/products/${#jptr:/Single Product Content/entry/_slug}
type: projectMapNode
nodeId: 702b0e0b-3858-4b5d-99e4-bdb98097ca0f
projectMapId: 537d11ff-9ebe-4420-9682-36694477e2f9
dynamicInputValues:
locale: ${locale}
product-slug: ${#jptr:/Single Product Content/entry/_slug}
displayName:
type: text
locales:
en: ${#jptr:/Single Product Content/entry/_name}
slots:
linkContent:
- _id: baf65f29-3f6b-460f-8206-f46f74460edd
type: card
_pattern: 665b55aa-f241-413e-8778-cff9a2f1f8aa
_dataResources:
Single Product Content:
type: singleProduct
variables:
locale: ${locale}
entryId: efc7afec-03c4-4fd4-b478-a32708f5852e
isPatternParameter: true
ignorePatternParameterDefault: true
_overrides:
baf65f29-3f6b-460f-8206-f46f74460edd:
parameters:
displayName:
type: text
locales:
en: ${#jptr:/Single Product Content/entry/_name}
baf65f29-3f6b-460f-8206-f46f74460edd|0952417a-061c-4634-91df-1341269e4054:
parameters:
image:
type: asset
value: ${#jptr:/Single Product Content/entry/fields/primaryImage/value}
baf65f29-3f6b-460f-8206-f46f74460edd|8bad3ddd-add0-43d3-a314-5836bf0c7a93:
parameters:
text:
type: text
value: >-
${#jptr:/Single Product
Content/entry/fields/variants/value/0/fields/currency/value}
${#jptr:/Single Product
Content/entry/fields/variants/value/0/fields/price/value}
baf65f29-3f6b-460f-8206-f46f74460edd|988f7805-9e0e-4b30-acaf-f97d7dd5099f:
parameters:
text:
type: text
value: >-
Vintage Drip Coffee Maker${#jptr:/Single Product
Content/entry/fields/variants/value/0/fields/title/value}
_overridability:
hideLockedParameters: true
_locales:
- en
created: '2025-03-18T20:14:39.454454+00:00'
modified: '2025-03-18T20:23:09.769177+00:00'
pattern: true
previewImageUrl: >-
https://res.cloudinary.com/uniform-demos/image/upload/v1731065901/csk-v-next/jd-template/product-card.jpg
categoryId: 096fd5ed-5e2a-4bfa-834b-fb805d1d1ce9
Loading