Something went wrong. Try again.
fork of prime agent with changes i want but are not upstreamable probqbly (and some fixes)
Something went wrong. Try again.
1.5 kB · 49 lines
TypeScript
at main
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950/** * Custom Model Selection * * Shows how to select a specific model and thinking level. */
import { getModel } from "@earendil-works/pi-ai";import { AuthStorage, createAgentSession, ModelRegistry } from "@earendil-works/pi-coding-agent";
// Set up auth storage and model registryconst authStorage = AuthStorage.create();const modelRegistry = ModelRegistry.create(authStorage);
// Option 1: Find a specific built-in model by provider/idconst 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 = await 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();}