forked from langgenius/dify
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'lindorm-vdb' of github.com:AlwaysBluer/dify into lindor…
…m-vdb * 'lindorm-vdb' of github.com:AlwaysBluer/dify: (39 commits) Feat : add LLM model indicator in prompt generator (langgenius#10187) chore: enable vision support for models in OpenRouter that should have supported vision (langgenius#10191) chore : code generator preview hint (langgenius#10188) fix: webapp upload file (langgenius#10195) fix(api): replace current_user with end_user in file upload (langgenius#10194) feat(document_extractor): integrate unstructured API for PPTX extraction (langgenius#10180) fix(tools): suppress RuntimeWarnings in podcast audio generator (langgenius#10182) [fix] fix the bug that modify document name not effective (langgenius#10154) fix(workflow model): ensure consistent timestamp updating (langgenius#10172) fix: Cannot find declaration to go to CLEAN_DAY_SETTING (langgenius#10157) feat: add gpustack model provider (langgenius#10158) refactor(tools): Avoid warnings. (langgenius#10161) refactor(migration/model): update column types for workflow schema (langgenius#10160) Feat/add-remote-file-upload-api (langgenius#9906) fix: upload remote image preview (langgenius#9952) clean un-allowed special charters when doing indexing estimate (langgenius#10153) refactor(service): handle unsupported DSL version with warning (langgenius#10151) Add VESSL AI OpenAI API-compatible model provider and LLM model (langgenius#9474) feat: synchronize input/output variables in the panel with generated code by the code generator (langgenius#10150) Refined README for better reading experience. (langgenius#10143) ...
- Loading branch information
Showing
158 changed files
with
3,323 additions
and
851 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from werkzeug.exceptions import HTTPException | ||
|
||
|
||
class FilenameNotExistsError(HTTPException): | ||
code = 400 | ||
description = "The specified filename does not exist." |
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,58 @@ | ||
import mimetypes | ||
import os | ||
import re | ||
import urllib.parse | ||
from uuid import uuid4 | ||
|
||
import httpx | ||
from pydantic import BaseModel | ||
|
||
|
||
class FileInfo(BaseModel): | ||
filename: str | ||
extension: str | ||
mimetype: str | ||
size: int | ||
|
||
|
||
def guess_file_info_from_response(response: httpx.Response): | ||
url = str(response.url) | ||
# Try to extract filename from URL | ||
parsed_url = urllib.parse.urlparse(url) | ||
url_path = parsed_url.path | ||
filename = os.path.basename(url_path) | ||
|
||
# If filename couldn't be extracted, use Content-Disposition header | ||
if not filename: | ||
content_disposition = response.headers.get("Content-Disposition") | ||
if content_disposition: | ||
filename_match = re.search(r'filename="?(.+)"?', content_disposition) | ||
if filename_match: | ||
filename = filename_match.group(1) | ||
|
||
# If still no filename, generate a unique one | ||
if not filename: | ||
unique_name = str(uuid4()) | ||
filename = f"{unique_name}" | ||
|
||
# Guess MIME type from filename first, then URL | ||
mimetype, _ = mimetypes.guess_type(filename) | ||
if mimetype is None: | ||
mimetype, _ = mimetypes.guess_type(url) | ||
if mimetype is None: | ||
# If guessing fails, use Content-Type from response headers | ||
mimetype = response.headers.get("Content-Type", "application/octet-stream") | ||
|
||
extension = os.path.splitext(filename)[1] | ||
|
||
# Ensure filename has an extension | ||
if not extension: | ||
extension = mimetypes.guess_extension(mimetype) or ".bin" | ||
filename = f"{filename}{extension}" | ||
|
||
return FileInfo( | ||
filename=filename, | ||
extension=extension, | ||
mimetype=mimetype, | ||
size=int(response.headers.get("Content-Length", -1)), | ||
) |
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
Oops, something went wrong.