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
582d11f1
Commit
582d11f1
authored
Apr 10, 2024
by
Timothy J. Baek
Browse files
refac: RAG_EMBEDDING_MODEL_PATH removed
parent
cb2158a7
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
30 deletions
+17
-30
backend/apps/rag/main.py
backend/apps/rag/main.py
+17
-30
No files found.
backend/apps/rag/main.py
View file @
582d11f1
...
...
@@ -80,16 +80,15 @@ app.state.RAG_TEMPLATE = RAG_TEMPLATE
app
.
state
.
RAG_EMBEDDING_MODEL
=
RAG_EMBEDDING_MODEL
app
.
state
.
RAG_EMBEDDING_MODEL_PATH
=
get_embedding_model_path
(
app
.
state
.
RAG_EMBEDDING_MODEL
,
RAG_EMBEDDING_MODEL_AUTO_UPDATE
)
app
.
state
.
TOP_K
=
4
app
.
state
.
sentence_transformer_ef
=
(
embedding_functions
.
SentenceTransformerEmbeddingFunction
(
model_name
=
app
.
state
.
RAG_EMBEDDING_MODEL_PATH
,
model_name
=
get_embedding_model_path
(
app
.
state
.
RAG_EMBEDDING_MODEL
,
RAG_EMBEDDING_MODEL_AUTO_UPDATE
),
device
=
DEVICE_TYPE
,
)
)
...
...
@@ -130,7 +129,6 @@ async def get_embedding_model(user=Depends(get_admin_user)):
return
{
"status"
:
True
,
"embedding_model"
:
app
.
state
.
RAG_EMBEDDING_MODEL
,
"embedding_model_path"
:
app
.
state
.
RAG_EMBEDDING_MODEL_PATH
,
}
...
...
@@ -143,44 +141,33 @@ async def update_embedding_model(
form_data
:
EmbeddingModelUpdateForm
,
user
=
Depends
(
get_admin_user
)
):
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
}
"
)
embedding_model_path
=
None
sentence_transformer_ef
=
None
try
:
embedding_model_path
=
get_embedding_model_path
(
form_data
.
embedding_model
,
True
)
if
app
.
state
.
RAG_EMBEDDING_MODEL_PATH
!=
embedding_model_path
:
sentence_transformer_ef
=
(
embedding_functions
.
SentenceTransformerEmbeddingFunction
(
model_name
=
embedding_model_path
,
model_name
=
get_
embedding_model_path
(
form_data
.
embedding_model
,
True
)
,
device
=
DEVICE_TYPE
,
)
)
except
Exception
as
e
:
log
.
exception
(
f
"Problem updating embedding model:
{
e
}
"
)
raise
HTTPException
(
status_code
=
status
.
HTTP_500_INTERNAL_SERVER_ERROR
,
detail
=
ERROR_MESSAGES
.
DEFAULT
(
e
),
)
if
sentence_transformer_ef
:
app
.
state
.
RAG_EMBEDDING_MODEL
=
form_data
.
embedding_model
app
.
state
.
RAG_EMBEDDING_MODEL_PATH
=
embedding_model_path
app
.
state
.
sentence_transformer_ef
=
sentence_transformer_ef
log
.
debug
(
f
"app.state.RAG_EMBEDDING_MODEL_PATH:
{
app
.
state
.
RAG_EMBEDDING_MODEL_PATH
}
"
)
return
{
"status"
:
sentence_transformer_ef
!=
Non
e
,
"status"
:
Tru
e
,
"embedding_model"
:
app
.
state
.
RAG_EMBEDDING_MODEL
,
"embedding_model_path"
:
app
.
state
.
RAG_EMBEDDING_MODEL_PATH
,
}
except
Exception
as
e
:
log
.
exception
(
f
"Problem updating embedding model:
{
e
}
"
)
raise
HTTPException
(
status_code
=
status
.
HTTP_500_INTERNAL_SERVER_ERROR
,
detail
=
ERROR_MESSAGES
.
DEFAULT
(
e
),
)
@
app
.
get
(
"/config"
)
async
def
get_rag_config
(
user
=
Depends
(
get_admin_user
)):
...
...
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