Skip to content

Commit 9def27a

Browse files
authored
Merge pull request #298 from n4ze3m/next
v1.11.1
2 parents 1274ad6 + c24f6b7 commit 9def27a

File tree

14 files changed

+188
-107
lines changed

14 files changed

+188
-107
lines changed

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.11.0",
4+
"version": "1.11.1",
55
"type": "module",
66
"scripts": {
77
"dev": "vite",

app/ui/src/App.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ const router = createHashRouter([
5454
{
5555
path: "/bot/:id",
5656
element: (
57-
<BotLayout>
57+
<BotLayout asideSpace="">
5858
<BotPreviewRoot />
5959
</BotLayout>
6060
),
@@ -70,7 +70,7 @@ const router = createHashRouter([
7070
{
7171
path: "/bot/:id/playground/:history_id",
7272
element: (
73-
<BotLayout>
73+
<BotLayout asideSpace="">
7474
<BotPreviewRoot />
7575
</BotLayout>
7676
),

app/ui/src/Layout/BotLayout.tsx

+45-45
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,11 @@ function classNames(...classes) {
6262

6363
export default function BotLayout({
6464
children,
65+
asideSpace = "md:ml-16",
6566
}: {
6667
children: React.ReactNode;
6768
noPadding?: boolean;
69+
asideSpace?: string;
6870
}) {
6971
const [sidebarOpen, setSidebarOpen] = useState(false);
7072
const params = useParams<{ id: string }>();
@@ -190,7 +192,7 @@ export default function BotLayout({
190192
</Transition.Root>
191193

192194
<div className="flex flex-col">
193-
<div className="sticky top-0 z-[999] flex h-14 bg-white border-b border-gray-200 dark:bg-[#171717] dark:border-gray-600">
195+
<header className="sticky top-0 z-[999] flex h-14 bg-white border-b border-gray-200 dark:bg-[#171717] dark:border-gray-600">
194196
<button
195197
type="button"
196198
className="border-r border-gray-200 px-4 text-gray-500 focus:outline-none focus:ring-2 focus:ring-inset focus:ring-indigo-500 md:hidden dark:border-gray-600 dark:text-gray-200"
@@ -210,55 +212,53 @@ export default function BotLayout({
210212
{`v${__APP_VERSION__}`}
211213
</span>
212214
</Link>
213-
214215
<div className="flex flex-1 justify-end px-4">
215216
<div className="ml-4 flex items-center md:ml-6">
216217
<ApplicationMenu />
217218
</div>
218219
</div>
219-
</div>
220-
<main className="flex-1">
221-
{children}
222-
{/* <div className="py-4">
223-
<div className="h-96 rounded-lg border-4 border-dashed border-gray-200" />
224-
</div> */}
225-
</main>
226-
</div>
227-
228-
<div className="hidden md:fixed md:inset-y-0 md:flex md:flex-col ">
229-
<div className="flex flex-grow flex-col overflow-y-auto border-r border-gray-200 bg-white pt-5 dark:bg-[#171717] dark:border-gray-600">
230-
<div className="mt-14 flex flex-grow flex-col">
231-
<nav className="flex-1 space-y-1 px-2 pb-4">
232-
{navigation.map((item) => (
233-
<Tooltip placement="right" key={item.name} title={item.name}>
234-
<Link
235-
to={{
236-
pathname: item.href.replace(":id", params.id!),
237-
}}
238-
className={classNames(
239-
location.pathname ===
240-
item.href.replace(":id", params.id!)
241-
? "bg-gray-100 text-gray-900 dark:bg-[#262626] dark:text-white"
242-
: "text-gray-600 hover:bg-gray-50 hover:text-gray-900 dark:text-gray-200 dark:hover:text-white dark:hover:bg-[#262626]",
243-
"group flex items-center px-2 py-2 text-sm font-medium rounded-md"
244-
)}
245-
>
246-
<item.icon
247-
className={classNames(
248-
location.pathname ===
249-
item.href.replace(":id", params.id!)
250-
? "text-gray-500 dark:text-white"
251-
: "text-gray-400 group-hover:text-gray-500 dark:text-gray-400 dark:group-hover:text-white",
252-
"flex-shrink-0 h-6 w-6"
253-
)}
254-
aria-hidden="true"
255-
/>
256-
{/* {item.name} */}
257-
</Link>
258-
</Tooltip>
259-
))}
260-
</nav>
261-
</div>
220+
</header>
221+
<div className="flex flex-1">
222+
<aside className="hidden md:flex md:flex-col md:w-16 md:fixed md:inset-y-0">
223+
<div className="flex flex-grow flex-col overflow-y-auto border-r border-gray-200 bg-white pt-5 dark:bg-[#171717] dark:border-gray-600">
224+
<div className="mt-14 flex flex-grow flex-col">
225+
<nav className="flex-1 space-y-1 px-2 pb-4">
226+
{navigation.map((item) => (
227+
<Tooltip
228+
placement="right"
229+
key={item.name}
230+
title={item.name}
231+
>
232+
<Link
233+
to={{
234+
pathname: item.href.replace(":id", params.id!),
235+
}}
236+
className={classNames(
237+
location.pathname ===
238+
item.href.replace(":id", params.id!)
239+
? "bg-gray-100 text-gray-900 dark:bg-[#262626] dark:text-white"
240+
: "text-gray-600 hover:bg-gray-50 hover:text-gray-900 dark:text-gray-200 dark:hover:text-white dark:hover:bg-[#262626]",
241+
"group flex items-center justify-center px-2 py-2 text-sm font-medium rounded-md"
242+
)}
243+
>
244+
<item.icon
245+
className={classNames(
246+
location.pathname ===
247+
item.href.replace(":id", params.id!)
248+
? "text-gray-500 dark:text-white"
249+
: "text-gray-400 group-hover:text-gray-500 dark:text-gray-400 dark:group-hover:text-white",
250+
"flex-shrink-0 h-6 w-6"
251+
)}
252+
aria-hidden="true"
253+
/>
254+
</Link>
255+
</Tooltip>
256+
))}
257+
</nav>
258+
</div>
259+
</div>
260+
</aside>
261+
<main className={`flex-1 ${asideSpace}`}>{children}</main>
262262
</div>
263263
</div>
264264
</div>

app/ui/src/components/Bot/Integration/IntegrationForm.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import axios from "axios";
88
import { ClipboardIcon } from "@heroicons/react/24/outline";
99
// import Switch from antd as AntdSwitch
1010
import { Switch as AntdSwitch } from "antd";
11+
import { clipbardCopy } from "../../../utils/clipboard";
1112

1213
//@ts-ignore
1314
function classNames(...classes) {
@@ -163,8 +164,8 @@ export const IntegrationForm: React.FC<Props> = ({ onClose, data }) => {
163164
<div className="flex-shrink-0 ml-3">
164165
<button
165166
type="button"
166-
onClick={() => {
167-
navigator.clipboard.writeText(
167+
onClick={async () => {
168+
await clipbardCopy(
168169
`${hostUrl}/api/v1/bot/integration/${params.id}/whatsapp`
169170
);
170171
notification.success({

app/ui/src/components/Bot/Playground/Message.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { removeUUID } from "../../../utils/filename";
1111
import { useSpeechSynthesis } from "../../../hooks/useSpeechSynthesis";
1212
import { useElevenLabsTTS } from "../../../hooks/useElevenLabsTTS";
1313
import { Collapse } from "antd";
14+
import { clipbardCopy } from "../../../utils/clipboard";
1415

1516
type Props = Message & {
1617
onSourceClick(source: any): void;
@@ -98,8 +99,8 @@ export const PlaygroundMessage = (props: Props) => {
9899
<div className="flex space-x-2">
99100
{!props.hideCopy && (
100101
<button
101-
onClick={() => {
102-
navigator.clipboard.writeText(props.message);
102+
onClick={async () => {
103+
await clipbardCopy(props.message);
103104
setIsBtnPressed(true);
104105
setTimeout(() => {
105106
setIsBtnPressed(false);

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React, { useState } from "react";
22
import { ClipboardIcon, CheckIcon } from "@heroicons/react/24/outline";
33
import { clcx } from "../../utils/classname";
4+
import { clipbardCopy } from "../../utils/clipboard";
45

56
type Props = {
67
value: string;
@@ -19,7 +20,7 @@ export const CopyBtn: React.FC<Props> = ({
1920

2021
const handleCopy = async () => {
2122
try {
22-
await navigator.clipboard.writeText(value);
23+
await clipbardCopy(value);
2324
setCopied(true);
2425
setTimeout(() => setCopied(false), 2000);
2526
} catch (err) {

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import React from "react";
1010
import { Modal, Tooltip } from "antd";
1111
import Mermaid from "./Mermaid";
1212
import { useMessage } from "../../hooks/useMessage";
13+
import { clipbardCopy } from "../../utils/clipboard";
1314

1415
export default function Markdown({ message }: { message: string }) {
1516
const [isBtnPressed, setIsBtnPressed] = React.useState(false);
@@ -64,8 +65,8 @@ export default function Markdown({ message }: { message: string }) {
6465
)}
6566
<Tooltip title="Copy to clipboard">
6667
<button
67-
onClick={() => {
68-
navigator.clipboard.writeText(children[0] as string);
68+
onClick={async () => {
69+
await clipbardCopy(children[0] as string);
6970
setIsBtnPressed(true);
7071
}}
7172
className="flex gap-1.5 items-center rounded bg-none p-1 text-xs text-gray-200 hover:bg-gray-700 hover:text-gray-100 focus:outline-none focus:ring-2 focus:ring-gray-500 focus:ring-offset-2 focus:ring-offset-gray-100"

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
import { Prism as SyntaxHighlighter } from "react-syntax-highlighter";
1212
import { nightOwl } from "react-syntax-highlighter/dist/cjs/styles/prism";
1313
import { useMessage } from "../../hooks/useMessage";
14+
import { clipbardCopy } from "../../utils/clipboard";
1415
mermaid.initialize({
1516
startOnLoad: true,
1617
flowchart: {
@@ -112,8 +113,8 @@ const Mermaid = React.memo((props: { code: string }) => {
112113

113114
<Tooltip title="Copy to clipboard">
114115
<button
115-
onClick={() => {
116-
navigator.clipboard.writeText(props.code);
116+
onClick={async () => {
117+
await clipbardCopy(props.code);
117118
setIsBtnCopied(true);
118119

119120
setTimeout(() => {

app/ui/src/utils/clipboard.ts

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
export const clipbardCopy = async (value: string) => {
2+
if (navigator.clipboard) {
3+
await navigator.clipboard.writeText(value);
4+
} else {
5+
const textArea = document.createElement("textarea");
6+
textArea.value = value;
7+
document.body.appendChild(textArea);
8+
textArea.select();
9+
document.execCommand("copy");
10+
document.body.removeChild(textArea);
11+
}
12+
}

package.json

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

server/src/handlers/api/v1/bot/bot/api.handler.ts

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export const createBotAPIHandler = async (
2929
question_generator_prompt,
3030
system_prompt,
3131
temperature,
32+
options
3233
} = request.body;
3334

3435
const prisma = request.server.prisma;
@@ -112,6 +113,7 @@ export const createBotAPIHandler = async (
112113

113114
const bot = await prisma.bot.create({
114115
data: {
116+
...options,
115117
name,
116118
embedding: embeddingInfo.model_id,
117119
model: modelInfo.model_id,

server/src/handlers/api/v1/bot/bot/types.ts

+10
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,16 @@ export interface CreateBotAPIRequest {
9696
system_prompt?: string;
9797
question_generator_prompt?: string;
9898
temperature?: number;
99+
options?: {
100+
noOfDocumentsToRetrieve?: number,
101+
noOfChatHistoryInContext?: number,
102+
publicBotPwdProtected? : boolean,
103+
semanticSearchSimilarityScore?: "none" |"0.2" |"0.5" |"0.7"
104+
autoResetSession?: boolean,
105+
internetSearchEnabled?: boolean
106+
use_hybrid_search?: boolean
107+
autoSyncDataSources?: boolean
108+
}
99109
};
100110
}
101111

0 commit comments

Comments
 (0)