mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-15 23:01:30 +00:00
12 examples showing increasing levels of customization: - 01-minimal: all defaults - 02-custom-model: model and thinking level - 03-custom-prompt: replace or modify prompt - 04-skills: discover, filter, merge skills - 05-tools: built-in tools, custom tools - 06-hooks: logging, blocking, result modification - 07-context-files: AGENTS.md files - 08-slash-commands: file-based commands - 09-api-keys-and-oauth: API key resolution, OAuth config - 10-settings: compaction, retry, terminal settings - 11-sessions: persistence options - 12-full-control: replace everything Also exports FileSlashCommand type from index.ts
36 lines
1 KiB
TypeScript
36 lines
1 KiB
TypeScript
/**
|
|
* Custom Model Selection
|
|
*
|
|
* Shows how to select a specific model and thinking level.
|
|
*/
|
|
|
|
import { createAgentSession, findModel, discoverAvailableModels } from "../../src/index.js";
|
|
|
|
// Option 1: Find a specific model by provider/id
|
|
const { model: sonnet } = findModel("anthropic", "claude-sonnet-4-20250514");
|
|
if (sonnet) {
|
|
console.log(`Found model: ${sonnet.provider}/${sonnet.id}`);
|
|
}
|
|
|
|
// Option 2: Pick from available models (have valid API keys)
|
|
const available = await discoverAvailableModels();
|
|
console.log(
|
|
"Available models:",
|
|
available.map((m) => `${m.provider}/${m.id}`),
|
|
);
|
|
|
|
if (available.length > 0) {
|
|
const { session } = await createAgentSession({
|
|
model: available[0],
|
|
thinkingLevel: "medium", // off, low, medium, high
|
|
});
|
|
|
|
session.subscribe((event) => {
|
|
if (event.type === "message_update" && event.assistantMessageEvent.type === "text_delta") {
|
|
process.stdout.write(event.assistantMessageEvent.delta);
|
|
}
|
|
});
|
|
|
|
await session.prompt("Say hello in one sentence.");
|
|
console.log();
|
|
}
|