feat: Add support for OpenAI-Organization and OpenAI-Project headers (#626)
Added support for OpenAI-Organization and OpenAI-Project headers for OpenAI API calls. This is for #74
This commit is contained in:
@@ -5,7 +5,13 @@ import type { FileOperation } from "../utils/singlepass/file_ops";
|
||||
|
||||
import Spinner from "./vendor/ink-spinner"; // Third‑party / vendor components
|
||||
import TextInput from "./vendor/ink-text-input";
|
||||
import { OPENAI_TIMEOUT_MS, getBaseUrl, getApiKey } from "../utils/config";
|
||||
import {
|
||||
OPENAI_TIMEOUT_MS,
|
||||
OPENAI_ORGANIZATION,
|
||||
OPENAI_PROJECT,
|
||||
getBaseUrl,
|
||||
getApiKey,
|
||||
} from "../utils/config";
|
||||
import {
|
||||
generateDiffSummary,
|
||||
generateEditSummary,
|
||||
@@ -393,10 +399,19 @@ export function SinglePassApp({
|
||||
files,
|
||||
});
|
||||
|
||||
const headers: Record<string, string> = {};
|
||||
if (OPENAI_ORGANIZATION) {
|
||||
headers["OpenAI-Organization"] = OPENAI_ORGANIZATION;
|
||||
}
|
||||
if (OPENAI_PROJECT) {
|
||||
headers["OpenAI-Project"] = OPENAI_PROJECT;
|
||||
}
|
||||
|
||||
const openai = new OpenAI({
|
||||
apiKey: getApiKey(config.provider),
|
||||
baseURL: getBaseUrl(config.provider),
|
||||
timeout: OPENAI_TIMEOUT_MS,
|
||||
defaultHeaders: headers,
|
||||
});
|
||||
const chatResp = await openai.beta.chat.completions.parse({
|
||||
model: config.model,
|
||||
|
||||
Reference in New Issue
Block a user