Spaces:
Running
Running
レビューを受けて修正
Browse files
.gitignore
CHANGED
@@ -162,11 +162,9 @@ cython_debug/
|
|
162 |
|
163 |
.DS_Store
|
164 |
|
165 |
-
#
|
166 |
-
data/
|
167 |
-
data/
|
168 |
-
data/output_deviation.docx
|
169 |
-
data/output_deviation_occurrence.docx
|
170 |
|
171 |
# ログフォルダ
|
172 |
logs
|
|
|
162 |
|
163 |
.DS_Store
|
164 |
|
165 |
+
# 連絡書/調査報告書はリポジトリにはアップロードしない。
|
166 |
+
data/output_deviation_notification.docx
|
167 |
+
data/output_deviation_investigation.docx
|
|
|
|
|
168 |
|
169 |
# ログフォルダ
|
170 |
logs
|
data/template/template_deviation_notification.docx
CHANGED
Binary files a/data/template/template_deviation_notification.docx and b/data/template/template_deviation_notification.docx differ
|
|
src/forms/deviation_notification_report.py
CHANGED
@@ -42,22 +42,22 @@ def deviation_notification_report_form() -> None:
|
|
42 |
st.session_state["product_name"] = ""
|
43 |
if "item_code" not in st.session_state:
|
44 |
st.session_state["item_code"] = ""
|
45 |
-
if "
|
46 |
-
st.session_state["
|
47 |
if "standard_number" not in st.session_state:
|
48 |
st.session_state["standard_number"] = ""
|
49 |
if "lot_number" not in st.session_state:
|
50 |
st.session_state["lot_number"] = ""
|
51 |
-
if "
|
52 |
-
st.session_state["
|
53 |
if "occurrence_place" not in st.session_state:
|
54 |
st.session_state["occurrence_place"] = ""
|
55 |
if "discoverer" not in st.session_state:
|
56 |
st.session_state["discoverer"] = ""
|
57 |
-
if "
|
58 |
-
st.session_state["
|
59 |
-
if "
|
60 |
-
st.session_state["
|
61 |
if "first_report_date" not in st.session_state:
|
62 |
st.session_state["first_report_date"] = date.today()
|
63 |
if "survey_department" not in st.session_state:
|
@@ -90,7 +90,7 @@ def deviation_notification_report_form() -> None:
|
|
90 |
|
91 |
col1, col2 = st.columns(2)
|
92 |
with col1:
|
93 |
-
st.text_input("工程名", key="
|
94 |
with col2:
|
95 |
st.text_input("標準書番号", key="standard_number")
|
96 |
|
@@ -98,7 +98,7 @@ def deviation_notification_report_form() -> None:
|
|
98 |
with col1:
|
99 |
st.text_input("ロット番号", key="lot_number")
|
100 |
with col2:
|
101 |
-
st.text_input("課名", key="
|
102 |
|
103 |
col1, col2 = st.columns(2)
|
104 |
with col1:
|
@@ -137,7 +137,7 @@ def deviation_notification_report_form() -> None:
|
|
137 |
"Q14 : その他の品質への影響があれば記入してください。",
|
138 |
]
|
139 |
|
140 |
-
|
141 |
"",
|
142 |
"",
|
143 |
"",
|
@@ -155,15 +155,15 @@ def deviation_notification_report_form() -> None:
|
|
155 |
]
|
156 |
q_num = len(q)
|
157 |
|
158 |
-
|
159 |
-
|
160 |
st.markdown("***")
|
161 |
for k in range(q_num):
|
162 |
-
|
163 |
-
q[k], key=f"input_deviatoin_notification_{k}"
|
164 |
-
)
|
165 |
if k > 2:
|
166 |
-
|
|
|
|
|
167 |
st.markdown("***")
|
168 |
|
169 |
st.text_area(
|
@@ -188,24 +188,23 @@ def deviation_notification_report_form() -> None:
|
|
188 |
|
189 |
if submitted or st.session_state["document_generated"]:
|
190 |
for i in range(q_num - 3):
|
191 |
-
if
|
192 |
-
|
193 |
|
194 |
if no_attached_file:
|
195 |
attached_files = "なし"
|
196 |
|
197 |
-
system_prompt =
|
198 |
-
deviation_notification_systemprompt_output_format_instructions
|
199 |
-
)
|
200 |
for k in range(q_num):
|
201 |
system_prompt += q[k]
|
202 |
system_prompt += "\n"
|
203 |
-
system_prompt +=
|
|
|
|
|
204 |
|
205 |
user_prompt = ""
|
206 |
for k in range(q_num):
|
207 |
-
user_prompt += f" A{k+1} : {
|
208 |
-
user_prompt += "\n"
|
209 |
|
210 |
logger.info("システムプロンプト(逸脱連絡書作成用): " + system_prompt)
|
211 |
logger.info("ユーザプロンプト(逸脱連絡書作成用): " + user_prompt)
|
@@ -266,10 +265,10 @@ def deviation_notification_report_form() -> None:
|
|
266 |
"管理番号": st.session_state["control_number"],
|
267 |
"品名": st.session_state["product_name"],
|
268 |
"品目コード": st.session_state["item_code"],
|
269 |
-
"工程名": st.session_state["
|
270 |
"標準書番号": st.session_state["standard_number"],
|
271 |
"ロット番号": st.session_state["lot_number"],
|
272 |
-
"課名": st.session_state["
|
273 |
"発生場所": st.session_state["occurrence_place"],
|
274 |
"発見者": st.session_state["discoverer"],
|
275 |
"発生日": formatted_occurrence_date,
|
@@ -288,7 +287,6 @@ def deviation_notification_report_form() -> None:
|
|
288 |
"措置の実施部署": st.session_state["measures_department"],
|
289 |
"調査回答期限(30営業日)": formatted_survey_response_deadline,
|
290 |
"添付資料": attached_files,
|
291 |
-
"ユーザープロンプト": user_prompt,
|
292 |
}
|
293 |
logger.info(
|
294 |
"wordテンプレート変数の置換用のjson: "
|
|
|
42 |
st.session_state["product_name"] = ""
|
43 |
if "item_code" not in st.session_state:
|
44 |
st.session_state["item_code"] = ""
|
45 |
+
if "process_name" not in st.session_state:
|
46 |
+
st.session_state["process_name"] = ""
|
47 |
if "standard_number" not in st.session_state:
|
48 |
st.session_state["standard_number"] = ""
|
49 |
if "lot_number" not in st.session_state:
|
50 |
st.session_state["lot_number"] = ""
|
51 |
+
if "section_name" not in st.session_state:
|
52 |
+
st.session_state["section_name"] = ""
|
53 |
if "occurrence_place" not in st.session_state:
|
54 |
st.session_state["occurrence_place"] = ""
|
55 |
if "discoverer" not in st.session_state:
|
56 |
st.session_state["discoverer"] = ""
|
57 |
+
if "occurrence_date" not in st.session_state:
|
58 |
+
st.session_state["occurrence_date"] = date.today()
|
59 |
+
if "discovery_date" not in st.session_state:
|
60 |
+
st.session_state["discovery_date"] = date.today()
|
61 |
if "first_report_date" not in st.session_state:
|
62 |
st.session_state["first_report_date"] = date.today()
|
63 |
if "survey_department" not in st.session_state:
|
|
|
90 |
|
91 |
col1, col2 = st.columns(2)
|
92 |
with col1:
|
93 |
+
st.text_input("工程名", key="process_name")
|
94 |
with col2:
|
95 |
st.text_input("標準書番号", key="standard_number")
|
96 |
|
|
|
98 |
with col1:
|
99 |
st.text_input("ロット番号", key="lot_number")
|
100 |
with col2:
|
101 |
+
st.text_input("課名", key="section_name")
|
102 |
|
103 |
col1, col2 = st.columns(2)
|
104 |
with col1:
|
|
|
137 |
"Q14 : その他の品質への影響があれば記入してください。",
|
138 |
]
|
139 |
|
140 |
+
negative_answers = [
|
141 |
"",
|
142 |
"",
|
143 |
"",
|
|
|
155 |
]
|
156 |
q_num = len(q)
|
157 |
|
158 |
+
answers = [""] * q_num
|
159 |
+
no_answer_checkbox = [False] * q_num
|
160 |
st.markdown("***")
|
161 |
for k in range(q_num):
|
162 |
+
answers[k] = st.text_area(q[k], key=f"answers_{k}")
|
|
|
|
|
163 |
if k > 2:
|
164 |
+
no_answer_checkbox[k] = st.checkbox(
|
165 |
+
f"{negative_answers[k]}", key=f"check_{k}"
|
166 |
+
)
|
167 |
st.markdown("***")
|
168 |
|
169 |
st.text_area(
|
|
|
188 |
|
189 |
if submitted or st.session_state["document_generated"]:
|
190 |
for i in range(q_num - 3):
|
191 |
+
if no_answer_checkbox[i + 2]:
|
192 |
+
answers[i + 3] = negative_answers[i + 3]
|
193 |
|
194 |
if no_attached_file:
|
195 |
attached_files = "なし"
|
196 |
|
197 |
+
system_prompt = deviation_notification_systemprompt_writing_instructions
|
|
|
|
|
198 |
for k in range(q_num):
|
199 |
system_prompt += q[k]
|
200 |
system_prompt += "\n"
|
201 |
+
system_prompt += (
|
202 |
+
deviation_notification_systemprompt_output_format_instructions
|
203 |
+
)
|
204 |
|
205 |
user_prompt = ""
|
206 |
for k in range(q_num):
|
207 |
+
user_prompt += f" A{k+1} : {answers[k]}"
|
|
|
208 |
|
209 |
logger.info("システムプロンプト(逸脱連絡書作成用): " + system_prompt)
|
210 |
logger.info("ユーザプロンプト(逸脱連絡書作成用): " + user_prompt)
|
|
|
265 |
"管理番号": st.session_state["control_number"],
|
266 |
"品名": st.session_state["product_name"],
|
267 |
"品目コード": st.session_state["item_code"],
|
268 |
+
"工程名": st.session_state["process_name"],
|
269 |
"標準書番号": st.session_state["standard_number"],
|
270 |
"ロット番号": st.session_state["lot_number"],
|
271 |
+
"課名": st.session_state["section_name"],
|
272 |
"発生場所": st.session_state["occurrence_place"],
|
273 |
"発見者": st.session_state["discoverer"],
|
274 |
"発生日": formatted_occurrence_date,
|
|
|
287 |
"措置の実施部署": st.session_state["measures_department"],
|
288 |
"調査回答期限(30営業日)": formatted_survey_response_deadline,
|
289 |
"添付資料": attached_files,
|
|
|
290 |
}
|
291 |
logger.info(
|
292 |
"wordテンプレート変数の置換用のjson: "
|
src/prompts/deviation_notification_report.py
CHANGED
@@ -7,11 +7,11 @@ deviation_notification_systemprompt_writing_instructions = """
|
|
7 |
***
|
8 |
あなたは、質問に対して入力された情報から、詳しい内容を含んだ逸脱連絡書の文章を生成するアシスタントです。\n
|
9 |
上記の形式に従って、入力された情報を当てはめて出力してください。連絡書の読みやすさ、明瞭さ、正確さに注意してください。\n
|
10 |
-
|
11 |
調査や措置に関することは「調査(根本原因・品質影響等)の提案」「措置(回復措置・製品等に対する措置)の提案」に記載し、それ以外の現時点で判明している状況等は全て「逸脱概要」に記載してください。\n
|
12 |
項目に記載する内容がない場合は空白にせず、「なし」と明記してください。\n
|
13 |
また、入力された内容をそのまま記載するのではなく、正しい日本語表現かどうかに注意し、わかりやすく簡潔な表現に直して記載してください。\n
|
14 |
-
|
15 |
あなたは返答をすべてJSON形式で出力します。\n
|
16 |
あなたが質問した内容は以下です。\n
|
17 |
***
|
@@ -21,13 +21,12 @@ deviation_notification_systemprompt_output_format_instructions = """
|
|
21 |
***
|
22 |
出力は以下のjsonテンプレートに従って出力してください。\n
|
23 |
{
|
24 |
-
"逸脱概要":"",
|
25 |
-
"応急措置":"",
|
26 |
-
"調査(根本原因・品質影響等)の提案": "",
|
27 |
-
"措置(回復措置・製品等に対する措置)の提案":""
|
28 |
}
|
29 |
***
|
30 |
-
「です・ます」調ではなく「だ・である」調で出力してください。\n
|
31 |
"""
|
32 |
|
33 |
deviation_notification_system_template_review = """
|
|
|
7 |
***
|
8 |
あなたは、質問に対して入力された情報から、詳しい内容を含んだ逸脱連絡書の文章を生成するアシスタントです。\n
|
9 |
上記の形式に従って、入力された情報を当てはめて出力してください。連絡書の読みやすさ、明瞭さ、正確さに注意してください。\n
|
10 |
+
変更や必要がないという回答に関しては特にそのことを記述する必要はありません。特別な記述があった場合にのみそれを記述してください。\n
|
11 |
調査や措置に関することは「調査(根本原因・品質影響等)の提案」「措置(回復措置・製品等に対する措置)の提案」に記載し、それ以外の現時点で判明している状況等は全て「逸脱概要」に記載してください。\n
|
12 |
項目に記載する内容がない場合は空白にせず、「なし」と明記してください。\n
|
13 |
また、入力された内容をそのまま記載するのではなく、正しい日本語表現かどうかに注意し、わかりやすく簡潔な表現に直して記載してください。\n
|
14 |
+
「です・ます」調ではなく「だ・である」調で出力してください。\n
|
15 |
あなたは返答をすべてJSON形式で出力します。\n
|
16 |
あなたが質問した内容は以下です。\n
|
17 |
***
|
|
|
21 |
***
|
22 |
出力は以下のjsonテンプレートに従って出力してください。\n
|
23 |
{
|
24 |
+
"逸脱概要": " ",
|
25 |
+
"応急措置": " ",
|
26 |
+
"調査(根本原因・品質影響等)の提案": " ",
|
27 |
+
"措置(回復措置・製品等に対する措置)の提案": " "
|
28 |
}
|
29 |
***
|
|
|
30 |
"""
|
31 |
|
32 |
deviation_notification_system_template_review = """
|
src/utils.py
CHANGED
@@ -56,35 +56,35 @@ def output_deviation_notification_report(contents: Dict[str, str]) -> None:
|
|
56 |
no = "□"
|
57 |
attachment = contents["添付資料"]
|
58 |
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
match contents["発生事象の分類"]:
|
67 |
case "工程内外観":
|
68 |
-
|
69 |
case "包装/表示":
|
70 |
-
|
71 |
case "交叉":
|
72 |
-
|
73 |
case "原材料異常":
|
74 |
-
|
75 |
case "規格外":
|
76 |
-
|
77 |
-
case "
|
78 |
-
|
79 |
case "手順からの逸脱":
|
80 |
-
|
81 |
|
82 |
replacements = {
|
83 |
"[subject]": contents["件名"],
|
84 |
"[control_number]": contents["管理番号"],
|
85 |
"[product_name]": contents["品名"],
|
86 |
"[item_code]": contents["品目コード"],
|
87 |
-
"[
|
88 |
"[standard_number]": contents["標準書番号"],
|
89 |
"[lot_number]": contents["ロット番号"],
|
90 |
"[section_name]": contents["課名"],
|
@@ -93,13 +93,13 @@ def output_deviation_notification_report(contents: Dict[str, str]) -> None:
|
|
93 |
"[occurrence_date]": contents["発生日"],
|
94 |
"[discovery_date]": contents["発見日"],
|
95 |
"[first_report_date]": contents["品質保証課への第一報日"],
|
96 |
-
"[
|
97 |
-
"[
|
98 |
-
"[
|
99 |
-
"[
|
100 |
-
"[
|
101 |
-
"[
|
102 |
-
"[
|
103 |
"[deviation_summary]": contents["逸脱概要"],
|
104 |
"[emergency_measures]": contents["応急措置"],
|
105 |
"[proposed_survey]": contents["調査(根本原因・品質影響等)の提案"],
|
|
|
56 |
no = "□"
|
57 |
attachment = contents["添付資料"]
|
58 |
|
59 |
+
process_view = "□"
|
60 |
+
packaging = "□"
|
61 |
+
crossover = "□"
|
62 |
+
raw_material_exception = "□"
|
63 |
+
out_of_specification = "□"
|
64 |
+
equipment_failure = "□"
|
65 |
+
from_procedure = "□"
|
66 |
match contents["発生事象の分類"]:
|
67 |
case "工程内外観":
|
68 |
+
process_view = "☑"
|
69 |
case "包装/表示":
|
70 |
+
packaging = "☑"
|
71 |
case "交叉":
|
72 |
+
crossover = "☑"
|
73 |
case "原材料異常":
|
74 |
+
raw_material_exception = "☑"
|
75 |
case "規格外":
|
76 |
+
out_of_specification = "☑"
|
77 |
+
case "設備不良":
|
78 |
+
equipment_failure = "☑"
|
79 |
case "手順からの逸脱":
|
80 |
+
from_procedure = "☑"
|
81 |
|
82 |
replacements = {
|
83 |
"[subject]": contents["件名"],
|
84 |
"[control_number]": contents["管理番号"],
|
85 |
"[product_name]": contents["品名"],
|
86 |
"[item_code]": contents["品目コード"],
|
87 |
+
"[process_name]": contents["工程名"],
|
88 |
"[standard_number]": contents["標準書番号"],
|
89 |
"[lot_number]": contents["ロット番号"],
|
90 |
"[section_name]": contents["課名"],
|
|
|
93 |
"[occurrence_date]": contents["発生日"],
|
94 |
"[discovery_date]": contents["発見日"],
|
95 |
"[first_report_date]": contents["品質保証課への第一報日"],
|
96 |
+
"[process_view]": process_view,
|
97 |
+
"[packaging]": packaging,
|
98 |
+
"[crossover]": crossover,
|
99 |
+
"[raw_material_exception]": raw_material_exception,
|
100 |
+
"[out_of_specification]": out_of_specification,
|
101 |
+
"[equipment_failure]": equipment_failure,
|
102 |
+
"[from_procedure]": from_procedure,
|
103 |
"[deviation_summary]": contents["逸脱概要"],
|
104 |
"[emergency_measures]": contents["応急措置"],
|
105 |
"[proposed_survey]": contents["調査(根本原因・品質影響等)の提案"],
|