Skip to content

Commit 591667e

Browse files
committed
fix: handle errors
1 parent f843f41 commit 591667e

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

src/components/Chat/CopilotInterface.tsx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,23 @@ export function CopilotInterface({
9999
actionText = "Collaborate",
100100
sidebarInitiallyClosed = false,
101101
}: CopilotInterfaceProps) {
102+
103+
const mergedConfig = {
104+
...aiConfig,
105+
onError: (error: any) => {
106+
// console.error("Error in CopilotInterface:", error);
107+
chatHook?.sendMessage({
108+
text: error.message,
109+
})
110+
console.log(error.code, error.message);
111+
},
112+
// Add any default AI configuration here
113+
// e.g., apiKey: process.env.AI_API_KEY,
114+
}
115+
116+
102117
// AI Chat Integration - use internal useChat by default, allow override
103-
const internalChat = useChat(aiConfig || {})
118+
const internalChat = useChat(mergedConfig || {})
104119
const chatHook = enableAI ? (useCustomChat || internalChat) : null
105120

106121
const [localInput, setLocalInput] = useState("")

0 commit comments

Comments
 (0)