import React, { useState } from 'react'; import { useCopilotAction } from '@copilotkit/react-core'; import { blogWriterApi, BlogResearchRequest, BlogResearchResponse } from '../../services/blogWriterApi'; import ResearchPollingHandler from './ResearchPollingHandler'; import { researchCache } from '../../services/researchCache'; const useCopilotActionTyped = useCopilotAction as any; interface KeywordInputFormProps { onKeywordsReceived?: (data: { keywords: string; blogLength: string }) => void; onResearchComplete?: (researchData: BlogResearchResponse) => void; onTaskStart?: (taskId: string) => void; } // Separate component to manage form state const ResearchForm: React.FC<{ prompt?: string; onSubmit: (data: { keywords: string; blogLength: string }) => void; onCancel: () => void; }> = ({ prompt, onSubmit, onCancel }) => { const [keywords, setKeywords] = useState(''); const [blogLength, setBlogLength] = useState('1000'); const hasValidInput = keywords.trim().length > 0; const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); if (hasValidInput) { onSubmit({ keywords: keywords.trim(), blogLength }); } else { window.alert('Please enter keywords or a topic to start research.'); } }; return (
); }; export const KeywordInputForm: React.FC✅ Research keywords received! Starting research...
• Connecting to Google Search grounding...
• Analyzing keywords and search intent...
• Gathering relevant sources and statistics...
• Generating content angles and search queries...