779ca4872b
- Removed Prettier configuration files (.prettierignore and .prettierrc) and migrated formatting to Biome. - Updated Biome configuration from version 2.3.11 to 2.3.12 and changed arrowParentheses rule from 'always' to 'asNeeded'. - Pinned @biomejs/biome dependency to exact version 2.3.12 in package.json and bun.lock. - Applied consistent arrow function formatting across 489 files by removing unnecessary parentheses around single parameters. - Removed blank lines after comment blocks and reorganized imports for consistency across the codebase.
49 lines
1.4 KiB
TypeScript
49 lines
1.4 KiB
TypeScript
/**
|
|
* Custom Model Selection
|
|
*
|
|
* Shows how to select a specific model and thinking level.
|
|
*/
|
|
import { getModel } from "@oh-my-pi/pi-ai";
|
|
import { createAgentSession, discoverAuthStorage, discoverModels } from "@oh-my-pi/pi-coding-agent";
|
|
|
|
// Set up auth storage and model registry
|
|
const authStorage = await discoverAuthStorage();
|
|
const modelRegistry = await discoverModels(authStorage);
|
|
|
|
// Option 1: Find a specific built-in model by provider/id
|
|
const opus = getModel("anthropic", "claude-opus-4-5");
|
|
if (opus) {
|
|
console.log(`Found model: ${opus.provider}/${opus.id}`);
|
|
}
|
|
|
|
// Option 2: Find model via registry (includes custom models from models.json)
|
|
const customModel = modelRegistry.find("my-provider", "my-model");
|
|
if (customModel) {
|
|
console.log(`Found custom model: ${customModel.provider}/${customModel.id}`);
|
|
}
|
|
|
|
// Option 3: Pick from available models (have valid API keys)
|
|
const available = modelRegistry.getAvailable();
|
|
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
|
|
authStorage,
|
|
modelRegistry,
|
|
});
|
|
|
|
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();
|
|
}
|