@@ -14,10 +14,12 @@ import { GitHubService } from "../services/github";
14
14
import {
15
15
AddCommentToIssueContent ,
16
16
AddCommentToIssueSchema ,
17
+ GenerateCommentForASpecificPRSchema ,
17
18
isAddCommentToIssueContent ,
19
+ isGenerateCommentForASpecificPRSchema ,
18
20
} from "../types" ;
19
- import { addCommentToIssueTemplate } from "../templates" ;
20
- import { incorporateRepositoryState } from "../utils" ;
21
+ import { addCommentToIssueTemplate , generateCommentForASpecificIssueTemplate } from "../templates" ;
22
+ import { getIssueFromMemories , incorporateRepositoryState } from "../utils" ;
21
23
22
24
export const addCommentToIssueAction : Action = {
23
25
name : "ADD_COMMENT_TO_ISSUE" ,
@@ -46,6 +48,7 @@ export const addCommentToIssueAction: Action = {
46
48
state = await runtime . updateRecentMessageState ( state ) ;
47
49
}
48
50
const updatedState = await incorporateRepositoryState ( state , runtime , message , [ ] ) ;
51
+ updatedState . specificIssue = 1 ; // update to the specific issue number
49
52
elizaLogger . info ( "State:" , updatedState ) ;
50
53
51
54
const context = composeContext ( {
@@ -67,18 +70,41 @@ export const addCommentToIssueAction: Action = {
67
70
68
71
const content = details . object as AddCommentToIssueContent ;
69
72
70
- elizaLogger . info ( "Adding comment to issue in the repository..." ) ;
71
-
72
73
const githubService = new GitHubService ( {
73
74
owner : content . owner ,
74
75
repo : content . repo ,
75
76
auth : runtime . getSetting ( "GITHUB_API_TOKEN" ) ,
76
77
} ) ;
78
+ const issue = await getIssueFromMemories ( runtime , message , content . issue ) ;
79
+ updatedState . specificIssue = JSON . stringify ( issue . content ) ;
80
+ const commentContext = composeContext ( {
81
+ state : updatedState ,
82
+ template : generateCommentForASpecificIssueTemplate ,
83
+ } ) ;
84
+
85
+ const commentDetails = await generateObject ( {
86
+ runtime,
87
+ context : commentContext ,
88
+ modelClass : ModelClass . LARGE ,
89
+ schema : GenerateCommentForASpecificPRSchema ,
90
+ } ) ;
91
+
92
+ if ( ! isGenerateCommentForASpecificPRSchema ( commentDetails . object ) ) {
93
+ elizaLogger . error ( "Invalid comment content:" , commentDetails . object ) ;
94
+ throw new Error ( "Invalid comment content" ) ;
95
+ }
96
+
97
+ const commentBody = commentDetails . object . comment ;
98
+
99
+ elizaLogger . info ( "Adding comment to issue in the repository..." , {
100
+ issue,
101
+ commentBody,
102
+ } ) ;
77
103
78
104
try {
79
105
const comment = await githubService . addIssueComment (
80
106
content . issue ,
81
- content . comment
107
+ commentBody
82
108
) ;
83
109
84
110
elizaLogger . info (
0 commit comments