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

chore(openai): update azure user agent #7543

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

sinedied
Copy link
Contributor

Changes

Fix library name and versioning, and add details about the Node.js version and platform in the user agent

Copy link

vercel bot commented Jan 17, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
langchainjs-docs ✅ Ready (Inspect) Visit Preview Feb 6, 2025 10:26am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
langchainjs-api-refs ⬜️ Ignored (Inspect) Feb 6, 2025 10:26am

@dosubot dosubot bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Jan 17, 2025
@dosubot dosubot bot added the auto:nit Small modifications/deletions, fixes, deps or improvements to existing code or docs label Jan 17, 2025
"User-Agent": params.defaultHeaders?.["User-Agent"]
? `${params.defaultHeaders["User-Agent"]}: langchainjs-azure-openai-v2`
: `langchainjs-azure-openai-v2`,
"User-Agent": `langchainjs-azure-openai/2.0.0 (node.js/${process.version}; ${process.platform}; ${process.arch}) ${params.defaultHeaders?.["User-Agent"] || ""}`

Choose a reason for hiding this comment

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

should the version be pulled from a variable, so this doesnt have to be reset on future releases? @sinedied ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Unfortunately we don't have a way to do this at the moment 😞

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@johnpapa the 2.0.0 is just to distinguish from the previous (deprecated) package implementation, it's not really a proper versioning as it won't change. It would be nice to send along the @langchain/openai package version though as Jacob mentioned it doesn't seem to be possible currently: from what I understand, we can't pull the version from package.json as the lib can also be ran from the browser where there's no FS access like with Node.js.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah we would need to manually some process to bump a statically specified version on release. We do it here:

https://github.com/langchain-ai/langsmith-sdk/blob/main/js/src/index.ts#L21

I just haven't had time to set it up

Copy link
Collaborator

@jacoblee93 jacoblee93 left a comment

Choose a reason for hiding this comment

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

Thanks!

"User-Agent": params.defaultHeaders?.["User-Agent"]
? `${params.defaultHeaders["User-Agent"]}: langchainjs-azure-openai-v2`
: `langchainjs-azure-openai-v2`,
"User-Agent": `langchainjs-azure-openai/2.0.0 (node.js/${process.version}; ${process.platform}; ${process.arch}) ${params.defaultHeaders?.["User-Agent"] || ""}`
Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah we would need to manually some process to bump a statically specified version on release. We do it here:

https://github.com/langchain-ai/langsmith-sdk/blob/main/js/src/index.ts#L21

I just haven't had time to set it up

@dosubot dosubot bot added the lgtm PRs that are ready to be merged as-is label Jan 22, 2025
@@ -1,3 +1,4 @@
import process from "node:process";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh hmm actually this will break non-node environments - can we use this instead? https://github.com/langchain-ai/langchainjs/blob/main/langchain-core/src/utils/env.ts#L40

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My bad, I forgot about this!
I sent an update using getEnv that fixes that

@dosubot dosubot bot removed the lgtm PRs that are ready to be merged as-is label Jan 22, 2025
@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. and removed size:XS This PR changes 0-9 lines, ignoring generated files. labels Feb 5, 2025
Copy link
Collaborator

@jacoblee93 jacoblee93 left a comment

Choose a reason for hiding this comment

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

Thanks!

@dosubot dosubot bot added the lgtm PRs that are ready to be merged as-is label Feb 5, 2025
"User-Agent": params.defaultHeaders?.["User-Agent"]
? `${params.defaultHeaders["User-Agent"]}: langchainjs-azure-openai-v2`
: `langchainjs-azure-openai-v2`,
"User-Agent": `langchainjs-azure-openai/2.0.0 (${env}) ${
Copy link
Collaborator

Choose a reason for hiding this comment

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

Actually, here you will have an extra space if no default user agent. How about:

const specifiedUserAgent = params.defaultHeaders?.["User-Agent"];

params.defaultHeaders = {
        ...params.defaultHeaders,
        "User-Agent": `langchainjs-azure-openai/2.0.0 (${env})${specifiedUserAgent ? ` ${specifiedUserAgent}` : ""}`
};

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the catch, I'll fix that!

@jacoblee93
Copy link
Collaborator

Also looks like lint is failing:

Error:   6:24  error  '@langchain/core/utils/env' imported multiple times  import/no-duplicates
Error:   7:40  error  '@langchain/core/utils/env' imported multiple times  import/no-duplicates

@jacoblee93
Copy link
Collaborator

@sinedied happy to merge as is, but LMK if you want to do this: #7543 (comment)

@sinedied
Copy link
Contributor Author

sinedied commented Feb 6, 2025

I've fixed the extra space, should be good now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto:nit Small modifications/deletions, fixes, deps or improvements to existing code or docs lgtm PRs that are ready to be merged as-is size:S This PR changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants