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
14226937
Commit
14226937
authored
Jan 07, 2024
by
Timothy J. Baek
Browse files
feat: vectordb query error handling
parent
ad3d69be
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
5 deletions
+12
-5
backend/apps/rag/main.py
backend/apps/rag/main.py
+12
-5
No files found.
backend/apps/rag/main.py
View file @
14226937
...
@@ -85,12 +85,19 @@ async def get_status():
...
@@ -85,12 +85,19 @@ async def get_status():
@
app
.
get
(
"/query/{collection_name}"
)
@
app
.
get
(
"/query/{collection_name}"
)
def
query_collection
(
collection_name
:
str
,
query
:
str
,
k
:
Optional
[
int
]
=
4
):
def
query_collection
(
collection_name
:
str
,
query
:
str
,
k
:
Optional
[
int
]
=
4
):
collection
=
CHROMA_CLIENT
.
get_collection
(
try
:
name
=
collection_name
,
collection
=
CHROMA_CLIENT
.
get_collection
(
)
name
=
collection_name
,
result
=
collection
.
query
(
query_texts
=
[
query
],
n_results
=
k
)
)
result
=
collection
.
query
(
query_texts
=
[
query
],
n_results
=
k
)
return
result
return
result
except
Exception
as
e
:
print
(
e
)
raise
HTTPException
(
status_code
=
status
.
HTTP_400_BAD_REQUEST
,
detail
=
ERROR_MESSAGES
.
DEFAULT
(
e
),
)
@
app
.
post
(
"/web"
)
@
app
.
post
(
"/web"
)
...
...
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