Skip to content

Commit

Permalink
[Azure OpenAI] Make credentials optional when env variables are set (#…
Browse files Browse the repository at this point in the history
…3418)

* Make Azure OpenAI credentials optional when env variables are set

* Add documentation for env vars
  • Loading branch information
JJK801 authored Nov 1, 2024
1 parent a159da5 commit 012eabc
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../
import { ChatOpenAI } from '../ChatOpenAI/FlowiseChatOpenAI'
import { getModels, MODEL_TYPE } from '../../../src/modelLoader'

const serverCredentialsExists =
!!process.env.AZURE_OPENAI_API_KEY &&
!!process.env.AZURE_OPENAI_API_INSTANCE_NAME &&
!!process.env.AZURE_OPENAI_API_DEPLOYMENT_NAME &&
!!process.env.AZURE_OPENAI_API_VERSION

class AzureChatOpenAI_ChatModels implements INode {
label: string
name: string
Expand All @@ -31,7 +37,8 @@ class AzureChatOpenAI_ChatModels implements INode {
label: 'Connect Credential',
name: 'credential',
type: 'credential',
credentialNames: ['azureOpenAIApi']
credentialNames: ['azureOpenAIApi'],
optional: serverCredentialsExists
}
this.inputs = [
{
Expand Down
16 changes: 16 additions & 0 deletions packages/components/nodes/chatmodels/AzureChatOpenAI/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Azure OpenAI Chat Model

Azure OpenAI Chat Model integration for Flowise

## 🌱 Env Variables

| Variable | Description | Type | Default |
| ---------------------------- | ----------------------------------------------------------------------------------------------- | ------------------------------------------------ | ----------------------------------- |
| AZURE_OPENAI_API_KEY | Default `credential.azureOpenAIApiKey` for Azure OpenAI Model | String | |
| AZURE_OPENAI_API_INSTANCE_NAME | Default `credential.azureOpenAIApiInstanceName` for Azure OpenAI Model | String | |
| AZURE_OPENAI_API_DEPLOYMENT_NAME | Default `credential.azureOpenAIApiDeploymentName` for Azure OpenAI Model | String | |
| AZURE_OPENAI_API_VERSION | Default `credential.azureOpenAIApiVersion` for Azure OpenAI Model | String | |

## License

Source code in this repository is made available under the [Apache License Version 2.0](https://github.com/FlowiseAI/Flowise/blob/master/LICENSE.md).
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ import { AzureOpenAIInput, OpenAIEmbeddings, OpenAIEmbeddingsParams } from '@lan
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'

const serverCredentialsExists =
!!process.env.AZURE_OPENAI_API_KEY &&
!!process.env.AZURE_OPENAI_API_INSTANCE_NAME &&
(!!process.env.AZURE_OPENAI_API_EMBEDDINGS_DEPLOYMENT_NAME || !!process.env.AZURE_OPENAI_API_DEPLOYMENT_NAME) &&
!!process.env.AZURE_OPENAI_API_VERSION

class AzureOpenAIEmbedding_Embeddings implements INode {
label: string
name: string
Expand All @@ -27,7 +33,8 @@ class AzureOpenAIEmbedding_Embeddings implements INode {
label: 'Connect Credential',
name: 'credential',
type: 'credential',
credentialNames: ['azureOpenAIApi']
credentialNames: ['azureOpenAIApi'],
optional: serverCredentialsExists
}
this.inputs = [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Azure OpenAI Embedding Model

Azure OpenAI Embedding Model integration for Flowise

## 🌱 Env Variables

| Variable | Description | Type | Default |
| ---------------------------- | ----------------------------------------------------------------------------------------------- | ------------------------------------------------ | ----------------------------------- |
| AZURE_OPENAI_API_KEY | Default `credential.azureOpenAIApiKey` for Azure OpenAI Model | String | |
| AZURE_OPENAI_API_INSTANCE_NAME | Default `credential.azureOpenAIApiInstanceName` for Azure OpenAI Model | String | |
| AZURE_OPENAI_API_EMBEDDINGS_DEPLOYMENT_NAME | Default `credential.azureOpenAIApiDeploymentName` for Azure OpenAI Model | String | |
| AZURE_OPENAI_API_VERSION | Default `credential.azureOpenAIApiVersion` for Azure OpenAI Model | String | |

## License

Source code in this repository is made available under the [Apache License Version 2.0](https://github.com/FlowiseAI/Flowise/blob/master/LICENSE.md).
9 changes: 8 additions & 1 deletion packages/components/nodes/llms/Azure OpenAI/AzureOpenAI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ import { ICommonObject, INode, INodeData, INodeOptionsValue, INodeParams } from
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
import { getModels, MODEL_TYPE } from '../../../src/modelLoader'

const serverCredentialsExists =
!!process.env.AZURE_OPENAI_API_KEY &&
!!process.env.AZURE_OPENAI_API_INSTANCE_NAME &&
!!process.env.AZURE_OPENAI_API_DEPLOYMENT_NAME &&
!!process.env.AZURE_OPENAI_API_VERSION

class AzureOpenAI_LLMs implements INode {
label: string
name: string
Expand All @@ -30,7 +36,8 @@ class AzureOpenAI_LLMs implements INode {
label: 'Connect Credential',
name: 'credential',
type: 'credential',
credentialNames: ['azureOpenAIApi']
credentialNames: ['azureOpenAIApi'],
optional: serverCredentialsExists
}
this.inputs = [
{
Expand Down
16 changes: 16 additions & 0 deletions packages/components/nodes/llms/Azure OpenAI/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Azure OpenAI LLM

Azure OpenAI LLM integration for Flowise

## 🌱 Env Variables

| Variable | Description | Type | Default |
| ---------------------------- | ----------------------------------------------------------------------------------------------- | ------------------------------------------------ | ----------------------------------- |
| AZURE_OPENAI_API_KEY | Default `credential.azureOpenAIApiKey` for Azure OpenAI LLM | String | |
| AZURE_OPENAI_API_INSTANCE_NAME | Default `credential.azureOpenAIApiInstanceName` for Azure OpenAI LLM | String | |
| AZURE_OPENAI_API_DEPLOYMENT_NAME | Default `credential.azureOpenAIApiDeploymentName` for Azure OpenAI LLM | String | |
| AZURE_OPENAI_API_VERSION | Default `credential.azureOpenAIApiVersion` for Azure OpenAI LLM | String | |

## License

Source code in this repository is made available under the [Apache License Version 2.0](https://github.com/FlowiseAI/Flowise/blob/master/LICENSE.md).

0 comments on commit 012eabc

Please sign in to comment.