CoDEVX / lib /llm-config.ts
Tiger's Macbook Air
Build agentic PM demo app
3f76ff4
export type LlmConfig = {
apiKey: string;
baseUrl: string;
model: string;
};
export const DEFAULT_LLM_BASE_URL = "https://api.deepseek.com/anthropic";
export const DEFAULT_LLM_MODEL = "deepseek-v4-flash";
export const LLM_SETTINGS_STORAGE_KEY = "agentic-pm-demo.llm-settings";
function clean(value: string | undefined | null) {
return value?.trim() ?? "";
}
export function normalizeLlmConfig(
config?: Partial<LlmConfig> | null,
): LlmConfig {
const apiKey = clean(config?.apiKey);
const baseUrl = (clean(config?.baseUrl) || DEFAULT_LLM_BASE_URL).replace(
/\/+$/,
"",
);
const model = clean(config?.model) || DEFAULT_LLM_MODEL;
return {
apiKey,
baseUrl,
model,
};
}
export function isLlmConfigReady(
config?: Partial<LlmConfig> | null,
): config is LlmConfig {
const normalized = normalizeLlmConfig(config);
return Boolean(
normalized.apiKey && normalized.baseUrl && normalized.model,
);
}
export function isAnthropicCompatibleBaseUrl(baseUrl: string) {
return /anthropic/i.test(baseUrl);
}