-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from DjangoPeng/v0.4.1
optimize prompts, upgrade LLM to GPT-4o-mini and add Chineses comments to other modules
- Loading branch information
Showing
11 changed files
with
151 additions
and
168 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
你接下来收到的都是开源项目的最新进展。 | ||
|
||
你根据进展,总结成一个中文的报告,以 项目名称和日期 开头,包含:新增功能、主要改进,修复问题等章节。 | ||
|
||
参考示例如下: | ||
|
||
# LangChain 项目进展 | ||
|
||
## 时间周期:2024-08-13至2024-08-18 | ||
|
||
## 新增功能 | ||
- langchain-box: 添加langchain box包和DocumentLoader | ||
- 添加嵌入集成测试 | ||
|
||
## 主要改进 | ||
- 将@root_validator用法升级以与pydantic 2保持一致 | ||
- 将根验证器升级为与pydantic 2兼容 | ||
|
||
## 修复问题 | ||
- 修复Azure的json模式问题 | ||
- 修复Databricks Vector Search演示笔记本问题 | ||
- 修复Microsoft Azure Cosmos集成测试中的连接字符串问题 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,40 @@ | ||
import shlex | ||
import shlex # 导入shlex库,用于正确解析命令行输入 | ||
|
||
from config import Config | ||
from github_client import GitHubClient | ||
from notifier import Notifier | ||
from report_generator import ReportGenerator | ||
from llm import LLM | ||
from subscription_manager import SubscriptionManager | ||
from command_handler import CommandHandler | ||
from logger import LOG | ||
from config import Config # 从config模块导入Config类,用于配置管理 | ||
from github_client import GitHubClient # 从github_client模块导入GitHubClient类,用于GitHub API操作 | ||
from notifier import Notifier # 从notifier模块导入Notifier类,用于通知功能 | ||
from report_generator import ReportGenerator # 从report_generator模块导入ReportGenerator类,用于报告生成 | ||
from llm import LLM # 从llm模块导入LLM类,可能用于语言模型相关操作 | ||
from subscription_manager import SubscriptionManager # 从subscription_manager模块导入SubscriptionManager类,管理订阅 | ||
from command_handler import CommandHandler # 从command_handler模块导入CommandHandler类,处理命令行命令 | ||
from logger import LOG # 从logger模块导入LOG对象,用于日志记录 | ||
|
||
def main(): | ||
config = Config() | ||
github_client = GitHubClient(config.github_token) | ||
notifier = Notifier(config.notification_settings) | ||
llm = LLM() | ||
report_generator = ReportGenerator(llm) | ||
subscription_manager = SubscriptionManager(config.subscriptions_file) | ||
command_handler = CommandHandler(github_client, subscription_manager, report_generator) | ||
config = Config() # 创建配置实例 | ||
github_client = GitHubClient(config.github_token) # 创建GitHub客户端实例 | ||
notifier = Notifier(config.notification_settings) # 创建通知器实例 | ||
llm = LLM() # 创建语言模型实例 | ||
report_generator = ReportGenerator(llm) # 创建报告生成器实例 | ||
subscription_manager = SubscriptionManager(config.subscriptions_file) # 创建订阅管理器实例 | ||
command_handler = CommandHandler(github_client, subscription_manager, report_generator) # 创建命令处理器实例 | ||
|
||
parser = command_handler.parser | ||
command_handler.print_help() | ||
parser = command_handler.parser # 获取命令解析器 | ||
command_handler.print_help() # 打印帮助信息 | ||
|
||
while True: | ||
try: | ||
user_input = input("GitHub Sentinel> ") | ||
if user_input in ['exit', 'quit']: | ||
user_input = input("GitHub Sentinel> ") # 等待用户输入 | ||
if user_input in ['exit', 'quit']: # 如果输入为退出命令,则结束循环 | ||
break | ||
try: | ||
args = parser.parse_args(shlex.split(user_input)) | ||
if args.command is None: | ||
args = parser.parse_args(shlex.split(user_input)) # 解析用户输入的命令 | ||
if args.command is None: # 如果没有命令被解析,则继续循环 | ||
continue | ||
args.func(args) | ||
except SystemExit as e: | ||
args.func(args) # 执行对应的命令函数 | ||
except SystemExit as e: # 捕获由于错误命令引发的异常 | ||
LOG.error("Invalid command. Type 'help' to see the list of available commands.") | ||
except Exception as e: | ||
LOG.error(f"Unexpected error: {e}") | ||
LOG.error(f"Unexpected error: {e}") # 记录其他未预期的错误 | ||
|
||
if __name__ == '__main__': | ||
main() | ||
main() # 如果直接运行该文件,则执行main函数 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,21 @@ | ||
import json | ||
import os | ||
|
||
class Config: | ||
def __init__(self): | ||
self.load_config() | ||
|
||
def load_config(self): | ||
# 从环境变量获取GitHub Token | ||
self.github_token = os.getenv('GITHUB_TOKEN') | ||
|
||
with open('config.json', 'r') as f: | ||
config = json.load(f) | ||
self.github_token = config.get('github_token') | ||
|
||
# 如果环境变量中没有GitHub Token,则从配置文件中读取 | ||
if not self.github_token: | ||
self.github_token = config.get('github_token') | ||
|
||
self.notification_settings = config.get('notification_settings') | ||
self.subscriptions_file = config.get('subscriptions_file') | ||
self.update_interval = config.get('update_interval', 24 * 60 * 60) # Default to 24 hours | ||
self.update_interval = config.get('update_interval', 24 * 60 * 60) # 默认24小时 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,53 @@ | ||
import daemon | ||
import threading | ||
import time | ||
import daemon # 导入daemon库,用于创建守护进程 | ||
import threading # 导入threading库,用于多线程处理 | ||
import time # 导入time库,用于控制时间间隔 | ||
|
||
|
||
from config import Config | ||
from github_client import GitHubClient | ||
from notifier import Notifier | ||
from report_generator import ReportGenerator | ||
from llm import LLM | ||
from subscription_manager import SubscriptionManager | ||
from scheduler import Scheduler | ||
from logger import LOG | ||
from config import Config # 导入配置管理类 | ||
from github_client import GitHubClient # 导入GitHub客户端类,处理GitHub API请求 | ||
from notifier import Notifier # 导入通知器类,用于发送通知 | ||
from report_generator import ReportGenerator # 导入报告生成器类 | ||
from llm import LLM # 导入语言模型类,可能用于生成报告内容 | ||
from subscription_manager import SubscriptionManager # 导入订阅管理器类,管理GitHub仓库订阅 | ||
from scheduler import Scheduler # 导入调度器类,用于定时执行任务 | ||
from logger import LOG # 导入日志记录器 | ||
|
||
def run_scheduler(scheduler): | ||
# 启动调度器的函数,用于在线程中运行 | ||
scheduler.start() | ||
|
||
def main(): | ||
config = Config() | ||
github_client = GitHubClient(config.github_token) | ||
notifier = Notifier(config.notification_settings) | ||
llm = LLM() | ||
report_generator = ReportGenerator(llm) | ||
subscription_manager = SubscriptionManager(config.subscriptions_file) | ||
config = Config() # 创建配置实例 | ||
github_client = GitHubClient(config.github_token) # 创建GitHub客户端实例 | ||
notifier = Notifier(config.notification_settings) # 创建通知器实例 | ||
llm = LLM() # 创建语言模型实例 | ||
report_generator = ReportGenerator(llm) # 创建报告生成器实例 | ||
subscription_manager = SubscriptionManager(config.subscriptions_file) # 创建订阅管理器实例 | ||
|
||
# 创建调度器实例,配置其参数 | ||
scheduler = Scheduler( | ||
github_client=github_client, | ||
notifier=notifier, | ||
report_generator=report_generator, | ||
subscription_manager=subscription_manager, | ||
interval=config.update_interval | ||
interval=config.update_interval # 设置更新间隔 | ||
) | ||
|
||
# 创建并启动调度器运行的线程 | ||
scheduler_thread = threading.Thread(target=run_scheduler, args=(scheduler,)) | ||
scheduler_thread.daemon = True | ||
scheduler_thread.start() | ||
scheduler_thread.daemon = True # 设置线程为守护线程 | ||
scheduler_thread.start() # 启动线程 | ||
|
||
LOG.info("Scheduler thread started.") | ||
LOG.info("Scheduler thread started.") # 记录调度器线程已启动 | ||
|
||
# Use python-daemon to properly daemonize the process | ||
# 使用python-daemon库,以守护进程方式运行程序 | ||
with daemon.DaemonContext(): | ||
try: | ||
while True: | ||
time.sleep(config.update_interval) | ||
time.sleep(config.update_interval) # 按配置的更新间隔休眠 | ||
except KeyboardInterrupt: | ||
LOG.info("Daemon process stopped.") | ||
LOG.info("Daemon process stopped.") # 在接收到中断信号时记录日志 | ||
|
||
if __name__ == '__main__': | ||
main() | ||
|
||
# nohup python3 src/daemon_process.py > logs/daemon_process.log 2>&1 & | ||
# 启动方式:nohup python3 src/daemon_process.py > logs/daemon_process.log 2>&1 & |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,41 @@ | ||
import gradio as gr | ||
import gradio as gr # 导入gradio库用于创建GUI | ||
|
||
from config import Config | ||
from github_client import GitHubClient | ||
from report_generator import ReportGenerator | ||
from llm import LLM | ||
from subscription_manager import SubscriptionManager | ||
from logger import LOG | ||
from config import Config # 导入配置管理模块 | ||
from github_client import GitHubClient # 导入用于GitHub API操作的客户端 | ||
from report_generator import ReportGenerator # 导入报告生成器模块 | ||
from llm import LLM # 导入可能用于处理语言模型的LLM类 | ||
from subscription_manager import SubscriptionManager # 导入订阅管理器 | ||
from logger import LOG # 导入日志记录器 | ||
|
||
# 创建各个组件的实例 | ||
config = Config() | ||
github_client = GitHubClient(config.github_token) | ||
llm = LLM() | ||
report_generator = ReportGenerator(llm) | ||
subscription_manager = SubscriptionManager(config.subscriptions_file) | ||
|
||
|
||
def export_progress_by_date_range(repo, days): | ||
raw_file_path = github_client.export_progress_by_date_range(repo, days) | ||
report, report_file_path = report_generator.generate_report_by_date_range(raw_file_path, days) | ||
# 定义一个函数,用于导出和生成指定时间范围内项目的进展报告 | ||
raw_file_path = github_client.export_progress_by_date_range(repo, days) # 导出原始数据文件路径 | ||
report, report_file_path = report_generator.generate_report_by_date_range(raw_file_path, days) # 生成并获取报告内容及文件路径 | ||
|
||
return report, report_file_path | ||
return report, report_file_path # 返回报告内容和报告文件路径 | ||
|
||
# 创建Gradio界面 | ||
demo = gr.Interface( | ||
fn=export_progress_by_date_range, | ||
title="GitHubSentinel", | ||
fn=export_progress_by_date_range, # 指定界面调用的函数 | ||
title="GitHubSentinel", # 设置界面标题 | ||
inputs=[ | ||
gr.Dropdown( | ||
subscription_manager.list_subscriptions(), label="订阅列表", info="已订阅GitHub项目" | ||
), | ||
), # 下拉菜单选择订阅的GitHub项目 | ||
gr.Slider(value=2, minimum=1, maximum=7, step=1, label="报告周期", info="生成项目过去一段时间进展,单位:天"), | ||
|
||
# 滑动条选择报告的时间范围 | ||
], | ||
outputs=[gr.Markdown(), gr.File(label="下载报告")], | ||
outputs=[gr.Markdown(), gr.File(label="下载报告")], # 输出格式:Markdown文本和文件下载 | ||
) | ||
|
||
if __name__ == "__main__": | ||
demo.launch(share=True, server_name="0.0.0.0") | ||
demo.launch(share=True, server_name="0.0.0.0") # 启动界面并设置为公共可访问 | ||
# 可选带有用户认证的启动方式 | ||
# demo.launch(share=True, server_name="0.0.0.0", auth=("django", "1234")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.