@vezlo/assistant-chat 1.0.0 → 1.1.0

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
@@ -19,8 +19,8 @@ export interface ConversationResponse {
19
19
  /**
20
20
  * Create a new conversation
21
21
  */
22
- export declare function createConversation(request: CreateConversationRequest): Promise<ConversationResponse>;
22
+ export declare function createConversation(request: CreateConversationRequest, apiUrl?: string): Promise<ConversationResponse>;
23
23
  /**
24
24
  * Get conversation by UUID
25
25
  */
26
- export declare function getConversation(uuid: string): Promise<ConversationResponse>;
26
+ 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',
@@ -68,7 +68,7 @@ export function Widget({ config, isPlayground = false, onOpen, onClose, onMessag
68
68
  title: 'New Chat',
69
69
  user_uuid: userUuid,
70
70
  company_uuid: companyUuid,
71
- });
71
+ }, config.apiUrl);
72
72
  setConversationUuid(conversation.uuid);
73
73
  console.log('[Widget] Conversation created:', conversation.uuid);
74
74
  // Add welcome message after conversation is created
@@ -123,13 +123,13 @@ export function Widget({ config, isPlayground = false, onOpen, onClose, onMessag
123
123
  // Step 1: Create user message via API
124
124
  const userMessageResponse = await createUserMessage(conversationUuid, {
125
125
  content: userMessageContent,
126
- });
126
+ }, config.apiUrl);
127
127
  console.log('[Widget] User message created:', userMessageResponse.uuid);
128
128
  // Update the user message with the actual UUID from server
129
129
  setMessages((prev) => prev.map((msg) => msg.id === userMessage.id ? { ...msg, id: userMessageResponse.uuid } : msg));
130
130
  // Step 2: Generate AI response
131
131
  // Keep loading indicator visible until AI response is received
132
- const aiResponse = await generateAIResponse(userMessageResponse.uuid);
132
+ const aiResponse = await generateAIResponse(userMessageResponse.uuid, config.apiUrl);
133
133
  console.log('[Widget] AI response received:', aiResponse.uuid);
134
134
  // Hide loading indicator now that we have the response
135
135
  setIsLoading(false);
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.0",
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
  };