@ax-llm/ax 11.0.14 → 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.d.cts CHANGED
@@ -1064,6 +1064,7 @@ interface AxAIGoogleGeminiArgs {
1064
1064
  apiKey?: string;
1065
1065
  projectId?: string;
1066
1066
  region?: string;
1067
+ endpoint?: string;
1067
1068
  config?: Readonly<Partial<AxAIGoogleGeminiConfig>>;
1068
1069
  options?: Readonly<AxAIServiceOptions & AxAIGoogleGeminiOptionsTools>;
1069
1070
  models?: AxAIModelList<AxAIGoogleGeminiModel>;
@@ -1072,7 +1073,7 @@ interface AxAIGoogleGeminiArgs {
1072
1073
  * AxAIGoogleGemini: AI Service
1073
1074
  */
1074
1075
  declare class AxAIGoogleGemini extends AxBaseAI<AxAIGoogleGeminiModel, AxAIGoogleGeminiEmbedModel, AxAIGoogleGeminiChatRequest, AxAIGoogleGeminiBatchEmbedRequest | AxAIGoogleVertexBatchEmbedRequest, AxAIGoogleGeminiChatResponse, AxAIGoogleGeminiChatResponseDelta, AxAIGoogleGeminiBatchEmbedResponse | AxAIGoogleVertexBatchEmbedResponse> {
1075
- constructor({ apiKey, projectId, region, config, options, models, }: Readonly<Omit<AxAIGoogleGeminiArgs, 'name'>>);
1076
+ constructor({ apiKey, projectId, region, endpoint, config, options, models, }: Readonly<Omit<AxAIGoogleGeminiArgs, 'name'>>);
1076
1077
  }
1077
1078
 
1078
1079
  declare enum AxAIGroqModel {
package/index.d.ts CHANGED
@@ -1064,6 +1064,7 @@ interface AxAIGoogleGeminiArgs {
1064
1064
  apiKey?: string;
1065
1065
  projectId?: string;
1066
1066
  region?: string;
1067
+ endpoint?: string;
1067
1068
  config?: Readonly<Partial<AxAIGoogleGeminiConfig>>;
1068
1069
  options?: Readonly<AxAIServiceOptions & AxAIGoogleGeminiOptionsTools>;
1069
1070
  models?: AxAIModelList<AxAIGoogleGeminiModel>;
@@ -1072,7 +1073,7 @@ interface AxAIGoogleGeminiArgs {
1072
1073
  * AxAIGoogleGemini: AI Service
1073
1074
  */
1074
1075
  declare class AxAIGoogleGemini extends AxBaseAI<AxAIGoogleGeminiModel, AxAIGoogleGeminiEmbedModel, AxAIGoogleGeminiChatRequest, AxAIGoogleGeminiBatchEmbedRequest | AxAIGoogleVertexBatchEmbedRequest, AxAIGoogleGeminiChatResponse, AxAIGoogleGeminiChatResponseDelta, AxAIGoogleGeminiBatchEmbedResponse | AxAIGoogleVertexBatchEmbedResponse> {
1075
- constructor({ apiKey, projectId, region, config, options, models, }: Readonly<Omit<AxAIGoogleGeminiArgs, 'name'>>);
1076
+ constructor({ apiKey, projectId, region, endpoint, config, options, models, }: Readonly<Omit<AxAIGoogleGeminiArgs, 'name'>>);
1076
1077
  }
1077
1078
 
1078
1079
  declare enum AxAIGroqModel {
package/index.js CHANGED
@@ -2584,9 +2584,10 @@ var axAIGoogleGeminiDefaultConfig = () => structuredClone({
2584
2584
  ...axBaseAIDefaultConfig()
2585
2585
  });
2586
2586
  var AxAIGoogleGeminiImpl = class {
2587
- constructor(config, isVertex, apiKey, options) {
2587
+ constructor(config, isVertex, endpoint, apiKey, options) {
2588
2588
  this.config = config;
2589
2589
  this.isVertex = isVertex;
2590
+ this.endpoint = endpoint;
2590
2591
  this.apiKey = apiKey;
2591
2592
  this.options = options;
2592
2593
  }
@@ -2611,9 +2612,16 @@ var AxAIGoogleGeminiImpl = class {
2611
2612
  if (!req.chatPrompt || req.chatPrompt.length === 0) {
2612
2613
  throw new Error("Chat prompt is empty");
2613
2614
  }
2614
- const apiConfig = {
2615
- name: stream ? `/models/${model}:streamGenerateContent?alt=sse` : `/models/${model}:generateContent`
2616
- };
2615
+ let apiConfig;
2616
+ if (this.endpoint) {
2617
+ apiConfig = {
2618
+ name: stream ? `/${this.endpoint}:streamGenerateContent?alt=sse` : `/${this.endpoint}:generateContent`
2619
+ };
2620
+ } else {
2621
+ apiConfig = {
2622
+ name: stream ? `/models/${model}:streamGenerateContent?alt=sse` : `/models/${model}:generateContent`
2623
+ };
2624
+ }
2617
2625
  if (!this.isVertex) {
2618
2626
  const pf = stream ? "&" : "?";
2619
2627
  apiConfig.name += `${pf}key=${this.apiKey}`;
@@ -2764,9 +2772,15 @@ var AxAIGoogleGeminiImpl = class {
2764
2772
  let apiConfig;
2765
2773
  let reqValue;
2766
2774
  if (this.isVertex) {
2767
- apiConfig = {
2768
- name: `/models/${model}:predict`
2769
- };
2775
+ if (this.endpoint) {
2776
+ apiConfig = {
2777
+ name: `/${this.endpoint}:predict`
2778
+ };
2779
+ } else {
2780
+ apiConfig = {
2781
+ name: `/models/${model}:predict`
2782
+ };
2783
+ }
2770
2784
  reqValue = {
2771
2785
  instances: req.texts.map((text) => ({
2772
2786
  content: text
@@ -2864,6 +2878,7 @@ var AxAIGoogleGemini = class extends AxBaseAI {
2864
2878
  apiKey,
2865
2879
  projectId,
2866
2880
  region,
2881
+ endpoint,
2867
2882
  config,
2868
2883
  options,
2869
2884
  models
@@ -2872,7 +2887,13 @@ var AxAIGoogleGemini = class extends AxBaseAI {
2872
2887
  let apiURL;
2873
2888
  let headers;
2874
2889
  if (isVertex) {
2875
- apiURL = `https://${region}-aiplatform.googleapis.com/v1/projects/${projectId}/locations/${region}/publishers/google/`;
2890
+ let path;
2891
+ if (endpoint) {
2892
+ path = "endpoints";
2893
+ } else {
2894
+ path = "publishers/google";
2895
+ }
2896
+ apiURL = `https://${region}-aiplatform.googleapis.com/v1/projects/${projectId}/locations/${region}/${path}`;
2876
2897
  if (apiKey) {
2877
2898
  headers = async () => ({ Authorization: `Bearer ${apiKey}` });
2878
2899
  } else {
@@ -2892,7 +2913,13 @@ var AxAIGoogleGemini = class extends AxBaseAI {
2892
2913
  ...axAIGoogleGeminiDefaultConfig(),
2893
2914
  ...config
2894
2915
  };
2895
- const aiImpl = new AxAIGoogleGeminiImpl(_config, isVertex, apiKey, options);
2916
+ const aiImpl = new AxAIGoogleGeminiImpl(
2917
+ _config,
2918
+ isVertex,
2919
+ endpoint,
2920
+ apiKey,
2921
+ options
2922
+ );
2896
2923
  super(aiImpl, {
2897
2924
  name: "GoogleGeminiAI",
2898
2925
  apiURL,
@@ -4358,6 +4385,8 @@ var validateValue = (field, value) => {
4358
4385
  return val instanceof Date || typeof val === "string";
4359
4386
  case "datetime":
4360
4387
  return val instanceof Date || typeof val === "string";
4388
+ case "json":
4389
+ return typeof val === "object" || typeof val === "string";
4361
4390
  default:
4362
4391
  return false;
4363
4392
  }