Spaces:
Running
Running
fix: bugs around dir update
Browse files- .gitignore +1 -0
- app/app.py +6 -4
- app/taskNonAI.py +4 -4
.gitignore
CHANGED
|
@@ -3,6 +3,7 @@
|
|
| 3 |
**/test_result.pdf
|
| 4 |
**/letter.typ
|
| 5 |
**/cover_letter_*.typ
|
|
|
|
| 6 |
|
| 7 |
.local/
|
| 8 |
.ruff_cache/
|
|
|
|
| 3 |
**/test_result.pdf
|
| 4 |
**/letter.typ
|
| 5 |
**/cover_letter_*.typ
|
| 6 |
+
**/cover_letter_*.pdf
|
| 7 |
|
| 8 |
.local/
|
| 9 |
.ruff_cache/
|
app/app.py
CHANGED
|
@@ -4,7 +4,7 @@ from config import STRONG_API_BASE, STRONG_API_KEY, STRONG_MODEL
|
|
| 4 |
from util import is_valid_url
|
| 5 |
from util import mylogger
|
| 6 |
from util import stream_together
|
| 7 |
-
from util import checkAPI
|
| 8 |
from taskNonAI import extract_url, file_to_html, compile_pdf
|
| 9 |
from taskAI import TaskAI
|
| 10 |
|
|
@@ -136,8 +136,8 @@ def finalize_letter_pdf(
|
|
| 136 |
pdf_context["letter_body"] = cover_letter_text
|
| 137 |
return meta_data, compile_pdf(
|
| 138 |
pdf_context,
|
| 139 |
-
tmpl_path="typst/template_letter.tmpl",
|
| 140 |
-
output_path=f"
|
| 141 |
is_debug=is_debug,
|
| 142 |
)
|
| 143 |
|
|
@@ -259,7 +259,9 @@ with gr.Blocks(
|
|
| 259 |
],
|
| 260 |
outputs=[strong_base, strong_key, strong_model],
|
| 261 |
).then(
|
| 262 |
-
fn=lambda: gr.Accordion("AI setup (OpenAI-compatible LLM API)", open=True),
|
|
|
|
|
|
|
| 263 |
)
|
| 264 |
|
| 265 |
infer_btn.click(
|
|
|
|
| 4 |
from util import is_valid_url
|
| 5 |
from util import mylogger
|
| 6 |
from util import stream_together
|
| 7 |
+
# from util import checkAPI
|
| 8 |
from taskNonAI import extract_url, file_to_html, compile_pdf
|
| 9 |
from taskAI import TaskAI
|
| 10 |
|
|
|
|
| 136 |
pdf_context["letter_body"] = cover_letter_text
|
| 137 |
return meta_data, compile_pdf(
|
| 138 |
pdf_context,
|
| 139 |
+
tmpl_path="app/typst/template_letter.tmpl",
|
| 140 |
+
output_path=f"cover_letter_by_{pdf_context['applicantFullName']}_to_{pdf_context['companyFullName']}.pdf",
|
| 141 |
is_debug=is_debug,
|
| 142 |
)
|
| 143 |
|
|
|
|
| 259 |
],
|
| 260 |
outputs=[strong_base, strong_key, strong_model],
|
| 261 |
).then(
|
| 262 |
+
fn=lambda: gr.Accordion("AI setup (OpenAI-compatible LLM API)", open=True),
|
| 263 |
+
inputs=None,
|
| 264 |
+
outputs=[setup_zone],
|
| 265 |
)
|
| 266 |
|
| 267 |
infer_btn.click(
|
app/taskNonAI.py
CHANGED
|
@@ -63,10 +63,10 @@ def _ensure_no_signature_in_body(cover_letter_body: str) -> str:
|
|
| 63 |
|
| 64 |
|
| 65 |
def compile_pdf(
|
| 66 |
-
context: dict, tmpl_path: str, output_path="
|
| 67 |
) -> list[str]:
|
| 68 |
# letter_src_filepath = "typst/letter.typ"
|
| 69 |
-
letter_src_filepath = "typst/" + output_path.split("/")[-1][: -len(".pdf")] + ".typ"
|
| 70 |
with open(tmpl_path, "r", encoding="utf8") as f:
|
| 71 |
tmpl = Template(f.read())
|
| 72 |
context = {k: _typst_escape(v) for k, v in context.items()}
|
|
@@ -79,8 +79,8 @@ def compile_pdf(
|
|
| 79 |
typst.compile(
|
| 80 |
letter_src_filepath,
|
| 81 |
output_path,
|
| 82 |
-
root=Path("
|
| 83 |
-
font_paths=[Path("
|
| 84 |
)
|
| 85 |
# os.remove(letter_src_filepath)
|
| 86 |
if is_debug:
|
|
|
|
| 63 |
|
| 64 |
|
| 65 |
def compile_pdf(
|
| 66 |
+
context: dict, tmpl_path: str, output_path="cover_letter.pdf", is_debug=False
|
| 67 |
) -> list[str]:
|
| 68 |
# letter_src_filepath = "typst/letter.typ"
|
| 69 |
+
letter_src_filepath = "app/typst/" + output_path.split("/")[-1][: -len(".pdf")] + ".typ"
|
| 70 |
with open(tmpl_path, "r", encoding="utf8") as f:
|
| 71 |
tmpl = Template(f.read())
|
| 72 |
context = {k: _typst_escape(v) for k, v in context.items()}
|
|
|
|
| 79 |
typst.compile(
|
| 80 |
letter_src_filepath,
|
| 81 |
output_path,
|
| 82 |
+
root=Path("app/typst/"),
|
| 83 |
+
font_paths=[Path("app/fonts/")],
|
| 84 |
)
|
| 85 |
# os.remove(letter_src_filepath)
|
| 86 |
if is_debug:
|