@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.js
CHANGED
|
@@ -616,6 +616,19 @@ var Auth = class {
|
|
|
616
616
|
const session = this.tokenManager.getSession();
|
|
617
617
|
if (session) {
|
|
618
618
|
this.http.setAuthToken(session.accessToken);
|
|
619
|
+
if (!session.user) {
|
|
620
|
+
try {
|
|
621
|
+
const authResponse = await this.http.get(
|
|
622
|
+
"/api/auth/sessions/current",
|
|
623
|
+
{ credentials: "include" }
|
|
624
|
+
);
|
|
625
|
+
if (authResponse.user) {
|
|
626
|
+
session.user = authResponse.user;
|
|
627
|
+
this.tokenManager.setUser(authResponse.user);
|
|
628
|
+
}
|
|
629
|
+
} catch {
|
|
630
|
+
}
|
|
631
|
+
}
|
|
619
632
|
return { data: { session }, error: null };
|
|
620
633
|
}
|
|
621
634
|
if (typeof window !== "undefined") {
|
|
@@ -1296,16 +1309,46 @@ var ChatCompletions = class {
|
|
|
1296
1309
|
* });
|
|
1297
1310
|
* console.log(completion.choices[0].message.content);
|
|
1298
1311
|
*
|
|
1299
|
-
* // With images
|
|
1312
|
+
* // With images (OpenAI-compatible format)
|
|
1300
1313
|
* const response = await client.ai.chat.completions.create({
|
|
1301
1314
|
* model: 'gpt-4-vision',
|
|
1302
1315
|
* messages: [{
|
|
1303
1316
|
* role: 'user',
|
|
1304
|
-
* content:
|
|
1305
|
-
*
|
|
1317
|
+
* content: [
|
|
1318
|
+
* { type: 'text', text: 'What is in this image?' },
|
|
1319
|
+
* { type: 'image_url', image_url: { url: 'https://example.com/image.jpg' } }
|
|
1320
|
+
* ]
|
|
1306
1321
|
* }]
|
|
1307
1322
|
* });
|
|
1308
1323
|
*
|
|
1324
|
+
* // With PDF files
|
|
1325
|
+
* const pdfResponse = await client.ai.chat.completions.create({
|
|
1326
|
+
* model: 'anthropic/claude-3.5-sonnet',
|
|
1327
|
+
* messages: [{
|
|
1328
|
+
* role: 'user',
|
|
1329
|
+
* content: [
|
|
1330
|
+
* { type: 'text', text: 'Summarize this document' },
|
|
1331
|
+
* { type: 'file', file: { filename: 'doc.pdf', file_data: 'https://example.com/doc.pdf' } }
|
|
1332
|
+
* ]
|
|
1333
|
+
* }],
|
|
1334
|
+
* fileParser: { enabled: true, pdf: { engine: 'mistral-ocr' } }
|
|
1335
|
+
* });
|
|
1336
|
+
*
|
|
1337
|
+
* // With web search
|
|
1338
|
+
* const searchResponse = await client.ai.chat.completions.create({
|
|
1339
|
+
* model: 'openai/gpt-4',
|
|
1340
|
+
* messages: [{ role: 'user', content: 'What are the latest news about AI?' }],
|
|
1341
|
+
* webSearch: { enabled: true, maxResults: 5 }
|
|
1342
|
+
* });
|
|
1343
|
+
* // Access citations from response.choices[0].message.annotations
|
|
1344
|
+
*
|
|
1345
|
+
* // With thinking/reasoning mode (Anthropic models)
|
|
1346
|
+
* const thinkingResponse = await client.ai.chat.completions.create({
|
|
1347
|
+
* model: 'anthropic/claude-3.5-sonnet',
|
|
1348
|
+
* messages: [{ role: 'user', content: 'Solve this complex math problem...' }],
|
|
1349
|
+
* thinking: true
|
|
1350
|
+
* });
|
|
1351
|
+
*
|
|
1309
1352
|
* // Streaming - returns async iterable
|
|
1310
1353
|
* const stream = await client.ai.chat.completions.create({
|
|
1311
1354
|
* model: 'gpt-4',
|
|
@@ -1327,7 +1370,11 @@ var ChatCompletions = class {
|
|
|
1327
1370
|
temperature: params.temperature,
|
|
1328
1371
|
maxTokens: params.maxTokens,
|
|
1329
1372
|
topP: params.topP,
|
|
1330
|
-
stream: params.stream
|
|
1373
|
+
stream: params.stream,
|
|
1374
|
+
// New plugin options
|
|
1375
|
+
webSearch: params.webSearch,
|
|
1376
|
+
fileParser: params.fileParser,
|
|
1377
|
+
thinking: params.thinking
|
|
1331
1378
|
};
|
|
1332
1379
|
if (params.stream) {
|
|
1333
1380
|
const headers = this.http.getHeaders();
|
|
@@ -1361,7 +1408,9 @@ var ChatCompletions = class {
|
|
|
1361
1408
|
index: 0,
|
|
1362
1409
|
message: {
|
|
1363
1410
|
role: "assistant",
|
|
1364
|
-
content
|
|
1411
|
+
content,
|
|
1412
|
+
// Include annotations if present (from web search or file parsing)
|
|
1413
|
+
...response.annotations && { annotations: response.annotations }
|
|
1365
1414
|
},
|
|
1366
1415
|
finish_reason: "stop"
|
|
1367
1416
|
}
|
|
@@ -1794,8 +1843,7 @@ var InsForgeClient = class {
|
|
|
1794
1843
|
this.http.setAuthToken(config.edgeFunctionToken);
|
|
1795
1844
|
this.tokenManager.saveSession({
|
|
1796
1845
|
accessToken: config.edgeFunctionToken,
|
|
1797
|
-
user:
|
|
1798
|
-
// Will be populated by getCurrentUser()
|
|
1846
|
+
user: null
|
|
1799
1847
|
});
|
|
1800
1848
|
}
|
|
1801
1849
|
const existingSession = this.tokenManager.getSession();
|