-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathcommand.py
More file actions
executable file
·101 lines (80 loc) · 2.15 KB
/
command.py
File metadata and controls
executable file
·101 lines (80 loc) · 2.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import os
from datetime import date
from devchat.llm import chat, chat_json
from community.gitlab.git_api import (
get_commit_author,
get_repo,
get_repo_commits,
get_repo_issues,
get_username,
)
from lib.workflow.decorators import check_input
def get_template():
template_path = os.path.join(os.path.dirname(__file__), "template.md")
with open(template_path, "r", encoding="utf-8") as f:
return f.read()
def get_issues(start_time, end_time):
name = get_username()
issue_repo = get_repo(True)
issues = get_repo_issues(
issue_repo, name, state=None, created_after=start_time, created_before=end_time
)
return issues
def get_commits(start_time, end_time):
name = get_commit_author()
issue_repo = get_repo(False)
commits = get_repo_commits(issue_repo, author=name, since=start_time, until=end_time)
return commits
@chat(
prompt="""
我希望你根据以下信息生成一份从 {start_time} 到 {end_time} 的工作报告。
问题列表:
<issues>
{issues}
</issues>
提交列表:
<commits>
{commits}
</commits>
请参考以下模板内容的格式:
<template>
{template}
</template>
""",
stream_out=True,
)
def generate_work_report(start_time, end_time, issues, commits, template):
pass
@chat_json(
prompt="""
今天是 {today},我希望你根据输入信息获取开始时间和结束时间。
如果无法获取,则获取昨天到今天的时间范围。
<input>
{input}
</input>
输出格式为 JSON 格式,如下所示:
{{
"start_time": "2025-05-19",
"end_time": "2025-05-20"
}}
"""
)
def get_date_range(today, input):
pass
@check_input("请输入需要生成工作报告的时间")
def main(input):
result = get_date_range(today=date.today(), input=input)
start_time = result["start_time"]
end_time = result["end_time"]
issues = get_issues(start_time, end_time)
commits = get_commits(start_time, end_time)
template = get_template()
generate_work_report(
start_time=start_time,
end_time=end_time,
issues=issues,
commits=commits,
template=template,
)
if __name__ == "__main__":
main()