Skip to content

Commit

Permalink
add 英语汇报
Browse files Browse the repository at this point in the history
  • Loading branch information
muyu66 committed Mar 23, 2024
1 parent b4763a9 commit 14ea5c4
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 26 deletions.
43 changes: 33 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* **报告聚合**:支持多个仓库的工作量自动聚合,自动加权均衡上报
* **多模型适配**:暂时只支持通义千问大模型、通义千问开源大模型
* **多仓库**:自动读取指定多个目录下的所有仓库
* **中英双语**:可用于外企工作汇报
* 自动/手动指定Git Author,防止工作日志错领
* 支持切换日报详细程度模式 (简单/详细),简单模式可以节省AI TOKEN消费
* 支持周报
Expand Down Expand Up @@ -41,11 +42,11 @@ Windows

## 效果展示

日报图片
日报
![](https://free.wzznft.com/i/2024/03/21/p1idmz.png)
周报图片
周报
![](https://free.wzznft.com/i/2024/03/22/upq0ns.png)
周报文本
周报

```text
尊敬的领导:
Expand All @@ -72,6 +73,33 @@ Windows
感谢您抽出宝贵的时间阅读我的工作报告。如果您有任何问题或建议,请随时与我联系。我会尽我最大的努力来完成下周的工作,并不断提升我们的产品和服务质量。
```

周报:

```text
Subject: Weekly Report - Mar 18 to Mar 24, 2024
Dear [Boss's Name],
I hope this email finds you well. I am writing to provide an overview of my work activities for the week ending March 24th, 2024.
1. Update on Rating-Related Features (March 18)
This week, I focused on updating the rating-related features in the newhire repository. I made changes to the build.gradle file to enhance the overall functionality and user experience.
2. Addition of More Features (March 22)
In the git-to-dailyreport repository, I added more features to improve the tool's capabilities. These updates include support for weekly reports and a terminal display option for generating reports. The README.md file was also updated with detailed information about these new features.
3. Completion of Newhire-Rate Project (March 19)
The newhire-rate project reached completion this week. I refactored and optimized several components, including the calc package, benchmarking tests, and consumer.go. These improvements led to significant performance enhancements, as demonstrated by the benchmark results.
4. Initialization of News-by-AI Project (March 22)
I began working on the news-by-ai project by setting up the initial files and dependencies. This includes creating the .gitignore, ai.go, config.go, go.mod, and go.sum files, as well as the main.go entry point for the application.
Looking ahead to next week, I plan to continue enhancing the git-to-dailyreport tool by addressing any bugs or issues that may arise. Additionally, I will focus on further developing the news-by-ai project, incorporating artificial intelligence algorithms to generate news content.
Thank you for your time and consideration. If you have any questions or require further clarification on any of the tasks mentioned above, please do not hesitate to reach out.
Best regards,
[Your Name]
[Your Title]
```

## 编译 Win64

.\build.bat # 编译脚本
Expand All @@ -82,12 +110,6 @@ Windows
config.yaml (与report.exe同目录)

```yaml
aiPrompt: |
我是一名程序员,我想用git日志来向领导表达我今天的工作内容,帮我根据git日志生成我今天的工作内容报道。
要求你以我的身份第一视角来写这份报告,不要提到是你帮助我写的,也不要透露是根据git日志生成的。
不要提到commit之类的git概念
需要分点来写
我的git日志如下:
ai:
ak: sk-xxxxxxxxxxxxxxxxxxx
# qwen1.5-72b-chat ⭐⭐⭐⭐
Expand Down Expand Up @@ -121,12 +143,13 @@ report:
# file 输出文本文件
# print 打印到终端
out: file
# 报告语言 [chs|en]
lang: chs
```
## Roadmap
* 将工作区、Stage区纳入上报的工作范围
* 支持超大规模压缩日志上传
* 可视化配置
* 更多大模型支持 (百度系、Meta、Google等)
* 更加傻瓜智能化,力求一键全自动处理
Expand Down
11 changes: 4 additions & 7 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@ package main

import "github.com/spf13/viper"

func getAiPromptConf(dayOrWeek string) string {
if dayOrWeek == "week" {
return viper.GetString("aiPrompt.week")
}
return viper.GetString("aiPrompt.day")
}

func getAiAkConf() string {
return viper.GetString("ai.ak")
}
Expand Down Expand Up @@ -40,3 +33,7 @@ func getReportIntervalDayConf() int {
func getReportOutConf() string {
return viper.GetString("report.out")
}

func getReportLangConf() string {
return viper.GetString("report.lang")
}
10 changes: 3 additions & 7 deletions config.sample.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
aiPrompt: |
我是一名程序员,我想用git日志来向领导表达我今天的工作内容,帮我根据git日志生成我今天的工作内容报道。
要求你以我的身份第一视角来写这份报告,不要提到是你帮助我写的,也不要透露是根据git日志生成的。
不要提到commit之类的git概念
需要分点来写
我的git日志如下:
ai:
ak: sk-xxxxxxxxxxxxxxxxxxx
# qwen1.5-72b-chat ⭐⭐⭐⭐
Expand Down Expand Up @@ -36,4 +30,6 @@ report:
# 输出模式
# file 输出文本文件
# print 打印到终端
out: file
out: file
# 报告语言 [chs|en]
lang: chs
20 changes: 18 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@ import (
"os"
"os/exec"
"path/filepath"
"regexp"
"strings"
"sync"
"sync/atomic"
"time"
)

var reportModeConf string
var reportCycle string
var reportModeConf string
var reportLangConf string

func init() {
log.SetLevel(log.DebugLevel)
Expand All @@ -39,6 +41,7 @@ func init() {

// 初始化全局配置
reportModeConf = getReportModeConf()
reportLangConf = getReportLangConf()
}

func loadCmdParams() {
Expand All @@ -51,7 +54,7 @@ func loadCmdParams() {
// TODO: 调整代码层次结构
func main() {
loadCmdParams()
prompt := getAiPromptConf(reportCycle)
prompt := getAiPrompt(reportCycle, reportLangConf)

gitLog := fire(prompt)

Expand All @@ -64,6 +67,17 @@ func main() {
out(&reportText)
}

func formatText(content string) string {
return regexp.MustCompile(`\s+`).ReplaceAllString(content, "")
}

func getAiPrompt(dayOrWeek string, lang string) string {
if dayOrWeek == "week" {
return getWeekPrompt(lang)
}
return getDayPrompt(lang)
}

func out(reportText *string) {
switch getReportOutConf() {
case "file":
Expand Down Expand Up @@ -191,6 +205,8 @@ func getGitLogs(repo string, gitLogMap *sync.Map, maxLogLen *int64, cmdInfo CmdI
if err != nil {
log.Error("[异常] 获取工作日志异常", repoPath)
}
// 压缩文本体积
gitLog = formatText(gitLog)
if len(gitLog) == 0 {
log.Info("未找到工作日志", repoPath)
} else {
Expand Down
31 changes: 31 additions & 0 deletions prompt.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package main

import "fmt"

func getLangPrompt(lang string) string {
switch lang {
case "en":
return "领导是外国人,请用国外的书信格式来写,全文要用英语"
default:
return "领导是中国人,请用中国的书信格式来写"
}
}

func getDayPrompt(lang string) string {
return fmt.Sprintf(`我是一名程序员,我想用git日志来向领导表达我今天的工作内容,帮我根据git日志生成我今天的工作内容报道。
要求你以我的身份第一视角来写这份报告,不要提到是你帮助我写的,也不要透露是根据git日志生成的。
不要提到commit之类的git概念
需要分点来写
%s
我的git日志如下:`, getLangPrompt(lang))
}

func getWeekPrompt(lang string) string {
return fmt.Sprintf(`我是一名程序员,我想用git日志来向领导表达我本周的工作内容,帮我根据git日志生成我本周的工作内容报道。
要求你以我的身份第一视角来写这份报告,不要提到是你帮助我写的,不要透露是根据git日志生成的。
不要提到commit之类的git概念
需要分点来写
需要展现出我对之前工作内容的总结,以及对下周工作的展望
%s
我的git日志如下:`, getLangPrompt(lang))
}

0 comments on commit 14ea5c4

Please sign in to comment.