@nextsparkjs/theme-default 0.1.0-beta.29 → 0.1.0-beta.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/public/01-overview/01-introduction.md +5 -0
- package/docs/public/01-overview/02-customization.md +5 -0
- package/docs/public/02-features/03-tasks-entity.md +5 -0
- package/docs/public/03-ai/01-overview.md +5 -0
- package/docs/public/03-ai/02-customization.md +5 -0
- package/docs/superadmin/01-setup/01-configuration.md +5 -0
- package/docs/superadmin/01-setup/02-deployment.md +5 -0
- package/docs/superadmin/02-management/01-users.md +5 -0
- package/docs/superadmin/03-integrations/01-langchain.md +139 -0
- package/package.json +3 -3
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: AI Assistant Overview
|
|
3
|
+
description: Learn about the AI-powered assistant features and multi-agent architecture.
|
|
4
|
+
---
|
|
5
|
+
|
|
1
6
|
# AI Assistant - Overview
|
|
2
7
|
|
|
3
8
|
This theme includes an AI-powered assistant that helps users manage tasks, customers, and pages through natural language.
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Configuration
|
|
3
|
+
description: Environment variables and configuration options for NextSpark applications.
|
|
4
|
+
---
|
|
5
|
+
|
|
1
6
|
# Configuration Guide
|
|
2
7
|
|
|
3
8
|
This guide covers the configuration options available to administrators for setting up and customizing your NextSpark application.
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Langchain Integration
|
|
3
|
+
description: Configure and manage the AI-powered Langchain plugin for your application.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Langchain Integration
|
|
7
|
+
|
|
8
|
+
The Langchain plugin provides AI-powered capabilities to your application, including conversational agents, document processing, and intelligent automation.
|
|
9
|
+
|
|
10
|
+
## Overview
|
|
11
|
+
|
|
12
|
+
Langchain is integrated as a plugin that can be enabled per-theme. It provides:
|
|
13
|
+
|
|
14
|
+
- **Conversational AI**: Build chat interfaces with context-aware responses
|
|
15
|
+
- **Memory Management**: Persistent conversation history with PostgreSQL storage
|
|
16
|
+
- **Tool Integration**: Connect AI to your application's data and actions
|
|
17
|
+
- **Streaming Responses**: Real-time AI responses for better UX
|
|
18
|
+
|
|
19
|
+
## Configuration
|
|
20
|
+
|
|
21
|
+
### Environment Variables
|
|
22
|
+
|
|
23
|
+
Add the following to your `.env` file:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
# OpenAI API Key (required)
|
|
27
|
+
OPENAI_API_KEY=sk-your-api-key-here
|
|
28
|
+
|
|
29
|
+
# Optional: Model configuration
|
|
30
|
+
LANGCHAIN_MODEL=gpt-4o-mini
|
|
31
|
+
LANGCHAIN_TEMPERATURE=0.7
|
|
32
|
+
LANGCHAIN_MAX_TOKENS=2000
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Plugin Activation
|
|
36
|
+
|
|
37
|
+
Enable the plugin in your theme configuration:
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
// themes/{theme}/config/theme.config.ts
|
|
41
|
+
export const themeConfig = {
|
|
42
|
+
plugins: ['langchain'],
|
|
43
|
+
// ...
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Database Setup
|
|
48
|
+
|
|
49
|
+
The plugin requires a memory table for conversation persistence. Run the migration:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
pnpm db:migrate
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
This creates the `langchain_memory` table with the following schema:
|
|
56
|
+
|
|
57
|
+
| Column | Type | Description |
|
|
58
|
+
|--------|------|-------------|
|
|
59
|
+
| id | uuid | Primary key |
|
|
60
|
+
| sessionId | varchar | Conversation session identifier |
|
|
61
|
+
| messages | jsonb | Array of message objects |
|
|
62
|
+
| metadata | jsonb | Additional context data |
|
|
63
|
+
| createdAt | timestamp | Creation timestamp |
|
|
64
|
+
| updatedAt | timestamp | Last update timestamp |
|
|
65
|
+
|
|
66
|
+
## Usage
|
|
67
|
+
|
|
68
|
+
### Basic Chat Endpoint
|
|
69
|
+
|
|
70
|
+
The plugin exposes an API endpoint for chat interactions:
|
|
71
|
+
|
|
72
|
+
```typescript
|
|
73
|
+
// POST /api/v1/ai/chat
|
|
74
|
+
{
|
|
75
|
+
"message": "Hello, how can you help me?",
|
|
76
|
+
"sessionId": "user-123-session-456"
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Response:
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
{
|
|
84
|
+
"success": true,
|
|
85
|
+
"data": {
|
|
86
|
+
"response": "Hello! I'm here to help you with...",
|
|
87
|
+
"sessionId": "user-123-session-456"
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Streaming Responses
|
|
93
|
+
|
|
94
|
+
For real-time streaming:
|
|
95
|
+
|
|
96
|
+
```typescript
|
|
97
|
+
// POST /api/v1/ai/chat/stream
|
|
98
|
+
{
|
|
99
|
+
"message": "Explain quantum computing",
|
|
100
|
+
"sessionId": "user-123-session-456",
|
|
101
|
+
"stream": true
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Security Considerations
|
|
106
|
+
|
|
107
|
+
- **API Key Protection**: Never expose your OpenAI API key in client-side code
|
|
108
|
+
- **Rate Limiting**: Consider implementing rate limits per user/team
|
|
109
|
+
- **Content Filtering**: The plugin includes basic content moderation
|
|
110
|
+
- **Session Isolation**: Conversations are isolated by sessionId
|
|
111
|
+
|
|
112
|
+
## Monitoring
|
|
113
|
+
|
|
114
|
+
View AI usage statistics in the Superadmin dashboard:
|
|
115
|
+
|
|
116
|
+
1. Navigate to **Superadmin > Analytics** (coming soon)
|
|
117
|
+
2. Select the **AI Usage** tab
|
|
118
|
+
3. Monitor token usage, response times, and error rates
|
|
119
|
+
|
|
120
|
+
## Troubleshooting
|
|
121
|
+
|
|
122
|
+
### Common Issues
|
|
123
|
+
|
|
124
|
+
**"OPENAI_API_KEY not configured"**
|
|
125
|
+
- Ensure the environment variable is set
|
|
126
|
+
- Restart the development server after adding the key
|
|
127
|
+
|
|
128
|
+
**"Rate limit exceeded"**
|
|
129
|
+
- OpenAI has per-minute and per-day limits
|
|
130
|
+
- Consider implementing request queuing
|
|
131
|
+
|
|
132
|
+
**"Memory not persisting"**
|
|
133
|
+
- Verify the database migration ran successfully
|
|
134
|
+
- Check that `sessionId` is being passed consistently
|
|
135
|
+
|
|
136
|
+
## Related Documentation
|
|
137
|
+
|
|
138
|
+
- [Plugin System](/docs/plugins/overview)
|
|
139
|
+
- [API Authentication](/docs/api/authentication)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nextsparkjs/theme-default",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.31",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./config/theme.config.ts",
|
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
],
|
|
10
10
|
"dependencies": {},
|
|
11
11
|
"peerDependencies": {
|
|
12
|
-
"@nextsparkjs/core": "0.1.0-beta.24",
|
|
13
12
|
"@tanstack/react-query": "^5.0.0",
|
|
14
13
|
"lucide-react": "^0.539.0",
|
|
15
14
|
"next": "^15.0.0",
|
|
@@ -17,7 +16,8 @@
|
|
|
17
16
|
"react": "^19.0.0",
|
|
18
17
|
"react-dom": "^19.0.0",
|
|
19
18
|
"react-markdown": "^10.1.0",
|
|
20
|
-
"zod": "^4.0.0"
|
|
19
|
+
"zod": "^4.0.0",
|
|
20
|
+
"@nextsparkjs/core": "0.1.0-beta.31"
|
|
21
21
|
},
|
|
22
22
|
"nextspark": {
|
|
23
23
|
"type": "theme",
|