This commit is contained in:
+1
-1
@@ -56,7 +56,7 @@ const App: Component = () => {
|
||||
setAiHelpTip(nextTip);
|
||||
await appendAIHelpTipHistory(nextTip);
|
||||
} catch (err) {
|
||||
console.error("Failed to generate AI help tip", err);
|
||||
console.warn("Tip generation skipped", err);
|
||||
}
|
||||
})();
|
||||
});
|
||||
|
||||
@@ -392,10 +392,10 @@ export const Sidebar: Component<{
|
||||
<div
|
||||
class={cn(
|
||||
"transition-all duration-300 ease-out overflow-hidden",
|
||||
props.isAIHelpOpen ? "max-h-[34rem] opacity-100" : "max-h-0 opacity-0 pointer-events-none"
|
||||
props.isAIHelpOpen ? "max-h-[44rem] opacity-100" : "max-h-0 opacity-0 pointer-events-none"
|
||||
)}
|
||||
>
|
||||
<AIHelpPanel variant="sidebar" class="h-[32rem]" />
|
||||
<AIHelpPanel variant="sidebar" class="h-[42rem]" />
|
||||
</div>
|
||||
|
||||
<div class="border-t border-border pt-3 space-y-1">
|
||||
|
||||
+33
-1
@@ -28,6 +28,33 @@ const normalizeLine = (value: string) =>
|
||||
|
||||
export const hasFireworksApiKey = () => FIREWORKS_API_KEY.trim().length > 0;
|
||||
|
||||
const extractTextFromContent = (content: unknown): string => {
|
||||
if (typeof content === "string") {
|
||||
return content.trim();
|
||||
}
|
||||
|
||||
if (Array.isArray(content)) {
|
||||
return content
|
||||
.map(part => {
|
||||
if (typeof part === "string") return part;
|
||||
if (part && typeof part === "object") {
|
||||
if ("text" in part && typeof (part as any).text === "string") {
|
||||
return (part as any).text;
|
||||
}
|
||||
if ("content" in part && typeof (part as any).content === "string") {
|
||||
return (part as any).content;
|
||||
}
|
||||
}
|
||||
return "";
|
||||
})
|
||||
.filter(Boolean)
|
||||
.join("\n")
|
||||
.trim();
|
||||
}
|
||||
|
||||
return "";
|
||||
};
|
||||
|
||||
const requestFireworks = async (messages: ChatRequestMessage[], options?: { maxTokens?: number; temperature?: number }) => {
|
||||
const response = await fetch(FIREWORKS_API_URL, {
|
||||
method: "POST",
|
||||
@@ -50,7 +77,12 @@ const requestFireworks = async (messages: ChatRequestMessage[], options?: { maxT
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
const content = data?.choices?.[0]?.message?.content?.trim();
|
||||
const choice = data?.choices?.[0];
|
||||
const content = extractTextFromContent(choice?.message?.content)
|
||||
|| extractTextFromContent(choice?.message?.reasoning_content)
|
||||
|| extractTextFromContent(choice?.delta?.content)
|
||||
|| extractTextFromContent(choice?.text)
|
||||
|| extractTextFromContent(data?.output_text);
|
||||
|
||||
if (!content) {
|
||||
throw new Error("The help assistant did not return any text.");
|
||||
|
||||
Reference in New Issue
Block a user