@neuralbase/client 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/README.md CHANGED
@@ -20,6 +20,16 @@ const client = new NeuralBase({
20
20
  // Chat
21
21
  const response = await client.chat.neural.ask({ question: 'Hello!' });
22
22
  console.log(response.answer); // "Hello there!"
23
+
24
+ // Custom Endpoints
25
+ const customClient = new NeuralBase({
26
+ baseURL: 'https://api.your-domain.com',
27
+ endpoints: {
28
+ chat: '/api/v1/chat',
29
+ stt: '/api/v1/stt',
30
+ tts: '/api/v1/tts'
31
+ }
32
+ });
23
33
  ```
24
34
 
25
35
  ## API Reference
@@ -31,6 +41,15 @@ console.log(response.answer); // "Hello there!"
31
41
  | `baseURL` | `string` | _Required_ | API endpoint |
32
42
  | `timeout` | `number` | `30000` | Request timeout (ms) |
33
43
  | `contextId` | `string` | `undefined` | Default RAG context ID |
44
+ | `endpoints` | `object` | `{}` | Custom API paths (chat, stt, tts) |
45
+
46
+ #### Default Endpoints
47
+
48
+ | Feature | Path |
49
+ |---|---|
50
+ | Chat | `/chat/context` |
51
+ | STT | `/stt` |
52
+ | TTS | `/tts` |
34
53
 
35
54
  ### Methods
36
55
 
package/dist/index.d.mts CHANGED
@@ -2,6 +2,11 @@ interface NeuralBaseConfig {
2
2
  baseURL?: string;
3
3
  contextId?: string;
4
4
  timeout?: number;
5
+ endpoints?: {
6
+ chat?: string;
7
+ stt?: string;
8
+ tts?: string;
9
+ };
5
10
  }
6
11
  interface NeuralChatOptions {
7
12
  question: string;
@@ -63,6 +68,11 @@ declare class NeuralBase {
63
68
  readonly baseURL: string;
64
69
  readonly timeout: number;
65
70
  readonly contextId?: string;
71
+ readonly endpoints: {
72
+ chat: string;
73
+ stt: string;
74
+ tts: string;
75
+ };
66
76
  readonly chat: ChatModule;
67
77
  readonly voice: VoiceModule;
68
78
  constructor(config?: NeuralBaseConfig);
package/dist/index.d.ts CHANGED
@@ -2,6 +2,11 @@ interface NeuralBaseConfig {
2
2
  baseURL?: string;
3
3
  contextId?: string;
4
4
  timeout?: number;
5
+ endpoints?: {
6
+ chat?: string;
7
+ stt?: string;
8
+ tts?: string;
9
+ };
5
10
  }
6
11
  interface NeuralChatOptions {
7
12
  question: string;
@@ -63,6 +68,11 @@ declare class NeuralBase {
63
68
  readonly baseURL: string;
64
69
  readonly timeout: number;
65
70
  readonly contextId?: string;
71
+ readonly endpoints: {
72
+ chat: string;
73
+ stt: string;
74
+ tts: string;
75
+ };
66
76
  readonly chat: ChatModule;
67
77
  readonly voice: VoiceModule;
68
78
  constructor(config?: NeuralBaseConfig);
package/dist/index.js CHANGED
@@ -93,7 +93,7 @@ var ChatModule = class {
93
93
  ask: (options, contextIdOverride) => {
94
94
  const question = typeof options === "string" ? options : options.question;
95
95
  const contextId = (typeof options === "object" ? options.contextId : contextIdOverride) || this.client.contextId;
96
- return this.client.post("/chat/context", { question, contextId });
96
+ return this.client.post(this.client.endpoints.chat, { question, contextId });
97
97
  }
98
98
  };
99
99
  }
@@ -113,7 +113,7 @@ var VoiceModule = class {
113
113
  * Transcribe raw PCM audio data/Blob
114
114
  */
115
115
  transcribe: (audioData) => {
116
- return this.client.post("/stt", audioData, {
116
+ return this.client.post(this.client.endpoints.stt, audioData, {
117
117
  "Content-Type": "application/octet-stream"
118
118
  });
119
119
  }
@@ -129,7 +129,7 @@ var VoiceModule = class {
129
129
  * Returns an ArrayBuffer of the WAV file
130
130
  */
131
131
  generate: (text, options = {}) => {
132
- return this.client.post("/tts", { text, ...options });
132
+ return this.client.post(this.client.endpoints.tts, { text, ...options });
133
133
  }
134
134
  };
135
135
  }
@@ -141,6 +141,11 @@ var NeuralBase = class {
141
141
  this.baseURL = (config.baseURL || "/api").replace(/\/$/, "");
142
142
  this.timeout = config.timeout || 3e4;
143
143
  this.contextId = config.contextId;
144
+ this.endpoints = {
145
+ chat: config.endpoints?.chat || "/chat/context",
146
+ stt: config.endpoints?.stt || "/stt",
147
+ tts: config.endpoints?.tts || "/tts"
148
+ };
144
149
  this.chat = new ChatModule(this);
145
150
  this.voice = new VoiceModule(this);
146
151
  }
package/dist/index.mjs CHANGED
@@ -62,7 +62,7 @@ var ChatModule = class {
62
62
  ask: (options, contextIdOverride) => {
63
63
  const question = typeof options === "string" ? options : options.question;
64
64
  const contextId = (typeof options === "object" ? options.contextId : contextIdOverride) || this.client.contextId;
65
- return this.client.post("/chat/context", { question, contextId });
65
+ return this.client.post(this.client.endpoints.chat, { question, contextId });
66
66
  }
67
67
  };
68
68
  }
@@ -82,7 +82,7 @@ var VoiceModule = class {
82
82
  * Transcribe raw PCM audio data/Blob
83
83
  */
84
84
  transcribe: (audioData) => {
85
- return this.client.post("/stt", audioData, {
85
+ return this.client.post(this.client.endpoints.stt, audioData, {
86
86
  "Content-Type": "application/octet-stream"
87
87
  });
88
88
  }
@@ -98,7 +98,7 @@ var VoiceModule = class {
98
98
  * Returns an ArrayBuffer of the WAV file
99
99
  */
100
100
  generate: (text, options = {}) => {
101
- return this.client.post("/tts", { text, ...options });
101
+ return this.client.post(this.client.endpoints.tts, { text, ...options });
102
102
  }
103
103
  };
104
104
  }
@@ -110,6 +110,11 @@ var NeuralBase = class {
110
110
  this.baseURL = (config.baseURL || "/api").replace(/\/$/, "");
111
111
  this.timeout = config.timeout || 3e4;
112
112
  this.contextId = config.contextId;
113
+ this.endpoints = {
114
+ chat: config.endpoints?.chat || "/chat/context",
115
+ stt: config.endpoints?.stt || "/stt",
116
+ tts: config.endpoints?.tts || "/tts"
117
+ };
113
118
  this.chat = new ChatModule(this);
114
119
  this.voice = new VoiceModule(this);
115
120
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@neuralbase/client",
3
- "version": "1.0.0",
4
- "description": "Simple, secure frontend chat SDK for NeuralBase - just send questions, get answers (no API keys required)",
3
+ "version": "1.1.0",
4
+ "description": "Frontend chat SDK for NeuralBase.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
7
7
  "types": "dist/index.d.ts",
@@ -37,4 +37,4 @@
37
37
  "tsup": "^8.0.1",
38
38
  "typescript": "^5.3.3"
39
39
  }
40
- }
40
+ }