our friendly logo that looks like a hashbrown character from an animated tv showhashbrown

@hashbrownai/reactuseStructuredChat

This React hook creates a chat instance used to interact with the LLM. The result object contains functions and state enabling you to send and receive messages and monitor the state of the chat.

The useStructuredChat hook provides functionality for structured chats. Structured chats are used when you want to use the LLM to generate structured data according to a defined schema. This is particularly useful for: - Generating typed data structures - Creating form responses - Building UI components - Extracting information into a specific format

function useStructuredChat<Schema extends s.HashbrownType, Tools extends Chat.AnyTool, Output extends s.Infer<Schema> = s.Infer<Schema>>(options: UseStructuredChatOptions<Schema, Tools, Output>): UseStructuredChatResult<Output, Tools>;
@paramoptions
UseStructuredChatOptions<Schema, Tools, Output>
@typeSchema
s.HashbrownType
@typeTools
Chat.AnyTool
@typeOutput
s.Infer<Schema>
@returns
{UseStructuredChatResult} An object containing chat state and functions to interact with the chat.
UseStructuredChatResult<Output, Tools>

Examples

In this example, the LLM will respond with a JSON object containing the translations of the input message into English, Spanish, and French.

const { messages, sendMessage } = useStructuredChat({
  model: 'gpt-4o',
  system: 'You are a helpful translator that provides accurate translations.',
  schema: s.object('Translations', {
    english: s.string('English translation'),
    spanish: s.string('Spanish translation'),
    french: s.string('French translation')
  }),
});

LiveLoveApp provides secure, compliant, and reliable long-term support to enterprises. We are a group of engineers who are passionate about open source.

Enterprise Support

AI Engineering Sprint

Get your team up-to-speed on AI engineering with a one week AI engineering sprint. Includes a workshop on AI engineering with hashbrown and a few days with the hashbrown developer team to bring your AI ideas to life.

Long Term Support

Keep your hashbrown deployments running at peak performance with our Long Term Support. Includes an ongoing support retainer for direct access to the hashbrown developer team, SLA-backed issue resolution, and guided upgrades.

Consulting

LiveLoveApp provides hands-on engagement with our AI engineers for architecture reviews, custom integrations, proof-of-concept builds, performance tuning, and expert guidance on best practices.