ayataca commited on
Commit
91c6b14
1 Parent(s): bdcb8d1

文書名変更(逸脱連絡書→deviation_notification_report、逸脱調査報告書→deviation_invedtigation_report)

Browse files
data/template/{template_deviation_1.docx → template_deviation_notification.docx} RENAMED
File without changes
main.py CHANGED
@@ -1,11 +1,11 @@
1
  import streamlit as st
2
 
3
- from src.forms.deviation_occurrence_report import deviation_occurrence_report_form
4
- from src.forms.deviation_report import deviation_report_form
5
 
6
  pages = {
7
- "逸脱連絡書": deviation_occurrence_report_form,
8
- "逸脱調査報告書": deviation_report_form,
9
  }
10
 
11
  selected_page = st.sidebar.selectbox(
 
1
  import streamlit as st
2
 
3
+ from src.forms.deviation_investigation_report import deviation_investigation_report_form
4
+ from src.forms.deviation_notification_report import deviation_notification_report_form
5
 
6
  pages = {
7
+ "逸脱連絡書": deviation_notification_report_form,
8
+ "逸脱調査報告書": deviation_investigation_report_form,
9
  }
10
 
11
  selected_page = st.sidebar.selectbox(
src/forms/{deviation_occurrence_report.py → deviation_notification_report.py} RENAMED
@@ -6,12 +6,12 @@ import streamlit as st
6
  from dotenv import load_dotenv
7
  from openai import OpenAI
8
 
9
- from src.prompts.deviation_occurrence_report import (
10
- deviation_occurrence_system_template_review,
11
- deviation_occurrence_systemprompt_template_1,
12
- deviation_occurrence_systemprompt_template_2,
13
  )
14
- from src.utils import output_deviation_occurrence_report, setup_logger
15
 
16
  OCCURRENCE_CLASSIFICATIONS = [
17
  "",
@@ -27,7 +27,7 @@ OCCURRENCE_CLASSIFICATIONS = [
27
  logger = setup_logger(__name__)
28
 
29
 
30
- def deviation_occurrence_report_form() -> None:
31
  st.title("逸脱連絡書 文書生成")
32
 
33
  load_dotenv()
@@ -73,7 +73,7 @@ def deviation_occurrence_report_form() -> None:
73
  if state not in st.session_state:
74
  st.session_state[state] = False
75
 
76
- with st.form("my_form_deviation_occurrence"):
77
  col1, col2 = st.columns(2)
78
  with col1:
79
  st.text_input("件名", key="subject")
@@ -159,7 +159,9 @@ def deviation_occurrence_report_form() -> None:
159
  nos = [False] * q_num
160
  st.markdown("***")
161
  for k in range(q_num):
162
- input_values[k] = st.text_area(q[k], key=f"input_deviatoin_occurrence_{k}")
 
 
163
  if k > 2:
164
  nos[k] = st.checkbox(f"{q_not[k]}", key=f"check_{k}")
165
  st.markdown("***")
@@ -178,7 +180,7 @@ def deviation_occurrence_report_form() -> None:
178
  )
179
  attached_files = st.text_area(
180
  "Q18 : 添付資料名を記入してください。",
181
- key="attached_files_deviation_occurrence",
182
  )
183
  no_attached_file = st.checkbox("添付資料なし", key="check_attached_file")
184
 
@@ -192,11 +194,13 @@ def deviation_occurrence_report_form() -> None:
192
  if no_attached_file:
193
  attached_files = "なし"
194
 
195
- system_prompt = deviation_occurrence_systemprompt_template_1
 
 
196
  for k in range(q_num):
197
  system_prompt += q[k]
198
  system_prompt += "\n"
199
- system_prompt += deviation_occurrence_systemprompt_template_2
200
 
201
  user_prompt = ""
202
  for k in range(q_num):
@@ -291,17 +295,17 @@ def deviation_occurrence_report_form() -> None:
291
  + str(st.session_state["contents"])
292
  )
293
 
294
- output_deviation_occurrence_report(st.session_state["contents"])
295
  st.session_state["document_generated"] = True
296
 
297
  if st.session_state["document_generated"]:
298
  st.markdown("以下の内容を記入した逸脱連絡書(.docx)を作成しました。")
299
 
300
- with open("data/output_deviation_occurrence.docx", "rb") as file:
301
  st.download_button(
302
  label="ダウンロード",
303
  data=file,
304
- file_name="output_deviation_occurrence.docx",
305
  mime="application/vnd.openxmlformats-officedocument.wordprocessingml.document",
306
  )
307
 
@@ -309,7 +313,7 @@ def deviation_occurrence_report_form() -> None:
309
  if key != "ユーザープロンプト":
310
  st.markdown(f"**{key}**: {value}")
311
 
312
- deviation_occurrence_user_template_review = f"""
313
  ## 今回の「逸脱概要」:
314
  {st.session_state["contents"]["逸脱概要"]}
315
 
@@ -323,11 +327,11 @@ def deviation_occurrence_report_form() -> None:
323
  messages=[
324
  {
325
  "role": "system",
326
- "content": deviation_occurrence_system_template_review,
327
  },
328
  {
329
  "role": "user",
330
- "content": deviation_occurrence_user_template_review,
331
  },
332
  ],
333
  temperature=0.7,
 
6
  from dotenv import load_dotenv
7
  from openai import OpenAI
8
 
9
+ from src.prompts.deviation_notification_report import (
10
+ deviation_notification_system_template_review,
11
+ deviation_notification_systemprompt_output_format_instructions,
12
+ deviation_notification_systemprompt_writing_instructions,
13
  )
14
+ from src.utils import output_deviation_notification_report, setup_logger
15
 
16
  OCCURRENCE_CLASSIFICATIONS = [
17
  "",
 
27
  logger = setup_logger(__name__)
28
 
29
 
30
+ def deviation_notification_report_form() -> None:
31
  st.title("逸脱連絡書 文書生成")
32
 
33
  load_dotenv()
 
73
  if state not in st.session_state:
74
  st.session_state[state] = False
75
 
76
+ with st.form("my_form_deviation_notification"):
77
  col1, col2 = st.columns(2)
78
  with col1:
79
  st.text_input("件名", key="subject")
 
159
  nos = [False] * q_num
160
  st.markdown("***")
161
  for k in range(q_num):
162
+ input_values[k] = st.text_area(
163
+ q[k], key=f"input_deviatoin_notification_{k}"
164
+ )
165
  if k > 2:
166
  nos[k] = st.checkbox(f"{q_not[k]}", key=f"check_{k}")
167
  st.markdown("***")
 
180
  )
181
  attached_files = st.text_area(
182
  "Q18 : 添付資料名を記入してください。",
183
+ key="attached_files_deviation_notification",
184
  )
185
  no_attached_file = st.checkbox("添付資料なし", key="check_attached_file")
186
 
 
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 += deviation_notification_systemprompt_writing_instructions
204
 
205
  user_prompt = ""
206
  for k in range(q_num):
 
295
  + str(st.session_state["contents"])
296
  )
297
 
298
+ output_deviation_notification_report(st.session_state["contents"])
299
  st.session_state["document_generated"] = True
300
 
301
  if st.session_state["document_generated"]:
302
  st.markdown("以下の内容を記入した逸脱連絡書(.docx)を作成しました。")
303
 
304
+ with open("data/output_deviation_notification.docx", "rb") as file:
305
  st.download_button(
306
  label="ダウンロード",
307
  data=file,
308
+ file_name="output_deviation_notification.docx",
309
  mime="application/vnd.openxmlformats-officedocument.wordprocessingml.document",
310
  )
311
 
 
313
  if key != "ユーザープロンプト":
314
  st.markdown(f"**{key}**: {value}")
315
 
316
+ deviation_notification_user_template_review = f"""
317
  ## 今回の「逸脱概要」:
318
  {st.session_state["contents"]["逸脱概要"]}
319
 
 
327
  messages=[
328
  {
329
  "role": "system",
330
+ "content": deviation_notification_system_template_review,
331
  },
332
  {
333
  "role": "user",
334
+ "content": deviation_notification_user_template_review,
335
  },
336
  ],
337
  temperature=0.7,
src/prompts/{deviation_occurrence_report.py → deviation_notification_report.py} RENAMED
@@ -1,4 +1,4 @@
1
- deviation_occurrence_systemprompt_template_1 = """
2
  ***
3
  逸脱概要:
4
  応急処置:
@@ -17,7 +17,7 @@ deviation_occurrence_systemprompt_template_1 = """
17
  ***
18
  """
19
 
20
- deviation_occurrence_systemprompt_template_2 = """
21
  ***
22
  出力は以下のjsonテンプレートに従って出力してください。\n
23
  {
@@ -30,7 +30,7 @@ deviation_occurrence_systemprompt_template_2 = """
30
  「です・ます」調ではなく「だ・である」調で出力してください。\n
31
  """
32
 
33
- deviation_occurrence_system_template_review = """
34
  あなたは製薬会社の品質管理部門のリーダーです。今回、あなたの部下が作成した逸脱連絡書の内容をレビューすることになりました。
35
  ## 出力例 を参考にしながら,以下の'''今回の「逸脱概要」'''の修正すべき点を指摘してください.
36
  逸脱の根本原因がしっかりと記載されているかが重要です.
 
1
+ deviation_notification_systemprompt_writing_instructions = """
2
  ***
3
  逸脱概要:
4
  応急処置:
 
17
  ***
18
  """
19
 
20
+ deviation_notification_systemprompt_output_format_instructions = """
21
  ***
22
  出力は以下のjsonテンプレートに従って出力してください。\n
23
  {
 
30
  「です・ます」調ではなく「だ・である」調で出力してください。\n
31
  """
32
 
33
+ deviation_notification_system_template_review = """
34
  あなたは製薬会社の品質管理部門のリーダーです。今回、あなたの部下が作成した逸脱連絡書の内容をレビューすることになりました。
35
  ## 出力例 を参考にしながら,以下の'''今回の「逸脱概要」'''の修正すべき点を指摘してください.
36
  逸脱の根本原因がしっかりと記載されているかが重要です.
src/utils.py CHANGED
@@ -44,8 +44,8 @@ def get_individual_questions(type: str, category: str, subcategory: str) -> List
44
  return questions
45
 
46
 
47
- def output_deviation_occurrence_report(contents: Dict[str, str]) -> None:
48
- template_path = "data/template/template_deviation_1.docx"
49
 
50
  if contents["添付資料"] == "なし":
51
  yes = "□"
@@ -113,13 +113,13 @@ def output_deviation_occurrence_report(contents: Dict[str, str]) -> None:
113
  }
114
 
115
  doc = replace_text_in_docx(template_path, replacements)
116
- output_path = "data/output_deviation_occurrence.docx"
117
  doc.save(output_path)
118
  logger.info(f"Document saved to {output_path}")
119
 
120
 
121
- def output_deviation_report(contents: Dict[str, str]) -> None:
122
- template_path = "data/template/template_deviation_2.docx"
123
 
124
  if contents["出荷の制限"] == "なし":
125
  yes_sr = "□"
@@ -161,7 +161,7 @@ def output_deviation_report(contents: Dict[str, str]) -> None:
161
  }
162
 
163
  doc = replace_text_in_docx(template_path, replacements)
164
- output_path = "data/output_deviation.docx"
165
  doc.save(output_path)
166
  logger.info(f"Document saved to {output_path}")
167
 
 
44
  return questions
45
 
46
 
47
+ def output_deviation_notification_report(contents: Dict[str, str]) -> None:
48
+ template_path = "data/template/template_deviation_notification.docx"
49
 
50
  if contents["添付資料"] == "なし":
51
  yes = "□"
 
113
  }
114
 
115
  doc = replace_text_in_docx(template_path, replacements)
116
+ output_path = "data/output_deviation_notification.docx"
117
  doc.save(output_path)
118
  logger.info(f"Document saved to {output_path}")
119
 
120
 
121
+ def output_deviation_investigation_report(contents: Dict[str, str]) -> None:
122
+ template_path = "data/template/template_deviation_investigation.docx"
123
 
124
  if contents["出荷の制限"] == "なし":
125
  yes_sr = "□"
 
161
  }
162
 
163
  doc = replace_text_in_docx(template_path, replacements)
164
+ output_path = "data/output_deviation_investigation.docx"
165
  doc.save(output_path)
166
  logger.info(f"Document saved to {output_path}")
167