@langchain/google-genai 0.0.12 → 0.0.14

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.
@@ -108,6 +108,18 @@ class ChatGoogleGenerativeAI extends chat_models_1.BaseChatModel {
108
108
  writable: true,
109
109
  value: void 0
110
110
  });
111
+ Object.defineProperty(this, "apiVersion", {
112
+ enumerable: true,
113
+ configurable: true,
114
+ writable: true,
115
+ value: "v1"
116
+ });
117
+ Object.defineProperty(this, "baseUrl", {
118
+ enumerable: true,
119
+ configurable: true,
120
+ writable: true,
121
+ value: "https://generativeai.googleapis.com"
122
+ });
111
123
  Object.defineProperty(this, "streaming", {
112
124
  enumerable: true,
113
125
  configurable: true,
@@ -171,6 +183,9 @@ class ChatGoogleGenerativeAI extends chat_models_1.BaseChatModel {
171
183
  topP: this.topP,
172
184
  topK: this.topK,
173
185
  },
186
+ }, {
187
+ apiVersion: this.apiVersion,
188
+ baseUrl: this.baseUrl,
174
189
  });
175
190
  }
176
191
  _combineLLMOutput() {
@@ -84,6 +84,14 @@ export interface GoogleGenerativeAIChatInput extends BaseChatModelParams {
84
84
  * Google API key to use
85
85
  */
86
86
  apiKey?: string;
87
+ /**
88
+ * Google API version to use
89
+ */
90
+ apiVersion?: string;
91
+ /**
92
+ * Google API base URL to use
93
+ */
94
+ baseUrl?: string;
87
95
  /** Whether to stream the results or not */
88
96
  streaming?: boolean;
89
97
  }
@@ -131,6 +139,8 @@ export declare class ChatGoogleGenerativeAI extends BaseChatModel implements Goo
131
139
  stopSequences: string[];
132
140
  safetySettings?: SafetySetting[];
133
141
  apiKey?: string;
142
+ apiVersion?: string;
143
+ baseUrl?: string;
134
144
  streaming: boolean;
135
145
  private client;
136
146
  get _isMultimodalModel(): boolean;
@@ -105,6 +105,18 @@ export class ChatGoogleGenerativeAI extends BaseChatModel {
105
105
  writable: true,
106
106
  value: void 0
107
107
  });
108
+ Object.defineProperty(this, "apiVersion", {
109
+ enumerable: true,
110
+ configurable: true,
111
+ writable: true,
112
+ value: "v1"
113
+ });
114
+ Object.defineProperty(this, "baseUrl", {
115
+ enumerable: true,
116
+ configurable: true,
117
+ writable: true,
118
+ value: "https://generativeai.googleapis.com"
119
+ });
108
120
  Object.defineProperty(this, "streaming", {
109
121
  enumerable: true,
110
122
  configurable: true,
@@ -168,6 +180,9 @@ export class ChatGoogleGenerativeAI extends BaseChatModel {
168
180
  topP: this.topP,
169
181
  topK: this.topK,
170
182
  },
183
+ }, {
184
+ apiVersion: this.apiVersion,
185
+ baseUrl: this.baseUrl,
171
186
  });
172
187
  }
173
188
  _combineLLMOutput() {
package/dist/utils.cjs CHANGED
@@ -34,6 +34,17 @@ function convertAuthorToRole(author) {
34
34
  }
35
35
  }
36
36
  exports.convertAuthorToRole = convertAuthorToRole;
37
+ function messageContentMedia(content) {
38
+ if ("mimeType" in content && "data" in content) {
39
+ return {
40
+ inlineData: {
41
+ mimeType: content.mimeType,
42
+ data: content.data,
43
+ },
44
+ };
45
+ }
46
+ throw new Error("Invalid media content");
47
+ }
37
48
  function convertMessageContentToParts(content, isMultimodalModel) {
38
49
  if (typeof content === "string") {
39
50
  return [{ text: content }];
@@ -73,6 +84,9 @@ function convertMessageContentToParts(content, isMultimodalModel) {
73
84
  },
74
85
  };
75
86
  }
87
+ else if (c.type === "media") {
88
+ return messageContentMedia(c);
89
+ }
76
90
  throw new Error(`Unknown content type ${c.type}`);
77
91
  });
78
92
  }
package/dist/utils.js CHANGED
@@ -29,6 +29,17 @@ export function convertAuthorToRole(author) {
29
29
  throw new Error(`Unknown / unsupported author: ${author}`);
30
30
  }
31
31
  }
32
+ function messageContentMedia(content) {
33
+ if ("mimeType" in content && "data" in content) {
34
+ return {
35
+ inlineData: {
36
+ mimeType: content.mimeType,
37
+ data: content.data,
38
+ },
39
+ };
40
+ }
41
+ throw new Error("Invalid media content");
42
+ }
32
43
  export function convertMessageContentToParts(content, isMultimodalModel) {
33
44
  if (typeof content === "string") {
34
45
  return [{ text: content }];
@@ -68,6 +79,9 @@ export function convertMessageContentToParts(content, isMultimodalModel) {
68
79
  },
69
80
  };
70
81
  }
82
+ else if (c.type === "media") {
83
+ return messageContentMedia(c);
84
+ }
71
85
  throw new Error(`Unknown content type ${c.type}`);
72
86
  });
73
87
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/google-genai",
3
- "version": "0.0.12",
3
+ "version": "0.0.14",
4
4
  "description": "Sample integration for LangChain.js",
5
5
  "type": "module",
6
6
  "engines": {
@@ -40,7 +40,7 @@
40
40
  "license": "MIT",
41
41
  "dependencies": {
42
42
  "@google/generative-ai": "^0.7.0",
43
- "@langchain/core": "~0.1.5"
43
+ "@langchain/core": ">0.1.5 <0.3.0"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@jest/globals": "^29.5.0",