Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -25,6 +25,7 @@ import uuid
|
|
| 25 |
import tqdm
|
| 26 |
|
| 27 |
import requests
|
|
|
|
| 28 |
|
| 29 |
|
| 30 |
def setup_poppler_linux():
|
|
@@ -104,6 +105,7 @@ Authorization = os.environ.get("Authorization")
|
|
| 104 |
client = AsyncOpenAI(
|
| 105 |
api_key=openai_api_key,
|
| 106 |
base_url=openai_api_base + "/v1",
|
|
|
|
| 107 |
)
|
| 108 |
|
| 109 |
|
|
@@ -166,6 +168,7 @@ def encode_image(image_path):
|
|
| 166 |
with open(image_path, "rb") as image_file:
|
| 167 |
return base64.b64encode(image_file.read()).decode("utf-8")
|
| 168 |
|
|
|
|
| 169 |
def build_message(image_path, prompt):
|
| 170 |
|
| 171 |
content = [
|
|
@@ -188,7 +191,6 @@ def build_message(image_path, prompt):
|
|
| 188 |
return messages
|
| 189 |
|
| 190 |
|
| 191 |
-
|
| 192 |
def download_markdown_file(md_text):
|
| 193 |
filename = f"markdown_{uuid.uuid4().hex[:8]}.md"
|
| 194 |
filepath = Path("downloads") / filename
|
|
@@ -252,6 +254,7 @@ def compress_directory_to_zip(directory_path, output_zip_path):
|
|
| 252 |
logger.exception(e)
|
| 253 |
return -1
|
| 254 |
|
|
|
|
| 255 |
latex_delimiters = [
|
| 256 |
{'left': '$$', 'right': '$$', 'display': True},
|
| 257 |
{'left': '$', 'right': '$', 'display': False},
|
|
@@ -259,11 +262,13 @@ latex_delimiters = [
|
|
| 259 |
{'left': '\\[', 'right': '\\]', 'display': True},
|
| 260 |
]
|
| 261 |
|
|
|
|
| 262 |
def check_prompt(prompt):
|
| 263 |
if not prompt or prompt.strip() == "":
|
| 264 |
raise gr.Error("Please select or enter a prompt before parsing.")
|
| 265 |
return prompt
|
| 266 |
|
|
|
|
| 267 |
def to_file(image_path):
|
| 268 |
|
| 269 |
if image_path.endswith("Academic_Papers.png"):
|
|
|
|
| 25 |
import tqdm
|
| 26 |
|
| 27 |
import requests
|
| 28 |
+
import httpx
|
| 29 |
|
| 30 |
|
| 31 |
def setup_poppler_linux():
|
|
|
|
| 105 |
client = AsyncOpenAI(
|
| 106 |
api_key=openai_api_key,
|
| 107 |
base_url=openai_api_base + "/v1",
|
| 108 |
+
http_client=httpx.AsyncClient(verify=False),
|
| 109 |
)
|
| 110 |
|
| 111 |
|
|
|
|
| 168 |
with open(image_path, "rb") as image_file:
|
| 169 |
return base64.b64encode(image_file.read()).decode("utf-8")
|
| 170 |
|
| 171 |
+
|
| 172 |
def build_message(image_path, prompt):
|
| 173 |
|
| 174 |
content = [
|
|
|
|
| 191 |
return messages
|
| 192 |
|
| 193 |
|
|
|
|
| 194 |
def download_markdown_file(md_text):
|
| 195 |
filename = f"markdown_{uuid.uuid4().hex[:8]}.md"
|
| 196 |
filepath = Path("downloads") / filename
|
|
|
|
| 254 |
logger.exception(e)
|
| 255 |
return -1
|
| 256 |
|
| 257 |
+
|
| 258 |
latex_delimiters = [
|
| 259 |
{'left': '$$', 'right': '$$', 'display': True},
|
| 260 |
{'left': '$', 'right': '$', 'display': False},
|
|
|
|
| 262 |
{'left': '\\[', 'right': '\\]', 'display': True},
|
| 263 |
]
|
| 264 |
|
| 265 |
+
|
| 266 |
def check_prompt(prompt):
|
| 267 |
if not prompt or prompt.strip() == "":
|
| 268 |
raise gr.Error("Please select or enter a prompt before parsing.")
|
| 269 |
return prompt
|
| 270 |
|
| 271 |
+
|
| 272 |
def to_file(image_path):
|
| 273 |
|
| 274 |
if image_path.endswith("Academic_Papers.png"):
|