Skip to content

Commit 4d21331

Browse files
authored
Merge pull request #103 from n4ze3m/next
v1.0.3 - rest api as data source
2 parents 6d77878 + 8019182 commit 4d21331

22 files changed

+283
-47
lines changed

README.md

+2-6
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ Dialoqbase is a side project and is not ready for production. It is still in the
119119
- [x] PDF (beta)
120120
- [x] Web crawler (beta)
121121
- [x] Microsoft Word documents (beta)
122-
- [ ] Sitemap
123122
- [x] Github repository
124123
- [x] mp3
125124
- [x] mp4
@@ -132,7 +131,8 @@ and more...
132131
- [x] OpenAI
133132
- [x] Anthropic
134133
- [x] Google chat-bison-001
135-
- [x] fireworks.ai's llama 2 models api
134+
- [x] fireworks.ai's llama 2 models
135+
- [x] fireworks.ai's mistral
136136

137137
### Embedding models
138138

@@ -152,11 +152,9 @@ need more ? create an issue...
152152
- [x] Generate responses
153153
- [x] Vector search
154154
- [x] Bot embed script for websites
155-
- [ ] Supabase Integration
156155
- [x] Prompt Editor
157156
- [ ] Chatbot API
158157
- [x] Chatbot theme editor
159-
- [ ] Chatbot analytics
160158
- [x] Streaming responses
161159

162160
### Integrations
@@ -166,8 +164,6 @@ need more ? create an issue...
166164
- [x] Discord (beta)
167165
- [ ] Slack
168166
- [X] Whatsapp (experimental)
169-
- [ ] Facebook Messenger
170-
- [ ] Instagram
171167

172168
need more ? create an issue...
173169

