logoassistant-ui

Trieve Cloud

Overview

Integration with Trieve Cloud. You will need to get a Trieve Cloud account and set up a dataset to use this runtime at https://dashboard.trieve.ai.

This runtime will allow you to use Trieve Cloud to manage your assistant's responses, along with the ability to use Trieve's advanced features like tagging, filtering, analytics, and more.

Getting Started

Create a Next.JS project

npx create-next-app@latest my-app
cd my-app

Install trieve-ts-sdk, @assistant-ui/react-trieve and @assistant-ui/react

npm install @assistant-ui/react @assistant-ui/react-trieve trieve-ts-sdk

Set up environment variables

.env
NEXT_PUBLIC_TRIEVE_API_URL=https://api.trieve.ai
NEXT_PUBLIC_TRIEVE_API_KEY="tr-*********************"
NEXT_PUBLIC_TRIEVE_DATASET_ID="********-****-****-****-************"

Setup Trieve SDK

@/app/trieve.tsx
"use client";
 
import {  } from "trieve-ts-sdk";
 
export const  = new ({
  : .["NEXT_PUBLIC_TRIEVE_API_URL"]!,
  : .["NEXT_PUBLIC_TRIEVE_API_KEY"]!,
  : .["NEXT_PUBLIC_TRIEVE_DATASET_ID"]!,
});

Define a MyRuntimeProvider component

@/app/MyRuntimeProvider.tsx
"use client";
 
import {  } from "@assistant-ui/react";
import {  } from "@assistant-ui/react-trieve";
import {  } from "@/app/trieve";
 
export const  = () => {
 const  = ({
    ,
    // Define what you want to key the owners for threads on
    : "abcd",
    // Define tags that you want to use for filtering
    : [
      {
        : "Stories",
        : "story",
      }
    ],
  });
 
  return (
    < ={}>
       {children}
    </>
  );
};

Wrap your app in MyRuntimeProvider

@/app/layout.tsx
import type {  } from "react";
import {  } from "@/app/MyRuntimeProvider";
 
export default function ({
  ,
}: <{
  : ;
}>) {
  return (
    <>
      < ="en">
        <>{}</>
      </>
    </>
  );
}

Example Usage

@/app/layout.tsx
import {  } from "@assistant-ui/react";
import {
  ,
  ,
  ,
  ,
} from "@assistant-ui/react-trieve";
 
const  = ();
 
export default function () {
  const {  } = ();
 
  return (
    < ="flex h-full flex-col overflow-hidden pt-8">
      < ="text-center text-xl font-bold">{}</>
      < ="flex-grow overflow-hidden">
        <
          ={{
            : ,
            : ,
          }}
          ={{ : { :  } }}
        />
      </>
    </>
  );
}

On this page

Edit on Github