forked from langgenius/dify
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge commit '6e0fb055d18969eb923e719ad92ecac3a5c5d534'
* commit '6e0fb055d18969eb923e719ad92ecac3a5c5d534': (42 commits) chore: bump version to 0.15.1 (langgenius#12690) feat: add table of contents to Knowledge API doc (langgenius#12688) [fix] support feature restore (langgenius#12563) api tool support multiple env url (langgenius#12249) Add new integration with Opik Tracking tool (langgenius#11501) fix: add type hints for App model and improve error handling in audio services (langgenius#12677) fix: Update variable handling in VariableAssignerNode and clean up app_dsl_service (langgenius#12672) Revert "Feat/new saas billing" (langgenius#12673) fix(workflow): fix answer node stream processing in conditional branches (langgenius#12510) fix: ruff with statements (langgenius#12578) fix: ruff check for True if ... else (langgenius#12576) chore: Adjust translations to align with Taiwanese Mandarin conventions (langgenius#12633) Fix pandas indexing method for knowledge base imports (langgenius#12637) (langgenius#12638) Feat/new saas billing (langgenius#12591) improve the readability of the function generate_api_key (langgenius#12552) chore: translate i18n files (langgenius#12543) Feat/add knowledge include all filter (langgenius#12537) fix: Add datasets list access control and fix datasets config display issue (langgenius#12533) fix: sum costs return error value on overview page (langgenius#12534) feat: show workflow running status (langgenius#12531) ... # Conflicts: # api/poetry.lock
- Loading branch information
Showing
147 changed files
with
2,930 additions
and
744 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
from werkzeug.exceptions import NotFound | ||
|
||
from controllers.service_api import api | ||
from controllers.service_api.wraps import ( | ||
DatasetApiResource, | ||
) | ||
from core.file import helpers as file_helpers | ||
from extensions.ext_database import db | ||
from models.dataset import Dataset | ||
from models.model import UploadFile | ||
from services.dataset_service import DocumentService | ||
|
||
|
||
class UploadFileApi(DatasetApiResource): | ||
def get(self, tenant_id, dataset_id, document_id): | ||
"""Get upload file.""" | ||
# check dataset | ||
dataset_id = str(dataset_id) | ||
tenant_id = str(tenant_id) | ||
dataset = db.session.query(Dataset).filter(Dataset.tenant_id == tenant_id, Dataset.id == dataset_id).first() | ||
if not dataset: | ||
raise NotFound("Dataset not found.") | ||
# check document | ||
document_id = str(document_id) | ||
document = DocumentService.get_document(dataset.id, document_id) | ||
if not document: | ||
raise NotFound("Document not found.") | ||
# check upload file | ||
if document.data_source_type != "upload_file": | ||
raise ValueError(f"Document data source type ({document.data_source_type}) is not upload_file.") | ||
data_source_info = document.data_source_info_dict | ||
if data_source_info and "upload_file_id" in data_source_info: | ||
file_id = data_source_info["upload_file_id"] | ||
upload_file = db.session.query(UploadFile).filter(UploadFile.id == file_id).first() | ||
if not upload_file: | ||
raise NotFound("UploadFile not found.") | ||
else: | ||
raise ValueError("Upload file id not found in document data source info.") | ||
|
||
url = file_helpers.get_signed_file_url(upload_file_id=upload_file.id) | ||
return { | ||
"id": upload_file.id, | ||
"name": upload_file.name, | ||
"size": upload_file.size, | ||
"extension": upload_file.extension, | ||
"url": url, | ||
"download_url": f"{url}&as_attachment=true", | ||
"mime_type": upload_file.mime_type, | ||
"created_by": upload_file.created_by, | ||
"created_at": upload_file.created_at.timestamp(), | ||
}, 200 | ||
|
||
|
||
api.add_resource(UploadFileApi, "/datasets/<uuid:dataset_id>/documents/<uuid:document_id>/upload-file") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Oops, something went wrong.