Widget component interacting with LangDB APIs. Visit docs to get started.

npm install @langdb/widgetor
pnpm install @langdb/widgetor
yarn add @langdb/widget- Make sure you have a LangDB account and an application created. If you don't have an account, you can create one here.
- Create new application and get either the
publicIdorappIdfrom the application settings. - Ensure you have a chatbot agent created in your application. If you don't have one, you can create one by executing the following SQL code in the LangDB console.
CHAT cities_info_model- Replace the
publicIdandmodelNamewith your applicationpublicIdandmodelNamerespectively.
import { Widget } from "@langdb/widget";
import '@langdb/widget/style.css';
const LANGDB_CLOUD_SERVER = 'https://api.dev.langdb.ai';
const user_picture_url = 'https://avatars.githubusercontent.com/u/1016591?v=4';
const agent_logo = 'https://app.dev.langdb.ai/static/media/logo.0d259c55b001b212cc0a.png';
const model_name = 'cities_info_model'; // replace with your model name
const publicId = '83186f34-84d7-4633-8da1-db3e579edeea'; // replace with your public app id
const App = () => {
return <div className="flex flex-1 h-full">
<Widget
publicId={publicId}
personaOptions={{
assistant: {
name: "LangDB",
tagline: "Build and Publish AI Agents using SQL",
avatar: agent_logo,
},
user: {
avatar: user_picture_url,
name: 'Alice',
}
}}
modelName={model_name}
advancedOptions={{
displayOptions: {
themeId: 'langdb',
colorScheme: 'light',
},
conversationOptions: {
conversationStarters: [
{
prompt: 'What is the most Populous City'
},
{
prompt: 'Tell me interesting facts about Tokyo.'
},
{
prompt: 'Give me some interesting cities to visit.'
}
]
}
}}
serverUrl={LANGDB_CLOUD_SERVER}
/>
</div>
};
export default App;