mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-12 12:25:20 +00:00
refac
This commit is contained in:
parent
5db60ca34f
commit
e8696c63fe
3 changed files with 6 additions and 9 deletions
|
|
@ -64,7 +64,7 @@ class DatalabMarkerLoader:
|
||||||
return mime_map.get(ext, "application/octet-stream")
|
return mime_map.get(ext, "application/octet-stream")
|
||||||
|
|
||||||
def check_marker_request_status(self, request_id: str) -> dict:
|
def check_marker_request_status(self, request_id: str) -> dict:
|
||||||
url = f"{self.api_base_url}/{request_id}"
|
url = f"{self.api_base_url}/marker/{request_id}"
|
||||||
headers = {"X-Api-Key": self.api_key}
|
headers = {"X-Api-Key": self.api_key}
|
||||||
try:
|
try:
|
||||||
response = requests.get(url, headers=headers)
|
response = requests.get(url, headers=headers)
|
||||||
|
|
@ -85,7 +85,6 @@ class DatalabMarkerLoader:
|
||||||
)
|
)
|
||||||
|
|
||||||
def load(self) -> List[Document]:
|
def load(self) -> List[Document]:
|
||||||
url = self.api_base_url
|
|
||||||
filename = os.path.basename(self.file_path)
|
filename = os.path.basename(self.file_path)
|
||||||
mime_type = self._get_mime_type(filename)
|
mime_type = self._get_mime_type(filename)
|
||||||
headers = {"X-Api-Key": self.api_key}
|
headers = {"X-Api-Key": self.api_key}
|
||||||
|
|
@ -112,7 +111,10 @@ class DatalabMarkerLoader:
|
||||||
with open(self.file_path, "rb") as f:
|
with open(self.file_path, "rb") as f:
|
||||||
files = {"file": (filename, f, mime_type)}
|
files = {"file": (filename, f, mime_type)}
|
||||||
response = requests.post(
|
response = requests.post(
|
||||||
url, data=form_data, files=files, headers=headers
|
f"{self.api_base_url}/marker",
|
||||||
|
data=form_data,
|
||||||
|
files=files,
|
||||||
|
headers=headers,
|
||||||
)
|
)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
result = response.json()
|
result = response.json()
|
||||||
|
|
|
||||||
|
|
@ -283,7 +283,7 @@ class Loader:
|
||||||
):
|
):
|
||||||
api_base_url = self.kwargs.get("DATALAB_MARKER_API_BASE_URL", "")
|
api_base_url = self.kwargs.get("DATALAB_MARKER_API_BASE_URL", "")
|
||||||
if not api_base_url or api_base_url.strip() == "":
|
if not api_base_url or api_base_url.strip() == "":
|
||||||
api_base_url = "https://www.datalab.to/api/v1/marker"
|
api_base_url = "https://www.datalab.to/api/v1"
|
||||||
|
|
||||||
loader = DatalabMarkerLoader(
|
loader = DatalabMarkerLoader(
|
||||||
file_path=file_path,
|
file_path=file_path,
|
||||||
|
|
|
||||||
|
|
@ -252,11 +252,6 @@
|
||||||
2
|
2
|
||||||
);
|
);
|
||||||
|
|
||||||
// Set default API Base URL if empty
|
|
||||||
if (!config.DATALAB_MARKER_API_BASE_URL) {
|
|
||||||
config.DATALAB_MARKER_API_BASE_URL = 'https://www.datalab.to/api/v1/marker';
|
|
||||||
}
|
|
||||||
|
|
||||||
RAGConfig = config;
|
RAGConfig = config;
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue