Spaces:
Running
Running
Refactor TextGeneration.tsx to handle input state locally
Browse files4 unmodified lines567891011121314151623 unmodified lines404142434445464 unmodified linesexport default function TextGeneration() {const [model, setModel] = useState('alias-code');const { messages, handleInputChange, handleSubmit } = useChat({api: '/api/text-generation',body: {model,},});return (<div className="flex flex-col w-full max-w-md py-24 mx-auto stretch">23 unmodified lines<form onSubmit={handleSubmit} className="flex-shrink-0"><inputclassName="w-full max-w-md p-2 border border-gray-300 rounded shadow-xl"value={input}placeholder="Say something..."onChange={handleInputChange}/>4 unmodified lines567891011121314151617181920212223 unmodified lines464748495051524 unmodified linesexport default function TextGeneration() {const [model, setModel] = useState('alias-code');const [inputValue, setInputValue] = useState('');const { messages, handleSubmit } = useChat({api: '/api/text-generation',body: {model,},initialInput: inputValue,});const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {setInputValue(e.target.value);};return (<div className="flex flex-col w-full max-w-md py-24 mx-auto stretch">23 unmodified lines<form onSubmit={handleSubmit} className="flex-shrink-0"><inputclassName="w-full max-w-md p-2 border border-gray-300 rounded shadow-xl"value={inputValue}placeholder="Say something..."onChange={handleInputChange}/>
components/app/TextGeneration.tsx+8-2