Skip to content

Commit

Permalink
enable disable
Browse files Browse the repository at this point in the history
  • Loading branch information
n4ze3m committed Oct 12, 2023
1 parent 6c3d448 commit 3d37873
Show file tree
Hide file tree
Showing 7 changed files with 360 additions and 293 deletions.
15 changes: 15 additions & 0 deletions app/ui/src/@types/bot.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export type BotSettings = {
id: string;
name: string;
model: string;
public_id: string;
temperature: number;
embedding: string;
qaPrompt: string;
questionGeneratorPrompt: string;
streaming: boolean;
showRef: boolean;
use_hybrid_search: boolean;
bot_protect: boolean;
use_rag: boolean;
};
29 changes: 12 additions & 17 deletions app/ui/src/components/Bot/Settings/SettingsCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,9 @@ import {
HELPFUL_ASSISTANT_WITH_CONTEXT_PROMPT,
HELPFUL_ASSISTANT_WITHOUT_CONTEXT_PROMPT,
} from "../../../utils/prompts";
import { BotSettings } from "../../../@types/bot";

export const SettingsCard = ({
data,
}: {
data: {
id: string;
name: string;
model: string;
public_id: string;
temperature: number;
embedding: string;
qaPrompt: string;
questionGeneratorPrompt: string;
streaming: boolean;
showRef: boolean;
use_hybrid_search: boolean;
};
}) => {
export const SettingsCard = ({ data }: { data: BotSettings }) => {
const [form] = Form.useForm();
const [disableStreaming, setDisableStreaming] = React.useState(false);
const params = useParams<{ id: string }>();
Expand Down Expand Up @@ -133,6 +118,7 @@ export const SettingsCard = ({
streaming: data.streaming,
showRef: data.showRef,
use_hybrid_search: data.use_hybrid_search,
bot_protect: data.bot_protect,
}}
form={form}
requiredMark={false}
Expand Down Expand Up @@ -317,6 +303,15 @@ export const SettingsCard = ({
>
<Switch />
</Form.Item>

<Form.Item
name="bot_protect"
label="Activate Public Bot Protection (Beta)"
valuePropName="checked"
tooltip="This will activate the public bot protection using session to avoid misuse of the bot"
>
<Switch />
</Form.Item>
</div>
</div>

Expand Down
16 changes: 2 additions & 14 deletions app/ui/src/routes/bot/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import api from "../../services/api";
import React from "react";
import { SkeletonLoading } from "../../components/Common/SkeletonLoading";
import { SettingsCard } from "../../components/Bot/Settings/SettingsCard";
import { BotSettings } from "../../@types/bot";

export default function BotSettingsRoot() {
const param = useParams<{ id: string }>();
Expand All @@ -14,19 +15,7 @@ export default function BotSettingsRoot() {
async () => {
const response = await api.get(`/bot/${param.id}`);
return response.data as {
data: {
id: string;
name: string;
model: string;
public_id: string;
temperature: number;
embedding: string;
qaPrompt: string;
questionGeneratorPrompt: string;
streaming: boolean;
showRef: boolean;
use_hybrid_search: boolean;
};
data: BotSettings
};
},
{
Expand All @@ -41,7 +30,6 @@ export default function BotSettingsRoot() {
}, [status]);
return (
<div className="mx-auto my-3 w-full max-w-7xl">

{status === "loading" && <SkeletonLoading />}
{status === "success" && <SettingsCard data={data.data} />}
</div>
Expand Down
2 changes: 2 additions & 0 deletions server/src/routes/api/v1/bot/handlers/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,7 @@ export interface UpdateBotById {
streaming: boolean;
showRef: boolean;
use_hybrid_search: boolean;
bot_protect: boolean;
use_rag: boolean;
};
}
Loading

0 comments on commit 3d37873

Please sign in to comment.