@insforge/sdk 1.1.1 → 1.1.2-edge.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/LICENSE +201 -201
- package/README.md +259 -259
- package/dist/index.d.mts +34 -4
- package/dist/index.d.ts +34 -4
- package/dist/index.js +55 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +55 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +68 -68
package/dist/index.mjs
CHANGED
|
@@ -577,6 +577,19 @@ var Auth = class {
|
|
|
577
577
|
const session = this.tokenManager.getSession();
|
|
578
578
|
if (session) {
|
|
579
579
|
this.http.setAuthToken(session.accessToken);
|
|
580
|
+
if (!session.user) {
|
|
581
|
+
try {
|
|
582
|
+
const authResponse = await this.http.get(
|
|
583
|
+
"/api/auth/sessions/current",
|
|
584
|
+
{ credentials: "include" }
|
|
585
|
+
);
|
|
586
|
+
if (authResponse.user) {
|
|
587
|
+
session.user = authResponse.user;
|
|
588
|
+
this.tokenManager.setUser(authResponse.user);
|
|
589
|
+
}
|
|
590
|
+
} catch {
|
|
591
|
+
}
|
|
592
|
+
}
|
|
580
593
|
return { data: { session }, error: null };
|
|
581
594
|
}
|
|
582
595
|
if (typeof window !== "undefined") {
|
|
@@ -1257,16 +1270,46 @@ var ChatCompletions = class {
|
|
|
1257
1270
|
* });
|
|
1258
1271
|
* console.log(completion.choices[0].message.content);
|
|
1259
1272
|
*
|
|
1260
|
-
* // With images
|
|
1273
|
+
* // With images (OpenAI-compatible format)
|
|
1261
1274
|
* const response = await client.ai.chat.completions.create({
|
|
1262
1275
|
* model: 'gpt-4-vision',
|
|
1263
1276
|
* messages: [{
|
|
1264
1277
|
* role: 'user',
|
|
1265
|
-
* content:
|
|
1266
|
-
*
|
|
1278
|
+
* content: [
|
|
1279
|
+
* { type: 'text', text: 'What is in this image?' },
|
|
1280
|
+
* { type: 'image_url', image_url: { url: 'https://example.com/image.jpg' } }
|
|
1281
|
+
* ]
|
|
1267
1282
|
* }]
|
|
1268
1283
|
* });
|
|
1269
1284
|
*
|
|
1285
|
+
* // With PDF files
|
|
1286
|
+
* const pdfResponse = await client.ai.chat.completions.create({
|
|
1287
|
+
* model: 'anthropic/claude-3.5-sonnet',
|
|
1288
|
+
* messages: [{
|
|
1289
|
+
* role: 'user',
|
|
1290
|
+
* content: [
|
|
1291
|
+
* { type: 'text', text: 'Summarize this document' },
|
|
1292
|
+
* { type: 'file', file: { filename: 'doc.pdf', file_data: 'https://example.com/doc.pdf' } }
|
|
1293
|
+
* ]
|
|
1294
|
+
* }],
|
|
1295
|
+
* fileParser: { enabled: true, pdf: { engine: 'mistral-ocr' } }
|
|
1296
|
+
* });
|
|
1297
|
+
*
|
|
1298
|
+
* // With web search
|
|
1299
|
+
* const searchResponse = await client.ai.chat.completions.create({
|
|
1300
|
+
* model: 'openai/gpt-4',
|
|
1301
|
+
* messages: [{ role: 'user', content: 'What are the latest news about AI?' }],
|
|
1302
|
+
* webSearch: { enabled: true, maxResults: 5 }
|
|
1303
|
+
* });
|
|
1304
|
+
* // Access citations from response.choices[0].message.annotations
|
|
1305
|
+
*
|
|
1306
|
+
* // With thinking/reasoning mode (Anthropic models)
|
|
1307
|
+
* const thinkingResponse = await client.ai.chat.completions.create({
|
|
1308
|
+
* model: 'anthropic/claude-3.5-sonnet',
|
|
1309
|
+
* messages: [{ role: 'user', content: 'Solve this complex math problem...' }],
|
|
1310
|
+
* thinking: true
|
|
1311
|
+
* });
|
|
1312
|
+
*
|
|
1270
1313
|
* // Streaming - returns async iterable
|
|
1271
1314
|
* const stream = await client.ai.chat.completions.create({
|
|
1272
1315
|
* model: 'gpt-4',
|
|
@@ -1288,7 +1331,11 @@ var ChatCompletions = class {
|
|
|
1288
1331
|
temperature: params.temperature,
|
|
1289
1332
|
maxTokens: params.maxTokens,
|
|
1290
1333
|
topP: params.topP,
|
|
1291
|
-
stream: params.stream
|
|
1334
|
+
stream: params.stream,
|
|
1335
|
+
// New plugin options
|
|
1336
|
+
webSearch: params.webSearch,
|
|
1337
|
+
fileParser: params.fileParser,
|
|
1338
|
+
thinking: params.thinking
|
|
1292
1339
|
};
|
|
1293
1340
|
if (params.stream) {
|
|
1294
1341
|
const headers = this.http.getHeaders();
|
|
@@ -1322,7 +1369,9 @@ var ChatCompletions = class {
|
|
|
1322
1369
|
index: 0,
|
|
1323
1370
|
message: {
|
|
1324
1371
|
role: "assistant",
|
|
1325
|
-
content
|
|
1372
|
+
content,
|
|
1373
|
+
// Include annotations if present (from web search or file parsing)
|
|
1374
|
+
...response.annotations && { annotations: response.annotations }
|
|
1326
1375
|
},
|
|
1327
1376
|
finish_reason: "stop"
|
|
1328
1377
|
}
|
|
@@ -1755,8 +1804,7 @@ var InsForgeClient = class {
|
|
|
1755
1804
|
this.http.setAuthToken(config.edgeFunctionToken);
|
|
1756
1805
|
this.tokenManager.saveSession({
|
|
1757
1806
|
accessToken: config.edgeFunctionToken,
|
|
1758
|
-
user:
|
|
1759
|
-
// Will be populated by getCurrentUser()
|
|
1807
|
+
user: null
|
|
1760
1808
|
});
|
|
1761
1809
|
}
|
|
1762
1810
|
const existingSession = this.tokenManager.getSession();
|