update pi

This commit is contained in:
2026-03-27 09:22:40 +00:00
parent d5b4042b06
commit 39e7bddb35
12 changed files with 82 additions and 65 deletions
+8 -7
View File
@@ -135,11 +135,11 @@ export default function(pi: ExtensionAPI) {
// Fire-and-forget: run auto-naming in background without blocking
const doAutoName = async () => {
const apiKey = await ctx.modelRegistry.getApiKey(AUTO_NAME_MODEL);
log(`Got API key: ${apiKey ? "yes" : "no"}`);
const auth = await ctx.modelRegistry.getApiKeyAndHeaders(AUTO_NAME_MODEL);
log(`Got API key: ${auth.ok ? "yes" : "no"}`);
if (!apiKey) {
log("No API key available, aborting");
if (!auth.ok) {
log(`No API key available, aborting: ${auth.error}`);
return;
}
@@ -157,7 +157,7 @@ export default function(pi: ExtensionAPI) {
const response = await complete(
AUTO_NAME_MODEL,
{ systemPrompt: SYSTEM_PROMPT, messages: [userMessage] },
{ apiKey },
{ apiKey: auth.apiKey, headers: auth.headers },
);
log(`Response received, stopReason: ${response.stopReason}`);
@@ -273,7 +273,8 @@ export default function(pi: ExtensionAPI) {
loader.onAbort = () => done(null);
const doGenerate = async () => {
const apiKey = await ctx.modelRegistry.getApiKey(AUTO_NAME_MODEL);
const auth = await ctx.modelRegistry.getApiKeyAndHeaders(AUTO_NAME_MODEL);
if (!auth.ok) throw new Error(auth.error);
const userMessage: Message = {
role: "user",
@@ -289,7 +290,7 @@ export default function(pi: ExtensionAPI) {
const response = await complete(
AUTO_NAME_MODEL,
{ systemPrompt: SYSTEM_PROMPT, messages: [userMessage] },
{ apiKey, signal: loader.signal },
{ apiKey: auth.apiKey, headers: auth.headers, signal: loader.signal },
);
if (response.stopReason === "aborted") {