import React, { useState, useCallback } from 'react'; import { generateProResponse } from '../services/geminiService'; import { Spinner } from '../components/Spinner'; import { MarkdownRenderer } from '../components/MarkdownRenderer'; const BlockchainAIModule: React.FC = () => { const [blockchain, setBlockchain] = useState<'XRPL' | 'Solana'>('XRPL'); const [query, setQuery] = useState(''); const [isLoading, setIsLoading] = useState(false); const [error, setError] = useState(null); const [insight, setInsight] = useState(null); const handleQuery = useCallback(async () => { if (!query.trim()) { setError('Please enter a query.'); return; } setIsLoading(true); setError(null); setInsight(null); const prompt = `As an AI specialist within the Sentient Constellation Codex focusing on decentralized technologies, provide a detailed analysis on the following query related to the ${blockchain} blockchain: "${query}". Discuss the technical implications, potential use cases, and the broader ecosystem context. Your response should be accurate, insightful, and well-structured.`; try { const result = await generateProResponse(prompt); setInsight(result.text); } catch (e: any) { setError(e.message || 'An unknown error occurred while generating insights.'); } finally { setIsLoading(false); } }, [query, blockchain]); return (

Blockchain AI Insights

Explore the synergies between Artificial Intelligence and leading blockchain platforms.

setQuery(e.target.value)} placeholder="e.g., How can AI enhance DeFi on this platform?" className="flex-grow bg-gray-700 border border-gray-600 rounded-md p-3 focus:outline-none focus:ring-2 focus:ring-cyan-500 text-white" disabled={isLoading} onKeyPress={(e) => e.key === 'Enter' && !isLoading && handleQuery()} />
{isLoading && } {error &&

{error}

} {insight && } {!isLoading && !insight && !error &&

Blockchain insights will materialize here.

}
); }; export default BlockchainAIModule;