This React hook creates a change instance used to interact with the LLM. The result object contains functions and state enabling you to send and recieve messages and monitor the state of the chat.
The useCompletion
hook provides functionality for completing unstructured inputs with predicted unstructured outputs. This is useful for things like natural language autocompletions.
function useCompletion<Input>(
options: UseCompletionOptions<Input>): UseCompletionResult;
@param
options
UseCompletionOptions<Input>
@type
Input
@returns
UseCompletionResult
Examples
const { output } = useCompletion({
model: 'gpt-4o-mini',
input: firstName,
system: `Help the user generate a last name for the given first name.`,
});