Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@langchain/google-common

Package Overview
Dependencies
Maintainers
0
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@langchain/google-common - npm Package Compare versions

Comparing version 0.1.3 to 0.1.4

14

dist/types.d.ts

@@ -229,3 +229,17 @@ import type { BaseLLMParams } from "@langchain/core/language_models/llms";

functionDeclarations?: GeminiFunctionDeclaration[];
googleSearchRetrieval?: GoogleSearchRetrieval;
retrieval?: VertexAIRetrieval;
}
export interface GoogleSearchRetrieval {
dynamicRetrievalConfig?: {
mode?: string;
dynamicThreshold?: number;
};
}
export interface VertexAIRetrieval {
vertexAiSearch: {
datastore: string;
};
disableAttribution?: boolean;
}
export interface GeminiFunctionDeclaration {

@@ -232,0 +246,0 @@ name: string;

57

dist/utils/common.js

@@ -37,28 +37,39 @@ import { isOpenAITool } from "@langchain/core/language_models/base";

export function convertToGeminiTools(tools) {
const geminiTools = [
{
functionDeclarations: [],
},
];
const geminiTools = [];
let functionDeclarationsIndex = -1;
tools.forEach((tool) => {
if ("functionDeclarations" in tool &&
Array.isArray(tool.functionDeclarations)) {
const funcs = tool.functionDeclarations;
geminiTools[0].functionDeclarations?.push(...funcs);
if ("googleSearchRetrieval" in tool || "retrieval" in tool) {
geminiTools.push(tool);
}
else if (isLangChainTool(tool)) {
const jsonSchema = zodToGeminiParameters(tool.schema);
geminiTools[0].functionDeclarations?.push({
name: tool.name,
description: tool.description ?? `A function available to call.`,
parameters: jsonSchema,
});
else {
if (functionDeclarationsIndex === -1) {
geminiTools.push({
functionDeclarations: [],
});
functionDeclarationsIndex = geminiTools.length - 1;
}
if ("functionDeclarations" in tool &&
Array.isArray(tool.functionDeclarations)) {
const funcs = tool.functionDeclarations;
geminiTools[functionDeclarationsIndex].functionDeclarations.push(...funcs);
}
else if (isLangChainTool(tool)) {
const jsonSchema = zodToGeminiParameters(tool.schema);
geminiTools[functionDeclarationsIndex].functionDeclarations.push({
name: tool.name,
description: tool.description ?? `A function available to call.`,
parameters: jsonSchema,
});
}
else if (isOpenAITool(tool)) {
geminiTools[functionDeclarationsIndex].functionDeclarations.push({
name: tool.function.name,
description: tool.function.description ?? `A function available to call.`,
parameters: jsonSchemaToGeminiParameters(tool.function.parameters),
});
}
else {
throw new Error(`Received invalid tool: ${JSON.stringify(tool)}`);
}
}
else if (isOpenAITool(tool)) {
geminiTools[0].functionDeclarations?.push({
name: tool.function.name,
description: tool.function.description ?? `A function available to call.`,
parameters: jsonSchemaToGeminiParameters(tool.function.parameters),
});
}
});

@@ -65,0 +76,0 @@ return geminiTools;

@@ -139,6 +139,6 @@ import { v4 as uuidv4 } from "uuid";

}
const mineTypeAndData = extractMimeType(url);
if (mineTypeAndData) {
const mimeTypeAndData = extractMimeType(url);
if (mimeTypeAndData) {
return {
inlineData: mineTypeAndData,
inlineData: mimeTypeAndData,
};

@@ -787,9 +787,2 @@ }

}
function structuredToolsToGeminiTools(tools) {
return [
{
functionDeclarations: tools.map(structuredToolToFunctionDeclaration),
},
];
}
function formatTools(parameters) {

@@ -800,13 +793,12 @@ const tools = parameters?.tools;

}
if (tools.every(isLangChainTool)) {
return structuredToolsToGeminiTools(tools);
// Group all LangChain tools into a single functionDeclarations array
const langChainTools = tools.filter(isLangChainTool);
const otherTools = tools.filter((tool) => !isLangChainTool(tool));
const result = [...otherTools];
if (langChainTools.length > 0) {
result.push({
functionDeclarations: langChainTools.map(structuredToolToFunctionDeclaration),
});
}
else {
if (tools.length === 1 &&
(!("functionDeclarations" in tools[0]) ||
!tools[0].functionDeclarations?.length)) {
return [];
}
return tools;
}
return result;
}

@@ -813,0 +805,0 @@ function formatToolConfig(parameters) {

{
"name": "@langchain/google-common",
"version": "0.1.3",
"version": "0.1.4",
"description": "Core types and classes for Google services.",

@@ -5,0 +5,0 @@ "type": "module",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc