useCompletion
useCompletion(
options):UseCompletionReturn
Defined in: use-completion.ts:43
useCompletion - React hook for text completion.
Provides state management and streaming for single-turn text completion tasks.
Parameters
Section titled “Parameters”options
Section titled “options”UseCompletionOptions = {}
Returns
Section titled “Returns”Example
Section titled “Example”import { useCompletion } from 'ai.matey.react.core';
function CompletionComponent() { const { completion, input, handleInputChange, handleSubmit, isLoading } = useCompletion({ api: '/api/completion', });
return ( <div> <p>{completion}</p> <form onSubmit={handleSubmit}> <input value={input} onChange={handleInputChange} placeholder="Enter a prompt..." /> <button type="submit" disabled={isLoading}>Complete</button> </form> </div> );}