/** * ============================================================================= * CODE GENERATION EXAMPLE - Codestral Integration * ============================================================================= * * Demonstrates code generation using Mistral's Codestral model. * * INTERVIEW NOTES: * - Codestral is optimized for code generation * - Supports multiple programming languages * - Lower temperature (0.2) for more deterministic output * - Great for autocomplete, refactoring, documentation */ import { useState } from 'react'; import { useMistralCode } from '@/hooks'; const EXAMPLE_PROMPTS = [ 'Create a React custom hook for debouncing', 'Write a TypeScript function to deep clone an object', 'Create a Python class for a binary search tree', 'Write a SQL query to find duplicate records', 'Create a Go function for rate limiting', ]; const LANGUAGES = [ { value: 'typescript', label: 'TypeScript' }, { value: 'javascript', label: 'JavaScript' }, { value: 'python', label: 'Python' }, { value: 'go', label: 'Go' }, { value: 'rust', label: 'Rust' }, { value: 'sql', label: 'SQL' }, ]; export default function CodeExample() { const [prompt, setPrompt] = useState(EXAMPLE_PROMPTS[0]); const [language, setLanguage] = useState('typescript'); const { code, loading, error, generate, reset } = useMistralCode(); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); if (!prompt.trim()) return; await generate(prompt, language); }; const handleExampleClick = (example: string) => { setPrompt(example); reset(); }; return (

Code Generation (Codestral)

Generate code in multiple languages using Mistral's specialized coding model.

{/* Example prompts */}

Try an example:

{EXAMPLE_PROMPTS.slice(0, 3).map((example) => ( ))}