mirror of
https://github.com/temporal-community/temporal-ai-agent.git
synced 2026-03-15 22:18:09 +01:00
basic react API
This commit is contained in:
34
frontend/src/components/LLMResponse.jsx
Normal file
34
frontend/src/components/LLMResponse.jsx
Normal file
@@ -0,0 +1,34 @@
|
||||
import React, { useState } from "react";
|
||||
import MessageBubble from "./MessageBubble";
|
||||
import ConfirmInline from "./ConfirmInline";
|
||||
|
||||
export default function LLMResponse({ data, onConfirm }) {
|
||||
const [isConfirmed, setIsConfirmed] = useState(false);
|
||||
|
||||
const handleConfirm = async () => {
|
||||
if (onConfirm) {
|
||||
await onConfirm();
|
||||
}
|
||||
setIsConfirmed(true); // Update state after confirmation
|
||||
};
|
||||
|
||||
const requiresConfirm = data.next === "confirm";
|
||||
|
||||
let displayText = (data.response || "").trim();
|
||||
if (!displayText && requiresConfirm) {
|
||||
displayText = `Agent is ready to run "${data.tool}". Please confirm.`;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="space-y-2">
|
||||
<MessageBubble message={{ response: displayText }} />
|
||||
{requiresConfirm && (
|
||||
<ConfirmInline
|
||||
data={data}
|
||||
confirmed={isConfirmed}
|
||||
onConfirm={handleConfirm}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user