@agtlantis/core 0.4.1 → 0.5.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/dist/{base-provider-C3mFLNiN.d.cts → base-provider-2TTw5HAa.d.cts} +20 -2
- package/dist/{base-provider-C3mFLNiN.d.ts → base-provider-2TTw5HAa.d.ts} +20 -2
- package/dist/index.cjs +92 -195
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +32 -28
- package/dist/index.d.ts +32 -28
- package/dist/index.js +92 -194
- package/dist/index.js.map +1 -1
- package/dist/testing/index.cjs +31 -8
- package/dist/testing/index.cjs.map +1 -1
- package/dist/testing/index.d.cts +5 -1
- package/dist/testing/index.d.ts +5 -1
- package/dist/testing/index.js +31 -4
- package/dist/testing/index.js.map +1 -1
- package/package.json +2 -4
package/dist/index.js
CHANGED
|
@@ -9,7 +9,6 @@ import * as yaml from 'yaml';
|
|
|
9
9
|
import { createHash } from 'crypto';
|
|
10
10
|
import { createGoogleGenerativeAI } from '@ai-sdk/google';
|
|
11
11
|
import { GoogleGenAI } from '@google/genai';
|
|
12
|
-
import merge from 'lodash/merge';
|
|
13
12
|
import { createOpenAI } from '@ai-sdk/openai';
|
|
14
13
|
|
|
15
14
|
// src/errors/utils.ts
|
|
@@ -1379,11 +1378,9 @@ function parsePromptYaml(content, promptId) {
|
|
|
1379
1378
|
try {
|
|
1380
1379
|
parsed = yaml.parse(content);
|
|
1381
1380
|
} catch (error) {
|
|
1382
|
-
throw new PromptInvalidFormatError(
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
{ cause: toErrorCause(error) }
|
|
1386
|
-
);
|
|
1381
|
+
throw new PromptInvalidFormatError(promptId, `Invalid YAML: ${toErrorMessage(error)}`, {
|
|
1382
|
+
cause: toErrorCause(error)
|
|
1383
|
+
});
|
|
1387
1384
|
}
|
|
1388
1385
|
if (!parsed || typeof parsed !== "object") {
|
|
1389
1386
|
throw new PromptInvalidFormatError(promptId, "Expected YAML object");
|
|
@@ -1469,17 +1466,17 @@ var FilePromptRepository = class {
|
|
|
1469
1466
|
}
|
|
1470
1467
|
throw new PromptIOError("read", filePath, { cause: toErrorCause(error) });
|
|
1471
1468
|
}
|
|
1472
|
-
const
|
|
1473
|
-
if (
|
|
1469
|
+
const promptTemplate = this.parseContent(content, id);
|
|
1470
|
+
if (promptTemplate.id !== id || promptTemplate.version !== version) {
|
|
1474
1471
|
throw new PromptInvalidFormatError(
|
|
1475
1472
|
id,
|
|
1476
|
-
`File content mismatch: expected id='${id}' version='${version}', got id='${
|
|
1473
|
+
`File content mismatch: expected id='${id}' version='${version}', got id='${promptTemplate.id}' version='${promptTemplate.version}'`
|
|
1477
1474
|
);
|
|
1478
1475
|
}
|
|
1479
1476
|
if (this.cacheEnabled) {
|
|
1480
|
-
this.contentCache.set(cacheKey,
|
|
1477
|
+
this.contentCache.set(cacheKey, promptTemplate);
|
|
1481
1478
|
}
|
|
1482
|
-
return
|
|
1479
|
+
return promptTemplate;
|
|
1483
1480
|
}
|
|
1484
1481
|
let files;
|
|
1485
1482
|
try {
|
|
@@ -1985,6 +1982,23 @@ var GoogleFileManager = class {
|
|
|
1985
1982
|
}
|
|
1986
1983
|
};
|
|
1987
1984
|
|
|
1985
|
+
// src/utils/deep-merge.ts
|
|
1986
|
+
function isPlainObject(value) {
|
|
1987
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1988
|
+
}
|
|
1989
|
+
function deepMerge(...sources) {
|
|
1990
|
+
const result = {};
|
|
1991
|
+
for (const source of sources) {
|
|
1992
|
+
if (!source) continue;
|
|
1993
|
+
for (const key of Object.keys(source)) {
|
|
1994
|
+
const existing = result[key];
|
|
1995
|
+
const incoming = source[key];
|
|
1996
|
+
result[key] = isPlainObject(existing) && isPlainObject(incoming) ? deepMerge(existing, incoming) : incoming;
|
|
1997
|
+
}
|
|
1998
|
+
}
|
|
1999
|
+
return result;
|
|
2000
|
+
}
|
|
2001
|
+
|
|
1988
2002
|
// src/session/usage-extractors.ts
|
|
1989
2003
|
function mergeUsages(usages) {
|
|
1990
2004
|
if (usages.length === 0) {
|
|
@@ -2253,6 +2267,7 @@ var SimpleSession = class {
|
|
|
2253
2267
|
providerPricing;
|
|
2254
2268
|
defaultProviderOptions;
|
|
2255
2269
|
defaultTools;
|
|
2270
|
+
defaultGenerationOptions;
|
|
2256
2271
|
_fileManager;
|
|
2257
2272
|
logger;
|
|
2258
2273
|
sessionStartTime;
|
|
@@ -2267,6 +2282,7 @@ var SimpleSession = class {
|
|
|
2267
2282
|
this.providerPricing = options.providerPricing;
|
|
2268
2283
|
this.defaultProviderOptions = options.defaultProviderOptions;
|
|
2269
2284
|
this.defaultTools = options.defaultTools;
|
|
2285
|
+
this.defaultGenerationOptions = options.defaultGenerationOptions;
|
|
2270
2286
|
this._fileManager = options.fileManager;
|
|
2271
2287
|
this.logger = options.logger ?? noopLogger;
|
|
2272
2288
|
this.sessionStartTime = options.startTime ?? Date.now();
|
|
@@ -2303,7 +2319,7 @@ var SimpleSession = class {
|
|
|
2303
2319
|
const { model: requestedModel, providerOptions, tools, ...restParams } = params;
|
|
2304
2320
|
const languageModel = this.getModel(requestedModel);
|
|
2305
2321
|
const modelId = this.extractModelId(languageModel);
|
|
2306
|
-
const mergedProviderOptions = this.defaultProviderOptions || providerOptions ?
|
|
2322
|
+
const mergedProviderOptions = this.defaultProviderOptions || providerOptions ? deepMerge(this.defaultProviderOptions ?? {}, providerOptions ?? {}) : void 0;
|
|
2307
2323
|
const mergedTools = this.defaultTools || tools ? { ...this.defaultTools, ...tools } : void 0;
|
|
2308
2324
|
this.logger.onLLMCallStart?.({
|
|
2309
2325
|
type: "llm_call_start",
|
|
@@ -2314,6 +2330,7 @@ var SimpleSession = class {
|
|
|
2314
2330
|
});
|
|
2315
2331
|
try {
|
|
2316
2332
|
const result = await generateText({
|
|
2333
|
+
...this.defaultGenerationOptions,
|
|
2317
2334
|
...restParams,
|
|
2318
2335
|
tools: mergedTools,
|
|
2319
2336
|
providerOptions: mergedProviderOptions,
|
|
@@ -2364,7 +2381,7 @@ var SimpleSession = class {
|
|
|
2364
2381
|
const { model: requestedModel, providerOptions, tools, ...restParams } = params;
|
|
2365
2382
|
const languageModel = this.getModel(requestedModel);
|
|
2366
2383
|
const modelId = this.extractModelId(languageModel);
|
|
2367
|
-
const mergedProviderOptions = this.defaultProviderOptions || providerOptions ?
|
|
2384
|
+
const mergedProviderOptions = this.defaultProviderOptions || providerOptions ? deepMerge(this.defaultProviderOptions ?? {}, providerOptions ?? {}) : void 0;
|
|
2368
2385
|
const mergedTools = this.defaultTools || tools ? { ...this.defaultTools, ...tools } : void 0;
|
|
2369
2386
|
this.logger.onLLMCallStart?.({
|
|
2370
2387
|
type: "llm_call_start",
|
|
@@ -2374,6 +2391,7 @@ var SimpleSession = class {
|
|
|
2374
2391
|
request: { params: restParams }
|
|
2375
2392
|
});
|
|
2376
2393
|
const result = streamText({
|
|
2394
|
+
...this.defaultGenerationOptions,
|
|
2377
2395
|
...restParams,
|
|
2378
2396
|
tools: mergedTools,
|
|
2379
2397
|
providerOptions: mergedProviderOptions,
|
|
@@ -2541,7 +2559,8 @@ var StreamingSession = class extends SimpleSession {
|
|
|
2541
2559
|
startTime: options.startTime,
|
|
2542
2560
|
signal: options.signal,
|
|
2543
2561
|
defaultProviderOptions: options.defaultProviderOptions,
|
|
2544
|
-
defaultTools: options.defaultTools
|
|
2562
|
+
defaultTools: options.defaultTools,
|
|
2563
|
+
defaultGenerationOptions: options.defaultGenerationOptions
|
|
2545
2564
|
});
|
|
2546
2565
|
this.lastEventTime = this._startTime;
|
|
2547
2566
|
this._logger.onExecutionStart?.({
|
|
@@ -2673,59 +2692,21 @@ function createStreamingSession(options) {
|
|
|
2673
2692
|
|
|
2674
2693
|
// src/provider/google/factory.ts
|
|
2675
2694
|
var GoogleProvider = class _GoogleProvider extends BaseProvider {
|
|
2676
|
-
constructor(
|
|
2695
|
+
constructor(config) {
|
|
2677
2696
|
super();
|
|
2678
|
-
this.
|
|
2679
|
-
this.
|
|
2680
|
-
this.logger = logger;
|
|
2681
|
-
this.safetySettings = safetySettings;
|
|
2682
|
-
this.pricingConfig = pricingConfig;
|
|
2683
|
-
this.defaultOptions = defaultOptions;
|
|
2684
|
-
this.searchEnabled = searchEnabled;
|
|
2685
|
-
this.urlContextEnabled = urlContextEnabled;
|
|
2686
|
-
this.fileCache = fileCache;
|
|
2687
|
-
this.google = createGoogleGenerativeAI({ apiKey });
|
|
2697
|
+
this.config = config;
|
|
2698
|
+
this.google = createGoogleGenerativeAI({ apiKey: config.apiKey });
|
|
2688
2699
|
}
|
|
2689
2700
|
google;
|
|
2690
2701
|
withDefaultModel(modelId) {
|
|
2691
|
-
return new _GoogleProvider(
|
|
2692
|
-
this.apiKey,
|
|
2693
|
-
modelId,
|
|
2694
|
-
this.logger,
|
|
2695
|
-
this.safetySettings,
|
|
2696
|
-
this.pricingConfig,
|
|
2697
|
-
this.defaultOptions,
|
|
2698
|
-
this.searchEnabled,
|
|
2699
|
-
this.urlContextEnabled,
|
|
2700
|
-
this.fileCache
|
|
2701
|
-
);
|
|
2702
|
+
return new _GoogleProvider({ ...this.config, defaultModelId: modelId });
|
|
2702
2703
|
}
|
|
2703
2704
|
withLogger(newLogger) {
|
|
2704
|
-
return new _GoogleProvider(
|
|
2705
|
-
this.apiKey,
|
|
2706
|
-
this.defaultModelId,
|
|
2707
|
-
newLogger,
|
|
2708
|
-
this.safetySettings,
|
|
2709
|
-
this.pricingConfig,
|
|
2710
|
-
this.defaultOptions,
|
|
2711
|
-
this.searchEnabled,
|
|
2712
|
-
this.urlContextEnabled,
|
|
2713
|
-
this.fileCache
|
|
2714
|
-
);
|
|
2705
|
+
return new _GoogleProvider({ ...this.config, logger: newLogger });
|
|
2715
2706
|
}
|
|
2716
2707
|
withPricing(pricing) {
|
|
2717
2708
|
validateProviderPricing(pricing, "google");
|
|
2718
|
-
return new _GoogleProvider(
|
|
2719
|
-
this.apiKey,
|
|
2720
|
-
this.defaultModelId,
|
|
2721
|
-
this.logger,
|
|
2722
|
-
this.safetySettings,
|
|
2723
|
-
pricing,
|
|
2724
|
-
this.defaultOptions,
|
|
2725
|
-
this.searchEnabled,
|
|
2726
|
-
this.urlContextEnabled,
|
|
2727
|
-
this.fileCache
|
|
2728
|
-
);
|
|
2709
|
+
return new _GoogleProvider({ ...this.config, pricingConfig: pricing });
|
|
2729
2710
|
}
|
|
2730
2711
|
/**
|
|
2731
2712
|
* Set default provider-specific options for all LLM calls.
|
|
@@ -2741,17 +2722,10 @@ var GoogleProvider = class _GoogleProvider extends BaseProvider {
|
|
|
2741
2722
|
* ```
|
|
2742
2723
|
*/
|
|
2743
2724
|
withDefaultOptions(options) {
|
|
2744
|
-
return new _GoogleProvider(
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
this.safetySettings,
|
|
2749
|
-
this.pricingConfig,
|
|
2750
|
-
options,
|
|
2751
|
-
this.searchEnabled,
|
|
2752
|
-
this.urlContextEnabled,
|
|
2753
|
-
this.fileCache
|
|
2754
|
-
);
|
|
2725
|
+
return new _GoogleProvider({ ...this.config, defaultOptions: options });
|
|
2726
|
+
}
|
|
2727
|
+
withDefaultGenerationOptions(options) {
|
|
2728
|
+
return new _GoogleProvider({ ...this.config, defaultGenOptions: options });
|
|
2755
2729
|
}
|
|
2756
2730
|
/**
|
|
2757
2731
|
* Enable Google Search grounding for all LLM calls.
|
|
@@ -2765,17 +2739,7 @@ var GoogleProvider = class _GoogleProvider extends BaseProvider {
|
|
|
2765
2739
|
* ```
|
|
2766
2740
|
*/
|
|
2767
2741
|
withSearchEnabled() {
|
|
2768
|
-
return new _GoogleProvider(
|
|
2769
|
-
this.apiKey,
|
|
2770
|
-
this.defaultModelId,
|
|
2771
|
-
this.logger,
|
|
2772
|
-
this.safetySettings,
|
|
2773
|
-
this.pricingConfig,
|
|
2774
|
-
this.defaultOptions,
|
|
2775
|
-
true,
|
|
2776
|
-
this.urlContextEnabled,
|
|
2777
|
-
this.fileCache
|
|
2778
|
-
);
|
|
2742
|
+
return new _GoogleProvider({ ...this.config, searchEnabled: true });
|
|
2779
2743
|
}
|
|
2780
2744
|
/**
|
|
2781
2745
|
* Enable URL Context grounding for all LLM calls.
|
|
@@ -2789,17 +2753,7 @@ var GoogleProvider = class _GoogleProvider extends BaseProvider {
|
|
|
2789
2753
|
* ```
|
|
2790
2754
|
*/
|
|
2791
2755
|
withUrlContextEnabled() {
|
|
2792
|
-
return new _GoogleProvider(
|
|
2793
|
-
this.apiKey,
|
|
2794
|
-
this.defaultModelId,
|
|
2795
|
-
this.logger,
|
|
2796
|
-
this.safetySettings,
|
|
2797
|
-
this.pricingConfig,
|
|
2798
|
-
this.defaultOptions,
|
|
2799
|
-
this.searchEnabled,
|
|
2800
|
-
true,
|
|
2801
|
-
this.fileCache
|
|
2802
|
-
);
|
|
2756
|
+
return new _GoogleProvider({ ...this.config, urlContextEnabled: true });
|
|
2803
2757
|
}
|
|
2804
2758
|
/**
|
|
2805
2759
|
* Set a file cache for reusing uploaded files across sessions.
|
|
@@ -2818,33 +2772,25 @@ var GoogleProvider = class _GoogleProvider extends BaseProvider {
|
|
|
2818
2772
|
* ```
|
|
2819
2773
|
*/
|
|
2820
2774
|
withFileCache(cache) {
|
|
2821
|
-
return new _GoogleProvider(
|
|
2822
|
-
this.apiKey,
|
|
2823
|
-
this.defaultModelId,
|
|
2824
|
-
this.logger,
|
|
2825
|
-
this.safetySettings,
|
|
2826
|
-
this.pricingConfig,
|
|
2827
|
-
this.defaultOptions,
|
|
2828
|
-
this.searchEnabled,
|
|
2829
|
-
this.urlContextEnabled,
|
|
2830
|
-
cache ?? new InMemoryFileCache()
|
|
2831
|
-
);
|
|
2775
|
+
return new _GoogleProvider({ ...this.config, fileCache: cache ?? new InMemoryFileCache() });
|
|
2832
2776
|
}
|
|
2833
2777
|
getSessionConfig() {
|
|
2778
|
+
const { searchEnabled, urlContextEnabled } = this.config;
|
|
2834
2779
|
const defaultTools = {
|
|
2835
|
-
...
|
|
2836
|
-
...
|
|
2780
|
+
...searchEnabled && { google_search: this.google.tools.googleSearch({}) },
|
|
2781
|
+
...urlContextEnabled && { url_context: this.google.tools.urlContext({}) }
|
|
2837
2782
|
};
|
|
2838
|
-
const hasDefaultTools =
|
|
2783
|
+
const hasDefaultTools = searchEnabled || urlContextEnabled;
|
|
2839
2784
|
return {
|
|
2840
|
-
defaultLanguageModel: this.defaultModelId ? this.createModel(this.defaultModelId) : null,
|
|
2785
|
+
defaultLanguageModel: this.config.defaultModelId ? this.createModel(this.config.defaultModelId) : null,
|
|
2841
2786
|
modelFactory: (modelId) => this.createModel(modelId),
|
|
2842
2787
|
providerType: "google",
|
|
2843
|
-
providerPricing: this.pricingConfig,
|
|
2844
|
-
fileManager: new GoogleFileManager(this.apiKey, { cache: this.fileCache }),
|
|
2845
|
-
logger: this.logger,
|
|
2846
|
-
defaultProviderOptions: this.defaultOptions ? { google: this.defaultOptions } : void 0,
|
|
2847
|
-
defaultTools: hasDefaultTools ? defaultTools : void 0
|
|
2788
|
+
providerPricing: this.config.pricingConfig,
|
|
2789
|
+
fileManager: new GoogleFileManager(this.config.apiKey, { cache: this.config.fileCache }),
|
|
2790
|
+
logger: this.config.logger,
|
|
2791
|
+
defaultProviderOptions: this.config.defaultOptions ? { google: this.config.defaultOptions } : void 0,
|
|
2792
|
+
defaultTools: hasDefaultTools ? defaultTools : void 0,
|
|
2793
|
+
defaultGenerationOptions: this.config.defaultGenOptions
|
|
2848
2794
|
};
|
|
2849
2795
|
}
|
|
2850
2796
|
createStreamingSession(signal) {
|
|
@@ -2858,75 +2804,42 @@ var GoogleProvider = class _GoogleProvider extends BaseProvider {
|
|
|
2858
2804
|
* include the second parameter, but it's supported at runtime.
|
|
2859
2805
|
*/
|
|
2860
2806
|
createModel(modelId) {
|
|
2861
|
-
if (this.safetySettings) {
|
|
2862
|
-
return this.google(modelId, { safetySettings: this.safetySettings });
|
|
2807
|
+
if (this.config.safetySettings) {
|
|
2808
|
+
return this.google(modelId, { safetySettings: this.config.safetySettings });
|
|
2863
2809
|
}
|
|
2864
2810
|
return this.google(modelId);
|
|
2865
2811
|
}
|
|
2866
2812
|
};
|
|
2867
2813
|
function createGoogleProvider(config) {
|
|
2868
|
-
return new GoogleProvider(
|
|
2869
|
-
config.apiKey,
|
|
2870
|
-
null,
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2814
|
+
return new GoogleProvider({
|
|
2815
|
+
apiKey: config.apiKey,
|
|
2816
|
+
defaultModelId: null,
|
|
2817
|
+
logger: noopLogger,
|
|
2818
|
+
safetySettings: config.safetySettings,
|
|
2819
|
+
searchEnabled: false,
|
|
2820
|
+
urlContextEnabled: false
|
|
2821
|
+
});
|
|
2875
2822
|
}
|
|
2876
2823
|
var OpenAIProvider = class _OpenAIProvider extends BaseProvider {
|
|
2877
|
-
constructor(
|
|
2824
|
+
constructor(config) {
|
|
2878
2825
|
super();
|
|
2879
|
-
this.
|
|
2880
|
-
this.defaultModelId = defaultModelId;
|
|
2881
|
-
this.logger = logger;
|
|
2882
|
-
this.baseURL = baseURL;
|
|
2883
|
-
this.organization = organization;
|
|
2884
|
-
this.pricingConfig = pricingConfig;
|
|
2885
|
-
this.defaultOptions = defaultOptions;
|
|
2886
|
-
this.fileCache = fileCache;
|
|
2826
|
+
this.config = config;
|
|
2887
2827
|
this.openai = createOpenAI({
|
|
2888
|
-
apiKey,
|
|
2889
|
-
baseURL,
|
|
2890
|
-
organization
|
|
2828
|
+
apiKey: config.apiKey,
|
|
2829
|
+
baseURL: config.baseURL,
|
|
2830
|
+
organization: config.organization
|
|
2891
2831
|
});
|
|
2892
2832
|
}
|
|
2893
2833
|
openai;
|
|
2894
2834
|
withDefaultModel(modelId) {
|
|
2895
|
-
return new _OpenAIProvider(
|
|
2896
|
-
this.apiKey,
|
|
2897
|
-
modelId,
|
|
2898
|
-
this.logger,
|
|
2899
|
-
this.baseURL,
|
|
2900
|
-
this.organization,
|
|
2901
|
-
this.pricingConfig,
|
|
2902
|
-
this.defaultOptions,
|
|
2903
|
-
this.fileCache
|
|
2904
|
-
);
|
|
2835
|
+
return new _OpenAIProvider({ ...this.config, defaultModelId: modelId });
|
|
2905
2836
|
}
|
|
2906
2837
|
withLogger(newLogger) {
|
|
2907
|
-
return new _OpenAIProvider(
|
|
2908
|
-
this.apiKey,
|
|
2909
|
-
this.defaultModelId,
|
|
2910
|
-
newLogger,
|
|
2911
|
-
this.baseURL,
|
|
2912
|
-
this.organization,
|
|
2913
|
-
this.pricingConfig,
|
|
2914
|
-
this.defaultOptions,
|
|
2915
|
-
this.fileCache
|
|
2916
|
-
);
|
|
2838
|
+
return new _OpenAIProvider({ ...this.config, logger: newLogger });
|
|
2917
2839
|
}
|
|
2918
2840
|
withPricing(pricing) {
|
|
2919
2841
|
validateProviderPricing(pricing, "openai");
|
|
2920
|
-
return new _OpenAIProvider(
|
|
2921
|
-
this.apiKey,
|
|
2922
|
-
this.defaultModelId,
|
|
2923
|
-
this.logger,
|
|
2924
|
-
this.baseURL,
|
|
2925
|
-
this.organization,
|
|
2926
|
-
pricing,
|
|
2927
|
-
this.defaultOptions,
|
|
2928
|
-
this.fileCache
|
|
2929
|
-
);
|
|
2842
|
+
return new _OpenAIProvider({ ...this.config, pricingConfig: pricing });
|
|
2930
2843
|
}
|
|
2931
2844
|
/**
|
|
2932
2845
|
* Set default provider-specific options for all LLM calls.
|
|
@@ -2943,16 +2856,10 @@ var OpenAIProvider = class _OpenAIProvider extends BaseProvider {
|
|
|
2943
2856
|
* ```
|
|
2944
2857
|
*/
|
|
2945
2858
|
withDefaultOptions(options) {
|
|
2946
|
-
return new _OpenAIProvider(
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
this.baseURL,
|
|
2951
|
-
this.organization,
|
|
2952
|
-
this.pricingConfig,
|
|
2953
|
-
options,
|
|
2954
|
-
this.fileCache
|
|
2955
|
-
);
|
|
2859
|
+
return new _OpenAIProvider({ ...this.config, defaultOptions: options });
|
|
2860
|
+
}
|
|
2861
|
+
withDefaultGenerationOptions(options) {
|
|
2862
|
+
return new _OpenAIProvider({ ...this.config, defaultGenOptions: options });
|
|
2956
2863
|
}
|
|
2957
2864
|
/**
|
|
2958
2865
|
* Set a file cache for API consistency with GoogleProvider.
|
|
@@ -2965,26 +2872,18 @@ var OpenAIProvider = class _OpenAIProvider extends BaseProvider {
|
|
|
2965
2872
|
* ```
|
|
2966
2873
|
*/
|
|
2967
2874
|
withFileCache(cache) {
|
|
2968
|
-
return new _OpenAIProvider(
|
|
2969
|
-
this.apiKey,
|
|
2970
|
-
this.defaultModelId,
|
|
2971
|
-
this.logger,
|
|
2972
|
-
this.baseURL,
|
|
2973
|
-
this.organization,
|
|
2974
|
-
this.pricingConfig,
|
|
2975
|
-
this.defaultOptions,
|
|
2976
|
-
cache
|
|
2977
|
-
);
|
|
2875
|
+
return new _OpenAIProvider({ ...this.config, fileCache: cache });
|
|
2978
2876
|
}
|
|
2979
2877
|
getSessionConfig() {
|
|
2980
2878
|
return {
|
|
2981
|
-
defaultLanguageModel: this.defaultModelId ? this.openai(this.defaultModelId) : null,
|
|
2879
|
+
defaultLanguageModel: this.config.defaultModelId ? this.openai(this.config.defaultModelId) : null,
|
|
2982
2880
|
modelFactory: (modelId) => this.openai(modelId),
|
|
2983
2881
|
providerType: "openai",
|
|
2984
|
-
providerPricing: this.pricingConfig,
|
|
2882
|
+
providerPricing: this.config.pricingConfig,
|
|
2985
2883
|
fileManager: new NoOpFileManager(),
|
|
2986
|
-
logger: this.logger,
|
|
2987
|
-
defaultProviderOptions: this.defaultOptions ? { openai: this.defaultOptions } : void 0
|
|
2884
|
+
logger: this.config.logger,
|
|
2885
|
+
defaultProviderOptions: this.config.defaultOptions ? { openai: this.config.defaultOptions } : void 0,
|
|
2886
|
+
defaultGenerationOptions: this.config.defaultGenOptions
|
|
2988
2887
|
};
|
|
2989
2888
|
}
|
|
2990
2889
|
createStreamingSession(signal) {
|
|
@@ -2995,14 +2894,13 @@ var OpenAIProvider = class _OpenAIProvider extends BaseProvider {
|
|
|
2995
2894
|
}
|
|
2996
2895
|
};
|
|
2997
2896
|
function createOpenAIProvider(config) {
|
|
2998
|
-
return new OpenAIProvider(
|
|
2999
|
-
config.apiKey,
|
|
3000
|
-
null,
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
config.
|
|
3004
|
-
|
|
3005
|
-
);
|
|
2897
|
+
return new OpenAIProvider({
|
|
2898
|
+
apiKey: config.apiKey,
|
|
2899
|
+
defaultModelId: null,
|
|
2900
|
+
logger: noopLogger,
|
|
2901
|
+
baseURL: config.baseURL,
|
|
2902
|
+
organization: config.organization
|
|
2903
|
+
});
|
|
3006
2904
|
}
|
|
3007
2905
|
|
|
3008
2906
|
// src/validation/validation-history.ts
|