Skip to content

Commit

Permalink
🚀 feat: Add OPENAI_ORGANIZATION for all OpenAI Requests (danny-avil…
Browse files Browse the repository at this point in the history
  • Loading branch information
danny-avila authored Jan 19, 2024
1 parent fc362f6 commit e6746c4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/clients/OpenAIClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -954,6 +954,10 @@ ${convo}
opts.defaultHeaders = { ...opts.defaultHeaders, 'api-key': this.apiKey };
}

if (process.env.OPENAI_ORGANIZATION) {
opts.organization = process.env.OPENAI_ORGANIZATION;
}

let chatCompletion;
const openai = new OpenAI({
apiKey: this.apiKey,
Expand Down
4 changes: 4 additions & 0 deletions server/services/ModelService.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ const fetchModels = async ({ apiKey, baseURL, name = 'OpenAI', azure = false })
payload.httpsAgent = new HttpsProxyAgent(PROXY);
}

if (process.env.OPENAI_ORGANIZATION && baseURL.includes('openai')) {
payload.headers['OpenAI-Organization'] = process.env.OPENAI_ORGANIZATION;
}

const res = await axios.get(`${baseURL}${azure ? '' : '/models'}`, payload);
models = res.data.data.map((item) => item.id);
} catch (err) {
Expand Down

0 comments on commit e6746c4

Please sign in to comment.