unausagi commited on
Commit
1f3c933
·
verified ·
1 Parent(s): 755313f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -14
app.py CHANGED
@@ -36,32 +36,40 @@ def read_docx(file):
36
  return "\n".join([para.text for para in doc.paragraphs])
37
 
38
  def generate_monthly_report(weekly_reports_files, last_month_report_file, llm_gpt4o):
39
- """Generates a monthly report based on weekly reports and the last month's report."""
40
  weekly_reports = [read_docx(file) for file in weekly_reports_files]
41
  last_month_report = read_docx(last_month_report_file) if last_month_report_file else ""
42
 
43
- prompt = f"""請根據以下資訊生成本月月報:
44
- 上個月月報:
 
45
  {last_month_report}
46
- 本月各週報:
 
 
47
  """
48
- for report in weekly_reports:
49
- prompt += f"{report}\n---\n"
50
 
51
  prompt += """
52
- I will provide the weekly reports for the current month and the monthly report from the previous month. Based on these documents, please:
53
 
54
- 1. Describe the overall progress and updates of each project for the current month, organized chronologically like a narrative.
55
- 2. Summarize the completed work for each project in the same format as the previous month’s report.
56
- 3. Write the work plan for next month for each project, following the "next month plan" format used in the previous monthly report.
57
- 4. At the end of the report, compile a separate summary list that clearly states the action items for next month for each project.
58
 
59
- ⚠️ Please write the entire response in **Traditional Chinese**, using a formal and professional tone, and strictly follow the format of the previous month’s monthly report.
 
60
 
61
- The source materials are the "current month weekly reports" and the "previous month monthly report" that I provided.
62
  """
 
63
  try:
64
- response = llm_gpt4o.invoke([("system", "You are a professional assistant."), ("human", prompt)])
 
 
 
65
  return response.content
66
  except Exception as e:
67
  raise ValueError(f"生成月報時發生錯誤:{str(e)}")
 
36
  return "\n".join([para.text for para in doc.paragraphs])
37
 
38
  def generate_monthly_report(weekly_reports_files, last_month_report_file, llm_gpt4o):
39
+ """根據本月份週報與上個月月報產生本月月報。"""
40
  weekly_reports = [read_docx(file) for file in weekly_reports_files]
41
  last_month_report = read_docx(last_month_report_file) if last_month_report_file else ""
42
 
43
+ # 構建 prompt
44
+ prompt = f"""
45
+ 上個月月報內容如下:
46
  {last_month_report}
47
+
48
+ ---
49
+ 本月份週報內容如下:
50
  """
51
+ for i, report in enumerate(weekly_reports, 1):
52
+ prompt += f"【第 {i} 週週報】\n{report}\n---\n"
53
 
54
  prompt += """
55
+ 請依據上方提供的「上個月月報」與「本月份週報」進行以下任務:
56
 
57
+ 1. 依照週報的時間順序,整理各專案在本月份的整體進度與內容(像故事一樣描述本月發生的事情)。
58
+ 2. 依照「上個月月報」的格式,針對每個專案整理本月份已完成的工作內容。
59
+ 3. 針對每個專案寫出下個月的預計工作計畫,格式與內容參考「上個月月報」的「下月預計工作」。
60
+ 4. 在報告最後,再統整列出一次每個專案下個月的工作項目(像行動項目)。
61
 
62
+ ⚠️請用**繁體中文**撰寫,語氣正式、專業。
63
+ ⚠️請完全依照「上個月月報」的段落、標題、格式風格來呈現,包含每個專案的順序與排版方式。
64
 
65
+ 資料來源:上方的「上個月月報」與「本月份週報」。
66
  """
67
+
68
  try:
69
+ response = llm_gpt4o.invoke([
70
+ ("system", "你是一位專業的助理,負責撰寫正式的工作月報。"),
71
+ ("human", prompt)
72
+ ])
73
  return response.content
74
  except Exception as e:
75
  raise ValueError(f"生成月報時發生錯誤:{str(e)}")