@ax-llm/ax 11.0.15 → 11.0.16
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/index.cjs +36 -9
- package/index.cjs.map +1 -1
- package/index.d.cts +2 -1
- package/index.d.ts +2 -1
- package/index.js +36 -9
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.cjs
CHANGED
|
@@ -2686,9 +2686,10 @@ var axAIGoogleGeminiDefaultConfig = () => structuredClone({
|
|
|
2686
2686
|
...axBaseAIDefaultConfig()
|
|
2687
2687
|
});
|
|
2688
2688
|
var AxAIGoogleGeminiImpl = class {
|
|
2689
|
-
constructor(config, isVertex, apiKey, options) {
|
|
2689
|
+
constructor(config, isVertex, endpoint, apiKey, options) {
|
|
2690
2690
|
this.config = config;
|
|
2691
2691
|
this.isVertex = isVertex;
|
|
2692
|
+
this.endpoint = endpoint;
|
|
2692
2693
|
this.apiKey = apiKey;
|
|
2693
2694
|
this.options = options;
|
|
2694
2695
|
}
|
|
@@ -2713,9 +2714,16 @@ var AxAIGoogleGeminiImpl = class {
|
|
|
2713
2714
|
if (!req.chatPrompt || req.chatPrompt.length === 0) {
|
|
2714
2715
|
throw new Error("Chat prompt is empty");
|
|
2715
2716
|
}
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2717
|
+
let apiConfig;
|
|
2718
|
+
if (this.endpoint) {
|
|
2719
|
+
apiConfig = {
|
|
2720
|
+
name: stream ? `/${this.endpoint}:streamGenerateContent?alt=sse` : `/${this.endpoint}:generateContent`
|
|
2721
|
+
};
|
|
2722
|
+
} else {
|
|
2723
|
+
apiConfig = {
|
|
2724
|
+
name: stream ? `/models/${model}:streamGenerateContent?alt=sse` : `/models/${model}:generateContent`
|
|
2725
|
+
};
|
|
2726
|
+
}
|
|
2719
2727
|
if (!this.isVertex) {
|
|
2720
2728
|
const pf = stream ? "&" : "?";
|
|
2721
2729
|
apiConfig.name += `${pf}key=${this.apiKey}`;
|
|
@@ -2866,9 +2874,15 @@ var AxAIGoogleGeminiImpl = class {
|
|
|
2866
2874
|
let apiConfig;
|
|
2867
2875
|
let reqValue;
|
|
2868
2876
|
if (this.isVertex) {
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
|
|
2877
|
+
if (this.endpoint) {
|
|
2878
|
+
apiConfig = {
|
|
2879
|
+
name: `/${this.endpoint}:predict`
|
|
2880
|
+
};
|
|
2881
|
+
} else {
|
|
2882
|
+
apiConfig = {
|
|
2883
|
+
name: `/models/${model}:predict`
|
|
2884
|
+
};
|
|
2885
|
+
}
|
|
2872
2886
|
reqValue = {
|
|
2873
2887
|
instances: req.texts.map((text) => ({
|
|
2874
2888
|
content: text
|
|
@@ -2966,6 +2980,7 @@ var AxAIGoogleGemini = class extends AxBaseAI {
|
|
|
2966
2980
|
apiKey,
|
|
2967
2981
|
projectId,
|
|
2968
2982
|
region,
|
|
2983
|
+
endpoint,
|
|
2969
2984
|
config,
|
|
2970
2985
|
options,
|
|
2971
2986
|
models
|
|
@@ -2974,7 +2989,13 @@ var AxAIGoogleGemini = class extends AxBaseAI {
|
|
|
2974
2989
|
let apiURL;
|
|
2975
2990
|
let headers;
|
|
2976
2991
|
if (isVertex) {
|
|
2977
|
-
|
|
2992
|
+
let path;
|
|
2993
|
+
if (endpoint) {
|
|
2994
|
+
path = "endpoints";
|
|
2995
|
+
} else {
|
|
2996
|
+
path = "publishers/google";
|
|
2997
|
+
}
|
|
2998
|
+
apiURL = `https://${region}-aiplatform.googleapis.com/v1/projects/${projectId}/locations/${region}/${path}`;
|
|
2978
2999
|
if (apiKey) {
|
|
2979
3000
|
headers = async () => ({ Authorization: `Bearer ${apiKey}` });
|
|
2980
3001
|
} else {
|
|
@@ -2994,7 +3015,13 @@ var AxAIGoogleGemini = class extends AxBaseAI {
|
|
|
2994
3015
|
...axAIGoogleGeminiDefaultConfig(),
|
|
2995
3016
|
...config
|
|
2996
3017
|
};
|
|
2997
|
-
const aiImpl = new AxAIGoogleGeminiImpl(
|
|
3018
|
+
const aiImpl = new AxAIGoogleGeminiImpl(
|
|
3019
|
+
_config,
|
|
3020
|
+
isVertex,
|
|
3021
|
+
endpoint,
|
|
3022
|
+
apiKey,
|
|
3023
|
+
options
|
|
3024
|
+
);
|
|
2998
3025
|
super(aiImpl, {
|
|
2999
3026
|
name: "GoogleGeminiAI",
|
|
3000
3027
|
apiURL,
|