-
Notifications
You must be signed in to change notification settings - Fork 6
Add metadata extension protocol for plugin extensibility #215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| --- | ||
| title: AIFieldExtension | ||
| description: AIFieldExtension Schema Reference | ||
| --- | ||
|
|
||
| ## Properties | ||
|
|
||
| | Property | Type | Required | Description | | ||
| | :--- | :--- | :--- | :--- | | ||
| | **ai_assistant.vectorIndexed** | `boolean` | optional | | | ||
| | **ai_assistant.embeddingModel** | `string` | optional | | | ||
| | **ai_assistant.chunkSize** | `number` | optional | | | ||
| | **ai_assistant.chunkOverlap** | `number` | optional | | | ||
| | **ai_assistant.autoSummarize** | `boolean` | optional | | | ||
| | **ai_assistant.summaryModel** | `string` | optional | | | ||
| | **ai_assistant.summaryMaxLength** | `number` | optional | | | ||
| | **ai_assistant.sentimentAnalysis** | `boolean` | optional | | | ||
| | **ai_assistant.sentimentField** | `string` | optional | | |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| { | ||
| "title": "Field Extensions" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| --- | ||
| title: AIObjectExtension | ||
| description: AIObjectExtension Schema Reference | ||
| --- | ||
|
|
||
| ## Properties | ||
|
|
||
| | Property | Type | Required | Description | | ||
| | :--- | :--- | :--- | :--- | | ||
| | **ai_assistant.enableRAG** | `boolean` | optional | | | ||
| | **ai_assistant.contextFields** | `string[]` | optional | | | ||
| | **ai_assistant.vectorIndex** | `string` | optional | | | ||
| | **ai_assistant.embeddingModel** | `string` | optional | | | ||
| | **ai_assistant.agentEnabled** | `boolean` | optional | | | ||
| | **ai_assistant.agentName** | `string` | optional | | | ||
| | **ai_assistant.agentTriggers** | `string[]` | optional | | | ||
| | **ai_assistant.predictiveEnabled** | `boolean` | optional | | | ||
| | **ai_assistant.predictiveModels** | `any[]` | optional | | | ||
| | **ai_assistant.autoClassification** | `boolean` | optional | | | ||
| | **ai_assistant.classificationField** | `string` | optional | | | ||
| | **ai_assistant.classificationModel** | `string` | optional | | | ||
| | **ai_assistant.classificationPrompt** | `string` | optional | | | ||
| | **ai_assistant.dataQualityEnabled** | `boolean` | optional | | | ||
| | **ai_assistant.dataQualityRules** | `any[]` | optional | | |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| { | ||
| "title": "Object Extensions" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| --- | ||
| title: ExtensionDefinition | ||
| description: ExtensionDefinition Schema Reference | ||
| --- | ||
|
|
||
| ## Properties | ||
|
|
||
| | Property | Type | Required | Description | | ||
| | :--- | :--- | :--- | :--- | | ||
| | **key** | `string` | ✅ | Fully qualified extension key (e.g., "ai_assistant.vectorIndexed") | | ||
| | **pluginId** | `string` | ✅ | ID of the plugin providing this extension | | ||
| | **label** | `string` | ✅ | Display label for the extension property | | ||
| | **description** | `string` | optional | Detailed description of the extension | | ||
| | **type** | `Enum<'string' \| 'number' \| 'boolean' \| 'object' \| 'array' \| 'any'>` | ✅ | Expected data type for this extension | | ||
| | **default** | `any` | optional | Default value for this extension | | ||
| | **appliesTo** | `Enum<'object' \| 'field' \| 'view' \| 'app' \| 'dashboard' \| 'report' \| 'action' \| 'workflow'>[]` | ✅ | Metadata types this extension can be applied to | | ||
| | **fieldTypes** | `string[]` | optional | Applicable field types (for field extensions) | | ||
| | **required** | `boolean` | optional | Whether this extension is required | | ||
| | **schema** | `any` | optional | JSON Schema for advanced validation | |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| --- | ||
| title: ExtensionRegistry | ||
| description: ExtensionRegistry Schema Reference | ||
| --- | ||
|
|
||
| ## Properties | ||
|
|
||
| | Property | Type | Required | Description | | ||
| | :--- | :--- | :--- | :--- | | ||
| | **extensions** | `Record<string, object>` | ✅ | Registry of available extension definitions | |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| title: ExtensionValue | ||
| description: ExtensionValue Schema Reference | ||
| --- | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| title: ExtensionsMap | ||
| description: Custom extension properties from plugins and modules | ||
| --- | ||
|
|
||
| Custom extension properties from plugins and modules | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| { | ||
| "title": "Extension" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |
| "pages": [ | ||
| "audit", | ||
| "events", | ||
| "extension", | ||
| "job", | ||
| "translation" | ||
| ] | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| # AI-Powered Customer Service Example | ||
|
|
||
| This example demonstrates how to use ObjectStack's metadata extension mechanism to build an AI-powered customer service system. | ||
|
|
||
| ## Features | ||
|
|
||
| ### Field-Level AI Extensions | ||
| - **Vector Indexing**: Enable semantic search on text fields | ||
| - **Auto-Summarization**: Automatically generate summaries of long descriptions | ||
| - **Sentiment Analysis**: Analyze sentiment of customer feedback | ||
|
|
||
| ### Object-Level AI Extensions | ||
| - **RAG (Retrieval-Augmented Generation)**: Enable context-aware AI responses | ||
| - **AI Agent Integration**: Automatic agent assistance on create/update | ||
| - **Auto-Classification**: Automatically categorize inquiries | ||
| - **Data Quality Checks**: AI-powered data validation | ||
|
|
||
| ## Objects | ||
|
|
||
| 1. **Customer Inquiry** - Support tickets with full AI assistance | ||
| 2. **Knowledge Article** - RAG-enabled knowledge base | ||
|
|
||
| ## Running the Example | ||
|
|
||
| ```bash | ||
| cd examples/ai-customer-service | ||
| npm install | ||
| npm run example | ||
| ``` | ||
|
|
||
| ## Usage | ||
|
|
||
| See `index.ts` for the complete implementation. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| /** | ||
| * AI-Powered Customer Service Example | ||
| * | ||
| * Demonstrates ObjectStack metadata extensions for AI capabilities | ||
| */ | ||
|
|
||
| import { ObjectSchema, Extension } from '@objectstack/spec'; | ||
|
||
|
|
||
| // Customer Inquiry Object with AI extensions | ||
| export const customerInquiryObject = { | ||
| name: 'customer_inquiry', | ||
| label: 'Customer Inquiry', | ||
| fields: { | ||
| title: { | ||
| name: 'title', | ||
| label: 'Title', | ||
| type: 'text' as const, | ||
| required: true, | ||
| extensions: { | ||
| 'ai_assistant.vectorIndexed': true, | ||
| 'ai_assistant.embeddingModel': 'text-embedding-3-small', | ||
| }, | ||
| }, | ||
| description: { | ||
| name: 'description', | ||
| label: 'Description', | ||
| type: 'textarea' as const, | ||
| extensions: { | ||
| 'ai_assistant.vectorIndexed': true, | ||
| 'ai_assistant.autoSummarize': true, | ||
| }, | ||
| }, | ||
| }, | ||
| extensions: { | ||
| 'ai_assistant.enableRAG': true, | ||
| 'ai_assistant.contextFields': ['title', 'description'], | ||
| 'ai_assistant.agentEnabled': true, | ||
| }, | ||
| }; | ||
|
|
||
| // Validate | ||
| const validated = ObjectSchema.parse(customerInquiryObject); | ||
| console.log('✓ Schema validated with AI extensions'); | ||
| console.log('RAG Enabled:', Extension.get(validated.extensions, 'ai_assistant.enableRAG')); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| { | ||
| "$ref": "#/definitions/AIFieldExtension", | ||
| "definitions": { | ||
| "AIFieldExtension": { | ||
| "type": "object", | ||
| "properties": { | ||
| "ai_assistant.vectorIndexed": { | ||
| "type": "boolean" | ||
| }, | ||
| "ai_assistant.embeddingModel": { | ||
| "type": "string" | ||
| }, | ||
| "ai_assistant.chunkSize": { | ||
| "type": "number" | ||
| }, | ||
| "ai_assistant.chunkOverlap": { | ||
| "type": "number" | ||
| }, | ||
| "ai_assistant.autoSummarize": { | ||
| "type": "boolean" | ||
| }, | ||
| "ai_assistant.summaryModel": { | ||
| "type": "string" | ||
| }, | ||
| "ai_assistant.summaryMaxLength": { | ||
| "type": "number" | ||
| }, | ||
| "ai_assistant.sentimentAnalysis": { | ||
| "type": "boolean" | ||
| }, | ||
| "ai_assistant.sentimentField": { | ||
| "type": "string" | ||
| } | ||
| }, | ||
| "additionalProperties": false | ||
| } | ||
| }, | ||
| "$schema": "http://json-schema.org/draft-07/schema#" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| { | ||
| "$ref": "#/definitions/AIObjectExtension", | ||
| "definitions": { | ||
| "AIObjectExtension": { | ||
| "type": "object", | ||
| "properties": { | ||
| "ai_assistant.enableRAG": { | ||
| "type": "boolean" | ||
| }, | ||
| "ai_assistant.contextFields": { | ||
| "type": "array", | ||
| "items": { | ||
| "type": "string" | ||
| } | ||
| }, | ||
| "ai_assistant.vectorIndex": { | ||
| "type": "string" | ||
| }, | ||
| "ai_assistant.embeddingModel": { | ||
| "type": "string" | ||
| }, | ||
| "ai_assistant.agentEnabled": { | ||
| "type": "boolean" | ||
| }, | ||
| "ai_assistant.agentName": { | ||
| "type": "string" | ||
| }, | ||
| "ai_assistant.agentTriggers": { | ||
| "type": "array", | ||
| "items": { | ||
| "type": "string" | ||
| } | ||
| }, | ||
| "ai_assistant.predictiveEnabled": { | ||
| "type": "boolean" | ||
| }, | ||
| "ai_assistant.predictiveModels": { | ||
| "type": "array" | ||
| }, | ||
| "ai_assistant.autoClassification": { | ||
| "type": "boolean" | ||
| }, | ||
| "ai_assistant.classificationField": { | ||
| "type": "string" | ||
| }, | ||
| "ai_assistant.classificationModel": { | ||
| "type": "string" | ||
| }, | ||
| "ai_assistant.classificationPrompt": { | ||
| "type": "string" | ||
| }, | ||
| "ai_assistant.dataQualityEnabled": { | ||
| "type": "boolean" | ||
| }, | ||
| "ai_assistant.dataQualityRules": { | ||
| "type": "array" | ||
| } | ||
| }, | ||
| "additionalProperties": false | ||
| } | ||
| }, | ||
| "$schema": "http://json-schema.org/draft-07/schema#" | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The run instructions assume
npm install/npm run exampleinsideexamples/ai-customer-service, but this folder currently has nopackage.json, so these steps won’t work. Either add a minimalpackage.json/script for the example or update the README to match the actual way examples are executed in this repo (e.g. via the monorepo root).