@vezlo/assistant-chat 1.0.0 → 1.1.1

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/PACKAGE_README.md CHANGED
@@ -28,6 +28,8 @@ import { Widget } from '@vezlo/assistant-chat';
28
28
  function App() {
29
29
  const widgetConfig = {
30
30
  uuid: 'your-widget-uuid',
31
+ apiUrl: 'http://localhost:3000',
32
+ apiKey: 'your-api-key',
31
33
  title: 'AI Assistant',
32
34
  subtitle: 'How can I help you?',
33
35
  placeholder: 'Type your message...',
@@ -47,6 +49,8 @@ function App() {
47
49
  The `WidgetConfig` interface includes:
48
50
 
49
51
  - `uuid`: Unique identifier for your widget
52
+ - `apiUrl`: Assistant Server API URL (required for NPM package usage)
53
+ - `apiKey`: API key for authentication (required)
50
54
  - `title`: Header title
51
55
  - `subtitle`: Subtitle text
52
56
  - `placeholder`: Input placeholder text
@@ -129,6 +133,8 @@ function MyApp() {
129
133
  <h1>My Website</h1>
130
134
  <Widget config={{
131
135
  uuid: 'my-widget-123',
136
+ apiUrl: 'http://localhost:3000',
137
+ apiKey: 'your-api-key',
132
138
  title: 'Support Chat',
133
139
  themeColor: '#3b82f6',
134
140
  position: 'bottom-right',
@@ -157,6 +163,8 @@ function MyApp() {
157
163
  <Widget
158
164
  config={{
159
165
  uuid: 'my-widget-123',
166
+ apiUrl: 'http://localhost:3000',
167
+ apiKey: 'your-api-key',
160
168
  title: 'Support Chat',
161
169
  themeColor: '#3b82f6'
162
170
  }}
@@ -177,6 +185,8 @@ function MyApp() {
177
185
  <Widget
178
186
  config={{
179
187
  uuid: 'my-widget-123',
188
+ apiUrl: 'http://localhost:3000',
189
+ apiKey: 'your-api-key',
180
190
  title: 'Support Chat',
181
191
  themeColor: '#3b82f6'
182
192
  }}
package/README.md CHANGED
@@ -35,6 +35,8 @@ import { Widget } from '@vezlo/assistant-chat';
35
35
  function App() {
36
36
  const config = {
37
37
  uuid: 'your-widget-uuid',
38
+ apiUrl: 'http://localhost:3000',
39
+ apiKey: 'your-api-key',
38
40
  title: 'AI Assistant',
39
41
  themeColor: '#10b981',
40
42
  // ... other config
@@ -101,8 +103,17 @@ npm publish # Publish to NPM
101
103
 
102
104
  ### App (Vercel)
103
105
 
104
- #### One-Click Deploy
105
- [![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https://github.com/vezlo/assistant-chat)
106
+ #### Deploy via Vercel Marketplace (Recommended)
107
+ [![Install on Vercel](https://vercel.com/button)](https://vercel.com/marketplace/vezlo-assistant-chat)
108
+
109
+ The marketplace app deploys the frontend automatically, prompts you for the **Assistant Server URL** and optional **API key**, and ships both the chat UI and embeddable widget without any manual environment setup. After connecting your Vercel project you can immediately visit:
110
+
111
+ - Chat UI: `https://your-project.vercel.app/`
112
+
113
+ #### One-Click Deploy (GitHub Clone)
114
+ [![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https://github.com/vezlo/assistant-chat&integration-ids=oac_ZKcos500xraYgL9hH2d3Bs3A)
115
+
116
+ This clones the repo into your GitHub account, spins up a new Vercel project using the default `main` branch, and links the same Vezlo integration so the Assistant Chat deployment can gather its Assistant Server URL and API key during setup.
106
117
 
107
118
  #### Manual Vercel CLI Deployment
108
119
  ```bash
@@ -116,13 +127,6 @@ vercel
116
127
  vercel env add VITE_ASSISTANT_SERVER_URL
117
128
  vercel env add VITE_ASSISTANT_SERVER_API_KEY
118
129
 
119
- # Optional environment variables
120
- vercel env add VITE_DEFAULT_USER_UUID
121
- vercel env add VITE_DEFAULT_COMPANY_UUID
122
- vercel env add VITE_WIDGET_DEFAULT_THEME
123
- vercel env add VITE_WIDGET_DEFAULT_POSITION
124
- vercel env add VITE_WIDGET_DEFAULT_SIZE
125
-
126
130
  # Deploy to production
127
131
  vercel --prod
128
132
  ```
@@ -3,9 +3,7 @@
3
3
  * Handles conversation creation and management
4
4
  */
5
5
  export interface CreateConversationRequest {
6
- title: string;
7
- user_uuid: string;
8
- company_uuid: string;
6
+ title?: string;
9
7
  }
10
8
  export interface ConversationResponse {
11
9
  uuid: string;
@@ -19,8 +17,8 @@ export interface ConversationResponse {
19
17
  /**
20
18
  * Create a new conversation
21
19
  */
22
- export declare function createConversation(request: CreateConversationRequest): Promise<ConversationResponse>;
20
+ export declare function createConversation(request: CreateConversationRequest, apiUrl?: string): Promise<ConversationResponse>;
23
21
  /**
24
22
  * Get conversation by UUID
25
23
  */
26
- export declare function getConversation(uuid: string): Promise<ConversationResponse>;
24
+ export declare function getConversation(uuid: string, apiUrl?: string): Promise<ConversationResponse>;
@@ -2,11 +2,12 @@
2
2
  * Conversation API Service
3
3
  * Handles conversation creation and management
4
4
  */
5
- const API_BASE_URL = import.meta.env.VITE_ASSISTANT_SERVER_URL || 'http://localhost:3000';
5
+ const DEFAULT_API_BASE_URL = import.meta.env.VITE_ASSISTANT_SERVER_URL || 'http://localhost:3000';
6
6
  /**
7
7
  * Create a new conversation
8
8
  */
9
- export async function createConversation(request) {
9
+ export async function createConversation(request, apiUrl) {
10
+ const API_BASE_URL = apiUrl || DEFAULT_API_BASE_URL;
10
11
  try {
11
12
  const response = await fetch(`${API_BASE_URL}/api/conversations`, {
12
13
  method: 'POST',
@@ -31,7 +32,8 @@ export async function createConversation(request) {
31
32
  /**
32
33
  * Get conversation by UUID
33
34
  */
34
- export async function getConversation(uuid) {
35
+ export async function getConversation(uuid, apiUrl) {
36
+ const API_BASE_URL = apiUrl || DEFAULT_API_BASE_URL;
35
37
  try {
36
38
  const response = await fetch(`${API_BASE_URL}/api/conversations/${uuid}`, {
37
39
  method: 'GET',
@@ -23,8 +23,8 @@ export interface GenerateMessageResponse {
23
23
  /**
24
24
  * Create a user message in a conversation
25
25
  */
26
- export declare function createUserMessage(conversationUuid: string, request: CreateMessageRequest): Promise<MessageResponse>;
26
+ export declare function createUserMessage(conversationUuid: string, request: CreateMessageRequest, apiUrl?: string): Promise<MessageResponse>;
27
27
  /**
28
28
  * Generate AI response for a user message
29
29
  */
30
- export declare function generateAIResponse(userMessageUuid: string): Promise<GenerateMessageResponse>;
30
+ export declare function generateAIResponse(userMessageUuid: string, apiUrl?: string): Promise<GenerateMessageResponse>;
@@ -2,11 +2,12 @@
2
2
  * Message API Service
3
3
  * Handles message creation and AI response generation
4
4
  */
5
- const API_BASE_URL = import.meta.env.VITE_ASSISTANT_SERVER_URL || 'http://localhost:3000';
5
+ const DEFAULT_API_BASE_URL = import.meta.env.VITE_ASSISTANT_SERVER_URL || 'http://localhost:3000';
6
6
  /**
7
7
  * Create a user message in a conversation
8
8
  */
9
- export async function createUserMessage(conversationUuid, request) {
9
+ export async function createUserMessage(conversationUuid, request, apiUrl) {
10
+ const API_BASE_URL = apiUrl || DEFAULT_API_BASE_URL;
10
11
  try {
11
12
  const response = await fetch(`${API_BASE_URL}/api/conversations/${conversationUuid}/messages`, {
12
13
  method: 'POST',
@@ -31,7 +32,8 @@ export async function createUserMessage(conversationUuid, request) {
31
32
  /**
32
33
  * Generate AI response for a user message
33
34
  */
34
- export async function generateAIResponse(userMessageUuid) {
35
+ export async function generateAIResponse(userMessageUuid, apiUrl) {
36
+ const API_BASE_URL = apiUrl || DEFAULT_API_BASE_URL;
35
37
  try {
36
38
  const response = await fetch(`${API_BASE_URL}/api/messages/${userMessageUuid}/generate`, {
37
39
  method: 'POST',
@@ -62,13 +62,9 @@ export function Widget({ config, isPlayground = false, onOpen, onClose, onMessag
62
62
  setIsCreatingConversation(true);
63
63
  try {
64
64
  // Create a new conversation
65
- const userUuid = import.meta.env.VITE_DEFAULT_USER_UUID || 'user-' + generateId().substring(0, 8);
66
- const companyUuid = import.meta.env.VITE_DEFAULT_COMPANY_UUID || 'company-' + generateId().substring(0, 8);
67
65
  const conversation = await createConversation({
68
66
  title: 'New Chat',
69
- user_uuid: userUuid,
70
- company_uuid: companyUuid,
71
- });
67
+ }, config.apiUrl);
72
68
  setConversationUuid(conversation.uuid);
73
69
  console.log('[Widget] Conversation created:', conversation.uuid);
74
70
  // Add welcome message after conversation is created
@@ -123,13 +119,13 @@ export function Widget({ config, isPlayground = false, onOpen, onClose, onMessag
123
119
  // Step 1: Create user message via API
124
120
  const userMessageResponse = await createUserMessage(conversationUuid, {
125
121
  content: userMessageContent,
126
- });
122
+ }, config.apiUrl);
127
123
  console.log('[Widget] User message created:', userMessageResponse.uuid);
128
124
  // Update the user message with the actual UUID from server
129
125
  setMessages((prev) => prev.map((msg) => msg.id === userMessage.id ? { ...msg, id: userMessageResponse.uuid } : msg));
130
126
  // Step 2: Generate AI response
131
127
  // Keep loading indicator visible until AI response is received
132
- const aiResponse = await generateAIResponse(userMessageResponse.uuid);
128
+ const aiResponse = await generateAIResponse(userMessageResponse.uuid, config.apiUrl);
133
129
  console.log('[Widget] AI response received:', aiResponse.uuid);
134
130
  // Hide loading indicator now that we have the response
135
131
  setIsLoading(false);
@@ -46,9 +46,6 @@ export interface WidgetProps {
46
46
  export interface EnvConfig {
47
47
  VITE_ASSISTANT_SERVER_URL: string;
48
48
  VITE_ASSISTANT_SERVER_API_KEY: string;
49
- VITE_WIDGET_DEFAULT_THEME: 'light' | 'dark';
50
- VITE_WIDGET_DEFAULT_POSITION: string;
51
- VITE_WIDGET_DEFAULT_SIZE: string;
52
49
  VITE_DEV_MODE: boolean;
53
50
  VITE_DEBUG_MODE: boolean;
54
51
  }
@@ -10,9 +10,6 @@ export declare function parseSize(sizeString: string): {
10
10
  export declare function getEnvConfig(): {
11
11
  VITE_ASSISTANT_SERVER_URL: any;
12
12
  VITE_ASSISTANT_SERVER_API_KEY: any;
13
- VITE_WIDGET_DEFAULT_THEME: "light" | "dark";
14
- VITE_WIDGET_DEFAULT_POSITION: any;
15
- VITE_WIDGET_DEFAULT_SIZE: any;
16
13
  VITE_DEV_MODE: boolean;
17
14
  VITE_DEBUG_MODE: boolean;
18
15
  };
@@ -32,9 +32,6 @@ export function getEnvConfig() {
32
32
  return {
33
33
  VITE_ASSISTANT_SERVER_URL: import.meta.env.VITE_ASSISTANT_SERVER_URL || 'http://localhost:3000',
34
34
  VITE_ASSISTANT_SERVER_API_KEY: import.meta.env.VITE_ASSISTANT_SERVER_API_KEY || '',
35
- VITE_WIDGET_DEFAULT_THEME: import.meta.env.VITE_WIDGET_DEFAULT_THEME || 'light',
36
- VITE_WIDGET_DEFAULT_POSITION: import.meta.env.VITE_WIDGET_DEFAULT_POSITION || 'bottom-right',
37
- VITE_WIDGET_DEFAULT_SIZE: import.meta.env.VITE_WIDGET_DEFAULT_SIZE || '350x500',
38
35
  VITE_DEV_MODE: import.meta.env.VITE_DEV_MODE === 'true',
39
36
  VITE_DEBUG_MODE: import.meta.env.VITE_DEBUG_MODE === 'true'
40
37
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vezlo/assistant-chat",
3
- "version": "1.0.0",
3
+ "version": "1.1.1",
4
4
  "description": "React component library for AI-powered chat widgets with RAG knowledge base integration and real-time streaming",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
package/public/widget.js CHANGED
@@ -26,6 +26,7 @@
26
26
  }
27
27
 
28
28
  // Default configuration
29
+ // Note: apiUrl is NOT set here - it will be read from environment in the widget page
29
30
  const defaultConfig = {
30
31
  theme: 'light',
31
32
  position: 'bottom-right',
@@ -34,7 +35,6 @@
34
35
  subtitle: 'How can I help you today?',
35
36
  placeholder: 'Type your message...',
36
37
  welcomeMessage: "Hello! I'm your AI assistant. How can I help you today?",
37
- apiUrl: baseUrl,
38
38
  apiKey: '',
39
39
  themeColor: '#059669'
40
40
  };