Skip to content

Commit dd79a51

Browse files
authored
Merge pull request #292 from n4ze3m/next
v1.10.0
2 parents 97e57ff + 664b0e7 commit dd79a51

File tree

23 files changed

+650
-91
lines changed

23 files changed

+650
-91
lines changed

app/ui/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "app",
33
"private": true,
4-
"version": "1.9.5",
4+
"version": "1.10.0",
55
"type": "module",
66
"scripts": {
77
"dev": "vite",

app/ui/src/@types/bot.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export type BotSettings = {
2222
inactivityTimeout: number;
2323
autoResetSession: boolean;
2424
autoSyncDataSources: boolean;
25+
internetSearchEnabled: boolean;
2526
};
2627
chatModel: {
2728
label: string;

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@ import { YoutubeIcon } from "../../Icons/YoutubeIcon";
1818
import { ApiIcon } from "../../Icons/ApiIcon";
1919
export const DsTable = ({
2020
data,
21+
searchNode
2122
}: {
2223
data: {
2324
id: string;
2425
type: string;
2526
content: string;
2627
status: string;
2728
}[];
29+
searchNode: React.ReactNode;
2830
}) => {
2931
const statusColor = (status: string) => {
3032
switch (status.toLowerCase()) {
@@ -134,6 +136,8 @@ export const DsTable = ({
134136
<div className="mt-8 flex flex-col">
135137
<div className="-my-2 -mx-4 overflow-x-auto sm:-mx-6 lg:-mx-8">
136138
<div className="inline-block min-w-full p-2 align-middle md:px-6 lg:px-8">
139+
{searchNode}
140+
137141
<div className="overflow-hidden bg-white ring-1 ring-black ring-opacity-5 rounded-lg dark:bg-[#262626]">
138142
{data.length === 0 && (
139143
<Empty description="No data sources found." className="m-8" />

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

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import React from "react";
1010
import { removeUUID } from "../../../utils/filename";
1111
import { useSpeechSynthesis } from "../../../hooks/useSpeechSynthesis";
1212
import { useElevenLabsTTS } from "../../../hooks/useElevenLabsTTS";
13+
import { Collapse } from "antd";
1314

1415
type Props = Message & {
1516
onSourceClick(source: any): void;
@@ -55,24 +56,41 @@ export const PlaygroundMessage = (props: Props) => {
5556
<Markdown message={props.message} />
5657
</div>
5758

58-
{props.isBot && (
59-
<div className="mt-3 flex flex-wrap gap-2">
60-
{props?.sources?.map((source, index) => (
61-
<button
62-
key={index}
63-
onClick={props.onSourceClick.bind(null, source)}
64-
className="inline-flex cursor-pointer transition-shadow duration-300 ease-in-out hover:shadow-lg items-center rounded-md bg-gray-100 p-1 text-xs text-gray-800 border border-gray-300 dark:bg-gray-800 dark:border-gray-700 dark:text-gray-100 opacity-80 hover:opacity-100"
65-
>
66-
<span className="text-xs">
67-
{removeUUID(
68-
`${
69-
source?.metadata?.path || source?.metadata?.source
70-
}`.replace("./uploads/", "")
71-
)}
72-
</span>
73-
</button>
74-
))}
75-
</div>
59+
{props.isBot && props?.sources && props?.sources?.length > 0 && (
60+
<Collapse
61+
className="mt-6"
62+
ghost
63+
items={[
64+
{
65+
key: "1",
66+
label: (
67+
<div className="italic text-gray-500 dark:text-gray-400">
68+
Bot sources
69+
</div>
70+
),
71+
children: (
72+
<div className="mt-3 flex flex-wrap gap-2">
73+
{props?.sources?.map((source, index) => (
74+
<button
75+
key={index}
76+
onClick={props.onSourceClick.bind(null, source)}
77+
className="inline-flex cursor-pointer transition-shadow !line-clamp-1 duration-300 ease-in-out hover:shadow-lg items-center rounded-md bg-gray-200 p-1 text-xs text-gray-800 border border-gray-300 dark:bg-gray-800 dark:border-gray-700 dark:text-gray-100 opacity-80 hover:opacity-100 "
78+
>
79+
<span className="text-xs">
80+
{removeUUID(
81+
`${
82+
source?.metadata?.path ||
83+
source?.metadata?.source
84+
}`.replace("./uploads/", "")
85+
)}
86+
</span>
87+
</button>
88+
))}
89+
</div>
90+
),
91+
},
92+
]}
93+
/>
7694
)}
7795
</div>
7896

app/ui/src/components/Bot/Settings/SettingsBody.tsx

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ export const SettingsBody: React.FC<BotSettings> = ({
169169
autoResetSession: data.autoResetSession,
170170
inactivityTimeout: data.inactivityTimeout,
171171
autoSyncDataSources: data.autoSyncDataSources,
172+
internetSearchEnabled: data.internetSearchEnabled,
172173
}}
173174
form={form}
174175
requiredMark={false}
@@ -226,7 +227,24 @@ export const SettingsBody: React.FC<BotSettings> = ({
226227
options={chatModel}
227228
/>
228229
</Form.Item>
229-
230+
<Form.Item
231+
label={"Embedding Method"}
232+
name="embedding"
233+
help={
234+
<>
235+
<p className="text-xs text-gray-500 dark:text-gray-400">
236+
If you change the embedding method, make sure to
237+
re-fetch the data source or choose a model with the same
238+
dimensions
239+
</p>
240+
</>
241+
}
242+
>
243+
<Select
244+
placeholder="Select an embedding method"
245+
options={embeddingModel}
246+
/>
247+
</Form.Item>
230248
<Form.Item
231249
hasFeedback={!isStreamingSupported(currentModel)}
232250
help={
@@ -266,23 +284,14 @@ export const SettingsBody: React.FC<BotSettings> = ({
266284
/>
267285
</Form.Item>
268286

287+
269288
<Form.Item
270-
label={"Embedding Method"}
271-
name="embedding"
272-
help={
273-
<>
274-
<p className="text-xs text-gray-500 dark:text-gray-400">
275-
If you change the embedding method, make sure to
276-
re-fetch the data source or choose a model with the same
277-
dimensions
278-
</p>
279-
</>
280-
}
289+
name="internetSearchEnabled"
290+
label="Enable internet search"
291+
valuePropName="checked"
292+
help="This is experimental and may not work as expected."
281293
>
282-
<Select
283-
placeholder="Select an embedding method"
284-
options={embeddingModel}
285-
/>
294+
<Switch />
286295
</Form.Item>
287296

288297
<Form.Item
@@ -455,7 +464,7 @@ export const SettingsBody: React.FC<BotSettings> = ({
455464
/>
456465
</Form.Item>
457466

458-
<Form.Item
467+
<Form.Item
459468
name="autoSyncDataSources"
460469
label="Auto Sync Data Source(s)"
461470
tooltip="This will automatically re-fetch the URL-based data sources at a certain interval."

app/ui/src/index.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,7 @@ markdown-processing {
5959
border: none !important;
6060
box-shadow: none !important;
6161
}
62+
63+
.ant-collapse-header {
64+
padding: 0 !important;
65+
}

app/ui/src/routes/bot/ds.tsx

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,27 @@ import React from "react";
44
import { SkeletonLoading } from "../../components/Common/SkeletonLoading";
55
import { DsTable } from "../../components/Bot/DS/DsTable";
66
import api from "../../services/api";
7-
import { Pagination } from "antd";
7+
import { Input, Pagination } from "antd";
88

99
export default function BotDSRoot() {
1010
const param = useParams<{ id: string }>();
1111
const navigate = useNavigate();
1212
const [page, setPage] = React.useState(1);
1313
const [limit, setLimit] = React.useState(10);
14+
const [search, setSearch] = React.useState<string | undefined>(undefined);
15+
const [searchValue, setSearchValue] = React.useState<string | undefined>(
16+
undefined
17+
);
1418

1519
const { data: botData, status } = useQuery(
16-
["getBotDS", param.id, page, limit],
20+
["getBotDS", param.id, page, limit, searchValue],
1721
async () => {
1822
const response = await api.get(
19-
`/bot/${param.id}/source?page=${page}&limit=${limit}`
23+
`/bot/${param.id}/source?page=${page}&limit=${limit}${
24+
searchValue && searchValue.trim().length > 0
25+
? `&search=${searchValue}`
26+
: ""
27+
}`
2028
);
2129
return response.data as {
2230
data: {
@@ -47,7 +55,20 @@ export default function BotDSRoot() {
4755
{status === "loading" && <SkeletonLoading />}
4856
{status === "success" && (
4957
<div className="px-4 sm:px-6 lg:px-8">
50-
<DsTable data={botData.data} />
58+
<DsTable
59+
data={botData.data}
60+
searchNode={
61+
<div className="flex mb-6 justify-end sm:justify-center md:justify-end">
62+
<Input.Search
63+
value={search}
64+
onSearch={(value) => setSearchValue(value)}
65+
onChange={(e) => setSearch(e.target.value)}
66+
placeholder="Search"
67+
style={{ width: 300 }}
68+
/>
69+
</div>
70+
}
71+
/>
5172
{botData.total >= 10 && (
5273
<div className="my-3 flex items-center justify-end">
5374
<Pagination

docker/docker-compose.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ services:
1010
environment:
1111
DATABASE_URL: postgres://postgres:postgres@dialoqbase-pg:5432/dialoqbase?connection_limit=15&pool_timeout=0
1212
DB_REDIS_URL: redis://redis:6379
13+
DB_SEARXNG_URL: http://searxng:8080
1314
env_file:
1415
- .env
1516
depends_on:
1617
- dialoqbase-pg
1718
- redis
19+
- searxng
1820
volumes:
1921
- .uploads:/app/uploads
2022

@@ -34,4 +36,10 @@ services:
3436
container_name: redis
3537
restart: unless-stopped
3638
volumes:
37-
- .redis:/data
39+
- .redis:/data
40+
41+
searxng:
42+
image: searxng/searxng
43+
volumes:
44+
- ./searxng:/etc/searxng:rw
45+
restart: unless-stopped

docker/searxng/limiter.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#https://docs.searxng.org/admin/searx.limiter.html

docker/searxng/settings.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
use_default_settings: true
2+
3+
search:
4+
# Filter results. 0: None, 1: Moderate, 2: Strict
5+
safe_search: 0
6+
# Existing autocomplete backends: "dbpedia", "duckduckgo", "google", "yandex", "mwmbl",
7+
# "seznam", "startpage", "stract", "swisscows", "qwant", "wikipedia" - leave blank to turn it off
8+
# by default.
9+
autocomplete: 'google'
10+
# minimun characters to type before autocompleter starts
11+
autocomplete_min: 4
12+
# Default search language - leave blank to detect from browser information or
13+
# use codes from 'languages.py'
14+
default_lang: 'auto'
15+
# max_page: 0 # if engine supports paging, 0 means unlimited numbers of pages
16+
# Available languages
17+
# languages:
18+
# - all
19+
# - en
20+
# - en-US
21+
# - de
22+
# - it-IT
23+
# - fr
24+
# - fr-BE
25+
# ban time in seconds after engine errors
26+
ban_time_on_fail: 5
27+
# max ban time in seconds after engine errors
28+
max_ban_time_on_fail: 120
29+
suspended_times:
30+
# Engine suspension time after error (in seconds; set to 0 to disable)
31+
# For error "Access denied" and "HTTP error [402, 403]"
32+
SearxEngineAccessDenied: 86400
33+
# For error "CAPTCHA"
34+
SearxEngineCaptcha: 86400
35+
# For error "Too many request" and "HTTP error 429"
36+
SearxEngineTooManyRequests: 3600
37+
# Cloudflare CAPTCHA
38+
cf_SearxEngineCaptcha: 1296000
39+
cf_SearxEngineAccessDenied: 86400
40+
# ReCAPTCHA
41+
recaptcha_SearxEngineCaptcha: 604800
42+
43+
# remove format to deny access, use lower case.
44+
# formats: [html, csv, json, rss]
45+
formats:
46+
- html
47+
- json
48+
49+
server:
50+
# Is overwritten by ${SEARXNG_PORT} and ${SEARXNG_BIND_ADDRESS}
51+
port: 8888
52+
bind_address: '0.0.0.0'
53+
# public URL of the instance, to ensure correct inbound links. Is overwritten
54+
# by ${SEARXNG_URL}.
55+
base_url: false # "http://example.com/location"
56+
# rate limit the number of request on the instance, block some bots.
57+
# Is overwritten by ${SEARXNG_LIMITER}
58+
limiter: false
59+
# enable features designed only for public instances.
60+
# Is overwritten by ${SEARXNG_PUBLIC_INSTANCE}
61+
public_instance: false
62+
63+
# If your instance owns a /etc/searxng/settings.yml file, then set the following
64+
# values there.
65+
66+
secret_key: 'KDzXs0qvZdoZnzW7Eq4jhubjgTWayRM' # Is overwritten by ${SEARXNG_SECRET}
67+
# Proxy image results through SearXNG. Is overwritten by ${SEARXNG_IMAGE_PROXY}
68+
image_proxy: false
69+
# 1.0 and 1.1 are supported
70+
http_protocol_version: '1.0'
71+
# POST queries are more secure as they don't show up in history but may cause
72+
# problems when using Firefox containers
73+
method: 'POST'
74+
default_http_headers:
75+
X-Content-Type-Options: nosniff
76+
X-Download-Options: noopen
77+
X-Robots-Tag: noindex, nofollow
78+
Referrer-Policy: no-referrer

0 commit comments

Comments
 (0)