@langchain/google-common 0.2.18 → 1.0.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.
Files changed (169) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/LICENSE +6 -6
  3. package/dist/_virtual/rolldown_runtime.cjs +25 -0
  4. package/dist/auth.cjs +82 -116
  5. package/dist/auth.cjs.map +1 -0
  6. package/dist/auth.d.cts +46 -0
  7. package/dist/auth.d.cts.map +1 -0
  8. package/dist/auth.d.ts +41 -36
  9. package/dist/auth.d.ts.map +1 -0
  10. package/dist/auth.js +80 -110
  11. package/dist/auth.js.map +1 -0
  12. package/dist/chat_models.cjs +251 -466
  13. package/dist/chat_models.cjs.map +1 -0
  14. package/dist/chat_models.d.cts +98 -0
  15. package/dist/chat_models.d.cts.map +1 -0
  16. package/dist/chat_models.d.ts +87 -73
  17. package/dist/chat_models.d.ts.map +1 -0
  18. package/dist/chat_models.js +245 -457
  19. package/dist/chat_models.js.map +1 -0
  20. package/dist/connection.cjs +321 -466
  21. package/dist/connection.cjs.map +1 -0
  22. package/dist/connection.d.cts +109 -0
  23. package/dist/connection.d.cts.map +1 -0
  24. package/dist/connection.d.ts +98 -91
  25. package/dist/connection.d.ts.map +1 -0
  26. package/dist/connection.js +317 -459
  27. package/dist/connection.js.map +1 -0
  28. package/dist/embeddings.cjs +135 -186
  29. package/dist/embeddings.cjs.map +1 -0
  30. package/dist/embeddings.d.cts +44 -0
  31. package/dist/embeddings.d.cts.map +1 -0
  32. package/dist/embeddings.d.ts +38 -32
  33. package/dist/embeddings.d.ts.map +1 -0
  34. package/dist/embeddings.js +133 -181
  35. package/dist/embeddings.js.map +1 -0
  36. package/dist/experimental/media.cjs +380 -482
  37. package/dist/experimental/media.cjs.map +1 -0
  38. package/dist/experimental/media.d.cts +198 -0
  39. package/dist/experimental/media.d.cts.map +1 -0
  40. package/dist/experimental/media.d.ts +190 -202
  41. package/dist/experimental/media.d.ts.map +1 -0
  42. package/dist/experimental/media.js +369 -468
  43. package/dist/experimental/media.js.map +1 -0
  44. package/dist/experimental/utils/media_core.cjs +403 -517
  45. package/dist/experimental/utils/media_core.cjs.map +1 -0
  46. package/dist/experimental/utils/media_core.d.cts +215 -0
  47. package/dist/experimental/utils/media_core.d.cts.map +1 -0
  48. package/dist/experimental/utils/media_core.d.ts +171 -165
  49. package/dist/experimental/utils/media_core.d.ts.map +1 -0
  50. package/dist/experimental/utils/media_core.js +395 -506
  51. package/dist/experimental/utils/media_core.js.map +1 -0
  52. package/dist/index.cjs +58 -27
  53. package/dist/index.d.cts +13 -0
  54. package/dist/index.d.ts +13 -11
  55. package/dist/index.js +13 -11
  56. package/dist/llms.cjs +157 -244
  57. package/dist/llms.cjs.map +1 -0
  58. package/dist/llms.d.cts +72 -0
  59. package/dist/llms.d.cts.map +1 -0
  60. package/dist/llms.d.ts +64 -54
  61. package/dist/llms.d.ts.map +1 -0
  62. package/dist/llms.js +154 -238
  63. package/dist/llms.js.map +1 -0
  64. package/dist/output_parsers.cjs +148 -173
  65. package/dist/output_parsers.cjs.map +1 -0
  66. package/dist/output_parsers.d.cts +53 -0
  67. package/dist/output_parsers.d.cts.map +1 -0
  68. package/dist/output_parsers.d.ts +46 -42
  69. package/dist/output_parsers.d.ts.map +1 -0
  70. package/dist/output_parsers.js +146 -168
  71. package/dist/output_parsers.js.map +1 -0
  72. package/dist/types-anthropic.d.cts +229 -0
  73. package/dist/types-anthropic.d.cts.map +1 -0
  74. package/dist/types-anthropic.d.ts +221 -215
  75. package/dist/types-anthropic.d.ts.map +1 -0
  76. package/dist/types.cjs +51 -62
  77. package/dist/types.cjs.map +1 -0
  78. package/dist/types.d.cts +748 -0
  79. package/dist/types.d.cts.map +1 -0
  80. package/dist/types.d.ts +669 -656
  81. package/dist/types.d.ts.map +1 -0
  82. package/dist/types.js +46 -45
  83. package/dist/types.js.map +1 -0
  84. package/dist/utils/anthropic.cjs +598 -821
  85. package/dist/utils/anthropic.cjs.map +1 -0
  86. package/dist/utils/anthropic.js +597 -818
  87. package/dist/utils/anthropic.js.map +1 -0
  88. package/dist/utils/common.cjs +130 -211
  89. package/dist/utils/common.cjs.map +1 -0
  90. package/dist/utils/common.d.cts +13 -0
  91. package/dist/utils/common.d.cts.map +1 -0
  92. package/dist/utils/common.d.ts +12 -7
  93. package/dist/utils/common.d.ts.map +1 -0
  94. package/dist/utils/common.js +128 -207
  95. package/dist/utils/common.js.map +1 -0
  96. package/dist/utils/failed_handler.cjs +28 -30
  97. package/dist/utils/failed_handler.cjs.map +1 -0
  98. package/dist/utils/failed_handler.d.cts +9 -0
  99. package/dist/utils/failed_handler.d.cts.map +1 -0
  100. package/dist/utils/failed_handler.d.ts +8 -2
  101. package/dist/utils/failed_handler.d.ts.map +1 -0
  102. package/dist/utils/failed_handler.js +28 -28
  103. package/dist/utils/failed_handler.js.map +1 -0
  104. package/dist/utils/gemini.cjs +1020 -1488
  105. package/dist/utils/gemini.cjs.map +1 -0
  106. package/dist/utils/gemini.d.cts +51 -0
  107. package/dist/utils/gemini.d.cts.map +1 -0
  108. package/dist/utils/gemini.d.ts +51 -48
  109. package/dist/utils/gemini.d.ts.map +1 -0
  110. package/dist/utils/gemini.js +1015 -1479
  111. package/dist/utils/gemini.js.map +1 -0
  112. package/dist/utils/index.cjs +38 -23
  113. package/dist/utils/index.d.cts +8 -0
  114. package/dist/utils/index.d.ts +8 -7
  115. package/dist/utils/index.js +8 -7
  116. package/dist/utils/palm.d.cts +11 -0
  117. package/dist/utils/palm.d.cts.map +1 -0
  118. package/dist/utils/palm.d.ts +9 -4
  119. package/dist/utils/palm.d.ts.map +1 -0
  120. package/dist/utils/safety.cjs +13 -22
  121. package/dist/utils/safety.cjs.map +1 -0
  122. package/dist/utils/safety.d.cts +12 -0
  123. package/dist/utils/safety.d.cts.map +1 -0
  124. package/dist/utils/safety.d.ts +10 -4
  125. package/dist/utils/safety.d.ts.map +1 -0
  126. package/dist/utils/safety.js +13 -19
  127. package/dist/utils/safety.js.map +1 -0
  128. package/dist/utils/stream.cjs +296 -475
  129. package/dist/utils/stream.cjs.map +1 -0
  130. package/dist/utils/stream.d.cts +165 -0
  131. package/dist/utils/stream.d.cts.map +1 -0
  132. package/dist/utils/stream.d.ts +156 -131
  133. package/dist/utils/stream.d.ts.map +1 -0
  134. package/dist/utils/stream.js +293 -469
  135. package/dist/utils/stream.js.map +1 -0
  136. package/dist/utils/zod_to_gemini_parameters.cjs +43 -81
  137. package/dist/utils/zod_to_gemini_parameters.cjs.map +1 -0
  138. package/dist/utils/zod_to_gemini_parameters.d.cts +22 -0
  139. package/dist/utils/zod_to_gemini_parameters.d.cts.map +1 -0
  140. package/dist/utils/zod_to_gemini_parameters.d.ts +21 -6
  141. package/dist/utils/zod_to_gemini_parameters.d.ts.map +1 -0
  142. package/dist/utils/zod_to_gemini_parameters.js +40 -76
  143. package/dist/utils/zod_to_gemini_parameters.js.map +1 -0
  144. package/package.json +69 -85
  145. package/dist/types-anthropic.cjs +0 -2
  146. package/dist/types-anthropic.js +0 -1
  147. package/dist/utils/anthropic.d.ts +0 -4
  148. package/dist/utils/palm.cjs +0 -2
  149. package/dist/utils/palm.js +0 -1
  150. package/experimental/media.cjs +0 -1
  151. package/experimental/media.d.cts +0 -1
  152. package/experimental/media.d.ts +0 -1
  153. package/experimental/media.js +0 -1
  154. package/experimental/utils/media_core.cjs +0 -1
  155. package/experimental/utils/media_core.d.cts +0 -1
  156. package/experimental/utils/media_core.d.ts +0 -1
  157. package/experimental/utils/media_core.js +0 -1
  158. package/index.cjs +0 -1
  159. package/index.d.cts +0 -1
  160. package/index.d.ts +0 -1
  161. package/index.js +0 -1
  162. package/types.cjs +0 -1
  163. package/types.d.cts +0 -1
  164. package/types.d.ts +0 -1
  165. package/types.js +0 -1
  166. package/utils.cjs +0 -1
  167. package/utils.d.cts +0 -1
  168. package/utils.d.ts +0 -1
  169. package/utils.js +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stream.js","names":["value: unknown","ret: Record<string, unknown>","v: Record<string, any>","val: unknown","data: string","start: string","ret: object | null","obj: unknown","chunk: any","baseStream: AbstractStream","body: ReadableStream | null","body: any","event: string | null","ret: Record<string, string>","jsonAttribute?: string"],"sources":["../../src/utils/stream.ts"],"sourcesContent":["import { GenerationChunk } from \"@langchain/core/outputs\";\n\nexport interface AbstractStream {\n /**\n * Add more text to the buffer\n * @param data\n */\n appendBuffer(data: string): void;\n\n /**\n * Indicate that there is no more text to be added to the buffer\n * (ie - our source material is done)\n */\n closeBuffer(): void;\n /**\n * Get the next chunk that is coming from the stream.\n * This chunk may be null, usually indicating the last chunk in the stream.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n nextChunk(): Promise<any>;\n\n /**\n * Is the stream done?\n * A stream is only done if all of the following are true:\n * - There is no more data to be added to the text buffer\n * - There is no more data in the text buffer\n * - There are no chunks that are waiting to be consumed\n */\n get streamDone(): boolean;\n}\n\nexport function complexValue(value: unknown): unknown {\n if (value === null || typeof value === \"undefined\") {\n // I dunno what to put here. An error, probably\n return undefined;\n } else if (typeof value === \"object\") {\n if (Array.isArray(value)) {\n return {\n list_val: value.map((avalue) => complexValue(avalue)),\n };\n } else {\n const ret: Record<string, unknown> = {};\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const v: Record<string, any> = value;\n Object.keys(v).forEach((key) => {\n ret[key] = complexValue(v[key]);\n });\n return { struct_val: ret };\n }\n } else if (typeof value === \"number\") {\n if (Number.isInteger(value)) {\n return { int_val: value };\n } else {\n return { float_val: value };\n }\n } else {\n return {\n string_val: [value],\n };\n }\n}\n\nexport function simpleValue(val: unknown): unknown {\n if (val && typeof val === \"object\" && !Array.isArray(val)) {\n // eslint-disable-next-line no-prototype-builtins\n if (val.hasOwnProperty(\"stringVal\")) {\n return (val as { stringVal: string[] }).stringVal[0];\n\n // eslint-disable-next-line no-prototype-builtins\n } else if (val.hasOwnProperty(\"boolVal\")) {\n return (val as { boolVal: boolean[] }).boolVal[0];\n\n // eslint-disable-next-line no-prototype-builtins\n } else if (val.hasOwnProperty(\"listVal\")) {\n const { listVal } = val as { listVal: unknown[] };\n return listVal.map((aval) => simpleValue(aval));\n\n // eslint-disable-next-line no-prototype-builtins\n } else if (val.hasOwnProperty(\"structVal\")) {\n const ret: Record<string, unknown> = {};\n const struct = (val as { structVal: Record<string, unknown> }).structVal;\n Object.keys(struct).forEach((key) => {\n ret[key] = simpleValue(struct[key]);\n });\n return ret;\n } else {\n const ret: Record<string, unknown> = {};\n const struct = val as Record<string, unknown>;\n Object.keys(struct).forEach((key) => {\n ret[key] = simpleValue(struct[key]);\n });\n return ret;\n }\n } else if (Array.isArray(val)) {\n return val.map((aval) => simpleValue(aval));\n } else {\n return val;\n }\n}\nexport class JsonStream implements AbstractStream {\n _buffer = \"\";\n\n _bufferOpen = true;\n\n _firstRun = true;\n\n /**\n * Add data to the buffer. This may cause chunks to be generated, if available.\n * @param data\n */\n appendBuffer(data: string): void {\n this._buffer += data;\n // Our first time, skip to the opening of the array\n if (this._firstRun) {\n this._skipTo(\"[\");\n this._firstRun = false;\n }\n\n this._parseBuffer();\n }\n\n /**\n * Indicate there is no more data that will be added to the text buffer.\n * This should be called when all the data has been read and added to indicate\n * that we should process everything remaining in the buffer.\n */\n closeBuffer(): void {\n this._bufferOpen = false;\n this._parseBuffer();\n }\n\n /**\n * Skip characters in the buffer till we get to the start of an object.\n * Then attempt to read a full object.\n * If we do read a full object, turn it into a chunk and send it to the chunk handler.\n * Repeat this for as much as we can.\n */\n _parseBuffer(): void {\n let obj = null;\n do {\n this._skipTo(\"{\");\n obj = this._getFullObject();\n if (obj !== null) {\n const chunk = this._simplifyObject(obj);\n this._handleChunk(chunk);\n }\n } while (obj !== null);\n\n if (!this._bufferOpen) {\n // No more data will be added, and we have parsed everything we could,\n // so everything else is garbage.\n this._handleChunk(null);\n this._buffer = \"\";\n }\n }\n\n /**\n * If the string is present, move the start of the buffer to the first occurrence\n * of that string. This is useful for skipping over elements or parts that we're not\n * really interested in parsing. (ie - the opening characters, comma separators, etc.)\n * @param start The string to start the buffer with\n */\n _skipTo(start: string): void {\n const index = this._buffer.indexOf(start);\n if (index > 0) {\n this._buffer = this._buffer.slice(index);\n }\n }\n\n /**\n * Given what is in the buffer, parse a single object out of it.\n * If a complete object isn't available, return null.\n * Assumes that we are at the start of an object to parse.\n */\n _getFullObject(): object | null {\n let ret: object | null = null;\n\n // Loop while we don't have something to return AND we have something in the buffer\n let index = 0;\n while (ret === null && this._buffer.length > index) {\n // Advance to the next close bracket after our current index\n index = this._buffer.indexOf(\"}\", index + 1);\n\n // If we don't find one, exit with null\n if (index === -1) {\n return null;\n }\n\n // If we have one, try to turn it into an object to return\n try {\n const objStr = this._buffer.substring(0, index + 1);\n ret = JSON.parse(objStr);\n\n // We only get here if it parsed it ok\n // If we did turn it into an object, remove it from the buffer\n this._buffer = this._buffer.slice(index + 1);\n } catch {\n // It didn't parse it correctly, so we swallow the exception and continue\n }\n }\n\n return ret;\n }\n\n _simplifyObject(obj: unknown): object {\n return obj as object;\n }\n\n // Set up a potential Promise that the handler can resolve.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n _chunkResolution: (chunk: any) => void;\n\n // If there is no Promise (it is null), the handler must add it to the queue\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n _chunkPending: Promise<any> | null = null;\n\n // A queue that will collect chunks while there is no Promise\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n _chunkQueue: any[] = [];\n\n /**\n * Register that we have another chunk available for consumption.\n * If we are waiting for a chunk, resolve the promise waiting for it immediately.\n * If not, then add it to the queue.\n * @param chunk\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n _handleChunk(chunk: any): void {\n if (this._chunkPending) {\n this._chunkResolution(chunk);\n this._chunkPending = null;\n } else {\n this._chunkQueue.push(chunk);\n }\n }\n\n /**\n * Get the next chunk that is coming from the stream.\n * This chunk may be null, usually indicating the last chunk in the stream.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n async nextChunk(): Promise<any> {\n if (this._chunkQueue.length > 0) {\n // If there is data in the queue, return the next queue chunk\n return this._chunkQueue.shift() as GenerationChunk;\n } else {\n // Otherwise, set up a promise that handleChunk will cause to be resolved\n this._chunkPending = new Promise((resolve) => {\n this._chunkResolution = resolve;\n });\n return this._chunkPending;\n }\n }\n\n /**\n * Is the stream done?\n * A stream is only done if all of the following are true:\n * - There is no more data to be added to the text buffer\n * - There is no more data in the text buffer\n * - There are no chunks that are waiting to be consumed\n */\n get streamDone(): boolean {\n return (\n !this._bufferOpen &&\n this._buffer.length === 0 &&\n this._chunkQueue.length === 0 &&\n this._chunkPending === null\n );\n }\n}\n\nexport class ComplexJsonStream extends JsonStream {\n _simplifyObject(obj: unknown): object {\n return simpleValue(obj) as object;\n }\n}\n\nexport class ReadableAbstractStream implements AbstractStream {\n private baseStream: AbstractStream;\n\n decoder: TextDecoder;\n\n constructor(baseStream: AbstractStream, body: ReadableStream | null) {\n this.baseStream = baseStream;\n this.decoder = new TextDecoder(\"utf-8\");\n if (body) {\n // eslint-disable-next-line no-void\n void this.run(body);\n } else {\n console.error(\"Unexpected empty body while streaming\");\n }\n }\n\n appendBuffer(data: string): void {\n return this.baseStream.appendBuffer(data);\n }\n\n closeBuffer(): void {\n return this.baseStream.closeBuffer();\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n nextChunk(): Promise<any> {\n return this.baseStream.nextChunk();\n }\n\n get streamDone(): boolean {\n return this.baseStream.streamDone;\n }\n\n // Should be a ReadableStream, but the Gaxios Readable stream isn't.\n // But both should support async iterators, so make sure of that.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n async run(body: any) {\n if (typeof body[Symbol.asyncIterator] === \"function\") {\n for await (const value of body) {\n const svalue = this.decoder.decode(value, { stream: true });\n this.appendBuffer(svalue);\n }\n this.closeBuffer();\n } else {\n throw Error(\"Stream must implement async iterator.\");\n }\n }\n}\n\nexport class ReadableJsonStream extends ReadableAbstractStream {\n constructor(body: ReadableStream | null) {\n super(new JsonStream(), body);\n }\n}\n\nexport class SseStream implements AbstractStream {\n _buffer = \"\";\n\n _bufferOpen = true;\n\n appendBuffer(data: string): void {\n this._buffer += data;\n this._parseBuffer();\n }\n\n closeBuffer(): void {\n this._bufferOpen = false;\n this._parseBuffer();\n }\n\n /**\n * Attempt to load an entire event.\n * For each entire event we load,\n * send them to be handled.\n */\n _parseBuffer(): void {\n const events = this._buffer.split(/\\n\\n/);\n this._buffer = events.pop() ?? \"\";\n events.forEach((event) => this._handleEvent(event.trim()));\n\n if (!this._bufferOpen) {\n // No more data will be added, and we have parsed\n // everything. So dump the rest.\n this._handleEvent(null);\n this._buffer = \"\";\n }\n }\n\n /**\n * Given an event string, get all the fields\n * in the event. It is assumed there is one field\n * per line, but that field names can be duplicated,\n * indicating to append the new value to the previous value\n * @param event\n */\n _parseEvent(event: string | null): Record<string, string> | null {\n if (!event || event.trim() === \"\") {\n return null;\n }\n const ret: Record<string, string> = {};\n\n const lines = event.split(/\\n/);\n lines.forEach((line) => {\n const match = line.match(/^([^:]+): \\s*(.+)\\n*$/);\n if (match && match.length === 3) {\n const key = match[1];\n const val = match[2];\n const cur = ret[key] ?? \"\";\n ret[key] = `${cur}${val}`;\n }\n });\n\n return ret;\n }\n\n // Set up a potential Promise that the handler can resolve.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n _chunkResolution: (chunk: any) => void;\n\n // If there is no Promise (it is null), the handler must add it to the queue\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n _chunkPending: Promise<any> | null = null;\n\n // A queue that will collect chunks while there is no Promise\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n _chunkQueue: any[] = [];\n\n _handleEvent(event: string | null): void {\n const chunk = this._parseEvent(event);\n if (this._chunkPending) {\n this._chunkResolution(chunk);\n this._chunkPending = null;\n } else {\n this._chunkQueue.push(chunk);\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n async nextChunk(): Promise<any> {\n if (this._chunkQueue.length > 0) {\n // If there is data in the queue, return the next queue chunk\n return this._chunkQueue.shift() as Record<string, string>;\n } else {\n // Otherwise, set up a promise that handleChunk will cause to be resolved\n this._chunkPending = new Promise((resolve) => {\n this._chunkResolution = resolve;\n });\n return this._chunkPending;\n }\n }\n\n get streamDone(): boolean {\n return (\n !this._bufferOpen &&\n this._buffer.length === 0 &&\n this._chunkQueue.length === 0 &&\n this._chunkPending === null\n );\n }\n}\n\nexport class ReadableSseStream extends ReadableAbstractStream {\n constructor(body: ReadableStream | null) {\n super(new SseStream(), body);\n }\n}\n\nexport class SseJsonStream extends SseStream {\n _jsonAttribute: string = \"data\";\n\n constructor(jsonAttribute?: string) {\n super();\n this._jsonAttribute = jsonAttribute ?? this._jsonAttribute;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n async nextChunk(): Promise<any> {\n const eventRecord = (await super.nextChunk()) as Record<string, string>;\n const json = eventRecord?.[this._jsonAttribute];\n if (!json) {\n return null;\n } else {\n return JSON.parse(json);\n }\n }\n}\n\nexport class ReadableSseJsonStream extends ReadableAbstractStream {\n constructor(body: ReadableStream | null) {\n super(new SseJsonStream(), body);\n }\n}\n"],"mappings":";AA+BA,SAAgB,aAAaA,OAAyB;AACpD,KAAI,UAAU,QAAQ,OAAO,UAAU,YAErC,QAAO;UACE,OAAO,UAAU,SAC1B,KAAI,MAAM,QAAQ,MAAM,CACtB,QAAO,EACL,UAAU,MAAM,IAAI,CAAC,WAAW,aAAa,OAAO,CAAC,CACtD;MACI;EACL,MAAMC,MAA+B,CAAE;EAEvC,MAAMC,IAAyB;EAC/B,OAAO,KAAK,EAAE,CAAC,QAAQ,CAAC,QAAQ;GAC9B,IAAI,OAAO,aAAa,EAAE,KAAK;EAChC,EAAC;AACF,SAAO,EAAE,YAAY,IAAK;CAC3B;UACQ,OAAO,UAAU,SAC1B,KAAI,OAAO,UAAU,MAAM,CACzB,QAAO,EAAE,SAAS,MAAO;KAEzB,QAAO,EAAE,WAAW,MA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9B,MAAM,cAAe,MAAM,MAAM,WAAW;EAC5C,MAAM,OAAO,cAAc,KAAK;AAChC,MAAI,CAAC,KACH,QAAO;MAEP,QAAO,KAAK,MAAM,KAAK;CAE1B;AACF;AAED,IAAa,wBAAb,cAA2C,uBAAuB;CAChE,YAAYJ,MAA6B;EACvC,MAAM,IAAI,iBAAiB,KAAK;CACjC;AACF"}
