pi-better-openai 0.1.9 → 0.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.ts +22 -7
- package/package.json +1 -1
- package/src/image.ts +7 -2
package/index.ts
CHANGED
|
@@ -107,6 +107,7 @@ export default function betterOpenAI(pi: ExtensionAPI): void {
|
|
|
107
107
|
let shuttingDown = false;
|
|
108
108
|
let usageAbortController: AbortController | undefined;
|
|
109
109
|
let footerInstalled = false;
|
|
110
|
+
let statusInstalled = false;
|
|
110
111
|
let requestFooterRender: (() => void) | undefined;
|
|
111
112
|
let lastInjectedAt: number | undefined;
|
|
112
113
|
let lastInjectedModel: string | undefined;
|
|
@@ -336,7 +337,7 @@ export default function betterOpenAI(pi: ExtensionAPI): void {
|
|
|
336
337
|
currentValue: cfg.footer.mode,
|
|
337
338
|
values: [...FOOTER_MODES],
|
|
338
339
|
description:
|
|
339
|
-
"replace = custom footer, status = pi footer plus status line, off = no Better OpenAI footer/status.",
|
|
340
|
+
"replace = custom footer, status = pi footer plus status line, off = no Better OpenAI footer/status and leaves other footers untouched.",
|
|
340
341
|
},
|
|
341
342
|
{
|
|
342
343
|
id: "usage.enabled",
|
|
@@ -676,20 +677,34 @@ export default function betterOpenAI(pi: ExtensionAPI): void {
|
|
|
676
677
|
});
|
|
677
678
|
}
|
|
678
679
|
|
|
680
|
+
function clearFooter(ctx: ExtensionContext): void {
|
|
681
|
+
if (!footerInstalled) return;
|
|
682
|
+
ctx.ui.setFooter(undefined);
|
|
683
|
+
footerInstalled = false;
|
|
684
|
+
requestFooterRender = undefined;
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
function setStatus(ctx: ExtensionContext, text: string | undefined): void {
|
|
688
|
+
if (!text && !statusInstalled) return;
|
|
689
|
+
ctx.ui.setStatus(STATUS_KEY, text);
|
|
690
|
+
statusInstalled = text !== undefined;
|
|
691
|
+
}
|
|
692
|
+
|
|
679
693
|
function updateFooter(ctx: ExtensionContext): void {
|
|
680
694
|
const cfg = config(ctx);
|
|
681
695
|
if (cfg.footer.mode === "replace") {
|
|
682
|
-
|
|
696
|
+
setStatus(ctx, undefined);
|
|
683
697
|
installFooter(ctx);
|
|
684
698
|
return;
|
|
685
699
|
}
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
700
|
+
|
|
701
|
+
clearFooter(ctx);
|
|
702
|
+
|
|
689
703
|
if (cfg.footer.mode === "off") {
|
|
690
|
-
|
|
704
|
+
setStatus(ctx, undefined);
|
|
691
705
|
return;
|
|
692
706
|
}
|
|
707
|
+
|
|
693
708
|
const fast =
|
|
694
709
|
active && supportsFast(ctx, cfg.supportedModels)
|
|
695
710
|
? `${ctx.model?.id ?? "model"} fast`
|
|
@@ -698,7 +713,7 @@ export default function betterOpenAI(pi: ExtensionAPI): void {
|
|
|
698
713
|
usageSnapshot && cfg.usage.enabled && isOpenAISubscriptionModel(ctx, cfg)
|
|
699
714
|
? formatUsageSnapshot(usageSnapshot, cfg.usage)
|
|
700
715
|
: undefined;
|
|
701
|
-
|
|
716
|
+
setStatus(ctx, [fast, usage].filter(Boolean).join(" | ") || undefined);
|
|
702
717
|
}
|
|
703
718
|
|
|
704
719
|
pi.on("session_start", (_event, ctx) => {
|
package/package.json
CHANGED
package/src/image.ts
CHANGED
|
@@ -497,7 +497,7 @@ function resolveToolPrompt(params: ToolParams, ctx: ExtensionContext): string {
|
|
|
497
497
|
|
|
498
498
|
function resultText(result: CodexImageResult): string {
|
|
499
499
|
const parts = [
|
|
500
|
-
`Generated image via openai-codex/${result.model}.`,
|
|
500
|
+
`Generated image using OpenAI image_generation tool via openai-codex/${result.model}.`,
|
|
501
501
|
`Action: ${result.action}.`,
|
|
502
502
|
`Prompt: ${result.prompt}`,
|
|
503
503
|
];
|
|
@@ -649,7 +649,12 @@ export function registerOpenAIImage(
|
|
|
649
649
|
const model = resolveModel(params, ctx, cfg);
|
|
650
650
|
const requestParams = { ...params, prompt: resolveToolPrompt(params, ctx) };
|
|
651
651
|
onUpdate?.({
|
|
652
|
-
content: [
|
|
652
|
+
content: [
|
|
653
|
+
{
|
|
654
|
+
type: "text",
|
|
655
|
+
text: `Requesting OpenAI image_generation via openai-codex/${model}...`,
|
|
656
|
+
},
|
|
657
|
+
],
|
|
653
658
|
details: undefined,
|
|
654
659
|
});
|
|
655
660
|
const result = await generate(requestParams, ctx, signal);
|