Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[engine/AI] 현재 author가 작성한 커밋이 있다면 최신 10개 커밋 요약하기 #718

Open
wants to merge 3 commits into
base: epic/ai-summary
Choose a base branch
from

Conversation

choisohyun
Copy link
Contributor

@choisohyun choisohyun commented Sep 9, 2024

Related issue

close #717

Result

vitest 레포지토리로 테스트

latestCommitSummary:  
- chore(deps): update dependencies
- feat(browser): support `--inspect-brk`
- fix(browser): exclude missed packages from optimization
- fix(ui): remove "filters" flickering
- fix: ignore importer when resolving Vitest
  • git 로그인 유저로 커밋이 없는 경우
currentUserCommitSummary:  Please provide the commit messages you would like me to summarize. I need the actual commit messages to follow the instructions and generate the output in the desired format.

개인 레포지토리 테스트

latestCommitSummary:  
- fix: protocol 기본을 https로 변경
- fix: build error
- fix: 잘못된 파일 삭제
- 4주차 템플릿 업로드
- 5주차 템플릿 업로드
- fix: 6주차 템플릿 업로드
- 7주차 템플릿 업로드
- 8주차 템플릿 업로드
- 8주차 서평 & 소감 
currentUserCommitSummary:  
- feat: nav 설정 추가
- fix: protocol 기본을 https로 변경
- fix: 잘못된 파일 삭제
- fix: build error
- 4주차 템플릿 업로드
- 5주차 템플릿 업로드
- fix: 6주차 템플릿 업로드
- 7주차 템플릿 업로드
- 8주차 템플릿 업로드

Work list

기존 커밋 요약 기능을 함수로 분리하고 머지 커밋을 아예 필터링하도록 개선했습니다. 현재 author가 작성한 커밋이 있다면 최신 10개 커밋 요약하는 함수를 추가했습니다.

  • getLatestCommitSummary: 최신 10개 커밋 필터해 요약하기
  • getCurrentUserCommitSummary: 현재 유저가 작성한 최신 커밋 10개 요약하기

Discussion

  • epic/ai-summary으로 머지합니다!
  • 후속 이슈에서 버튼과 상호작용해서 동작하도록 수정할 예정입니다.

@choisohyun choisohyun self-assigned this Sep 9, 2024
@choisohyun choisohyun added this to the v0.7.2 milestone Sep 9, 2024
@choisohyun choisohyun changed the base branch from main to epic/ai-summary September 9, 2024 14:39
@choisohyun choisohyun changed the title [engine/AI] 현재 author가 작성한 커밋이 있다면 최신 10개 커밋 요약하기 [WIP][engine/AI] 현재 author가 작성한 커밋이 있다면 최신 10개 커밋 요약하기 Sep 9, 2024
@choisohyun choisohyun marked this pull request as ready for review September 11, 2024 12:16
@choisohyun choisohyun requested review from a team as code owners September 11, 2024 12:16
@choisohyun choisohyun changed the title [WIP][engine/AI] 현재 author가 작성한 커밋이 있다면 최신 10개 커밋 요약하기 [engine/AI] 현재 author가 작성한 커밋이 있다면 최신 10개 커밋 요약하기 Sep 11, 2024
const nodes = stemDict
.get(baseBranchName)
?.nodes?.map(({ commit }) => commit)
.filter(({ message }) => !message.includes("Merge branch") && !message.includes("Merge pull request"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(궁금) 혹시 Merge branch와 Merge pull request를 상수를 만들어 관리하는 건 별로일까용?? 아래쪽에도 똑같이 쓰이는 것 같아서 여쭤보았습니다!!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

좋습니다! 상수/함수로 분리시켜보았습니다! 91b5a22

Comment on lines +78 to +81
const latestCommitSummary = await getLatestCommitSummary(stemDict, this.baseBranchName);
if (this.isDebugMode) console.log("latestCommitSummary: ", latestCommitSummary);

const currentUserCommitSummary = await getCurrentUserCommitSummary(stemDict, this.baseBranchName, this.octokit);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

변수명이 직관적이라 좋은 것 같아요!!👍👍👍👍👍👍‼️

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

한번 분석을 하고 끝나면 engine의 역할과는 달리, 향후 밖으로 쏘는 API를 가정하고 만들고 있기 때문에 AnalysisEngine클래스안에 어떻게 들어가야할지는 고민이 많이 되네요🤔 목요일에 자세하게 얘기해봅시다!!


const apiKey = process.env.GEMENI_API_KEY || '';
const apiUrl = "https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash-latest:generateContent?key=";
const API_KEY = process.env.GEMENI_API_KEY || "";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(궁금) || "" 을 붙인건 API_KEY가 없어도 fetch를 가능하게 하기 위함인건가요?

혹시 empty string일 때 동작을 하지 않는 케이스라면 따로 처리를 하는게 좋을 수도 있어서 여쭤봤습니다~

export async function getSummary(csmNodes: CommitRaw[]) {
const commitMessages = csmNodes.map((csmNode) => csmNode.message.split('\n')[0]).join(', ');
async function getSummary(csmNodes: CommitRaw[]) {
const commitMessages = csmNodes.map((csmNode) => csmNode.message.split("\n")[0]).join(", ");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SEPERATOR 들은 따로 변수로 빼도 좋을 것 같습니다!

Copy link
Contributor

@mdgarden mdgarden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생하셨습니다!! 깔끔한 코드작성 넘 좋아용 여러모로 자세한 이야기는 목요일에 얘기해봐욥👍👍👍👍👍

Comment on lines +78 to +81
const latestCommitSummary = await getLatestCommitSummary(stemDict, this.baseBranchName);
if (this.isDebugMode) console.log("latestCommitSummary: ", latestCommitSummary);

const currentUserCommitSummary = await getCurrentUserCommitSummary(stemDict, this.baseBranchName, this.octokit);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

한번 분석을 하고 끝나면 engine의 역할과는 달리, 향후 밖으로 쏘는 API를 가정하고 만들고 있기 때문에 AnalysisEngine클래스안에 어떻게 들어가야할지는 고민이 많이 되네요🤔 목요일에 자세하게 얘기해봅시다!!

try {
const response = await fetch(apiUrl + apiKey, {
const response = await fetch(API_URL + API_KEY, {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI에 직접적으로 API를 쏘는 부분은 별도로 함수 분리하면 좋을 것 같습니다!
최종적으로는 generatePrompt 등의 함수로 비교하고 싶은 커밋 + 프롬프트를 합치는 함수와, 해당 내용을 받아서 API를 쏘기만하는 함수 이렇게 나누고 싶습니다.


return await getSummary(currentUserNodes ? currentUserNodes?.slice(-10) : []);
}

const prompt = `Proceed with the task of summarising the contents of the commit message provided.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기도 커맨드마다 프롬프트가 달라지므로 향후 프롬프트들을 어떻게 관리해야할지 고민해봐야할 것 같습니다 ㅠ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[engine/AI] 현재 author가 작성한 커밋이 있다면 최신 10개 커밋 요약하기
4 participants