@langchain/google-common 0.1.4 → 0.1.5

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.
@@ -356,6 +356,7 @@ class ChatGoogleBase extends chat_models_1.BaseChatModel {
356
356
  }
357
357
  const llm = this.bind({
358
358
  tools,
359
+ tool_choice: functionName,
359
360
  });
360
361
  if (!includeRaw) {
361
362
  return llm.pipe(outputParser).withConfig({
@@ -352,6 +352,7 @@ export class ChatGoogleBase extends BaseChatModel {
352
352
  }
353
353
  const llm = this.bind({
354
354
  tools,
355
+ tool_choice: functionName,
355
356
  });
356
357
  if (!includeRaw) {
357
358
  return llm.pipe(outputParser).withConfig({
@@ -19,6 +19,10 @@ class EmbeddingsConnection extends connection_js_1.GoogleAIConnection {
19
19
  async buildUrlMethod() {
20
20
  return "predict";
21
21
  }
22
+ get modelPublisher() {
23
+ // All the embedding models are currently published by "google"
24
+ return "google";
25
+ }
22
26
  async formatData(input, parameters) {
23
27
  return {
24
28
  instances: input,
@@ -16,6 +16,10 @@ class EmbeddingsConnection extends GoogleAIConnection {
16
16
  async buildUrlMethod() {
17
17
  return "predict";
18
18
  }
19
+ get modelPublisher() {
20
+ // All the embedding models are currently published by "google"
21
+ return "google";
22
+ }
19
23
  async formatData(input, parameters) {
20
24
  return {
21
25
  instances: input,
@@ -808,10 +808,19 @@ function getGeminiAPI(config) {
808
808
  if (!parameters.tool_choice || typeof parameters.tool_choice !== "string") {
809
809
  return undefined;
810
810
  }
811
+ if (["auto", "any", "none"].includes(parameters.tool_choice)) {
812
+ return {
813
+ functionCallingConfig: {
814
+ mode: parameters.tool_choice,
815
+ allowedFunctionNames: parameters.allowed_function_names,
816
+ },
817
+ };
818
+ }
819
+ // force tool choice to be a single function name in case of structured output
811
820
  return {
812
821
  functionCallingConfig: {
813
- mode: parameters.tool_choice,
814
- allowedFunctionNames: parameters.allowed_function_names,
822
+ mode: "any",
823
+ allowedFunctionNames: [parameters.tool_choice],
815
824
  },
816
825
  };
817
826
  }
@@ -803,10 +803,19 @@ export function getGeminiAPI(config) {
803
803
  if (!parameters.tool_choice || typeof parameters.tool_choice !== "string") {
804
804
  return undefined;
805
805
  }
806
+ if (["auto", "any", "none"].includes(parameters.tool_choice)) {
807
+ return {
808
+ functionCallingConfig: {
809
+ mode: parameters.tool_choice,
810
+ allowedFunctionNames: parameters.allowed_function_names,
811
+ },
812
+ };
813
+ }
814
+ // force tool choice to be a single function name in case of structured output
806
815
  return {
807
816
  functionCallingConfig: {
808
- mode: parameters.tool_choice,
809
- allowedFunctionNames: parameters.allowed_function_names,
817
+ mode: "any",
818
+ allowedFunctionNames: [parameters.tool_choice],
810
819
  },
811
820
  };
812
821
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/google-common",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "Core types and classes for Google services.",
5
5
  "type": "module",
6
6
  "engines": {