Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

google-common[patch]: adding client-info #5103

Merged
merged 11 commits into from
May 1, 2024
3 changes: 2 additions & 1 deletion libs/langchain-google-common/src/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ export abstract class GoogleConnection<
clientLibraryVersion: string;
}> {
const env = await getRuntimeEnvironment();
const packageJson = require('../package.json');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've discussed this with @jacoblee93 before (who can correct me if I mis-state something).
Unfortunately, while this works in Node, it doesn't work in all environments. Otherwise it would have been done in getRuntimeEnvironment() (which would be the best place to fix it, so it is available to all packages).

require itself is node-specific, but it isn't the only problem here.

const langchain = env?.library ?? "langchain-js";
const langchainVersion = env?.libraryVersion ?? "0";
const langchainVersion = packageJson.dependencies["@langchain/core"] ?? "0";
const moduleName = await this._moduleName();
let clientLibraryVersion = `${langchain}/${langchainVersion}`;
if (moduleName && moduleName.length) {
Expand Down