@devvibex/aiflow 1.0.2 → 1.0.3
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.json +1 -1
- package/src/index.js +15 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devvibex/aiflow",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "First-party LLM gateway SDK for apps generated on the VibeX platform — chat, streaming, image generation and embeddings without shipping any third-party API key.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
package/src/index.js
CHANGED
|
@@ -124,6 +124,17 @@ export class AIFlowClient {
|
|
|
124
124
|
return cfg.defaults[kind];
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
+
/**
|
|
128
|
+
* Resolve the system prompt: user-provided > server config > null.
|
|
129
|
+
* If user provides a system prompt, it always wins.
|
|
130
|
+
* If not, use the systemPrompt from the server config.
|
|
131
|
+
*/
|
|
132
|
+
async _resolveSystemPrompt(userSystem) {
|
|
133
|
+
if (userSystem) return userSystem;
|
|
134
|
+
const cfg = await this.getConfig();
|
|
135
|
+
return cfg.systemPrompt || null;
|
|
136
|
+
}
|
|
137
|
+
|
|
127
138
|
/**
|
|
128
139
|
* Non-streaming chat completion.
|
|
129
140
|
* @returns {Promise<{id:string, model:string, content:string, usage:{inputTokens:number,outputTokens:number,creditsUsed:number}}>}
|
|
@@ -141,11 +152,12 @@ export class AIFlowClient {
|
|
|
141
152
|
throw new AIFlowError('messages must be a non-empty array');
|
|
142
153
|
}
|
|
143
154
|
const resolvedModel = model || (await this._resolveDefaultModel('chat'));
|
|
155
|
+
const resolvedSystem = await this._resolveSystemPrompt(system);
|
|
144
156
|
const res = await this._request(
|
|
145
157
|
'/chat',
|
|
146
158
|
{
|
|
147
159
|
model: resolvedModel,
|
|
148
|
-
system,
|
|
160
|
+
system: resolvedSystem,
|
|
149
161
|
messages,
|
|
150
162
|
maxTokens,
|
|
151
163
|
temperature,
|
|
@@ -173,11 +185,12 @@ export class AIFlowClient {
|
|
|
173
185
|
throw new AIFlowError('messages must be a non-empty array');
|
|
174
186
|
}
|
|
175
187
|
const resolvedModel = model || (await this._resolveDefaultModel('chat'));
|
|
188
|
+
const resolvedSystem = await this._resolveSystemPrompt(system);
|
|
176
189
|
const res = await this._request(
|
|
177
190
|
'/chat/stream',
|
|
178
191
|
{
|
|
179
192
|
model: resolvedModel,
|
|
180
|
-
system,
|
|
193
|
+
system: resolvedSystem,
|
|
181
194
|
messages,
|
|
182
195
|
maxTokens,
|
|
183
196
|
temperature,
|