hashbrown

useCompletion

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.

API

export declare function useCompletion<Input>(
  options:  UseCompletionOptions <Input>,
):  UseCompletionResult; 
useCompletion
UseCompletionResult
@paramoptions:
UseCompletionOptions<Input>
@typeInput
@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.`,
});