update pi
This commit is contained in:
@@ -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") {
|
||||
|
||||
Reference in New Issue
Block a user