mirror of
https://git.mirrors.martin98.com/https://github.com/open-webui/open-webui
synced 2025-08-19 20:29:10 +08:00
refac
This commit is contained in:
parent
5c9dd25459
commit
a0fb4a9b84
@ -729,13 +729,9 @@ def process_file(
|
|||||||
text_content = " ".join([doc.page_content for doc in docs])
|
text_content = " ".join([doc.page_content for doc in docs])
|
||||||
log.debug(f"text_content: {text_content}")
|
log.debug(f"text_content: {text_content}")
|
||||||
|
|
||||||
Files.update_files_metadata_by_id(
|
Files.update_files_data_by_id(
|
||||||
form_data.file_id,
|
form_data.file_id,
|
||||||
{
|
{"content": text_content},
|
||||||
"content": {
|
|
||||||
"text": text_content,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -112,6 +112,17 @@ class FilesTable:
|
|||||||
for file in db.query(File).filter_by(user_id=user_id).all()
|
for file in db.query(File).filter_by(user_id=user_id).all()
|
||||||
]
|
]
|
||||||
|
|
||||||
|
def update_files_data_by_id(self, id: str, data: dict) -> Optional[FileModel]:
|
||||||
|
with get_db() as db:
|
||||||
|
try:
|
||||||
|
file = db.query(File).filter_by(id=id).first()
|
||||||
|
file.data = {**file.data, **data}
|
||||||
|
db.commit()
|
||||||
|
|
||||||
|
return FileModel.model_validate(file)
|
||||||
|
except Exception:
|
||||||
|
return None
|
||||||
|
|
||||||
def update_files_metadata_by_id(self, id: str, meta: dict) -> Optional[FileModel]:
|
def update_files_metadata_by_id(self, id: str, meta: dict) -> Optional[FileModel]:
|
||||||
with get_db() as db:
|
with get_db() as db:
|
||||||
try:
|
try:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user