Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -27,7 +27,7 @@ def process_resumes(files, candidate_id: str, additional_notes: str = ""):
|
|
| 27 |
partial_records = []
|
| 28 |
raw_texts = []
|
| 29 |
|
| 30 |
-
# files は 'filepath'
|
| 31 |
for path in files:
|
| 32 |
filepath = str(path)
|
| 33 |
filename = os.path.basename(filepath)
|
|
@@ -36,16 +36,16 @@ def process_resumes(files, candidate_id: str, additional_notes: str = ""):
|
|
| 36 |
|
| 37 |
filetype = detect_filetype(filename, raw_bytes)
|
| 38 |
|
| 39 |
-
# 1)
|
| 40 |
if filetype in {"pdf", "image"}:
|
| 41 |
text = extract_text_with_openai(raw_bytes, filename=filename, filetype=filetype)
|
| 42 |
-
|
| 43 |
base_text = load_doc_text(filetype, raw_bytes)
|
| 44 |
text = extract_text_with_openai(base_text.encode("utf-8"), filename=filename, filetype="txt")
|
| 45 |
|
| 46 |
raw_texts.append({"filename": filename, "text": text})
|
| 47 |
|
| 48 |
-
# 2)
|
| 49 |
structured = structure_with_openai(text)
|
| 50 |
normalized = normalize_resume({
|
| 51 |
"work_experience": structured.get("work_experience_raw", ""),
|
|
@@ -60,7 +60,7 @@ def process_resumes(files, candidate_id: str, additional_notes: str = ""):
|
|
| 60 |
"normalized": normalized,
|
| 61 |
})
|
| 62 |
|
| 63 |
-
# 3)
|
| 64 |
merged = merge_normalized_records([r["normalized"] for r in partial_records])
|
| 65 |
|
| 66 |
# 4) スキル抽出
|
|
@@ -112,7 +112,7 @@ def process_resumes(files, candidate_id: str, additional_notes: str = ""):
|
|
| 112 |
|
| 113 |
return (
|
| 114 |
json.dumps(result_json, ensure_ascii=False, indent=2),
|
| 115 |
-
json.dumps(skills, ensure_ascii=False, indent=2), # ←
|
| 116 |
json.dumps(score, ensure_ascii=False, indent=2),
|
| 117 |
summaries["300chars"],
|
| 118 |
summaries["100chars"],
|
|
@@ -130,7 +130,7 @@ with gr.Blocks(title=APP_TITLE) as demo:
|
|
| 130 |
label="レジュメ類 (PDF/画像/Word/テキスト) 複数可",
|
| 131 |
file_count="multiple",
|
| 132 |
file_types=[".pdf", ".png", ".jpg", ".jpeg", ".tiff", ".bmp", ".docx", ".txt"],
|
| 133 |
-
type="filepath", # ← 重要:'file'
|
| 134 |
)
|
| 135 |
candidate_id = gr.Textbox(label="候補者ID(任意。未入力なら自動生成)")
|
| 136 |
notes = gr.Textbox(label="補足メモ(任意)", lines=3)
|
|
@@ -141,7 +141,7 @@ with gr.Blocks(title=APP_TITLE) as demo:
|
|
| 141 |
out_json = gr.Code(label="統合出力 (JSON)")
|
| 142 |
|
| 143 |
with gr.Tab("抽出スキル"):
|
| 144 |
-
out_skills = gr.Code(label="スキル一覧 (JSON)") # ← gr.JSON
|
| 145 |
|
| 146 |
with gr.Tab("品質スコア"):
|
| 147 |
out_score = gr.Code(label="品質評価")
|
|
@@ -165,4 +165,4 @@ with gr.Blocks(title=APP_TITLE) as demo:
|
|
| 165 |
|
| 166 |
|
| 167 |
if __name__ == "__main__":
|
| 168 |
-
demo.launch(share=True) # ←
|
|
|
|
| 27 |
partial_records = []
|
| 28 |
raw_texts = []
|
| 29 |
|
| 30 |
+
# files は 'filepath'(文字列パス)
|
| 31 |
for path in files:
|
| 32 |
filepath = str(path)
|
| 33 |
filename = os.path.basename(filepath)
|
|
|
|
| 36 |
|
| 37 |
filetype = detect_filetype(filename, raw_bytes)
|
| 38 |
|
| 39 |
+
# 1) テキスト抽出
|
| 40 |
if filetype in {"pdf", "image"}:
|
| 41 |
text = extract_text_with_openai(raw_bytes, filename=filename, filetype=filetype)
|
| 42 |
+
else:
|
| 43 |
base_text = load_doc_text(filetype, raw_bytes)
|
| 44 |
text = extract_text_with_openai(base_text.encode("utf-8"), filename=filename, filetype="txt")
|
| 45 |
|
| 46 |
raw_texts.append({"filename": filename, "text": text})
|
| 47 |
|
| 48 |
+
# 2) 構造化 → 正規化
|
| 49 |
structured = structure_with_openai(text)
|
| 50 |
normalized = normalize_resume({
|
| 51 |
"work_experience": structured.get("work_experience_raw", ""),
|
|
|
|
| 60 |
"normalized": normalized,
|
| 61 |
})
|
| 62 |
|
| 63 |
+
# 3) 統合
|
| 64 |
merged = merge_normalized_records([r["normalized"] for r in partial_records])
|
| 65 |
|
| 66 |
# 4) スキル抽出
|
|
|
|
| 112 |
|
| 113 |
return (
|
| 114 |
json.dumps(result_json, ensure_ascii=False, indent=2),
|
| 115 |
+
json.dumps(skills, ensure_ascii=False, indent=2), # ← Codeに渡すため文字列に
|
| 116 |
json.dumps(score, ensure_ascii=False, indent=2),
|
| 117 |
summaries["300chars"],
|
| 118 |
summaries["100chars"],
|
|
|
|
| 130 |
label="レジュメ類 (PDF/画像/Word/テキスト) 複数可",
|
| 131 |
file_count="multiple",
|
| 132 |
file_types=[".pdf", ".png", ".jpg", ".jpeg", ".tiff", ".bmp", ".docx", ".txt"],
|
| 133 |
+
type="filepath", # ← 重要:'file' ではなく 'filepath'
|
| 134 |
)
|
| 135 |
candidate_id = gr.Textbox(label="候補者ID(任意。未入力なら自動生成)")
|
| 136 |
notes = gr.Textbox(label="補足メモ(任意)", lines=3)
|
|
|
|
| 141 |
out_json = gr.Code(label="統合出力 (JSON)")
|
| 142 |
|
| 143 |
with gr.Tab("抽出スキル"):
|
| 144 |
+
out_skills = gr.Code(label="スキル一覧 (JSON)") # ← gr.JSON から変更
|
| 145 |
|
| 146 |
with gr.Tab("品質スコア"):
|
| 147 |
out_score = gr.Code(label="品質評価")
|
|
|
|
| 165 |
|
| 166 |
|
| 167 |
if __name__ == "__main__":
|
| 168 |
+
demo.launch(share=True) # ← 必須
|