app/ui/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "app",
33
"private": true,
4-
"version": "1.0.2",
4+
"version": "1.0.3",
55
"type": "module",
66
"scripts": {
77
"dev": "vite",

app/ui/src/components/Bot/DS/DsTable.tsx

+5-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ import api from "../../../services/api";
1313
import { useParams } from "react-router-dom";
1414
import { NewDsForm } from "./NewDsForm";
1515
import React from "react";
16-
import { GithubIcon } from "../../Common/GithubIcon";
17-
import { YoutubeIcon } from "../../Common/Youtube";
16+
import { GithubIcon } from "../../Icons/GithubIcon";
17+
import { YoutubeIcon } from "../../Icons/YoutubeIcon";
18+
import { ApiIcon } from "../../Icons/ApiIcon";
1819

1920
export const DsTable = ({
2021
data,
@@ -57,6 +58,8 @@ export const DsTable = ({
5758
return <PlayCircleIcon className="h-10 w-10 text-gray-400" />;
5859
case "youtube":
5960
return <YoutubeIcon className="h-10 w-10 text-gray-400" />;
61+
case "rest":
62+
return <ApiIcon className="h-10 w-10 text-gray-400" />;
6063
default:
6164
return <DocumentTextIcon className="h-10 w-10 text-gray-400" />;
6265
}

app/ui/src/components/Common/BotForm.tsx

+100-6
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ import {
1919
import React from "react";
2020
import { availableEmbeddingTypes } from "../../utils/embeddings";
2121
import { availableChatModels } from "../../utils/chatModels";
22-
import { SpiderIcon } from "./SpiderIcon";
23-
import { GithubIcon } from "./GithubIcon";
24-
import { YoutubeIcon } from "./Youtube";
22+
import { SpiderIcon } from "../Icons/SpiderIcon";
23+
import { GithubIcon } from "../Icons/GithubIcon";
24+
import { YoutubeIcon } from "../Icons/YoutubeIcon";
25+
import { ApiIcon } from "../Icons/ApiIcon";
2526

2627
type Props = {
2728
createBot: (values: any) => void;
@@ -42,6 +43,8 @@ export const BotForm = ({
4243
form,
4344
showEmbeddingAndModels,
4445
}: Props) => {
46+
const embeddingType = Form.useWatch("embedding", form);
47+
4548
const [availableSources] = React.useState([
4649
{
4750
id: 1,
@@ -365,14 +368,70 @@ export const BotForm = ({
365368
</>
366369
),
367370
},
371+
{
372+
id: 8,
373+
value: "rest",
374+
title: "REST API",
375+
icon: ApiIcon,
376+
formComponent: (
377+
<>
378+
<Row gutter={24}>
379+
<Col span={6}>
380+
<Form.Item
381+
name={["options", "method"]}
382+
rules={[
383+
{
384+
required: true,
385+
message: "Please select a method",
386+
},
387+
]}
388+
>
389+
<Select
390+
size="large"
391+
options={[
392+
{
393+
label: "GET",
394+
value: "get",
395+
},
396+
{
397+
label: "POST",
398+
value: "post",
399+
},
400+
]}
401+
/>
402+
</Form.Item>
403+
</Col>
404+
<Col span={18}>
405+
<Form.Item
406+
name="content"
407+
rules={[
408+
{
409+
required: true,
410+
message: "Please enter a valid REST API URL",
411+
},
412+
{
413+
pattern: new RegExp(/^(https?:\/\/)?(www\.)?(.+)\.(.+)$/),
414+
message: "Please enter a valid REST API URL",
415+
},
416+
]}
417+
>
418+
<input
419+
type="url"
420+
placeholder="Enter the REST API URL"
421+
className=" block w-full shadow-sm sm:text-sm focus:ring-indigo-500 focus:border-indigo-500 border-gray-300 rounded-md"
422+
/>
423+
</Form.Item>
424+
</Col>
425+
</Row>
426+
</>
427+
),
428+
},
368429
]);
369430

370431
const [selectedSource, _setSelectedSource] = React.useState<any>(
371432
showEmbeddingAndModels ? null : availableSources[0]
372433
);
373434

374-
const embeddingType = Form.useWatch("embedding", form);
375-
376435
return (
377436
<Form
378437
layout="vertical"
@@ -387,6 +446,9 @@ export const BotForm = ({
387446
options: {
388447
branch: "main",
389448
is_private: false,
449+
method: "get",
450+
headers: "{}",
451+
body: "{}",
390452
},
391453
}}
392454
>
@@ -446,6 +508,39 @@ export const BotForm = ({
446508

447509
{selectedSource && selectedSource.formComponent}
448510

511+
{selectedSource && selectedSource.value === "rest" && (
512+
<Row gutter={24}>
513+
<Col span={12}>
514+
<Form.Item
515+
name={["options", "headers"]}
516+
label="Headers"
517+
>
518+
<textarea
519+
placeholder="Enter the headers"
520+
className=" block w-full shadow-sm sm:text-sm focus:ring-indigo-500 focus:border-indigo-500 border-gray-300 rounded-md"
521+
/>
522+
</Form.Item>
523+
</Col>
524+
<Col span={12}>
525+
<Form.Item
526+
name={["options", "body"]}
527+
label="Body (JSON)"
528+
rules={[
529+
{
530+
required: true,
531+
message: "Please enter a valid JSON",
532+
},
533+
]}
534+
>
535+
<textarea
536+
placeholder="Enter the body"
537+
className=" block w-full shadow-sm sm:text-sm focus:ring-indigo-500 focus:border-indigo-500 border-gray-300 rounded-md"
538+
/>
539+
</Form.Item>
540+
</Col>
541+
</Row>
542+
)}
543+
449544
<Form.Item hidden={!showEmbeddingAndModels} noStyle>
450545
<Divider />
451546
</Form.Item>
@@ -462,7 +557,6 @@ export const BotForm = ({
462557
options={availableChatModels}
463558
/>
464559
</Form.Item>
465-
466560
<Form.Item
467561
hidden={!showEmbeddingAndModels}
468562
label={
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import React from "react";
2+
3+
export const ApiIcon = React.forwardRef<
4+
SVGSVGElement,
5+
React.SVGProps<SVGSVGElement>
6+
>((props, ref) => {
7+
return (
8+
<svg
9+
xmlns="http://www.w3.org/2000/svg"
10+
version="1.1"
11+
viewBox="0 0 511 511"
12+
xmlSpace="preserve"
13+
ref={ref}
14+
{...props}
15+
>
16+
<path d="M492.168 309.579l-17.626-10.177c2.96-14.723 4.458-29.466 4.458-43.902 0-14.646-1.474-29.403-4.384-43.946l17.552-10.134c5.436-3.138 9.325-8.206 10.949-14.269s.791-12.396-2.348-17.832l-48-83.139A23.345 23.345 0 00438.5 75.231a23.349 23.349 0 00-17.833 2.348l-17.566 10.142C380.912 68.2 354.798 53.092 327 43.692V23.5C327 10.542 316.458 0 303.5 0h-96C194.542 0 184 10.542 184 23.5v20.193c-27.65 9.362-53.728 24.49-75.999 44.088L90.332 77.579a23.345 23.345 0 00-17.833-2.348A23.349 23.349 0 0058.23 86.18l-48 83.139c-3.139 5.436-3.972 11.769-2.348 17.832s5.513 11.131 10.949 14.269l17.626 10.177C33.499 226.32 32 241.063 32 255.5c0 14.644 1.474 29.401 4.384 43.945l-17.552 10.134c-11.222 6.479-15.08 20.879-8.602 32.102l48 83.139c6.479 11.221 20.879 15.08 32.102 8.601l17.565-10.142c22.19 19.521 48.303 34.629 76.103 44.03V487.5c0 12.958 10.542 23.5 23.5 23.5h96c12.958 0 23.5-10.542 23.5-23.5v-20.193c27.651-9.362 53.729-24.49 76-44.087l17.668 10.201c11.221 6.479 25.623 2.62 32.102-8.601l48-83.139c6.478-11.223 2.62-25.623-8.602-32.102zm-4.389 24.602l-48 83.138c-2.343 4.06-7.552 5.455-11.611 3.111l-22.392-12.928a7.5 7.5 0 00-8.842.989c-22.893 21.173-50.437 37.148-79.653 46.199a7.5 7.5 0 00-5.281 7.164V487.5c0 4.687-3.813 8.5-8.5 8.5h-96c-4.687 0-8.5-3.813-8.5-8.5v-25.645a7.501 7.501 0 00-5.28-7.164c-29.396-9.107-56.974-25.062-79.755-46.139a7.494 7.494 0 00-8.843-.99l-22.29 12.868c-4.06 2.343-9.268.948-11.611-3.111l-48-83.138c-2.343-4.059-.947-9.268 3.111-11.612l22.272-12.859a7.499 7.499 0 003.566-8.146C48.739 286.357 47 270.858 47 255.5c0-15.1 1.765-30.584 5.247-46.022a7.5 7.5 0 00-3.566-8.145L26.332 188.43a8.445 8.445 0 01-3.96-5.161 8.448 8.448 0 01.849-6.45l48-83.139a8.44 8.44 0 015.162-3.96 8.444 8.444 0 016.45.849l22.392 12.928a7.498 7.498 0 008.842-.989c22.894-21.173 50.437-37.148 79.653-46.199a7.5 7.5 0 005.281-7.164V23.5c0-4.687 3.813-8.5 8.5-8.5h96c4.687 0 8.5 3.813 8.5 8.5v25.645a7.501 7.501 0 005.28 7.164c29.395 9.106 56.973 25.061 79.755 46.139a7.5 7.5 0 008.843.99l22.29-12.869a8.445 8.445 0 016.45-.849 8.45 8.45 0 015.162 3.96l48 83.139a8.444 8.444 0 01.849 6.45 8.445 8.445 0 01-3.96 5.161l-22.272 12.859a7.5 7.5 0 00-3.566 8.146c3.431 15.206 5.17 30.704 5.17 46.065 0 15.1-1.765 30.584-5.247 46.021a7.501 7.501 0 003.566 8.145l22.349 12.903c4.057 2.344 5.453 7.553 3.109 11.612z"></path>
17+
<path d="M255.5 104C171.962 104 104 171.963 104 255.5S171.962 407 255.5 407 407 339.037 407 255.5 339.038 104 255.5 104zm0 288C180.234 392 119 330.766 119 255.5S180.234 119 255.5 119 392 180.234 392 255.5 330.766 392 255.5 392z"></path>
18+
<path d="M283.5 216h-28a7.5 7.5 0 00-7.5 7.5v64a7.5 7.5 0 0015 0V271h20.5c15.164 0 27.5-12.336 27.5-27.5S298.664 216 283.5 216zm0 40H263v-25h20.5c6.893 0 12.5 5.607 12.5 12.5s-5.607 12.5-12.5 12.5zM214.522 220.867A7.5 7.5 0 00207.5 216h-8a7.498 7.498 0 00-7.022 4.867l-24 64a7.5 7.5 0 0014.045 5.267L186.697 279h33.605l4.175 11.133a7.503 7.503 0 007.023 4.869 7.5 7.5 0 007.021-10.135l-23.999-64zM192.322 264l11.178-29.807L214.678 264h-22.356zM327.5 216a7.5 7.5 0 00-7.5 7.5v64a7.5 7.5 0 0015 0v-64a7.5 7.5 0 00-7.5-7.5zM309.152 87.3a175.962 175.962 0 0115.421 5.726 7.473 7.473 0 002.934.601 7.5 7.5 0 002.941-14.402 191.008 191.008 0 00-16.742-6.216 7.5 7.5 0 00-4.554 14.291zM100.45 339.904a7.5 7.5 0 00-13.168 7.184 192.173 192.173 0 0010.239 16.677 7.492 7.492 0 006.189 3.255 7.5 7.5 0 006.176-11.746 177.217 177.217 0 01-9.436-15.37zM240.14 431.341c-40.189-3.463-78.337-20.879-107.416-49.041a7.5 7.5 0 10-10.435 10.775c31.55 30.555 72.947 49.452 116.563 53.21a7.501 7.501 0 008.116-6.828 7.501 7.501 0 00-6.828-8.116zM363.425 97.287a7.5 7.5 0 00-8.464 12.384c34.844 23.813 60.049 59.248 70.972 99.776a7.503 7.503 0 007.237 5.55 7.5 7.5 0 007.246-9.453c-11.852-43.98-39.195-82.426-76.991-108.257z"></path>
19+
</svg>
20+
);
21+
});

app/ui/src/utils/embeddings.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
export const availableEmbeddingTypes = [
22
{ value: "openai", label: "OpenAI" },
3-
{ value: "tensorflow", label: "Tensorflow" },
3+
{ value: "tensorflow", label: "Tensorflow (cpu)" },
44
{ value: "cohere", label: "Cohere" },
55
{ value: "huggingface-api", label: "HuggingFace (Inference)" },
66
{
77
value: "transformer",
8-
label: "all-MiniLM-L6-v2 (xenova/transformers)",
8+
label: "Xenova/all-MiniLM-L6-v2 (cpu)",
9+
},
10+
{
11+
value: "supabase",
12+
label: "Supabase/gte-small (cpu)",
913
},
1014
{
1115
value: "google-gecko",

app/ui/src/utils/sources.tsx

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { GithubIcon } from "../components/Common/GithubIcon";
2-
import { SpiderIcon } from "../components/Common/SpiderIcon";
3-
import { YoutubeIcon } from "../components/Common/Youtube";
1+
import { ApiIcon } from "../components/Icons/ApiIcon";
2+
import { GithubIcon } from "../components/Icons/GithubIcon";
3+
import { SpiderIcon } from "../components/Icons/SpiderIcon";
4+
import { YoutubeIcon } from "../components/Icons/YoutubeIcon";
45

56
export const sources = {
67
website: (
@@ -148,4 +149,5 @@ export const sources = {
148149
<rect width="8" height="6" x="2" y="12" rx="1"></rect>
149150
</svg>
150151
),
152+
rest: <ApiIcon className="h-4 w-4" />,
151153
};

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dialoqbase",
3-
"version": "1.0.2",
3+
"version": "1.0.3",
44
"description": "Create chatbots with ease",
55
"scripts": {
66
"ui:dev": "pnpm run --filter ui dev",

server/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"@tensorflow/tfjs-converter": "^4.7.0",
4141
"@tensorflow/tfjs-core": "^4.7.0",
4242
"@waylaidwanderer/fastify-sse-v2": "^3.1.0",
43-
"@xenova/transformers": "^2.3.0",
43+
"@xenova/transformers": "^2.6.2",
4444
"axios": "^1.4.0",
4545
"bcryptjs": "^2.4.3",
4646
"bull": "^4.10.4",
@@ -59,7 +59,7 @@
5959
"grammy": "^1.16.2",
6060
"ignore": "^5.2.4",
6161
"ioredis": "^5.3.2",
62-
"langchain": "^0.0.151",
62+
"langchain": "^0.0.160",
6363
"mammoth": "^1.6.0",
6464
"pdf-parse": "^1.1.1",
6565
"pdfjs-dist": "^3.7.107",

server/src/integration/discord.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,27 @@ export default class DiscordBot {
1818
static async connect(
1919
identifier: string,
2020
token: string,
21-
slashCommands: string = "/hey",
21+
command: string = "hey",
2222
slashCommandsDescription: string = "Say hey to the bot",
2323
) {
2424
try {
2525
if (this._clients.has(identifier)) {
2626
await this.disconnect(identifier);
2727
}
28-
2928
const bot = new Client({ intents: [GatewayIntentBits.Guilds] });
3029

3130
this._clients.set(identifier, bot);
3231

32+
let slashCommands = command.replace(/[^a-zA-Z0-9]/g, "");
33+
3334
bot.on("ready", async () => {
3435
console.log(`Logged in as ${bot.user?.tag}!`);
3536
const clientId = bot.user?.id;
3637
if (clientId) {
3738
await this.setCommand(
3839
token,
3940
clientId,
40-
slashCommands,
41+
slashCommands.replace(/[^a-zA-Z0-9]/g, ""),
4142
slashCommandsDescription,
4243
);
4344
}
@@ -131,7 +132,7 @@ ${bot_response}
131132
static async setCommand(
132133
token: string,
133134
clientId: string,
134-
slashCommands: string = "/hey",
135+
slashCommands: string = "hey",
135136
slashCommandsDescription: string = "Say hey to the bot",
136137
) {
137138
try {

0 commit comments

Comments
 (0)