mirror of
https://github.com/DayuanJiang/next-ai-draw-io.git
synced 2026-01-02 22:32:27 +08:00
fix: implement client-side caching for example diagrams (#150)
- Add client-side cache check in onFormSubmit to bypass API calls for example prompts - Use findCachedResponse to match input against cached examples - Directly set messages with cached tool response when example matches - Hide regenerate button for cached example responses (toolCallId starts with 'cached-') - Prevents unnecessary API calls when using example buttons Co-authored-by: dayuan.jiang <jiangdy@amazon.co.jp>
This commit is contained in:
@@ -676,9 +676,14 @@ export function ChatMessageDisplay({
|
||||
<Copy className="h-3.5 w-3.5" />
|
||||
)}
|
||||
</button>
|
||||
{/* Regenerate button - only on last assistant message */}
|
||||
{/* Regenerate button - only on last assistant message, not for cached examples */}
|
||||
{onRegenerate &&
|
||||
isLastAssistantMessage && (
|
||||
isLastAssistantMessage &&
|
||||
!message.parts?.some((p: any) =>
|
||||
p.toolCallId?.startsWith(
|
||||
"cached-",
|
||||
),
|
||||
) && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() =>
|
||||
|
||||
Reference in New Issue
Block a user