w (#8)
This commit is contained in:
committed by
GitHub
parent
8794df3c08
commit
1b40e19baf
@@ -63,7 +63,7 @@ export type MemoryConfig = {
|
|||||||
enabled: boolean;
|
enabled: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Represents full runtime config, including loaded instructions
|
// Represents full runtime config, including loaded instructions.
|
||||||
export type AppConfig = {
|
export type AppConfig = {
|
||||||
apiKey?: string;
|
apiKey?: string;
|
||||||
model: string;
|
model: string;
|
||||||
@@ -91,7 +91,7 @@ export function discoverProjectDocPath(startDir: string): string | null {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2) Fallback: walk up to the Git root and look there
|
// 2) Fallback: walk up to the Git root and look there.
|
||||||
let dir = cwd;
|
let dir = cwd;
|
||||||
// eslint-disable-next-line no-constant-condition
|
// eslint-disable-next-line no-constant-condition
|
||||||
while (true) {
|
while (true) {
|
||||||
@@ -104,13 +104,13 @@ export function discoverProjectDocPath(startDir: string): string | null {
|
|||||||
return candidate;
|
return candidate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// If Git root but no doc, stop looking
|
// If Git root but no doc, stop looking.
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const parent = dirname(dir);
|
const parent = dirname(dir);
|
||||||
if (parent === dir) {
|
if (parent === dir) {
|
||||||
// Reached filesystem root without finding Git
|
// Reached filesystem root without finding Git.
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
dir = parent;
|
dir = parent;
|
||||||
@@ -157,7 +157,6 @@ export function loadProjectDoc(cwd: string, explicitPath?: string): string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// (Receives params for testing)
|
|
||||||
export type LoadConfigOptions = {
|
export type LoadConfigOptions = {
|
||||||
/** Working directory used for project doc discovery */
|
/** Working directory used for project doc discovery */
|
||||||
cwd?: string;
|
cwd?: string;
|
||||||
@@ -210,7 +209,7 @@ export const loadConfig = (
|
|||||||
? readFileSync(instructionsFilePathResolved, "utf-8")
|
? readFileSync(instructionsFilePathResolved, "utf-8")
|
||||||
: DEFAULT_INSTRUCTIONS;
|
: DEFAULT_INSTRUCTIONS;
|
||||||
|
|
||||||
// Project doc -----------------------------------------------------------
|
// Project doc support.
|
||||||
const shouldLoadProjectDoc =
|
const shouldLoadProjectDoc =
|
||||||
!options.disableProjectDoc &&
|
!options.disableProjectDoc &&
|
||||||
process.env["CODEX_DISABLE_PROJECT_DOC"] !== "1";
|
process.env["CODEX_DISABLE_PROJECT_DOC"] !== "1";
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { OPENAI_API_KEY } from "./config";
|
import { OPENAI_API_KEY } from "./config";
|
||||||
import OpenAI from "openai";
|
import OpenAI from "openai";
|
||||||
|
|
||||||
|
const MODEL_LIST_TIMEOUT_MS = 2_000; // 2 seconds
|
||||||
export const RECOMMENDED_MODELS: Array<string> = ["o4-mini", "o3"];
|
export const RECOMMENDED_MODELS: Array<string> = ["o4-mini", "o3"];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -14,9 +15,9 @@ export const RECOMMENDED_MODELS: Array<string> = ["o4-mini", "o3"];
|
|||||||
let modelsPromise: Promise<Array<string>> | null = null;
|
let modelsPromise: Promise<Array<string>> | null = null;
|
||||||
|
|
||||||
async function fetchModels(): Promise<Array<string>> {
|
async function fetchModels(): Promise<Array<string>> {
|
||||||
// If the user has not configured an API key we cannot hit the network
|
// If the user has not configured an API key we cannot hit the network.
|
||||||
if (!OPENAI_API_KEY) {
|
if (!OPENAI_API_KEY) {
|
||||||
return ["o4-mini"];
|
return RECOMMENDED_MODELS;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -67,8 +68,6 @@ export async function isModelSupportedForResponses(
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const MODEL_LIST_TIMEOUT_MS = 2_000;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const models = await Promise.race<Array<string>>([
|
const models = await Promise.race<Array<string>>([
|
||||||
getAvailableModels(),
|
getAvailableModels(),
|
||||||
|
|||||||
Reference in New Issue
Block a user