Spaces:
Sleeping
Sleeping
rearrange project files structure & update test data
Browse files- .gitignore +1 -1
- data_test.py β _data_test.py +4 -4
- _secret.template.py +11 -0
- test.py β _test.py +5 -5
- app.py +2 -21
- config_secret.tmpl.py +0 -3
- font/OFL.txt +0 -94
- font/PTSans-Bold.ttf +0 -3
- font/PTSans-BoldItalic.ttf +0 -3
- font/PTSans-Italic.ttf +0 -3
- font/PTSans-Regular.ttf +0 -3
- font/Testimonia More Info.txt +0 -25
- font/Testimonia.otf +0 -3
- font/Testimonia.ttf +0 -3
- taskNonAI.py +2 -2
- Signature.png β typst/Signature.png +0 -0
- typst/letter.typ +17 -0
- template_base.typ β typst/template_base.typ +0 -0
- template_letter.tmpl β typst/template_letter.tmpl +0 -0
.gitignore
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
*_secret.py
|
2 |
*_secret.py*
|
3 |
-
test_result.pdf
|
4 |
|
5 |
.local/
|
6 |
.ruff_cache/
|
|
|
1 |
*_secret.py
|
2 |
*_secret.py*
|
3 |
+
**test_result.pdf
|
4 |
|
5 |
.local/
|
6 |
.ruff_cache/
|
data_test.py β _data_test.py
RENAMED
@@ -71,10 +71,10 @@ Languages:
|
|
71 |
Fluent in English and French
|
72 |
"""
|
73 |
pdf_context = {
|
74 |
-
"companyFullName": "
|
75 |
-
"jobTitle": "
|
76 |
-
"applicantFullName": "
|
77 |
-
"applicantContactInformation": "
|
78 |
"letter_body": "text,\n\ntest test"
|
79 |
}
|
80 |
|
|
|
71 |
Fluent in English and French
|
72 |
"""
|
73 |
pdf_context = {
|
74 |
+
"companyFullName": "Queen of Hearts' Garden",
|
75 |
+
"jobTitle": "Card Guards",
|
76 |
+
"applicantFullName": "Sherlock Holmes",
|
77 |
+
"applicantContactInformation": "221B Baker Street, London, +44 (020) 1234-5678, sherlock.holmes@sherlockHolmes.com",
|
78 |
"letter_body": "text,\n\ntest test"
|
79 |
}
|
80 |
|
_secret.template.py
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from util import zip_api
|
2 |
+
|
3 |
+
api_test = zip_api(
|
4 |
+
api_base="",
|
5 |
+
api_key="",
|
6 |
+
model=""
|
7 |
+
)
|
8 |
+
|
9 |
+
cmd = """
|
10 |
+
OPENAI_API_BASE="" OPENAI_API_KEY="" CHEAP_MODEL="" STRONG_MODEL="" run.sh
|
11 |
+
"""
|
test.py β _test.py
RENAMED
@@ -1,13 +1,13 @@
|
|
1 |
from taskAI import TaskAI
|
2 |
from taskNonAI import compile_pdf
|
3 |
-
from
|
4 |
-
from
|
5 |
|
6 |
from llama_index.llms.openai_like import OpenAILike
|
7 |
from llama_index.core.llms import ChatMessage
|
8 |
|
9 |
|
10 |
-
def
|
11 |
messages = [
|
12 |
ChatMessage(role="system", content="You are a helpful assistant"),
|
13 |
ChatMessage(role="user", content="What is your name"),
|
@@ -29,10 +29,10 @@ def test_taskAI():
|
|
29 |
print(chunk)
|
30 |
|
31 |
def test_typst_pdf():
|
32 |
-
compile_pdf(tmpl_path='template_letter.tmpl',context=pdf_context, output_path='test_result.pdf')
|
33 |
# os
|
34 |
|
35 |
if __name__ == "__main__":
|
36 |
# test_taskAI()
|
37 |
-
#
|
38 |
test_typst_pdf()
|
|
|
1 |
from taskAI import TaskAI
|
2 |
from taskNonAI import compile_pdf
|
3 |
+
from _data_test import mock_jd, mock_cv, pdf_context
|
4 |
+
from _secret import api_test
|
5 |
|
6 |
from llama_index.llms.openai_like import OpenAILike
|
7 |
from llama_index.core.llms import ChatMessage
|
8 |
|
9 |
|
10 |
+
def test_ai_integration():
|
11 |
messages = [
|
12 |
ChatMessage(role="system", content="You are a helpful assistant"),
|
13 |
ChatMessage(role="user", content="What is your name"),
|
|
|
29 |
print(chunk)
|
30 |
|
31 |
def test_typst_pdf():
|
32 |
+
compile_pdf(tmpl_path='typst/template_letter.tmpl', context=pdf_context, output_path='test_result.pdf')
|
33 |
# os
|
34 |
|
35 |
if __name__ == "__main__":
|
36 |
# test_taskAI()
|
37 |
+
# test_ai_integration()
|
38 |
test_typst_pdf()
|
app.py
CHANGED
@@ -7,7 +7,7 @@ from util import stream_together
|
|
7 |
from taskNonAI import extract_url, file_to_html, compile_pdf
|
8 |
from taskAI import TaskAI
|
9 |
## load data
|
10 |
-
from
|
11 |
## ui
|
12 |
import gradio as gr
|
13 |
## dependency
|
@@ -53,20 +53,6 @@ def run_refine(api_base, api_key, api_model, jd_info, cv_text):
|
|
53 |
taskAI.jd_preprocess(input=jd),
|
54 |
taskAI.cv_preprocess(input=cv),
|
55 |
)
|
56 |
-
# result = [""] * 2
|
57 |
-
# while 1:
|
58 |
-
# stop: bool = True
|
59 |
-
# for i in range(len(gen)):
|
60 |
-
# try:
|
61 |
-
# result[i] += next(gen[i]).delta
|
62 |
-
# stop = False
|
63 |
-
# except StopIteration:
|
64 |
-
# # info(f"gen[{i}] exhausted")
|
65 |
-
# pass
|
66 |
-
# yield result
|
67 |
-
# if stop:
|
68 |
-
# info("tasks done")
|
69 |
-
# break
|
70 |
for result in gen:
|
71 |
yield result
|
72 |
|
@@ -87,11 +73,6 @@ def finalize_letter_txt(api_base, api_key, api_model, debug_CoT):
|
|
87 |
for response in taskAI.purify_letter(full_text=debug_CoT):
|
88 |
result += response.delta
|
89 |
yield result
|
90 |
-
# gen = stream_together(
|
91 |
-
# taskAI.purify_letter(full_text=debug_CoT),
|
92 |
-
# )
|
93 |
-
# for result in gen:
|
94 |
-
# yield result
|
95 |
|
96 |
def finalize_letter_pdf(api_base, api_key, api_model, jd, cv, cover_letter_text):
|
97 |
cheapAPI = {"base": api_base, "key": api_key, "model": api_model}
|
@@ -99,7 +80,7 @@ def finalize_letter_pdf(api_base, api_key, api_model, jd, cv, cover_letter_text)
|
|
99 |
meta_data = next(taskAI.get_jobapp_meta(JD=jd, CV=cv))
|
100 |
pdf_context = json.loads(meta_data)
|
101 |
pdf_context["letter_body"] = cover_letter_text
|
102 |
-
return meta_data, compile_pdf(pdf_context,tmpl_path="template_letter.tmpl",output_path=f"/tmp/cover_letter_by_{pdf_context['applicantFullName']}_to_{pdf_context['companyFullName']}.pdf")
|
103 |
|
104 |
with gr.Blocks(
|
105 |
title=DEMO_TITLE,
|
|
|
7 |
from taskNonAI import extract_url, file_to_html, compile_pdf
|
8 |
from taskAI import TaskAI
|
9 |
## load data
|
10 |
+
from _data_test import mock_jd, mock_cv
|
11 |
## ui
|
12 |
import gradio as gr
|
13 |
## dependency
|
|
|
53 |
taskAI.jd_preprocess(input=jd),
|
54 |
taskAI.cv_preprocess(input=cv),
|
55 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
for result in gen:
|
57 |
yield result
|
58 |
|
|
|
73 |
for response in taskAI.purify_letter(full_text=debug_CoT):
|
74 |
result += response.delta
|
75 |
yield result
|
|
|
|
|
|
|
|
|
|
|
76 |
|
77 |
def finalize_letter_pdf(api_base, api_key, api_model, jd, cv, cover_letter_text):
|
78 |
cheapAPI = {"base": api_base, "key": api_key, "model": api_model}
|
|
|
80 |
meta_data = next(taskAI.get_jobapp_meta(JD=jd, CV=cv))
|
81 |
pdf_context = json.loads(meta_data)
|
82 |
pdf_context["letter_body"] = cover_letter_text
|
83 |
+
return meta_data, compile_pdf(pdf_context,tmpl_path="typst/template_letter.tmpl",output_path=f"/tmp/cover_letter_by_{pdf_context['applicantFullName']}_to_{pdf_context['companyFullName']}.pdf")
|
84 |
|
85 |
with gr.Blocks(
|
86 |
title=DEMO_TITLE,
|
config_secret.tmpl.py
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
from util import zip_api
|
2 |
-
|
3 |
-
api_test = zip_api()
|
|
|
|
|
|
|
|
font/OFL.txt
DELETED
@@ -1,94 +0,0 @@
|
|
1 |
-
ο»ΏCopyright (c) 2010, ParaType Ltd. (http://www.paratype.com/public),
|
2 |
-
with Reserved Font Names "PT Sans" and "ParaType".
|
3 |
-
|
4 |
-
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
5 |
-
This license is copied below, and is also available with a FAQ at:
|
6 |
-
https://openfontlicense.org
|
7 |
-
|
8 |
-
|
9 |
-
-----------------------------------------------------------
|
10 |
-
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
11 |
-
-----------------------------------------------------------
|
12 |
-
|
13 |
-
PREAMBLE
|
14 |
-
The goals of the Open Font License (OFL) are to stimulate worldwide
|
15 |
-
development of collaborative font projects, to support the font creation
|
16 |
-
efforts of academic and linguistic communities, and to provide a free and
|
17 |
-
open framework in which fonts may be shared and improved in partnership
|
18 |
-
with others.
|
19 |
-
|
20 |
-
The OFL allows the licensed fonts to be used, studied, modified and
|
21 |
-
redistributed freely as long as they are not sold by themselves. The
|
22 |
-
fonts, including any derivative works, can be bundled, embedded,
|
23 |
-
redistributed and/or sold with any software provided that any reserved
|
24 |
-
names are not used by derivative works. The fonts and derivatives,
|
25 |
-
however, cannot be released under any other type of license. The
|
26 |
-
requirement for fonts to remain under this license does not apply
|
27 |
-
to any document created using the fonts or their derivatives.
|
28 |
-
|
29 |
-
DEFINITIONS
|
30 |
-
"Font Software" refers to the set of files released by the Copyright
|
31 |
-
Holder(s) under this license and clearly marked as such. This may
|
32 |
-
include source files, build scripts and documentation.
|
33 |
-
|
34 |
-
"Reserved Font Name" refers to any names specified as such after the
|
35 |
-
copyright statement(s).
|
36 |
-
|
37 |
-
"Original Version" refers to the collection of Font Software components as
|
38 |
-
distributed by the Copyright Holder(s).
|
39 |
-
|
40 |
-
"Modified Version" refers to any derivative made by adding to, deleting,
|
41 |
-
or substituting -- in part or in whole -- any of the components of the
|
42 |
-
Original Version, by changing formats or by porting the Font Software to a
|
43 |
-
new environment.
|
44 |
-
|
45 |
-
"Author" refers to any designer, engineer, programmer, technical
|
46 |
-
writer or other person who contributed to the Font Software.
|
47 |
-
|
48 |
-
PERMISSION & CONDITIONS
|
49 |
-
Permission is hereby granted, free of charge, to any person obtaining
|
50 |
-
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
51 |
-
redistribute, and sell modified and unmodified copies of the Font
|
52 |
-
Software, subject to the following conditions:
|
53 |
-
|
54 |
-
1) Neither the Font Software nor any of its individual components,
|
55 |
-
in Original or Modified Versions, may be sold by itself.
|
56 |
-
|
57 |
-
2) Original or Modified Versions of the Font Software may be bundled,
|
58 |
-
redistributed and/or sold with any software, provided that each copy
|
59 |
-
contains the above copyright notice and this license. These can be
|
60 |
-
included either as stand-alone text files, human-readable headers or
|
61 |
-
in the appropriate machine-readable metadata fields within text or
|
62 |
-
binary files as long as those fields can be easily viewed by the user.
|
63 |
-
|
64 |
-
3) No Modified Version of the Font Software may use the Reserved Font
|
65 |
-
Name(s) unless explicit written permission is granted by the corresponding
|
66 |
-
Copyright Holder. This restriction only applies to the primary font name as
|
67 |
-
presented to the users.
|
68 |
-
|
69 |
-
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
70 |
-
Software shall not be used to promote, endorse or advertise any
|
71 |
-
Modified Version, except to acknowledge the contribution(s) of the
|
72 |
-
Copyright Holder(s) and the Author(s) or with their explicit written
|
73 |
-
permission.
|
74 |
-
|
75 |
-
5) The Font Software, modified or unmodified, in part or in whole,
|
76 |
-
must be distributed entirely under this license, and must not be
|
77 |
-
distributed under any other license. The requirement for fonts to
|
78 |
-
remain under this license does not apply to any document created
|
79 |
-
using the Font Software.
|
80 |
-
|
81 |
-
TERMINATION
|
82 |
-
This license becomes null and void if any of the above conditions are
|
83 |
-
not met.
|
84 |
-
|
85 |
-
DISCLAIMER
|
86 |
-
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
87 |
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
88 |
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
89 |
-
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
90 |
-
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
91 |
-
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
92 |
-
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
93 |
-
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
94 |
-
OTHER DEALINGS IN THE FONT SOFTWARE.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
font/PTSans-Bold.ttf
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:6233f84e139f226690649b3105c077b0f87ec24a23ca4a18ada298c962a06f4f
|
3 |
-
size 288340
|
|
|
|
|
|
|
|
font/PTSans-BoldItalic.ttf
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:18c002cfa215bac056c4de4399bc9bae6bd009ae1b240738c45ffa39e3dbeb71
|
3 |
-
size 210224
|
|
|
|
|
|
|
|
font/PTSans-Italic.ttf
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:72a98ad8f3c30a29c37aeddfa25baad0983ed9f39137a164262453944d8f05bb
|
3 |
-
size 270920
|
|
|
|
|
|
|
|
font/PTSans-Regular.ttf
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:23b91352992c21de231c39dd77441f7c5c3f3e684f4a06e31b65c63d33427560
|
3 |
-
size 278612
|
|
|
|
|
|
|
|
font/Testimonia More Info.txt
DELETED
@@ -1,25 +0,0 @@
|
|
1 |
-
First of All,
|
2 |
-
|
3 |
-
Thank you for download my product.
|
4 |
-
This product 100% free for personal use & commercial use
|
5 |
-
|
6 |
-
File include :
|
7 |
-
|
8 |
-
1. Testimonia.ttf
|
9 |
-
2. Testimonia.otf
|
10 |
-
|
11 |
-
More Info :
|
12 | |
13 |
-
|
14 |
-
For Donation:
|
15 |
-
paypal.me/jalembe
|
16 |
-
|
17 |
-
My OnlineShop:
|
18 |
-
https://www.creativefabrica.com/ref/53/
|
19 |
-
|
20 |
-
My Portofolio:
|
21 |
-
https://www.behance.net/khurasan
|
22 |
-
|
23 |
-
My web:
|
24 |
-
www.khurasanstudio.com
|
25 |
-
www.mbkaos.com
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
font/Testimonia.otf
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:0436835ce604a4bcfb1993d1dedece1dd1a1827b2231c0a4159802c727857aea
|
3 |
-
size 19584
|
|
|
|
|
|
|
|
font/Testimonia.ttf
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:94fe08b3527c582846900ec15cf5a0e97908a4d26b6d165f249e31ef564d07ec
|
3 |
-
size 32488
|
|
|
|
|
|
|
|
taskNonAI.py
CHANGED
@@ -54,8 +54,8 @@ def compile_pdf(context: dict, tmpl_path: str, output_path="/tmp/cover_letter.pd
|
|
54 |
context = {k: typst_escape(v) for k, v in context.items()}
|
55 |
context.update({'date_string': date()})
|
56 |
letter_typ = tmpl.safe_substitute(context)
|
57 |
-
with open('letter.typ', 'w', encoding='utf8') as f:
|
58 |
f.write(letter_typ)
|
59 |
-
typst.compile('letter.typ', output_path, font_paths=[Path('./fonts/')])
|
60 |
os.remove('letter.typ')
|
61 |
return output_path
|
|
|
54 |
context = {k: typst_escape(v) for k, v in context.items()}
|
55 |
context.update({'date_string': date()})
|
56 |
letter_typ = tmpl.safe_substitute(context)
|
57 |
+
with open('typst/letter.typ', 'w', encoding='utf8') as f:
|
58 |
f.write(letter_typ)
|
59 |
+
typst.compile('typst/letter.typ', output_path, root=Path('./typst/'), font_paths=[Path('./fonts/')])
|
60 |
os.remove('letter.typ')
|
61 |
return output_path
|
Signature.png β typst/Signature.png
RENAMED
File without changes
|
typst/letter.typ
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#import "template_base.typ": *
|
2 |
+
#show: letter.with(
|
3 |
+
sender: [
|
4 |
+
123 Main St., Emerald City, KS 12345, (123) 456-7890, dorothy\@wizardofoz.com
|
5 |
+
],
|
6 |
+
recipient: [
|
7 |
+
Hiring Manager \
|
8 |
+
Mastercard \
|
9 |
+
],
|
10 |
+
date: [March 30th , 2024],
|
11 |
+
subject: [Cover Letter for Project Management Intern],
|
12 |
+
name: [Dorothy Gale],
|
13 |
+
)
|
14 |
+
|
15 |
+
text,
|
16 |
+
|
17 |
+
test test
|
template_base.typ β typst/template_base.typ
RENAMED
File without changes
|
template_letter.tmpl β typst/template_letter.tmpl
RENAMED
File without changes
|