@future-explorer/lib 1.0.4 → 1.0.6
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 +46 -0
- package/dist/clients/ai/clients/unified-ai-sdk/index.d.ts +3 -0
- package/dist/clients/ai/clients/unified-ai-sdk/index.d.ts.map +1 -0
- package/dist/clients/ai/clients/unified-ai-sdk/index.js +18 -0
- package/dist/clients/ai/clients/unified-ai-sdk/unified-ai-client.d.ts +53 -0
- package/dist/clients/ai/clients/unified-ai-sdk/unified-ai-client.d.ts.map +1 -0
- package/dist/clients/ai/clients/unified-ai-sdk/unified-ai-client.js +81 -0
- package/dist/clients/ai/clients/unified-ai-sdk/unified-ai-client.model.d.ts +18 -0
- package/dist/clients/ai/clients/unified-ai-sdk/unified-ai-client.model.d.ts.map +1 -0
- package/dist/clients/ai/clients/unified-ai-sdk/unified-ai-client.model.js +21 -0
- package/dist/clients/ai/grok/GrokAiClient.d.ts +10 -0
- package/dist/clients/ai/grok/GrokAiClient.d.ts.map +1 -0
- package/dist/clients/ai/grok/index.d.ts +2 -0
- package/dist/clients/ai/grok/index.d.ts.map +1 -0
- package/dist/clients/ai/grok/index.js +17 -0
- package/dist/clients/ai/index.d.ts +4 -0
- package/dist/clients/ai/index.d.ts.map +1 -0
- package/dist/clients/ai/index.js +19 -0
- package/dist/{types.d.ts → clients/ai/shared/dto.d.ts} +16 -1
- package/dist/clients/ai/shared/dto.d.ts.map +1 -0
- package/dist/clients/ai/shared/index.d.ts +2 -0
- package/dist/clients/ai/shared/index.d.ts.map +1 -0
- package/dist/clients/ai/shared/index.js +17 -0
- package/dist/clients/index.d.ts +2 -0
- package/dist/clients/index.d.ts.map +1 -0
- package/dist/clients/index.js +17 -0
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -3
- package/package.json +23 -7
- package/dist/GrokAiClient.d.ts +0 -19
- package/dist/GrokAiClient.d.ts.map +0 -1
- package/dist/types.d.ts.map +0 -1
- /package/dist/{GrokAiClient.js → clients/ai/grok/GrokAiClient.js} +0 -0
- /package/dist/{types.js → clients/ai/shared/dto.js} +0 -0
package/README.md
CHANGED
|
@@ -65,6 +65,52 @@ if (response) {
|
|
|
65
65
|
- `maxTokens` (optional): Default max tokens (default: 4096)
|
|
66
66
|
- `logger` (optional): Logger instance with `warn` and `error` methods
|
|
67
67
|
|
|
68
|
+
## UnifiedAiClient
|
|
69
|
+
|
|
70
|
+
Multi-provider AI client supporting OpenAI, XAI (Grok), and Google Gemini with Zod schema-based structured outputs.
|
|
71
|
+
|
|
72
|
+
### Basic Usage
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
import { UnifiedAiClient, Provider } from '@future-explorer/lib';
|
|
76
|
+
import { z } from 'zod';
|
|
77
|
+
|
|
78
|
+
// Create client with desired provider
|
|
79
|
+
const client = new UnifiedAiClient(Provider.OpenAI);
|
|
80
|
+
// or Provider.XAI, Provider.Gemini
|
|
81
|
+
|
|
82
|
+
// Define a Zod schema for the response
|
|
83
|
+
const SentimentSchema = z.object({
|
|
84
|
+
sentiment: z.enum(['positive', 'negative', 'neutral']),
|
|
85
|
+
confidence: z.number().min(0).max(1),
|
|
86
|
+
summary: z.string(),
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
// Generate structured response
|
|
90
|
+
const result = await client.generateStructuredResponse(
|
|
91
|
+
SentimentSchema,
|
|
92
|
+
'I absolutely love this product!',
|
|
93
|
+
'You are a sentiment analysis expert.'
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
console.log(result.sentiment); // 'positive'
|
|
97
|
+
console.log(result.confidence); // 0.95
|
|
98
|
+
console.log(result.summary); // '...'
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Providers
|
|
102
|
+
|
|
103
|
+
| Provider | Enum Value | Required Environment Variables |
|
|
104
|
+
|----------|------------|-------------------------------|
|
|
105
|
+
| OpenAI | `Provider.OpenAI` | `OPENAI_API_KEY`, `MODEL_OPEN_AI` |
|
|
106
|
+
| XAI (Grok) | `Provider.XAI` | `XAI_API_KEY`, `MODEL_XAI` |
|
|
107
|
+
| Google Gemini | `Provider.Gemini` | `GOOGLE_GENERATIVE_AI_API_KEY`, `MODEL_GEMINI` |
|
|
108
|
+
|
|
109
|
+
### Methods
|
|
110
|
+
|
|
111
|
+
- `generateStructuredResponse<T>(schema, userPrompt, systemMessage?)`: Generates a structured response matching the Zod schema
|
|
112
|
+
- `getModel()`: Returns the underlying LanguageModel instance
|
|
113
|
+
|
|
68
114
|
## Development
|
|
69
115
|
|
|
70
116
|
### Build
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/clients/ai/clients/unified-ai-sdk/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./unified-ai-client"), exports);
|
|
18
|
+
__exportStar(require("./unified-ai-client.model"), exports);
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { LanguageModel } from 'ai';
|
|
2
|
+
import { ZodSchema } from 'zod';
|
|
3
|
+
import { Provider } from './unified-ai-client.model';
|
|
4
|
+
/**
|
|
5
|
+
* Unified AI Client that supports multiple AI providers (OpenAI, XAI, Gemini)
|
|
6
|
+
* and allows generating structured responses based on Zod schemas.
|
|
7
|
+
*/
|
|
8
|
+
export declare class UnifiedAiClient {
|
|
9
|
+
private model;
|
|
10
|
+
constructor(provider: Provider);
|
|
11
|
+
/**
|
|
12
|
+
* Generates a structured response from the AI model based on a Zod schema.
|
|
13
|
+
*
|
|
14
|
+
* @template T - The type inferred from the Zod schema
|
|
15
|
+
*
|
|
16
|
+
* @param schema - Zod schema defining the expected response structure.
|
|
17
|
+
* The AI model will be constrained to return data matching this schema.
|
|
18
|
+
* @param prompt - User input/message to send to the AI model (role: user)
|
|
19
|
+
* @param system - Optional system instructions that define the AI's behavior,
|
|
20
|
+
* persona, and task context (role: system)
|
|
21
|
+
*
|
|
22
|
+
* @returns Promise resolving to the validated object matching the schema type T
|
|
23
|
+
*
|
|
24
|
+
* @throws {Error} If the AI provider fails to generate a valid response
|
|
25
|
+
* @throws {Error} If the response doesn't match the provided schema
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* // Define a schema
|
|
29
|
+
* const SentimentSchema = z.object({
|
|
30
|
+
* sentiment: z.enum(['positive', 'negative', 'neutral']),
|
|
31
|
+
* confidence: z.number().min(0).max(1),
|
|
32
|
+
* summary: z.string(),
|
|
33
|
+
* });
|
|
34
|
+
*
|
|
35
|
+
* // Generate structured response
|
|
36
|
+
* const result = await service.generateStructuredResponse(
|
|
37
|
+
* SentimentSchema,
|
|
38
|
+
* 'I absolutely love this product!',
|
|
39
|
+
* 'You are a sentiment analysis expert. Be precise with confidence scores.'
|
|
40
|
+
* );
|
|
41
|
+
*
|
|
42
|
+
* console.log(result.sentiment); // 'positive'
|
|
43
|
+
* console.log(result.confidence); // 0.95
|
|
44
|
+
*/
|
|
45
|
+
generateStructuredResponse<T>(schema: ZodSchema<T>, userPrompt: string, systemMessage?: string): Promise<T>;
|
|
46
|
+
/**
|
|
47
|
+
* Retrieves the underlying LanguageModel instance.
|
|
48
|
+
* @returns The LanguageModel instance used by the UnifiedAiClient.
|
|
49
|
+
*/
|
|
50
|
+
getModel(): LanguageModel;
|
|
51
|
+
private createModel;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=unified-ai-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unified-ai-client.d.ts","sourceRoot":"","sources":["../../../../../src/clients/ai/clients/unified-ai-sdk/unified-ai-client.ts"],"names":[],"mappings":"AAGA,OAAO,EAAkB,aAAa,EAAE,MAAM,IAAI,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAErD;;;GAGG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,KAAK,CAAgB;gBAEjB,QAAQ,EAAE,QAAQ;IAI9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiCG;IACG,0BAA0B,CAAC,CAAC,EAChC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,EACpB,UAAU,EAAE,MAAM,EAClB,aAAa,CAAC,EAAE,MAAM,GACrB,OAAO,CAAC,CAAC,CAAC;IAWb;;;OAGG;IACH,QAAQ,IAAI,aAAa;IAIzB,OAAO,CAAC,WAAW;CAYpB"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UnifiedAiClient = void 0;
|
|
4
|
+
const google_1 = require("@ai-sdk/google");
|
|
5
|
+
const openai_1 = require("@ai-sdk/openai");
|
|
6
|
+
const xai_1 = require("@ai-sdk/xai");
|
|
7
|
+
const ai_1 = require("ai");
|
|
8
|
+
const unified_ai_client_model_1 = require("./unified-ai-client.model");
|
|
9
|
+
/**
|
|
10
|
+
* Unified AI Client that supports multiple AI providers (OpenAI, XAI, Gemini)
|
|
11
|
+
* and allows generating structured responses based on Zod schemas.
|
|
12
|
+
*/
|
|
13
|
+
class UnifiedAiClient {
|
|
14
|
+
model;
|
|
15
|
+
constructor(provider) {
|
|
16
|
+
this.model = this.createModel(provider);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Generates a structured response from the AI model based on a Zod schema.
|
|
20
|
+
*
|
|
21
|
+
* @template T - The type inferred from the Zod schema
|
|
22
|
+
*
|
|
23
|
+
* @param schema - Zod schema defining the expected response structure.
|
|
24
|
+
* The AI model will be constrained to return data matching this schema.
|
|
25
|
+
* @param prompt - User input/message to send to the AI model (role: user)
|
|
26
|
+
* @param system - Optional system instructions that define the AI's behavior,
|
|
27
|
+
* persona, and task context (role: system)
|
|
28
|
+
*
|
|
29
|
+
* @returns Promise resolving to the validated object matching the schema type T
|
|
30
|
+
*
|
|
31
|
+
* @throws {Error} If the AI provider fails to generate a valid response
|
|
32
|
+
* @throws {Error} If the response doesn't match the provided schema
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* // Define a schema
|
|
36
|
+
* const SentimentSchema = z.object({
|
|
37
|
+
* sentiment: z.enum(['positive', 'negative', 'neutral']),
|
|
38
|
+
* confidence: z.number().min(0).max(1),
|
|
39
|
+
* summary: z.string(),
|
|
40
|
+
* });
|
|
41
|
+
*
|
|
42
|
+
* // Generate structured response
|
|
43
|
+
* const result = await service.generateStructuredResponse(
|
|
44
|
+
* SentimentSchema,
|
|
45
|
+
* 'I absolutely love this product!',
|
|
46
|
+
* 'You are a sentiment analysis expert. Be precise with confidence scores.'
|
|
47
|
+
* );
|
|
48
|
+
*
|
|
49
|
+
* console.log(result.sentiment); // 'positive'
|
|
50
|
+
* console.log(result.confidence); // 0.95
|
|
51
|
+
*/
|
|
52
|
+
async generateStructuredResponse(schema, userPrompt, systemMessage) {
|
|
53
|
+
const result = await (0, ai_1.generateObject)({
|
|
54
|
+
model: this.model,
|
|
55
|
+
schema: schema, // Option 2: Use jsonSchema instead of Zod directly: schema: jsonSchema<T>(zodToJsonSchema(schema) as any),
|
|
56
|
+
prompt: userPrompt,
|
|
57
|
+
system: systemMessage,
|
|
58
|
+
});
|
|
59
|
+
return result.object;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Retrieves the underlying LanguageModel instance.
|
|
63
|
+
* @returns The LanguageModel instance used by the UnifiedAiClient.
|
|
64
|
+
*/
|
|
65
|
+
getModel() {
|
|
66
|
+
return this.model;
|
|
67
|
+
}
|
|
68
|
+
createModel(provider) {
|
|
69
|
+
switch (provider) {
|
|
70
|
+
case unified_ai_client_model_1.Provider.OpenAI:
|
|
71
|
+
return (0, openai_1.openai)(process.env.MODEL_OPEN_AI);
|
|
72
|
+
case unified_ai_client_model_1.Provider.XAI:
|
|
73
|
+
return (0, xai_1.xai)(process.env.MODEL_XAI);
|
|
74
|
+
case unified_ai_client_model_1.Provider.Gemini:
|
|
75
|
+
return (0, google_1.google)(process.env.MODEL_GEMINI);
|
|
76
|
+
default:
|
|
77
|
+
throw new Error(`Unknown provider: ${provider}`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
exports.UnifiedAiClient = UnifiedAiClient;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enum representing supported AI providers.
|
|
3
|
+
*/
|
|
4
|
+
export declare enum Provider {
|
|
5
|
+
/**
|
|
6
|
+
* Expects 'OPENAI_API_KEY' and 'MODEL_OPEN_AI' environment variables to be set.
|
|
7
|
+
*/
|
|
8
|
+
OpenAI = "openai",
|
|
9
|
+
/**
|
|
10
|
+
* Expects 'XAI_API_KEY' and 'MODEL_XAI' environment variables to be set.
|
|
11
|
+
*/
|
|
12
|
+
XAI = "xai",
|
|
13
|
+
/**
|
|
14
|
+
* Expects 'GOOGLE_GENERATIVE_AI_API_KEY' and 'MODEL_GEMINI' environment variables to be set.
|
|
15
|
+
*/
|
|
16
|
+
Gemini = "gemini"
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=unified-ai-client.model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unified-ai-client.model.d.ts","sourceRoot":"","sources":["../../../../../src/clients/ai/clients/unified-ai-sdk/unified-ai-client.model.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,oBAAY,QAAQ;IAClB;;OAEG;IACH,MAAM,WAAW;IACjB;;OAEG;IACH,GAAG,QAAQ;IACX;;OAEG;IACH,MAAM,WAAW;CAClB"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Provider = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Enum representing supported AI providers.
|
|
6
|
+
*/
|
|
7
|
+
var Provider;
|
|
8
|
+
(function (Provider) {
|
|
9
|
+
/**
|
|
10
|
+
* Expects 'OPENAI_API_KEY' and 'MODEL_OPEN_AI' environment variables to be set.
|
|
11
|
+
*/
|
|
12
|
+
Provider["OpenAI"] = "openai";
|
|
13
|
+
/**
|
|
14
|
+
* Expects 'XAI_API_KEY' and 'MODEL_XAI' environment variables to be set.
|
|
15
|
+
*/
|
|
16
|
+
Provider["XAI"] = "xai";
|
|
17
|
+
/**
|
|
18
|
+
* Expects 'GOOGLE_GENERATIVE_AI_API_KEY' and 'MODEL_GEMINI' environment variables to be set.
|
|
19
|
+
*/
|
|
20
|
+
Provider["Gemini"] = "gemini";
|
|
21
|
+
})(Provider || (exports.Provider = Provider = {}));
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AiClientOptions, GetGenericStructuredResponse, GetGenericStructuredResponseArgs } from '../shared';
|
|
2
|
+
export declare class GrokAiClient {
|
|
3
|
+
private readonly xaiClient;
|
|
4
|
+
private temperature;
|
|
5
|
+
private maxTokens;
|
|
6
|
+
private logger?;
|
|
7
|
+
constructor(options?: AiClientOptions);
|
|
8
|
+
getGenericStructuredResponse<T>(payload: GetGenericStructuredResponseArgs): Promise<GetGenericStructuredResponse<T> | null>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=GrokAiClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GrokAiClient.d.ts","sourceRoot":"","sources":["../../../../src/clients/ai/grok/GrokAiClient.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,eAAe,EACf,4BAA4B,EAC5B,gCAAgC,EACjC,MAAM,WAAW,CAAC;AAEnB,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA+B;IACzD,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,MAAM,CAAC,CAA4B;gBAE/B,OAAO,GAAE,eAAoB;IAa5B,4BAA4B,CAAC,CAAC,EACzC,OAAO,EAAE,gCAAgC,GACxC,OAAO,CAAC,4BAA4B,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;CA2CnD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/clients/ai/grok/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./GrokAiClient"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/clients/ai/index.ts"],"names":[],"mappings":"AAAA,cAAc,4CAA4C,CAAC;AAC3D,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./clients/unified-ai-sdk/unified-ai-client"), exports);
|
|
18
|
+
__exportStar(require("./grok"), exports);
|
|
19
|
+
__exportStar(require("./shared"), exports);
|
|
@@ -1,4 +1,19 @@
|
|
|
1
|
+
import { JSONSchema7 } from 'ai';
|
|
1
2
|
import { LanguageModelV2Message } from '@ai-sdk/provider';
|
|
3
|
+
export interface AiClientOptions {
|
|
4
|
+
apiKey?: string;
|
|
5
|
+
temperature?: number;
|
|
6
|
+
maxTokens?: number;
|
|
7
|
+
logger?: {
|
|
8
|
+
warn: (message: string, ...args: any[]) => void;
|
|
9
|
+
error: (message: string, ...args: any[]) => void;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export interface FunctionDefinitionInterface {
|
|
13
|
+
name: string;
|
|
14
|
+
description: string;
|
|
15
|
+
jsonSchema: JSONSchema7;
|
|
16
|
+
}
|
|
2
17
|
export interface GetGenericStructuredResponseArgs {
|
|
3
18
|
model?: string;
|
|
4
19
|
messages: LanguageModelV2Message[];
|
|
@@ -14,4 +29,4 @@ export interface GetGenericStructuredResponse<T> {
|
|
|
14
29
|
args: T | null;
|
|
15
30
|
functionName: string;
|
|
16
31
|
}
|
|
17
|
-
//# sourceMappingURL=
|
|
32
|
+
//# sourceMappingURL=dto.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dto.d.ts","sourceRoot":"","sources":["../../../../src/clients/ai/shared/dto.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,IAAI,CAAC;AACjC,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAE1D,MAAM,WAAW,eAAe;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE;QACP,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC;QAChD,KAAK,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC;KAClD,CAAC;CACH;AAED,MAAM,WAAW,2BAA2B;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,WAAW,CAAC;CACzB;AAED,MAAM,WAAW,gCAAgC;IAC/C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,sBAAsB,EAAE,CAAC;IACnC,KAAK,CAAC,EAAE,GAAG,EAAE,CAAC;IACd,UAAU,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,GAAG,UAAU,GAAG,MAAM,CAAA;KAAE,CAAC;IACtE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,4BAA4B,CAAC,CAAC;IAC7C,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;CACtB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/clients/ai/shared/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./dto"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/clients/index.ts"],"names":[],"mappings":"AAAA,cAAc,MAAM,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./ai"), exports);
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports
|
|
4
|
-
var GrokAiClient_1 = require("./GrokAiClient");
|
|
5
|
-
Object.defineProperty(exports, "GrokAiClient", { enumerable: true, get: function () { return GrokAiClient_1.GrokAiClient; } });
|
|
17
|
+
__exportStar(require("./clients"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@future-explorer/lib",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "Shared utilities and clients for Future Explorer projects",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -16,10 +16,23 @@
|
|
|
16
16
|
},
|
|
17
17
|
"keywords": [
|
|
18
18
|
"future-explorer",
|
|
19
|
+
"ai-sdk",
|
|
20
|
+
"openai",
|
|
21
|
+
"gemini",
|
|
19
22
|
"grok",
|
|
20
|
-
"
|
|
23
|
+
"xai",
|
|
24
|
+
"unified-ai"
|
|
25
|
+
],
|
|
26
|
+
"contributors": [
|
|
27
|
+
{
|
|
28
|
+
"name": "Alexander Grigoryan",
|
|
29
|
+
"email": "agrigoryan1982@gmail.com"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"name": "Renat Gatin",
|
|
33
|
+
"email": "renat.gatin@gmail.com"
|
|
34
|
+
}
|
|
21
35
|
],
|
|
22
|
-
"author": "",
|
|
23
36
|
"license": "ISC",
|
|
24
37
|
"publishConfig": {
|
|
25
38
|
"access": "public"
|
|
@@ -29,13 +42,16 @@
|
|
|
29
42
|
"url": "https://github.com/future-explorer/future-explorer.git",
|
|
30
43
|
"directory": "future-explorer-lib"
|
|
31
44
|
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@ai-sdk/google": "^2.0.52",
|
|
47
|
+
"@ai-sdk/openai": "^2.0.89",
|
|
48
|
+
"@ai-sdk/xai": "^2.0.31",
|
|
49
|
+
"ai": "^5.0.92"
|
|
50
|
+
},
|
|
32
51
|
"peerDependencies": {
|
|
33
|
-
"
|
|
34
|
-
"@ai-sdk/xai": "^2.0.0"
|
|
52
|
+
"zod": "^3.0.0"
|
|
35
53
|
},
|
|
36
54
|
"devDependencies": {
|
|
37
|
-
"@ai-sdk/provider": "^2.0.0",
|
|
38
|
-
"@ai-sdk/xai": "^2.0.31",
|
|
39
55
|
"@types/node": "^24.5.2",
|
|
40
56
|
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
41
57
|
"@typescript-eslint/parser": "^8.0.0",
|
package/dist/GrokAiClient.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { GetGenericStructuredResponse, GetGenericStructuredResponseArgs } from './types';
|
|
2
|
-
export interface GrokAiClientOptions {
|
|
3
|
-
apiKey?: string;
|
|
4
|
-
temperature?: number;
|
|
5
|
-
maxTokens?: number;
|
|
6
|
-
logger?: {
|
|
7
|
-
warn: (message: string, ...args: any[]) => void;
|
|
8
|
-
error: (message: string, ...args: any[]) => void;
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
export declare class GrokAiClient {
|
|
12
|
-
private readonly xaiClient;
|
|
13
|
-
private temperature;
|
|
14
|
-
private maxTokens;
|
|
15
|
-
private logger?;
|
|
16
|
-
constructor(options?: GrokAiClientOptions);
|
|
17
|
-
getGenericStructuredResponse<T>(payload: GetGenericStructuredResponseArgs): Promise<GetGenericStructuredResponse<T> | null>;
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=GrokAiClient.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GrokAiClient.d.ts","sourceRoot":"","sources":["../src/GrokAiClient.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,4BAA4B,EAAE,gCAAgC,EAAE,MAAM,SAAS,CAAC;AAEzF,MAAM,WAAW,mBAAmB;IAClC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE;QACP,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC;QAChD,KAAK,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC;KAClD,CAAC;CACH;AAED,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA+B;IACzD,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,MAAM,CAAC,CAAgC;gBAEnC,OAAO,GAAE,mBAAwB;IAahC,4BAA4B,CAAC,CAAC,EACzC,OAAO,EAAE,gCAAgC,GACxC,OAAO,CAAC,4BAA4B,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;CA2CnD"}
|
package/dist/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAE1D,MAAM,WAAW,gCAAgC;IAC/C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,sBAAsB,EAAE,CAAC;IACnC,KAAK,CAAC,EAAE,GAAG,EAAE,CAAC;IACd,UAAU,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,GAAG,UAAU,GAAG,MAAM,CAAA;KAAE,CAAC;IACtE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,4BAA4B,CAAC,CAAC;IAC7C,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;CACtB"}
|
|
File without changes
|
|
File without changes
|