Skip to content

Commit

Permalink
Merge pull request #682 from githru/feat/579
Browse files Browse the repository at this point in the history
[engine/AI] AI 요약 기능 고도화
  • Loading branch information
choisohyun authored Aug 31, 2024
2 parents ed73632 + d73a815 commit 886be7a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/analysis-engine/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
dist
coverage
.env
3 changes: 2 additions & 1 deletion packages/analysis-engine/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ export class AnalysisEngine {
if (this.isDebugMode) console.log("stemDict: ", stemDict);
const csmDict = buildCSMDict(commitDict, stemDict, this.baseBranchName, pullRequests);
if (this.isDebugMode) console.log("csmDict: ", csmDict);
const geminiCommitSummary = await getSummary(commitRaws?.slice(-10) ?? []);
const nodes = stemDict.get(this.baseBranchName)?.nodes?.map(({commit}) => commit);
const geminiCommitSummary = await getSummary(nodes ? nodes?.slice(-10) : []);
if (this.isDebugMode) console.log("GeminiCommitSummary: ", geminiCommitSummary);

return {
Expand Down
3 changes: 1 addition & 2 deletions packages/analysis-engine/src/summary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ const apiKey = process.env.GEMENI_API_KEY || '';
const apiUrl = "https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash-latest:generateContent?key=";

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

console.log(commitMessages, 'apiKey');
try {
const response = await fetch(apiUrl + apiKey, {
method: "POST",
Expand Down

0 comments on commit 886be7a

Please sign in to comment.