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
075fbedb
Commit
075fbedb
authored
Apr 04, 2024
by
Self Denial
Browse files
More format fixes
parent
bcf79c83
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
5 deletions
+12
-5
backend/apps/rag/main.py
backend/apps/rag/main.py
+11
-5
backend/apps/rag/utils.py
backend/apps/rag/utils.py
+1
-0
No files found.
backend/apps/rag/main.py
View file @
075fbedb
...
@@ -141,17 +141,21 @@ async def update_embedding_model(
...
@@ -141,17 +141,21 @@ async def update_embedding_model(
app
.
state
.
RAG_EMBEDDING_MODEL
=
form_data
.
embedding_model
app
.
state
.
RAG_EMBEDDING_MODEL
=
form_data
.
embedding_model
log
.
debug
(
f
"form_data.embedding_model:
{
form_data
.
embedding_model
}
"
)
log
.
debug
(
f
"form_data.embedding_model:
{
form_data
.
embedding_model
}
"
)
log
.
info
(
f
"Updating embedding model:
{
app
.
state
.
RAG_EMBEDDING_MODEL
}
to
{
form_data
.
embedding_model
}
"
)
log
.
info
(
f
"Updating embedding model:
{
app
.
state
.
RAG_EMBEDDING_MODEL
}
to
{
form_data
.
embedding_model
}
"
)
try
:
try
:
app
.
state
.
RAG_EMBEDDING_MODEL_PATH
=
embedding_model_get_path
(
app
.
state
.
RAG_EMBEDDING_MODEL
,
True
)
app
.
state
.
RAG_EMBEDDING_MODEL_PATH
=
embedding_model_get_path
(
app
.
state
.
RAG_EMBEDDING_MODEL
,
True
)
app
.
state
.
sentence_transformer_ef
=
(
app
.
state
.
sentence_transformer_ef
=
(
embedding_functions
.
SentenceTransformerEmbeddingFunction
(
embedding_functions
.
SentenceTransformerEmbeddingFunction
(
model_name
=
app
.
state
.
RAG_EMBEDDING_MODEL_PATH
,
model_name
=
app
.
state
.
RAG_EMBEDDING_MODEL_PATH
,
device
=
RAG_EMBEDDING_MODEL_DEVICE_TYPE
,
device
=
RAG_EMBEDDING_MODEL_DEVICE_TYPE
,
)
)
)
)
except
Exception
as
e
:
except
Exception
as
e
:
log
.
exception
(
f
"Problem updating embedding model:
{
e
}
"
)
log
.
exception
(
f
"Problem updating embedding model:
{
e
}
"
)
raise
HTTPException
(
raise
HTTPException
(
status_code
=
status
.
HTTP_500_INTERNAL_SERVER_ERROR
,
status_code
=
status
.
HTTP_500_INTERNAL_SERVER_ERROR
,
...
@@ -159,9 +163,11 @@ async def update_embedding_model(
...
@@ -159,9 +163,11 @@ async def update_embedding_model(
)
)
if
app
.
state
.
RAG_EMBEDDING_MODEL_PATH
==
old_model_path
:
if
app
.
state
.
RAG_EMBEDDING_MODEL_PATH
==
old_model_path
:
status
=
False
status
=
False
log
.
debug
(
f
"app.state.RAG_EMBEDDING_MODEL_PATH:
{
app
.
state
.
RAG_EMBEDDING_MODEL_PATH
}
"
)
log
.
debug
(
f
"app.state.RAG_EMBEDDING_MODEL_PATH:
{
app
.
state
.
RAG_EMBEDDING_MODEL_PATH
}
"
)
log
.
debug
(
f
"old_model_path:
{
old_model_path
}
"
)
log
.
debug
(
f
"old_model_path:
{
old_model_path
}
"
)
log
.
debug
(
f
"status:
{
status
}
"
)
log
.
debug
(
f
"status:
{
status
}
"
)
...
...
backend/apps/rag/utils.py
View file @
075fbedb
...
@@ -191,6 +191,7 @@ def rag_messages(docs, messages, template, k, embedding_function):
...
@@ -191,6 +191,7 @@ def rag_messages(docs, messages, template, k, embedding_function):
return
messages
return
messages
def
embedding_model_get_path
(
def
embedding_model_get_path
(
embedding_model
:
str
,
update_embedding_model
:
bool
=
False
embedding_model
:
str
,
update_embedding_model
:
bool
=
False
):
):
...
...
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