fix(ai): polish ask ash chat widget
This commit is contained in:
parent
5973e6216e
commit
89ee3f8067
1 changed files with 32 additions and 11 deletions
|
|
@ -7,6 +7,8 @@ interface ChatMessage {
|
|||
role: "user" | "assistant";
|
||||
content: string;
|
||||
intent?: string;
|
||||
status?: string;
|
||||
suggestedAction?: string;
|
||||
}
|
||||
|
||||
interface ChatResponse {
|
||||
|
|
@ -18,6 +20,21 @@ interface ChatResponse {
|
|||
remaining_daily_actions?: number;
|
||||
credits_charged?: number;
|
||||
message?: string;
|
||||
status?: string;
|
||||
suggested_action?: string;
|
||||
}
|
||||
|
||||
function statusLabel(status?: string): string | null {
|
||||
switch (status) {
|
||||
case "ticket_created":
|
||||
return "Support ticket created";
|
||||
case "kb_results":
|
||||
return "Help articles found";
|
||||
case "usage_summary":
|
||||
return "AI usage summary";
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
interface UsageStatus {
|
||||
|
|
@ -124,6 +141,8 @@ export function AiChatWidget() {
|
|||
role: "assistant",
|
||||
content: data.message || data.reply,
|
||||
intent: data.intent,
|
||||
status: data.status,
|
||||
suggestedAction: data.suggested_action,
|
||||
};
|
||||
setMessages((prev) => [...prev, assistantMessage]);
|
||||
} catch (err) {
|
||||
|
|
@ -326,17 +345,19 @@ export function AiChatWidget() {
|
|||
}}
|
||||
>
|
||||
<p style={{ margin: 0, "white-space": "pre-wrap" }}>{msg.content}</p>
|
||||
<Show when={msg.intent && msg.role === "assistant"}>
|
||||
<p
|
||||
style={{
|
||||
margin: "4px 0 0",
|
||||
"font-size": "10px",
|
||||
color: "#9CA3AF",
|
||||
"font-style": "italic",
|
||||
}}
|
||||
>
|
||||
Intent: {msg.intent}
|
||||
</p>
|
||||
<Show when={msg.role === "assistant" && statusLabel(msg.status)}>
|
||||
{(label) => (
|
||||
<p
|
||||
style={{
|
||||
margin: "6px 0 0",
|
||||
"font-size": "10px",
|
||||
color: "#6B7280",
|
||||
"font-weight": "600",
|
||||
}}
|
||||
>
|
||||
{label()}
|
||||
</p>
|
||||
)}
|
||||
</Show>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue