-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
openai[minor]: Update OpenAI with Azure Specific Code #5323
openai[minor]: Update OpenAI with Azure Specific Code #5323
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@@ -41,11 +41,12 @@ | |||
"dependencies": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey there! 👋 I noticed that the package.json file has an update to the "openai" dependency version and a new dev dependency "@azure/identity" added. This is just a heads up for the maintainers to review the changes in dependencies. Keep up the great work! 🚀
@@ -48,6 +43,56 @@ export class AzureChatOpenAI extends ChatOpenAI { | |||
super(newFields); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey there! I've reviewed the code changes and it looks like a new HTTP request setup using the AzureOpenAIClient has been added in the _getClientOptions
method. I've flagged this for your review to ensure it aligns with the project's requirements. Let me know if you have any questions or need further clarification.
@@ -0,0 +1,829 @@ | |||
import { test, jest, expect } from "@jest/globals"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey team, I've reviewed the code and noticed that the changes in this PR access environment variables using the getEnvironmentVariable
function. This comment is to flag the change for your review. Let me know if you need any further assistance!
@@ -0,0 +1,333 @@ | |||
import { test, expect } from "@jest/globals"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey team, just a heads up that I've flagged a change in the PR that uses the getEnvironmentVariable
function to access environment variables. It's important for maintainers to review this change to ensure proper handling of environment variables.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why wouldn't you just use the @langchain/azure-openai
package?
The It is possible that similar changes could happen in |
But what are the features that would compel someone to use If it's just the ability to have one package installed, and use it to hit the OAI & Azure APIs, I don't think we want that since the packages are small enough already. |
@bracesproul Actually Yes. It is the reasoning that the users could just install one package ( Now, if you prefer I could make the same change in |
@bracesproul, The goal here is to provide LangChainJS developers using OpenAI with the same quality of experience as LangChain (Python) developers. JavaScript developers want to seamlessly switch between OpenAI and Azure OpenAI endpoints using a single SDK without needing to change packages when talking to different OpenAI endpoints. All LangChain (Python) developers already enjoy this capability today without needing any Azure specific packages across the board: https://python.langchain.com/v0.1/docs/integrations/llms/azure_openai/#deployments. In order to enable this experience, we first developed an Azure OpenAI client natively in the OpenAI SDK for JavaScript in order to be on par with Python. We just shipped this support a few days ago (https://www.npmjs.com/package/openai). The problem with the additional azure specific package is not just the size, it's the fact that if there's a new feature in OpenAI that shows up in Azure OpenAI endpoint; they need to wait first for Azure OpenAI SDK for JavaScript to release a new version and then wait for the @langchain/azure-openai package to be updated to use this version. So they need to perform at least an additional package install/upgrade and if breaking, an additional code update. This is cumbersome (and error prone if there are versioning mismatches across these libraries as OpenAI APIs evolve rapidly). Our solution provides a simple streamlined developer experience around OpenAI for LangChainJS customers. Hope this helps clarify. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a few comments. Good start, need to cleanup a couple nits. Thanks for working on this large PR!
Also, CI is failing, if you could resolve those errors that would be great!
Co-authored-by: Brace Sproul <[email protected]>
Co-authored-by: Brace Sproul <[email protected]>
@bracesproul I have addressed the feedback. Could you please take a look at the PR? Thanks |
…update_openai_with_azure
I think consolidation is good - but what will become of the |
@@ -27,15 +29,8 @@ export class AzureOpenAI extends OpenAI { | |||
configuration?: ClientOptions & LegacyOpenAIInput; | |||
} | |||
) { | |||
// assume the base URL does not contain "openai" nor "deployments" prefix | |||
let basePath = fields?.openAIBasePath ?? ""; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, this is breaking, isn't it?
I don't think this is heavily used yet and there are no examples in our docs, so I'm ok with a change now.
Thanks! As noted above, it's technically breaking but this code path doesn't seem to be in our docs yet. Let's try to shim things in the future though once it becomes more prominent. |
* Update OpenAI with Azure Specific Code * Export Embeddings * Add deployment parameters * Check to fix build issue * Update libs/langchain-openai/src/azure/embeddings.ts Co-authored-by: Brace Sproul <[email protected]> * Update libs/langchain-openai/src/azure/embeddings.ts Co-authored-by: Brace Sproul <[email protected]> * nit changes * Update Test Descriptions * Format * Fix types --------- Co-authored-by: Brace Sproul <[email protected]> Co-authored-by: jacoblee93 <[email protected]>
* Update OpenAI with Azure Specific Code * Export Embeddings * Add deployment parameters * Check to fix build issue * Update libs/langchain-openai/src/azure/embeddings.ts * Update libs/langchain-openai/src/azure/embeddings.ts * nit changes * Update Test Descriptions * Format * Fix types --------- Co-authored-by: Sarangan Rajamanickam <[email protected]> Co-authored-by: Brace Sproul <[email protected]>
Azure SDK Team has made changes to Open AI Node SDK in PR openai/openai-node#718. In that PR, a new AzureOpenAI Client has been introduced. This enables the OpenAI SDK Users to access Azure Hosted Services with their credentials object instead of OpenAI Key.
This PR is to make changes to @langchain/openai package to make the corresponding changes so Langchain users also could access their Azure Hosted OpenAI service with the credentials object. Required test cases have already been added to the PR.
@achandmsft @deyaaeldeen @xirzec FYI.....