Skip to content

Commit 3693261

Browse files
committed
chore: Update sidebar links in Vitepress config
1 parent fe93067 commit 3693261

File tree

2 files changed

+140
-4
lines changed

2 files changed

+140
-4
lines changed

docs/.vitepress/config.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ function sidebarGuide(): DefaultTheme.SidebarItem[] {
127127
text: "Adjusting Bots Creation Limit For Users",
128128
},
129129
{
130-
link:"/application/setting-up-dialoqbase-queue-concurrency",
131-
text:"Setting up Dialoqbase Queue Concurrency"
130+
link: "/application/setting-up-dialoqbase-queue-concurrency",
131+
text: "Setting up Dialoqbase Queue Concurrency"
132132
}
133133
],
134134
},
@@ -175,8 +175,8 @@ function sidebarReference(): DefaultTheme.SidebarItem[] {
175175
text: "Reference",
176176
items: [
177177
{
178-
text:"Getting Started",
179-
link:"/getting-started"
178+
text: "Getting Started",
179+
link: "/getting-started"
180180
},
181181
{
182182
text: "Create Bot",
@@ -195,6 +195,15 @@ function sidebarReference(): DefaultTheme.SidebarItem[] {
195195
link: "/chat-with-bot",
196196
}
197197
]
198+
},
199+
{
200+
text: "Examples",
201+
items: [
202+
{
203+
text: "Creating a Tiny AI App Using Dialoqbase API",
204+
link: "/examples/creating-tiny-ai-app-using-dialoqbase-api"
205+
}
206+
]
198207
}
199208
]
200209
}
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
# Creating a Tiny AI App Using Dialoqbase API
2+
3+
Learn how to create a custom AI chatbot application using the Dialoqbase API. This guide covers essential features including user-specific bot management, knowledge base creation, and interactive chat functionality.
4+
5+
## Key Features
6+
7+
1. **User-Specific Bot Management**: Create and manage dedicated chatbots for individual users.
8+
2. **Bot Creation and Knowledge Integration**: Set up new bots and populate them with relevant information.
9+
3. **Interactive Chat Interface**: Engage with the bot using the OpenAI SDK.
10+
11+
## Before You Begin
12+
13+
Ensure you have:
14+
15+
- Node.js (or your preferred programming language)
16+
- Dialoqbase running locally or on a cloud server
17+
- Dialoqbase API key (admin access recommended)
18+
19+
This tutorial uses Node.js with Dialoqbase running locally at `http://localhost:3000`. The example API key is `dq_xxxyyyzzz`.
20+
21+
## Step-by-Step Guide
22+
23+
### 1. Implement User-Specific Bot Management
24+
25+
Create a unique bot for each user, similar to Stripe's customer management system.
26+
27+
```javascript
28+
const response = await fetch('http://localhost:3000/api/v1/admin/register-user', {
29+
method: 'POST',
30+
headers: {
31+
'Content-Type': 'application/json',
32+
'Authorization': 'Bearer dq_xxxyyyzzz'
33+
},
34+
body: JSON.stringify({
35+
email: 'darthvader@galacticempire.com',
36+
name: 'Darth Vader',
37+
password: 'password',
38+
return_id: true
39+
})
40+
});
41+
42+
const userData = await response.json();
43+
const userId = userData.user_id;
44+
const userApiKey = userData.api_key;
45+
```
46+
47+
Note: Set `return_id` to `true` to receive the `user_id` and `api_key`. Store these for future use.
48+
49+
### 2. Create a Bot and Add Knowledge
50+
51+
Now that we have a user, let's create their personalized bot and add information to it.
52+
53+
```javascript
54+
const botResponse = await fetch('http://localhost:3000/api/v1/bot/api', {
55+
method: 'POST',
56+
headers: {
57+
'Content-Type': 'application/json',
58+
'Authorization': `Bearer ${userApiKey}`
59+
},
60+
body: JSON.stringify({
61+
name: 'Darth Vader Bot',
62+
model: "claude-3-opus-20240229",
63+
embedding: "nomic-ai/nomic-embed-text-v1.5"
64+
})
65+
});
66+
67+
const botData = await botResponse.json();
68+
const botId = botData.id;
69+
70+
// Add knowledge to the bot
71+
await fetch(`http://localhost:3000/api/v1/bot/${botId}/source/bulk`, {
72+
method: 'POST',
73+
headers: {
74+
'Content-Type': 'application/json',
75+
'Authorization': `Bearer ${userApiKey}`
76+
},
77+
body: JSON.stringify({
78+
data: [
79+
{
80+
"content": "https://n4ze3m.com",
81+
"type": "website"
82+
}
83+
]
84+
})
85+
});
86+
```
87+
88+
This example uses the `claude-3-opus-20240229` model and `nomic-ai/nomic-embed-text-v1.5` embedding. Choose any model and embedding enabled in your Dialoqbase instance.
89+
90+
### 3. Interact with Your Bot
91+
92+
Install the OpenAI SDK:
93+
94+
```bash
95+
npm install openai
96+
```
97+
98+
Use the following code to chat with your bot:
99+
100+
```javascript
101+
import { OpenAI } from "openai";
102+
103+
const dialoqbase = new OpenAI({
104+
apiKey: userApiKey,
105+
baseURL: "http://localhost:3000/api/v1/openai",
106+
});
107+
108+
const chatResponse = await dialoqbase.chat.completions.create({
109+
model: botId,
110+
messages: [
111+
{ role: "user", content: "Hello" },
112+
],
113+
stream: true,
114+
});
115+
116+
for await (const chunk of chatResponse) {
117+
process.stdout.write(chunk.choices[0]?.delta?.content || '');
118+
}
119+
```
120+
121+
## Conclusion
122+
123+
Congratulations! You've successfully created a personalized AI chatbot application using the Dialoqbase API. This foundation allows you to:
124+
125+
1. Create user-specific bots
126+
2. Add custom knowledge to each bot
127+
3. Engage in interactive conversations

0 commit comments

Comments
 (0)