@@ -1,86 +1,48 @@
1
- "use strict";
2
- /* eslint-disable @typescript-eslint/no-unused-vars */
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.adjustObjectType = adjustObjectType;
5
- exports.removeAdditionalProperties = removeAdditionalProperties;
6
- exports.schemaToGeminiParameters = schemaToGeminiParameters;
7
- exports.jsonSchemaToGeminiParameters = jsonSchemaToGeminiParameters;
8
- const types_1 = require("@langchain/core/utils/types");
9
- const json_schema_1 = require("@langchain/core/utils/json_schema");
10
- /* eslint-disable no-param-reassign */
11
- function adjustObjectType(
12
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
13
- obj
14
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
15
- ) {
16
- if (!Array.isArray(obj.type)) {
17
- return obj;
18
- }
19
- const len = obj.type.length;
20
- const nullIndex = obj.type.indexOf("null");
21
- if (len === 2 && nullIndex >= 0) {
22
- // There are only two values set for the type, and one of them is "null".
23
- // Set the type to the other one and set nullable to true.
24
- const typeIndex = nullIndex === 0 ? 1 : 0;
25
- obj.type = obj.type[typeIndex];
26
- obj.nullable = true;
27
- }
28
- else if (len === 1 && nullIndex === 0) {
29
- // This is nullable only without a type, which doesn't
30
- // make sense for Gemini
31
- throw new Error("zod_to_gemini_parameters: Gemini cannot handle null type");
32
- }
33
- else if (len === 1) {
34
- // Although an array, it has only one value.
35
- // So set it to the string to match what Gemini expects.
36
- obj.type = obj?.type[0];
37
- }
38
- else {
39
- // Anything else could be a union type, so reject it.
40
- throw new Error("zod_to_gemini_parameters: Gemini cannot handle union types");
41
- }
42
- return obj;
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
+ const __langchain_core_utils_types = require_rolldown_runtime.__toESM(require("@langchain/core/utils/types"));
3
+ const __langchain_core_utils_json_schema = require_rolldown_runtime.__toESM(require("@langchain/core/utils/json_schema"));
4
+
5
+ //#region src/utils/zod_to_gemini_parameters.ts
6
+ function adjustObjectType(obj) {
7
+ if (!Array.isArray(obj.type)) return obj;
8
+ const len = obj.type.length;
9
+ const nullIndex = obj.type.indexOf("null");
10
+ if (len === 2 && nullIndex >= 0) {
11
+ const typeIndex = nullIndex === 0 ? 1 : 0;
12
+ obj.type = obj.type[typeIndex];
13
+ obj.nullable = true;
14
+ } else if (len === 1 && nullIndex === 0) throw new Error("zod_to_gemini_parameters: Gemini cannot handle null type");
15
+ else if (len === 1) obj.type = obj?.type[0];
16
+ else throw new Error("zod_to_gemini_parameters: Gemini cannot handle union types");
17
+ return obj;
43
18
  }
44
- /* eslint-enable no-param-reassign */
45
- function removeAdditionalProperties(
46
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
47
- obj) {
48
- if (typeof obj === "object" && obj !== null) {
49
- const newObj = { ...obj };
50
- if ("additionalProperties" in newObj) {
51
- delete newObj.additionalProperties;
52
- }
53
- adjustObjectType(newObj);
54
- for (const key in newObj) {
55
- if (key in newObj) {
56
- if (Array.isArray(newObj[key])) {
57
- newObj[key] = newObj[key].map(removeAdditionalProperties);
58
- }
59
- else if (typeof newObj[key] === "object" && newObj[key] !== null) {
60
- newObj[key] = removeAdditionalProperties(newObj[key]);
61
- }
62
- }
63
- }
64
- return newObj;
65
- }
66
- return obj;
19
+ function removeAdditionalProperties(obj) {
20
+ if (typeof obj === "object" && obj !== null) {
21
+ const newObj = { ...obj };
22
+ if ("additionalProperties" in newObj) delete newObj.additionalProperties;
23
+ adjustObjectType(newObj);
24
+ for (const key in newObj) if (key in newObj) {
25
+ if (Array.isArray(newObj[key])) newObj[key] = newObj[key].map(removeAdditionalProperties);
26
+ else if (typeof newObj[key] === "object" && newObj[key] !== null) newObj[key] = removeAdditionalProperties(newObj[key]);
27
+ }
28
+ return newObj;
29
+ }
30
+ return obj;
67
31
  }
68
32
  function schemaToGeminiParameters(schema) {
69
- // Gemini doesn't accept either the $schema or additionalProperties
70
- // attributes, so we need to explicitly remove them.
71
- // Zod sometimes also makes an array of type (because of .nullish()),
72
- // which needs cleaning up.
73
- const jsonSchema = removeAdditionalProperties((0, types_1.isInteropZodSchema)(schema) ? (0, json_schema_1.toJsonSchema)(schema) : schema);
74
- const { $schema, ...rest } = jsonSchema;
75
- return rest;
33
+ const jsonSchema = removeAdditionalProperties((0, __langchain_core_utils_types.isInteropZodSchema)(schema) ? (0, __langchain_core_utils_json_schema.toJsonSchema)(schema) : schema);
34
+ const { $schema,...rest } = jsonSchema;
35
+ return rest;
76
36
  }
77
- function jsonSchemaToGeminiParameters(
78
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
79
- schema) {
80
- // Gemini doesn't accept either the $schema or additionalProperties
81
- // attributes, so we need to explicitly remove them.
82
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
83
- const jsonSchema = removeAdditionalProperties(schema);
84
- const { $schema, ...rest } = jsonSchema;
85
- return rest;
37
+ function jsonSchemaToGeminiParameters(schema) {
38
+ const jsonSchema = removeAdditionalProperties(schema);
39
+ const { $schema,...rest } = jsonSchema;
40
+ return rest;
86
41
  }
42
+
43
+ //#endregion
44
+ exports.adjustObjectType = adjustObjectType;
45
+ exports.jsonSchemaToGeminiParameters = jsonSchemaToGeminiParameters;
46
+ exports.removeAdditionalProperties = removeAdditionalProperties;
47
+ exports.schemaToGeminiParameters = schemaToGeminiParameters;
48
+ //# sourceMappingURL=zod_to_gemini_parameters.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zod_to_gemini_parameters.cjs","names":["obj: Record<string, any>","schema: InteropZodType<RunOutput> | JsonSchema7Type","schema: Record<string, any>"],"sources":["../../src/utils/zod_to_gemini_parameters.ts"],"sourcesContent":["import {\n InteropZodType,\n isInteropZodSchema,\n} from \"@langchain/core/utils/types\";\nimport {\n type JsonSchema7Type,\n toJsonSchema,\n} from \"@langchain/core/utils/json_schema\";\nimport {\n GeminiFunctionSchema,\n GeminiJsonSchema,\n GeminiJsonSchemaDirty,\n} from \"../types.js\";\n\nexport function adjustObjectType(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n obj: Record<string, any>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): Record<string, any> {\n if (!Array.isArray(obj.type)) {\n return obj;\n }\n\n const len = obj.type.length;\n const nullIndex = obj.type.indexOf(\"null\");\n if (len === 2 && nullIndex >= 0) {\n // There are only two values set for the type, and one of them is \"null\".\n // Set the type to the other one and set nullable to true.\n const typeIndex = nullIndex === 0 ? 1 : 0;\n obj.type = obj.type[typeIndex];\n obj.nullable = true;\n } else if (len === 1 && nullIndex === 0) {\n // This is nullable only without a type, which doesn't\n // make sense for Gemini\n throw new Error(\"zod_to_gemini_parameters: Gemini cannot handle null type\");\n } else if (len === 1) {\n // Although an array, it has only one value.\n // So set it to the string to match what Gemini expects.\n obj.type = obj?.type[0];\n } else {\n // Anything else could be a union type, so reject it.\n throw new Error(\n \"zod_to_gemini_parameters: Gemini cannot handle union types\"\n );\n }\n return obj;\n}\n\nexport function removeAdditionalProperties(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n obj: Record<string, any>\n): GeminiJsonSchema {\n if (typeof obj === \"object\" && obj !== null) {\n const newObj = { ...obj };\n\n if (\"additionalProperties\" in newObj) {\n delete newObj.additionalProperties;\n }\n\n adjustObjectType(newObj);\n\n for (const key in newObj) {\n if (key in newObj) {\n if (Array.isArray(newObj[key])) {\n newObj[key] = newObj[key].map(removeAdditionalProperties);\n } else if (typeof newObj[key] === \"object\" && newObj[key] !== null) {\n newObj[key] = removeAdditionalProperties(newObj[key]);\n }\n }\n }\n\n return newObj as GeminiJsonSchema;\n }\n\n return obj as GeminiJsonSchema;\n}\n\nexport function schemaToGeminiParameters<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput extends Record<string, any> = Record<string, any>\n>(schema: InteropZodType<RunOutput> | JsonSchema7Type): GeminiFunctionSchema {\n // Gemini doesn't accept either the $schema or additionalProperties\n // attributes, so we need to explicitly remove them.\n // Zod sometimes also makes an array of type (because of .nullish()),\n // which needs cleaning up.\n const jsonSchema = removeAdditionalProperties(\n isInteropZodSchema(schema) ? toJsonSchema(schema) : schema\n );\n const { $schema, ...rest } = jsonSchema;\n\n return rest;\n}\n\nexport function jsonSchemaToGeminiParameters(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n schema: Record<string, any>\n): GeminiFunctionSchema {\n // Gemini doesn't accept either the $schema or additionalProperties\n // attributes, so we need to explicitly remove them.\n const jsonSchema = removeAdditionalProperties(\n schema as GeminiJsonSchemaDirty\n );\n const { $schema, ...rest } = jsonSchema;\n\n return rest;\n}\n"],"mappings":";;;;;AAcA,SAAgB,iBAEdA,KAEqB;AACrB,KAAI,CAAC,MAAM,QAAQ,IAAI,KAAK,CAC1B,QAAO;CAGT,MAAM,MAAM,IAAI,KAAK;CACrB,MAAM,YAAY,IAAI,KAAK,QAAQ,OAAO;AAC1C,KAAI,QAAQ,KAAK,aAAa,GAAG;EAG/B,MAAM,YAAY,cAAc,IAAI,IAAI;EACxC,IAAI,OAAO,IAAI,KAAK;EACpB,IAAI,WAAW;CAChB,WAAU,QAAQ,KAAK,cAAc,EAGpC,OAAM,IAAI,MAAM;UACP,QAAQ,GAGjB,IAAI,OAAO,KAAK,KAAK;KAGrB,OAAM,IAAI,MACR;AAGJ,QAAO;AACR;AAED,SAAgB,2BAEdA,KACkB;AAClB,KAAI,OAAO,QAAQ,YAAY,QAAQ,MAAM;EAC3C,MAAM,SAAS,EAAE,GAAG,IAAK;AAEzB,MAAI,0BAA0B,QAC5B,OAAO,OAAO;EAGhB,iBAAiB,OAAO;AAExB,OAAK,MAAM,OAAO,OAChB,KAAI,OAAO,QACT;OAAI,MAAM,QAAQ,OAAO,KAAK,EAC5B,OAAO,OAAO,OAAO,KAAK,IAAI,2BAA2B;YAChD,OAAO,OAAO,SAAS,YAAY,OAAO,SAAS,MAC5D,OAAO,OAAO,2BAA2B,OAAO,KAAK;EACtD;AAIL,SAAO;CACR;AAED,QAAO;AACR;AAED,SAAgB,yBAGdC,QAA2E;CAK3E,MAAM,aAAa,gFACE,OAAO,wDAAgB,OAAO,GAAG,OACrD;CACD,MAAM,EAAE,QAAS,GAAG,MAAM,GAAG;AAE7B,QAAO;AACR;AAED,SAAgB,6BAEdC,QACsB;CAGtB,MAAM,aAAa,2BACjB,OACD;CACD,MAAM,EAAE,QAAS,GAAG,MAAM,GAAG;AAE7B,QAAO;AACR"}
@@ -0,0 +1,22 @@
1
+ import { GeminiFunctionSchema, GeminiJsonSchema } from "../types.cjs";
2
+ import { InteropZodType } from "@langchain/core/utils/types";
3
+ import { JsonSchema7Type } from "@langchain/core/utils/json_schema";
4
+
5
+ //#region src/utils/zod_to_gemini_parameters.d.ts
6
+ declare function adjustObjectType(
7
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
8
+ obj: Record<string, any>
9
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
+ ): Record<string, any>;
11
+ declare function removeAdditionalProperties(
12
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
13
+ obj: Record<string, any>): GeminiJsonSchema;
14
+ declare function schemaToGeminiParameters<
15
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
+ RunOutput extends Record<string, any> = Record<string, any>>(schema: InteropZodType<RunOutput> | JsonSchema7Type): GeminiFunctionSchema;
17
+ declare function jsonSchemaToGeminiParameters(
18
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
19
+ schema: Record<string, any>): GeminiFunctionSchema;
20
+ //#endregion
21
+ export { adjustObjectType, jsonSchemaToGeminiParameters, removeAdditionalProperties, schemaToGeminiParameters };
22
+ //# sourceMappingURL=zod_to_gemini_parameters.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zod_to_gemini_parameters.d.cts","names":["InteropZodType","JsonSchema7Type","GeminiFunctionSchema","GeminiJsonSchema","adjustObjectType","Record","removeAdditionalProperties","schemaToGeminiParameters","RunOutput","jsonSchemaToGeminiParameters"],"sources":["../../src/utils/zod_to_gemini_parameters.d.ts"],"sourcesContent":["import { InteropZodType } from \"@langchain/core/utils/types\";\nimport { type JsonSchema7Type } from \"@langchain/core/utils/json_schema\";\nimport { GeminiFunctionSchema, GeminiJsonSchema } from \"../types.js\";\nexport declare function adjustObjectType(\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nobj: Record<string, any>\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\n): Record<string, any>;\nexport declare function removeAdditionalProperties(\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nobj: Record<string, any>): GeminiJsonSchema;\nexport declare function schemaToGeminiParameters<\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nRunOutput extends Record<string, any> = Record<string, any>>(schema: InteropZodType<RunOutput> | JsonSchema7Type): GeminiFunctionSchema;\nexport declare function jsonSchemaToGeminiParameters(\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nschema: Record<string, any>): GeminiFunctionSchema;\n"],"mappings":";;;;;iBAGwBI,gBAAAA;;AAAxB,GAAA,EAEKC,MAFmBD,CAAAA,MAAAA,EAAAA,GAAgB;;CAAA,EAIrCC,MAFEA,CAAAA,MAAAA,EAAAA,GAAAA,CAAAA;AAEFA,iBACqBC,0BAAAA;AADf;AACT,GAAA,EAEKD,MAFmBC,CAAAA,MAAAA,EAAAA,GAAAA,CAAAA,CAAAA,EAEGH,gBAFuB;AAAA,iBAG1BI,wBAH0B;;kBAKhCF,MAHSF,CAAAA,MAAAA,EAAAA,GAAAA,CAAAA,GAGaE,MAHbF,CAAAA,MAAAA,EAAAA,GAAAA,CAAAA,CAAAA,CAAAA,MAAAA,EAG0CH,cAH1CG,CAGyDK,SAHzDL,CAAAA,GAGsEF,eAHtEE,CAAAA,EAGwFD,oBAHxFC;AAAgB,iBAInBM,4BAAAA;AAHxB;MAAgD,EAKxCJ,MALwC,CAAA,MAAA,EAAA,GAAA,CAAA,CAAA,EAKlBH,oBALkB"}
@@ -1,7 +1,22 @@
1
- import { InteropZodType } from "@langchain/core/utils/types";
2
- import { type JsonSchema7Type } from "@langchain/core/utils/json_schema";
3
1
  import { GeminiFunctionSchema, GeminiJsonSchema } from "../types.js";
4
- export declare function adjustObjectType(obj: Record<string, any>): Record<string, any>;
5
- export declare function removeAdditionalProperties(obj: Record<string, any>): GeminiJsonSchema;
6
- export declare function schemaToGeminiParameters<RunOutput extends Record<string, any> = Record<string, any>>(schema: InteropZodType<RunOutput> | JsonSchema7Type): GeminiFunctionSchema;
7
- export declare function jsonSchemaToGeminiParameters(schema: Record<string, any>): GeminiFunctionSchema;
2
+ import { InteropZodType } from "@langchain/core/utils/types";
3
+ import { JsonSchema7Type } from "@langchain/core/utils/json_schema";
4
+
5
+ //#region src/utils/zod_to_gemini_parameters.d.ts
6
+ declare function adjustObjectType(
7
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
8
+ obj: Record<string, any>
9
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
+ ): Record<string, any>;
11
+ declare function removeAdditionalProperties(
12
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
13
+ obj: Record<string, any>): GeminiJsonSchema;
14
+ declare function schemaToGeminiParameters<
15
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
+ RunOutput extends Record<string, any> = Record<string, any>>(schema: InteropZodType<RunOutput> | JsonSchema7Type): GeminiFunctionSchema;
17
+ declare function jsonSchemaToGeminiParameters(
18
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
19
+ schema: Record<string, any>): GeminiFunctionSchema;
20
+ //#endregion
21
+ export { adjustObjectType, jsonSchemaToGeminiParameters, removeAdditionalProperties, schemaToGeminiParameters };
22
+ //# sourceMappingURL=zod_to_gemini_parameters.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zod_to_gemini_parameters.d.ts","names":["InteropZodType","JsonSchema7Type","GeminiFunctionSchema","GeminiJsonSchema","adjustObjectType","Record","removeAdditionalProperties","schemaToGeminiParameters","RunOutput","jsonSchemaToGeminiParameters"],"sources":["../../src/utils/zod_to_gemini_parameters.d.ts"],"sourcesContent":["import { InteropZodType } from \"@langchain/core/utils/types\";\nimport { type JsonSchema7Type } from \"@langchain/core/utils/json_schema\";\nimport { GeminiFunctionSchema, GeminiJsonSchema } from \"../types.js\";\nexport declare function adjustObjectType(\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nobj: Record<string, any>\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\n): Record<string, any>;\nexport declare function removeAdditionalProperties(\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nobj: Record<string, any>): GeminiJsonSchema;\nexport declare function schemaToGeminiParameters<\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nRunOutput extends Record<string, any> = Record<string, any>>(schema: InteropZodType<RunOutput> | JsonSchema7Type): GeminiFunctionSchema;\nexport declare function jsonSchemaToGeminiParameters(\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nschema: Record<string, any>): GeminiFunctionSchema;\n"],"mappings":";;;;;iBAGwBI,gBAAAA;;AAAxB,GAAA,EAEKC,MAFmBD,CAAAA,MAAAA,EAAAA,GAAgB;;CAAA,EAIrCC,MAFEA,CAAAA,MAAAA,EAAAA,GAAAA,CAAAA;AAEFA,iBACqBC,0BAAAA;AADf;AACT,GAAA,EAEKD,MAFmBC,CAAAA,MAAAA,EAAAA,GAAAA,CAAAA,CAAAA,EAEGH,gBAFuB;AAAA,iBAG1BI,wBAH0B;;kBAKhCF,MAHSF,CAAAA,MAAAA,EAAAA,GAAAA,CAAAA,GAGaE,MAHbF,CAAAA,MAAAA,EAAAA,GAAAA,CAAAA,CAAAA,CAAAA,MAAAA,EAG0CH,cAH1CG,CAGyDK,SAHzDL,CAAAA,GAGsEF,eAHtEE,CAAAA,EAGwFD,oBAHxFC;AAAgB,iBAInBM,4BAAAA;AAHxB;MAAgD,EAKxCJ,MALwC,CAAA,MAAA,EAAA,GAAA,CAAA,CAAA,EAKlBH,oBALkB"}
@@ -1,80 +1,44 @@
1
- /* eslint-disable @typescript-eslint/no-unused-vars */
2
- import { isInteropZodSchema, } from "@langchain/core/utils/types";
3
- import { toJsonSchema, } from "@langchain/core/utils/json_schema";
4
- /* eslint-disable no-param-reassign */
5
- export function adjustObjectType(
6
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
7
- obj
8
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
9
- ) {
10
- if (!Array.isArray(obj.type)) {
11
- return obj;
12
- }
13
- const len = obj.type.length;
14
- const nullIndex = obj.type.indexOf("null");
15
- if (len === 2 && nullIndex >= 0) {
16
- // There are only two values set for the type, and one of them is "null".
17
- // Set the type to the other one and set nullable to true.
18
- const typeIndex = nullIndex === 0 ? 1 : 0;
19
- obj.type = obj.type[typeIndex];
20
- obj.nullable = true;
21
- }
22
- else if (len === 1 && nullIndex === 0) {
23
- // This is nullable only without a type, which doesn't
24
- // make sense for Gemini
25
- throw new Error("zod_to_gemini_parameters: Gemini cannot handle null type");
26
- }
27
- else if (len === 1) {
28
- // Although an array, it has only one value.
29
- // So set it to the string to match what Gemini expects.
30
- obj.type = obj?.type[0];
31
- }
32
- else {
33
- // Anything else could be a union type, so reject it.
34
- throw new Error("zod_to_gemini_parameters: Gemini cannot handle union types");
35
- }
36
- return obj;
1
+ import { isInteropZodSchema } from "@langchain/core/utils/types";
2
+ import { toJsonSchema } from "@langchain/core/utils/json_schema";
3
+
4
+ //#region src/utils/zod_to_gemini_parameters.ts
5
+ function adjustObjectType(obj) {
6
+ if (!Array.isArray(obj.type)) return obj;
7
+ const len = obj.type.length;
8
+ const nullIndex = obj.type.indexOf("null");
9
+ if (len === 2 && nullIndex >= 0) {
10
+ const typeIndex = nullIndex === 0 ? 1 : 0;
11
+ obj.type = obj.type[typeIndex];
12
+ obj.nullable = true;
13
+ } else if (len === 1 && nullIndex === 0) throw new Error("zod_to_gemini_parameters: Gemini cannot handle null type");
14
+ else if (len === 1) obj.type = obj?.type[0];
15
+ else throw new Error("zod_to_gemini_parameters: Gemini cannot handle union types");
16
+ return obj;
37
17
  }
38
- /* eslint-enable no-param-reassign */
39
- export function removeAdditionalProperties(
40
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
41
- obj) {
42
- if (typeof obj === "object" && obj !== null) {
43
- const newObj = { ...obj };
44
- if ("additionalProperties" in newObj) {
45
- delete newObj.additionalProperties;
46
- }
47
- adjustObjectType(newObj);
48
- for (const key in newObj) {
49
- if (key in newObj) {
50
- if (Array.isArray(newObj[key])) {
51
- newObj[key] = newObj[key].map(removeAdditionalProperties);
52
- }
53
- else if (typeof newObj[key] === "object" && newObj[key] !== null) {
54
- newObj[key] = removeAdditionalProperties(newObj[key]);
55
- }
56
- }
57
- }
58
- return newObj;
59
- }
60
- return obj;
18
+ function removeAdditionalProperties(obj) {
19
+ if (typeof obj === "object" && obj !== null) {
20
+ const newObj = { ...obj };
21
+ if ("additionalProperties" in newObj) delete newObj.additionalProperties;
22
+ adjustObjectType(newObj);
23
+ for (const key in newObj) if (key in newObj) {
24
+ if (Array.isArray(newObj[key])) newObj[key] = newObj[key].map(removeAdditionalProperties);
25
+ else if (typeof newObj[key] === "object" && newObj[key] !== null) newObj[key] = removeAdditionalProperties(newObj[key]);
26
+ }
27
+ return newObj;
28
+ }
29
+ return obj;
61
30
  }
62
- export function schemaToGeminiParameters(schema) {
63
- // Gemini doesn't accept either the $schema or additionalProperties
64
- // attributes, so we need to explicitly remove them.
65
- // Zod sometimes also makes an array of type (because of .nullish()),
66
- // which needs cleaning up.
67
- const jsonSchema = removeAdditionalProperties(isInteropZodSchema(schema) ? toJsonSchema(schema) : schema);
68
- const { $schema, ...rest } = jsonSchema;
69
- return rest;
31
+ function schemaToGeminiParameters(schema) {
32
+ const jsonSchema = removeAdditionalProperties(isInteropZodSchema(schema) ? toJsonSchema(schema) : schema);
33
+ const { $schema,...rest } = jsonSchema;
34
+ return rest;
70
35
  }
71
- export function jsonSchemaToGeminiParameters(
72
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
73
- schema) {
74
- // Gemini doesn't accept either the $schema or additionalProperties
75
- // attributes, so we need to explicitly remove them.
76
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
77
- const jsonSchema = removeAdditionalProperties(schema);
78
- const { $schema, ...rest } = jsonSchema;
79
- return rest;
36
+ function jsonSchemaToGeminiParameters(schema) {
37
+ const jsonSchema = removeAdditionalProperties(schema);
38
+ const { $schema,...rest } = jsonSchema;
39
+ return rest;
80
40
  }
41
+
42
+ //#endregion
43
+ export { adjustObjectType, jsonSchemaToGeminiParameters, removeAdditionalProperties, schemaToGeminiParameters };
44
+ //# sourceMappingURL=zod_to_gemini_parameters.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zod_to_gemini_parameters.js","names":["obj: Record<string, any>","schema: InteropZodType<RunOutput> | JsonSchema7Type","schema: Record<string, any>"],"sources":["../../src/utils/zod_to_gemini_parameters.ts"],"sourcesContent":["import {\n InteropZodType,\n isInteropZodSchema,\n} from \"@langchain/core/utils/types\";\nimport {\n type JsonSchema7Type,\n toJsonSchema,\n} from \"@langchain/core/utils/json_schema\";\nimport {\n GeminiFunctionSchema,\n GeminiJsonSchema,\n GeminiJsonSchemaDirty,\n} from \"../types.js\";\n\nexport function adjustObjectType(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n obj: Record<string, any>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): Record<string, any> {\n if (!Array.isArray(obj.type)) {\n return obj;\n }\n\n const len = obj.type.length;\n const nullIndex = obj.type.indexOf(\"null\");\n if (len === 2 && nullIndex >= 0) {\n // There are only two values set for the type, and one of them is \"null\".\n // Set the type to the other one and set nullable to true.\n const typeIndex = nullIndex === 0 ? 1 : 0;\n obj.type = obj.type[typeIndex];\n obj.nullable = true;\n } else if (len === 1 && nullIndex === 0) {\n // This is nullable only without a type, which doesn't\n // make sense for Gemini\n throw new Error(\"zod_to_gemini_parameters: Gemini cannot handle null type\");\n } else if (len === 1) {\n // Although an array, it has only one value.\n // So set it to the string to match what Gemini expects.\n obj.type = obj?.type[0];\n } else {\n // Anything else could be a union type, so reject it.\n throw new Error(\n \"zod_to_gemini_parameters: Gemini cannot handle union types\"\n );\n }\n return obj;\n}\n\nexport function removeAdditionalProperties(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n obj: Record<string, any>\n): GeminiJsonSchema {\n if (typeof obj === \"object\" && obj !== null) {\n const newObj = { ...obj };\n\n if (\"additionalProperties\" in newObj) {\n delete newObj.additionalProperties;\n }\n\n adjustObjectType(newObj);\n\n for (const key in newObj) {\n if (key in newObj) {\n if (Array.isArray(newObj[key])) {\n newObj[key] = newObj[key].map(removeAdditionalProperties);\n } else if (typeof newObj[key] === \"object\" && newObj[key] !== null) {\n newObj[key] = removeAdditionalProperties(newObj[key]);\n }\n }\n }\n\n return newObj as GeminiJsonSchema;\n }\n\n return obj as GeminiJsonSchema;\n}\n\nexport function schemaToGeminiParameters<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput extends Record<string, any> = Record<string, any>\n>(schema: InteropZodType<RunOutput> | JsonSchema7Type): GeminiFunctionSchema {\n // Gemini doesn't accept either the $schema or additionalProperties\n // attributes, so we need to explicitly remove them.\n // Zod sometimes also makes an array of type (because of .nullish()),\n // which needs cleaning up.\n const jsonSchema = removeAdditionalProperties(\n isInteropZodSchema(schema) ? toJsonSchema(schema) : schema\n );\n const { $schema, ...rest } = jsonSchema;\n\n return rest;\n}\n\nexport function jsonSchemaToGeminiParameters(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n schema: Record<string, any>\n): GeminiFunctionSchema {\n // Gemini doesn't accept either the $schema or additionalProperties\n // attributes, so we need to explicitly remove them.\n const jsonSchema = removeAdditionalProperties(\n schema as GeminiJsonSchemaDirty\n );\n const { $schema,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"0.2.18",
3
+ "version": "1.0.0",
4
4
  "description": "Core types and classes for Google services.",
5
5
  "type": "module",
6
6
  "engines": {
7
- "node": ">=18"
7
+ "node": ">=20"
8
8
  },
9
- "main": "./index.js",
10
- "types": "./index.d.ts",
11
9
  "repository": {
12
10
  "type": "git",
13
11
  "url": "git@github.com:langchain-ai/langchainjs.git"
14
12
  },
15
13
  "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-google-common/",
16
- "scripts": {
17
- "build": "yarn turbo:command build:internal --filter=@langchain/google-common",
18
- "build:internal": "yarn lc_build --create-entrypoints --pre --tree-shaking",
19
- "lint:eslint": "NODE_OPTIONS=--max-old-space-size=4096 eslint --cache --ext .ts,.js src/",
20
- "lint:dpdm": "dpdm --skip-dynamic-imports circular --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts",
21
- "lint": "yarn lint:eslint && yarn lint:dpdm",
22
- "lint:fix": "yarn lint:eslint --fix && yarn lint:dpdm",
23
- "clean": "rm -rf .turbo dist/",
24
- "prepack": "yarn build",
25
- "test": "NODE_OPTIONS=--experimental-vm-modules jest --testPathIgnorePatterns=\\.int\\.test.ts --testTimeout 30000 --maxWorkers=50%",
26
- "test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch --testPathIgnorePatterns=\\.int\\.test.ts",
27
- "test:single": "NODE_OPTIONS=--experimental-vm-modules yarn run jest --config jest.config.cjs --testTimeout 100000",
28
- "test:int": "NODE_OPTIONS=--experimental-vm-modules jest --testPathPattern=\\.int\\.test.ts --testTimeout 100000 --maxWorkers=50%",
29
- "format": "prettier --config .prettierrc --write \"src\"",
30
- "format:check": "prettier --config .prettierrc --check \"src\""
31
- },
32
14
  "author": "LangChain",
33
15
  "license": "MIT",
34
16
  "dependencies": {
35
17
  "uuid": "^10.0.0"
36
18
  },
37
19
  "peerDependencies": {
38
- "@langchain/core": ">=0.3.58 <0.4.0"
20
+ "@langchain/core": "^1.0.0"
39
21
  },
40
22
  "devDependencies": {
41
23
  "@jest/globals": "^29.5.0",
42
- "@langchain/core": "workspace:*",
43
- "@langchain/scripts": ">=0.1.0 <0.2.0",
24
+ "@types/uuid": "^10.0.0",
44
25
  "@swc/core": "^1.3.90",
45
26
  "@swc/jest": "^0.2.29",
46
27
  "@tsconfig/recommended": "^1.0.3",
47
- "@typescript-eslint/eslint-plugin": "^6.12.0",
48
- "@typescript-eslint/parser": "^6.12.0",
49
28
  "dotenv": "^16.3.1",
50
29
  "dpdm": "^3.14.0",
51
- "eslint": "^8.33.0",
52
- "eslint-config-airbnb-base": "^15.0.0",
53
- "eslint-config-prettier": "^8.6.0",
54
- "eslint-plugin-import": "^2.27.5",
55
- "eslint-plugin-no-instanceof": "^1.0.1",
56
- "eslint-plugin-prettier": "^4.2.1",
30
+ "eslint": "^9.34.0",
57
31
  "jest": "^29.5.0",
58
32
  "jest-environment-node": "^29.6.4",
59
33
  "prettier": "^2.8.3",
60
- "release-it": "^18.1.2",
61
34
  "rollup": "^4.5.2",
62
35
  "ts-jest": "^29.1.0",
63
36
  "typescript": "~5.8.3",
64
- "zod": "^3.22.4"
37
+ "zod": "^3.25.76",
38
+ "@langchain/eslint": "0.1.0",
39
+ "@langchain/core": "1.0.0"
65
40
  },
66
41
  "publishConfig": {
67
42
  "access": "public"
68
43
  },
44
+ "main": "./dist/index.js",
45
+ "types": "./dist/index.d.ts",
69
46
  "exports": {
70
47
  ".": {
71
- "types": {
72
- "import": "./index.d.ts",
73
- "require": "./index.d.cts",
74
- "default": "./index.d.ts"
48
+ "input": "./src/index.ts",
49
+ "import": {
50
+ "types": "./dist/index.d.ts",
51
+ "default": "./dist/index.js"
75
52
  },
76
- "import": "./index.js",
77
- "require": "./index.cjs"
53
+ "require": {
54
+ "types": "./dist/index.d.cts",
55
+ "default": "./dist/index.cjs"
56
+ }
78
57
  },
79
58
  "./utils": {
80
- "types": {
81
- "import": "./utils.d.ts",
82
- "require": "./utils.d.cts",
83
- "default": "./utils.d.ts"
59
+ "input": "./src/utils/index.ts",
60
+ "import": {
61
+ "types": "./dist/utils/index.d.ts",
62
+ "default": "./dist/utils/index.js"
84
63
  },
85
- "import": "./utils.js",
86
- "require": "./utils.cjs"
64
+ "require": {
65
+ "types": "./dist/utils/index.d.cts",
66
+ "default": "./dist/utils/index.cjs"
67
+ }
87
68
  },
88
69
  "./types": {
89
- "types": {
90
- "import": "./types.d.ts",
91
- "require": "./types.d.cts",
92
- "default": "./types.d.ts"
70
+ "input": "./src/types.ts",
71
+ "import": {
72
+ "types": "./dist/types.d.ts",
73
+ "default": "./dist/types.js"
93
74
  },
94
- "import": "./types.js",
95
- "require": "./types.cjs"
75
+ "require": {
76
+ "types": "./dist/types.d.cts",
77
+ "default": "./dist/types.cjs"
78
+ }
96
79
  },
97
80
  "./experimental/media": {
98
- "types": {
99
- "import": "./experimental/media.d.ts",
100
- "require": "./experimental/media.d.cts",
101
- "default": "./experimental/media.d.ts"
81
+ "input": "./src/experimental/media.ts",
82
+ "import": {
83
+ "types": "./dist/experimental/media.d.ts",
84
+ "default": "./dist/experimental/media.js"
102
85
  },
103
- "import": "./experimental/media.js",
104
- "require": "./experimental/media.cjs"
86
+ "require": {
87
+ "types": "./dist/experimental/media.d.cts",
88
+ "default": "./dist/experimental/media.cjs"
89
+ }
105
90
  },
106
91
  "./experimental/utils/media_core": {
107
- "types": {
108
- "import": "./experimental/utils/media_core.d.ts",
109
- "require": "./experimental/utils/media_core.d.cts",
110
- "default": "./experimental/utils/media_core.d.ts"
92
+ "input": "./src/experimental/utils/media_core.ts",
93
+ "import": {
94
+ "types": "./dist/experimental/utils/media_core.d.ts",
95
+ "default": "./dist/experimental/utils/media_core.js"
111
96
  },
112
- "import": "./experimental/utils/media_core.js",
113
- "require": "./experimental/utils/media_core.cjs"
97
+ "require": {
98
+ "types": "./dist/experimental/utils/media_core.d.cts",
99
+ "default": "./dist/experimental/utils/media_core.cjs"
100
+ }
114
101
  },
115
102
  "./package.json": "./package.json"
116
103
  },
117
104
  "files": [
118
105
  "dist/",
119
- "index.cjs",
120
- "index.js",
121
- "index.d.ts",
122
- "index.d.cts",
123
- "utils.cjs",
124
- "utils.js",
125
- "utils.d.ts",
126
- "utils.d.cts",
127
- "types.cjs",
128
- "types.js",
129
- "types.d.ts",
130
- "types.d.cts",
131
- "experimental/media.cjs",
132
- "experimental/media.js",
133
- "experimental/media.d.ts",
134
- "experimental/media.d.cts",
135
- "experimental/utils/media_core.cjs",
136
- "experimental/utils/media_core.js",
137
- "experimental/utils/media_core.d.ts",
138
- "experimental/utils/media_core.d.cts"
139
- ]
140
- }
106
+ "CHANGELOG.md",
107
+ "README.md",
108
+ "LICENSE"
109
+ ],
110
+ "scripts": {
111
+ "build": "pnpm --filter @langchain/build compile @langchain/google-common",
112
+ "lint:eslint": "eslint --cache src/",
113
+ "lint:dpdm": "dpdm --skip-dynamic-imports circular --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts",
114
+ "lint": "pnpm lint:eslint && pnpm lint:dpdm",
115
+ "lint:fix": "pnpm lint:eslint --fix && pnpm lint:dpdm",
116
+ "clean": "rm -rf .turbo dist/",
117
+ "test": "NODE_OPTIONS=--experimental-vm-modules jest --testPathIgnorePatterns=\\.int\\.test.ts --testTimeout 30000 --maxWorkers=50%",
118
+ "test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch --testPathIgnorePatterns=\\.int\\.test.ts",
119
+ "test:single": "NODE_OPTIONS=--experimental-vm-modules pnpm run jest --config jest.config.cjs --testTimeout 100000",
120
+ "test:int": "NODE_OPTIONS=--experimental-vm-modules jest --testPathPattern=\\.int\\.test.ts --testTimeout 100000 --maxWorkers=50%",
121
+ "format": "prettier --config .prettierrc --write \"src\"",
122
+ "format:check": "prettier --config .prettierrc --check \"src\""
123
+ }
124
+ }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1 +0,0 @@
1
- export {};
@@ -1,4 +0,0 @@
1
- import { AnthropicAPIConfig, GoogleAIAPI, GoogleAIModelParams } from "../types.js";
2
- export declare function getAnthropicAPI(config?: AnthropicAPIConfig): GoogleAIAPI;
3
- export declare function validateClaudeParams(_params: GoogleAIModelParams): void;
4
- export declare function isModelClaude(modelName: string): boolean;