mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-15 23:01:30 +00:00
Allow startup without API keys, fixes #288
This commit is contained in:
parent
ce8a1c8eb1
commit
e234e8d18f
4 changed files with 48 additions and 12 deletions
|
|
@ -422,8 +422,7 @@ export class AgentSession {
|
|||
if (!this.model) {
|
||||
throw new Error(
|
||||
"No model selected.\n\n" +
|
||||
"Set an API key (ANTHROPIC_API_KEY, OPENAI_API_KEY, etc.)\n" +
|
||||
`or create ${getModelsPath()}\n\n` +
|
||||
`Use /login, set an API key environment variable or create ${getModelsPath()}\n\n` +
|
||||
"Then use /model to select a model.",
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -517,15 +517,14 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
|
|||
if (!model) {
|
||||
const available = await discoverAvailableModels();
|
||||
time("discoverAvailableModels");
|
||||
if (available.length === 0) {
|
||||
throw new Error(
|
||||
"No models available. Set an API key environment variable " +
|
||||
"(ANTHROPIC_API_KEY, OPENAI_API_KEY, etc.) or provide a model explicitly.",
|
||||
);
|
||||
}
|
||||
model = available[0];
|
||||
if (modelFallbackMessage) {
|
||||
modelFallbackMessage += `. Using ${model.provider}/${model.id}`;
|
||||
if (available.length > 0) {
|
||||
model = available[0];
|
||||
if (modelFallbackMessage) {
|
||||
modelFallbackMessage += `. Using ${model.provider}/${model.id}`;
|
||||
}
|
||||
} else {
|
||||
// No models available - set message so user knows to /login or configure keys
|
||||
modelFallbackMessage = "No models available. Use /login or set an API key environment variable.";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -542,7 +541,7 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
|
|||
}
|
||||
|
||||
// Clamp to model capabilities
|
||||
if (!model.reasoning) {
|
||||
if (!model || !model.reasoning) {
|
||||
thinkingLevel = "off";
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue