Skip to content

Commit

Permalink
Fixed to match new apiKey field
Browse files Browse the repository at this point in the history
  • Loading branch information
scottforte committed Jun 10, 2024
1 parent 6535861 commit dcec704
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
4 changes: 3 additions & 1 deletion langchain/src/chains/openai_moderation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ export class OpenAIModerationChain
super(fields);
this.throwError = fields?.throwError ?? false;
this.openAIApiKey =
fields?.openAIApiKey ?? getEnvironmentVariable("OPENAI_API_KEY");
fields?.apiKey ??
fields?.openAIApiKey ??
getEnvironmentVariable("OPENAI_API_KEY");

if (!this.openAIApiKey) {
throw new Error("OpenAI API key not found");
Expand Down
4 changes: 3 additions & 1 deletion libs/langchain-azure-openai/src/chat_models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,9 @@ export class AzureChatOpenAI
getEnvironmentVariable("AZURE_OPENAI_API_DEPLOYMENT_NAME");

const openAiApiKey =
fields?.openAIApiKey ?? getEnvironmentVariable("OPENAI_API_KEY");
fields?.apiKey ??
fields?.openAIApiKey ??
getEnvironmentVariable("OPENAI_API_KEY");

this.azureOpenAIApiKey =
fields?.apiKey ??
Expand Down
4 changes: 3 additions & 1 deletion libs/langchain-azure-openai/src/embeddings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ export class AzureOpenAIEmbeddings
getEnvironmentVariable("AZURE_OPENAI_API_ENDPOINT");

const openAiApiKey =
fields?.openAIApiKey ?? getEnvironmentVariable("OPENAI_API_KEY");
fields?.apiKey ??
fields?.openAIApiKey ??
getEnvironmentVariable("OPENAI_API_KEY");

this.azureOpenAIApiKey =
fields?.apiKey ??
Expand Down
4 changes: 3 additions & 1 deletion libs/langchain-azure-openai/src/llms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@ export class AzureOpenAI<
getEnvironmentVariable("AZURE_OPENAI_API_DEPLOYMENT_NAME");

const openAiApiKey =
fields?.openAIApiKey ?? getEnvironmentVariable("OPENAI_API_KEY");
fields?.apiKey ??
fields?.openAIApiKey ??
getEnvironmentVariable("OPENAI_API_KEY");

this.azureOpenAIApiKey =
fields?.apiKey ??
Expand Down
4 changes: 3 additions & 1 deletion libs/langchain-openai/src/legacy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,9 @@ export class OpenAIChat
super(fields ?? {});

this.openAIApiKey =
fields?.openAIApiKey ?? getEnvironmentVariable("OPENAI_API_KEY");
fields?.apiKey ??
fields?.openAIApiKey ??
getEnvironmentVariable("OPENAI_API_KEY");

this.azureOpenAIApiKey =
fields?.azureOpenAIApiKey ??
Expand Down

0 comments on commit dcec704

Please sign in to comment.