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

@hashbrownai/reactuseChat

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 recieve messages and monitor the state of the chat.

The useChat hook provides the most basic functionality for un-structured chats. Unstructured chats include things like general chats and natural language controls.

function useChat<Tools extends Chat.AnyTool>(
options: UseChatOptions<Tools>): UseChatResult<Tools>;
@paramoptions
UseChatOptions<Tools>
@typeTools
Chat.AnyTool
@returns
{UseChatResult} An object containing chat state and functions to interact with the chat.
UseChatResult<Tools>

Examples

This example demonstrates how to use the useChat hook to create a simple chat component.

const MyChatComponent = () => {
  const { messages, sendMessage, status } = useChat({
    model: 'gpt-4o',
    system: 'You are a helpful assistant.',
    tools: [],
  });

  const handleSendMessage = () => {
    sendMessage({ role: 'user', content: 'Hello, how are you?' });
  };

  return (
    <div>
      <button onClick={handleSendMessage}>Send Message</button>
      <div>Status: {status}</div>
      <ul>
        {messages.map((msg, index) => (
          <li key={index}>{msg.content}</li>
        ))}
      </ul>
    </div>
  );
};

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.