Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
open-webui
Commits
f58eb0d2
Commit
f58eb0d2
authored
May 06, 2024
by
Timothy J. Baek
Browse files
feat: browser search engine support
parent
66e7e577
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
42 additions
and
1 deletion
+42
-1
backend/config.py
backend/config.py
+3
-0
backend/main.py
backend/main.py
+17
-1
src/app.html
src/app.html
+6
-0
src/routes/(app)/+page.svelte
src/routes/(app)/+page.svelte
+8
-0
static/opensearch.xml
static/opensearch.xml
+8
-0
No files found.
backend/config.py
View file @
f58eb0d2
...
@@ -76,8 +76,11 @@ WEBUI_NAME = os.environ.get("WEBUI_NAME", "Open WebUI")
...
@@ -76,8 +76,11 @@ WEBUI_NAME = os.environ.get("WEBUI_NAME", "Open WebUI")
if
WEBUI_NAME
!=
"Open WebUI"
:
if
WEBUI_NAME
!=
"Open WebUI"
:
WEBUI_NAME
+=
" (Open WebUI)"
WEBUI_NAME
+=
" (Open WebUI)"
WEBUI_URL
=
os
.
environ
.
get
(
"WEBUI_URL"
,
"http://localhost:3000"
)
WEBUI_FAVICON_URL
=
"https://openwebui.com/favicon.png"
WEBUI_FAVICON_URL
=
"https://openwebui.com/favicon.png"
####################################
####################################
# ENV (dev,test,prod)
# ENV (dev,test,prod)
####################################
####################################
...
...
backend/main.py
View file @
f58eb0d2
...
@@ -15,7 +15,7 @@ from fastapi.middleware.wsgi import WSGIMiddleware
...
@@ -15,7 +15,7 @@ from fastapi.middleware.wsgi import WSGIMiddleware
from
fastapi.middleware.cors
import
CORSMiddleware
from
fastapi.middleware.cors
import
CORSMiddleware
from
starlette.exceptions
import
HTTPException
as
StarletteHTTPException
from
starlette.exceptions
import
HTTPException
as
StarletteHTTPException
from
starlette.middleware.base
import
BaseHTTPMiddleware
from
starlette.middleware.base
import
BaseHTTPMiddleware
from
starlette.responses
import
StreamingResponse
from
starlette.responses
import
StreamingResponse
,
Response
from
apps.ollama.main
import
app
as
ollama_app
from
apps.ollama.main
import
app
as
ollama_app
from
apps.openai.main
import
app
as
openai_app
from
apps.openai.main
import
app
as
openai_app
...
@@ -43,6 +43,7 @@ from apps.rag.utils import rag_messages
...
@@ -43,6 +43,7 @@ from apps.rag.utils import rag_messages
from
config
import
(
from
config
import
(
CONFIG_DATA
,
CONFIG_DATA
,
WEBUI_NAME
,
WEBUI_NAME
,
WEBUI_URL
,
ENV
,
ENV
,
VERSION
,
VERSION
,
CHANGELOG
,
CHANGELOG
,
...
@@ -350,6 +351,21 @@ async def get_manifest_json():
...
@@ -350,6 +351,21 @@ async def get_manifest_json():
}
}
@
app
.
get
(
"/opensearch.xml"
)
async
def
get_opensearch_xml
():
xml_content
=
rf
"""
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/">
<ShortName>
{
WEBUI_NAME
}
</ShortName>
<Description>Search
{
WEBUI_NAME
}
</Description>
<InputEncoding>UTF-8</InputEncoding>
<Image width="16" height="16" type="image/x-icon">
{
WEBUI_URL
}
/favicon.png</Image>
<Url type="text/html" method="get" template="
{
WEBUI_URL
}
/?q=
{
"
{
searchTerms
}
"
}
"/>
<moz:SearchForm>
{
WEBUI_URL
}
</moz:SearchForm>
</OpenSearchDescription>
"""
return
Response
(
content
=
xml_content
,
media_type
=
"application/xml"
)
app
.
mount
(
"/static"
,
StaticFiles
(
directory
=
STATIC_DIR
),
name
=
"static"
)
app
.
mount
(
"/static"
,
StaticFiles
(
directory
=
STATIC_DIR
),
name
=
"static"
)
app
.
mount
(
"/cache"
,
StaticFiles
(
directory
=
CACHE_DIR
),
name
=
"cache"
)
app
.
mount
(
"/cache"
,
StaticFiles
(
directory
=
CACHE_DIR
),
name
=
"cache"
)
...
...
src/app.html
View file @
f58eb0d2
...
@@ -6,6 +6,12 @@
...
@@ -6,6 +6,12 @@
<link
rel=
"manifest"
href=
"%sveltekit.assets%/manifest.json"
crossorigin=
"use-credentials"
/>
<link
rel=
"manifest"
href=
"%sveltekit.assets%/manifest.json"
crossorigin=
"use-credentials"
/>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1, maximum-scale=1"
/>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1, maximum-scale=1"
/>
<meta
name=
"robots"
content=
"noindex,nofollow"
/>
<meta
name=
"robots"
content=
"noindex,nofollow"
/>
<link
rel=
"search"
type=
"application/opensearchdescription+xml"
title=
"Open WebUI"
href=
"/opensearch.xml"
/>
<script>
<script>
// On page load or when changing themes, best to add inline in `head` to avoid FOUC
// On page load or when changing themes, best to add inline in `head` to avoid FOUC
(()
=>
{
(()
=>
{
...
...
src/routes/(app)/+page.svelte
View file @
f58eb0d2
...
@@ -134,6 +134,14 @@
...
@@ -134,6 +134,14 @@
selectedModels
=
[
''
];
selectedModels
=
[
''
];
}
}
if
($
page
.
url
.
searchParams
.
get
(
'q'
))
{
prompt
=
$
page
.
url
.
searchParams
.
get
(
'q'
)
??
''
;
if
(
prompt
)
{
await
tick
();
submitPrompt
(
prompt
);
}
}
selectedModels
=
selectedModels
.
map
((
modelId
)
=>
selectedModels
=
selectedModels
.
map
((
modelId
)
=>
$
models
.
map
((
m
)
=>
m
.
id
).
includes
(
modelId
)
?
modelId
:
''
$
models
.
map
((
m
)
=>
m
.
id
).
includes
(
modelId
)
?
modelId
:
''
);
);
...
...
static/opensearch.xml
0 → 100644
View file @
f58eb0d2
<OpenSearchDescription
xmlns=
"http://a9.com/-/spec/opensearch/1.1/"
xmlns:moz=
"http://www.mozilla.org/2006/browser/search/"
>
<ShortName>
Open WebUI
</ShortName>
<Description>
Search Open WebUI
</Description>
<InputEncoding>
UTF-8
</InputEncoding>
<Image
width=
"16"
height=
"16"
type=
"image/x-icon"
>
http://localhost:5137/favicon.png
</Image>
<Url
type=
"text/html"
method=
"get"
template=
"http://localhost:5137/?q={searchTerms}"
/>
<moz:SearchForm>
http://localhost:5137
</moz:SearchForm>
</OpenSearchDescription>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment