《李明宇-基于GPT的代碼PRreview助手開發與應用.pdf》由會員分享,可在線閱讀,更多相關《李明宇-基于GPT的代碼PRreview助手開發與應用.pdf(38頁珍藏版)》請在三個皮匠報告上搜索。
1、基于GPT的代碼PR review助手開發與應用李明宇 中國科學院計算技術研究所演講嘉賓李明宇中科院計算所高級工程師/“編程老師傅”l前深信服科技集團云計算首席專家l中科院計算所高級工程師,開源項目活躍開發者,20 余年編程與軟件開發經驗,10余年云端系統研發與產業化工作經歷。歷任國家重點實驗室研究組負責人,上市公司事業群技術總監、首席技術專家。l李老師在理論研究和產業實踐均有豐富的經驗,為多家知名企業和單位落地云原生和數字化轉型項目。榮獲中國軟件協會“優秀CTO”等多項榮譽,兼任中國新一代IT產業聯盟分委會秘書長、全國高校人工智能與大數據創新聯盟專家委員、北京開源創新委員會委員。目 錄CON
2、TENTS1.背景與痛點 讓人又愛又恨的 Code Review 環節2.Code-Chat-Reviewer開發歷程與 實現原理3.應用效果與優缺點4.11月6日以來的新進展5.總結與展望目前的PR Review生成效果目前的PR Review生成效果目前的PR Review生成效果目前的PR Review生成效果目前的PR Review生成效果對:過去(4份)背景與痛點 讓人又愛又恨的Code Review 環節PART 01背景與痛點 讓人又愛又恨的 Code Review 環節Pull/Merge Request Review眾所周知的重要性:質量!知識共享、持續維護背景與痛點 讓人又
3、愛又恨的 Code Review 環節Reviewer X 2Pull/Merge Request Review眾所周知的重要性:質量!知識共享、持續維護但是,沒有喜歡 PR Review:成本、短期效率理和社交壓核成員的精分配與持續成背景與痛點 讓人又愛又恨的 Code Review 環節LLM+Reviewer X 1Pull/Merge Request Review眾所周知的重要性:質量!知識共享、持續維護但是,沒有喜歡 PR Review:成本、短期效率理和社交壓核成員的精分配與持續成另個問題:為什么要在 Pull/Merge Request Review環節LLM?為什么不在其他環節
4、對代碼審查中解決?如VS Code CopilotReview對象不同,上下、時間點不同Code-Chat-Review 開發歷程與實現原理PART 02Code-Chat-Review 開發歷程與實現原理Git1.git pushReview-BotContributor2.Webhook3.GETCode Changes 5.POSTReview Comments4.Prompts/MessagesGenerated Review Commentsv0.1 gpt-3.5gpt-4 API waitlist.Human Reviewer X17.Comment/Approve6.Revis
5、eGPT效果與問題:gpt-3.5效果不理想,挑出來的問題較瑣碎 家很期待 gpt-4 API的開放Code-Chat-Review 開發歷程與實現原理Git1.git pushReview-BotContributor2.Webhook3.GETCode Changes 5.POSTReview Comments4.Prompts/MessagesGenerated Review Commentsv0.1 gpt-3.5gpt-4 API waitlist.Human Reviewer X17.Comment/Approve6.ReviseGPT效果與問題:gpt-3.5效果不理想,挑出來的
6、問題較瑣碎 家很期待 gpt-4 API的開放messages=role:system,content:As an AI assistant with expertise in programming,your primary task is to review the pull request provided by the user.When generating your review,adhere to the following template:*Changes*:Summarize the main changes made in the pull request in less
7、 than 50 words.*Suggestions*:Provide any suggestions or improvements for the code.Focus on code quality,logic,potential bugs and performance problems.Refrain from mentioning document-related suggestions such as I suggest adding some comments,etc.*Clarifications*:(Optional)If there are parts of the p
8、ull request that are unclear or lack sufficient context,ask for clarification here.If not,this section can be omitted.*Conclusion*:Conclude the review with an overall assessment.*Other*:(Optional)If there are additional observations or notes,mention them here.If not,this section can be omitted.The u
9、ser may also engage in further discussions about the review.It is not necessary to use the template when discussing with the user.,role:user,content:fReview the following pull request.The patches are in standard diff format.Evaluate the pull request within the context of the referenced issues and fu
10、ll content of the code file(s).nchanges_strn,Code-Chat-Review 開發歷程與實現原理Git1.git pushReview-BotContributor2.Webhook3.GETCode Changes 5.POSTReview CommentsGenerated Review Commentsv0.2 gpt-4prompt engineeringHuman Reviewer X17.Comment/Approve6.Revise4.Prompts/MessagesGPT效果與問題:效果未達預期,能提出些有的建議,但是采率不:1)看
11、不懂或看懂了但改起來費勁;2)設計原因 Code-Chat-Review 開發歷程與實現原理Git1.git pushReview-BotContributor2.Webhook3.GETCode Changes 5.POSTReview CommentsGenerated Review Commentsv1-alpha Database Chat/ConversationHuman Reviewer X18.Comment/ApproveMongoDB6.Chat/Conversation7.Revise4.Prompts/MessagesGPT效果與問題:引Chat機制帶來的效果不錯 但,
12、Review結果不收斂,修改后提出新的意,沒完沒了.Code-Chat-Review 開發歷程與實現原理Git1.git pushReview-BotContributor2.Webhook3.GETCode Changes 5.POSTReview CommentsGenerated Review Commentsv1-alpha Database Chat/ConversationHuman Reviewer X18.Comment/ApproveMongoDB6.Chat/Conversation7.Revise4.Prompts/MessagesGPT效果與問題:引Chat機制帶來的效
13、果不錯 但,Review結果不收斂,修改后提出新的意,沒完沒了.Code-Chat-Review 開發歷程與實現原理Git1.git pushReview-BotContributor2.Webhook3.GETCode Changes 5.POSTReview CommentsGenerated Review Commentsv1-alpha Database Chat/ConversationHuman Reviewer X18.Comment/ApproveMongoDB6.Chat/Conversation7.Revise4.Prompts/MessagesGPT效果與問題:引Chat
14、機制帶來的效果不錯 但,Review結果不收斂,修改后提出新的意,沒完沒了.Code-Chat-Review 開發歷程與實現原理Git1.git pushReview-BotContributor2.Webhook3.GETCode Changes 4.GET Issue Description/Previous Comments6.POSTReview CommentsGenerated Review Commentsv1-beta More ContextHuman Reviewer X19.Comment/ApproveMongoDB7.Chat/Conversation8.Revise
15、5.Prompts/MessagesGPT效果與問題:解決了Review結果收斂問題,上下代碼缺失導致誤判(加哪些代碼到 review 過程,直是個問題)Code-Chat-Review 開發歷程與實現原理Git1.git pushReview AgentContributor2.Webhook3.GETCode Changes 4.GET Issue Description/Previous Comments5.GETMore Context Codelines with Function Calling7.POSTReview CommentsGenerated Review Commen
16、tsv1.0 Function CallingHuman Reviewer X110.Comment/ApproveMongoDB8.Chat/Conversation9.Revise6.Prompts/MessagesChat BotGPTCode-Chat-Review 開發歷程與實現原理Git1.git pushReview AgentContributor2.Webhook3.GETCode Changes 4.GET Issue Description/Previous Comments5.GETMore Context Codelines with Function Calling
17、7.POSTReview CommentsGenerated Review Commentsv1.1 Function Calling with fine-tuned modelHuman Reviewer X110.Comment/ApproveMongoDB8.Chat/Conversation9.Revise6.Prompts/MessagesChat BotGPTFine-tunedLLM應用效果與優缺點PART 03應用效果 優點https:/ “為等待Minikube步驟添加超時,以防Minikube啟動失敗時工作流無限期地運行”應用效果 優點針對產和原型系統提出不同的修改意應用效
18、果 優點 交流設計考量 給出實現代碼應用效果 不足一些簡單的問題并沒有檢查出來(但大部分應該可以通過自動化測試避免)缺少對項目整體上下文的考慮 未來 100K 以上 tokens context-length 模型的測試 (一行代碼大約1020個tokens)對自身代碼Review時容易混淆Prompts,對其他同類項目有可能存在類似問題?(未驗證)還是會提一些瑣碎的問題11月6日以來的新進展PART 0411月6日以來新進展Git1.git pushReview AgentContributor2.Webhook3.GETCode Changes 4.GET Issue Descriptio
19、n/Previous Comments5.GETMore Context Codelines with Function Calling7.POSTReview CommentsGenerated Review Commentsv1.gpt-4 turboassistant apiGPTsHuman Reviewer X110.Comment/Approve8.Chat/Conversation9.Revise6.Prompts/MessagesChat BotGPTGPT-4 Turbo128K Tokens Context Length,最夠多的上下,但復雜項還是不。Function Ca
20、lling獲取上下需要微調。后續討論仍然硬地套格式,雖然在最開始的system prompt已經有了.It is not necessary to use the template when discussing with the user.解決法(很簡單)后續討論組裝messages,把system prompt排除在外GPTs上傳、下載圖、Code Interpreter GPTs看不到構建歷史,也法調試戶訪問本志,但是從外部調可以記錄志RAG效果難盡復雜場景前還是需要接第三服務GPTs上傳、下載圖、Code Interpreter GPTs看不到構建歷史,也法調試戶訪問本志,但是從外部調
21、可以記錄志RAG效果難盡復雜場景前還是需要接第三服務Assistant APIAssistant API不保存對話歷史了很便地換System Message(Instruction)前不持回調總結與展望PART 05整體效果與體會低頻場景,異步:可以接受比較貴(常常也慢)的模型,可以構造比較復雜的調用鏈以及多模型融合整體效果:審核工作量降低 70+%局部問題導致的代碼質量問題減少 40+%核心程序員代碼貢獻量提高一倍以上未來計劃 系統性地標準化測試 其他模型測試較及融合(多個 Review Agent 印證與互補)模型微調 通過向量數據庫接類專家知識,改善對特定項的Review效果 將代碼審查與Git之外的信息(例如需求檔)結合未來計劃RHINO,基于大模型的科研計算平臺 從論idea 實驗代碼 實驗代碼及結果Review 論輔助撰寫/修改ReviewerHelperInnovationNetworkedObservationTHANKS