Skip to content

Commit

Permalink
Merge pull request #19 from DjangoPeng/v0.7
Browse files Browse the repository at this point in the history
fix: support report_type on ReportGenerator
  • Loading branch information
DjangoPeng authored Aug 31, 2024
2 parents 333fdae + f45756c commit 588c4a5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/report_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ class ReportGenerator:
def __init__(self, llm):
self.llm = llm # 初始化时接受一个LLM实例,用于后续生成报告

def generate_daily_report(self, markdown_file_path):
def generate_daily_report(self, markdown_file_path, report_type="github"):
# 读取 github 项目进展文件并调用 LLM 生成日报
with open(markdown_file_path, 'r') as file:
markdown_content = file.read()

report = self.llm.generate_daily_report(markdown_content) # 调用LLM生成报告
report = self.llm.generate_report(report_type, markdown_content) # 调用LLM生成报告

report_file_path = os.path.splitext(markdown_file_path)[0] + "_report.md"
with open(report_file_path, 'w+') as report_file:
Expand Down
6 changes: 3 additions & 3 deletions tests/test_report_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def test_generate_daily_report(self):
"""
# 模拟 LLM 返回的报告内容
mock_report = "This is a generated report."
self.mock_llm.generate_daily_report.return_value = mock_report
self.mock_llm.generate_report.return_value = mock_report # 修改此行代码

# 调用 generate_daily_report 方法
report, report_file_path = self.report_generator.generate_daily_report(self.test_markdown_file_path)
Expand All @@ -64,8 +64,8 @@ def test_generate_daily_report(self):
content = file.read()
self.assertEqual(content, mock_report)

# 验证 LLM 的 generate_daily_report 方法是否被正确调用,且传入了正确的参数
self.mock_llm.generate_daily_report.assert_called_once_with(self.markdown_content)
# 验证 LLM 的 generate_report 方法是否被正确调用,且传入了正确的参数
self.mock_llm.generate_report.assert_called_once_with("github", self.markdown_content)

if __name__ == '__main__':
unittest.main()

0 comments on commit 588c4a5

Please sign in to comment.