@@ -25,17 +25,19 @@ export async function searchIssuesAndPRs(octokit, owner, repo, query, perPage =
2525
2626 try {
2727 const gptscriptClient = new GPTScript ( ) ;
28- const dataset = await gptscriptClient . createDataset ( process . env . GPTSCRIPT_WORKSPACE_ID , `${ query } _github_issues_prs` , `Search results for ${ query } on GitHub` ) ;
2928 const elements = items . map ( issue => {
3029 return {
31- name : issue . id ,
30+ name : ` ${ issue . id } ` ,
3231 description : '' ,
33- contents : Buffer . from ( `#${ issue . number } - ${ issue . title } (ID: ${ issue . id } ) - ${ issue . html_url } ` )
32+ contents : `#${ issue . number } - ${ issue . title } (ID: ${ issue . id } ) - ${ issue . html_url } `
3433 }
3534 } ) ;
36- await gptscriptClient . addDatasetElements ( process . env . GPTSCRIPT_WORKSPACE_ID , dataset . id , elements ) ;
35+ const datasetID = await gptscriptClient . addDatasetElements ( elements , {
36+ name : `${ query } _github_issues_prs` ,
37+ description : `Search results for ${ query } on GitHub`
38+ } )
3739
38- console . log ( `Created dataset with ID ${ dataset . id } with ${ elements . length } results` ) ;
40+ console . log ( `Created dataset with ID ${ datasetID } with ${ elements . length } results` ) ;
3941 } catch ( e ) {
4042 console . log ( 'Failed to create dataset:' , e )
4143 }
@@ -93,21 +95,18 @@ export async function listIssueComments(octokit, owner, repo, issueNumber) {
9395
9496 try {
9597 const gptscriptClient = new GPTScript ( ) ;
96- const dataset = await gptscriptClient . createDataset (
97- process . env . GPTSCRIPT_WORKSPACE_ID ,
98- `${ owner } _${ repo } _issue_${ issueNumber } _comments` ,
99- `Comments for issue #${ issueNumber } in ${ owner } /${ repo } `
100- ) ;
10198 const elements = data . map ( comment => {
10299 return {
103- name : comment . id ,
100+ name : ` ${ comment . id } ` ,
104101 description : '' ,
105- contents : Buffer . from ( `Comment by ${ comment . user . login } : ${ comment . body } - https://github.com/${ owner } /${ repo } /issues/${ issueNumber } #issuecomment-${ comment . id } ` )
102+ contents : `Comment by ${ comment . user . login } : ${ comment . body } - https://github.com/${ owner } /${ repo } /issues/${ issueNumber } #issuecomment-${ comment . id } `
106103 }
107104 } ) ;
108- await gptscriptClient . addDatasetElements ( process . env . GPTSCRIPT_WORKSPACE_ID , dataset . id , elements ) ;
109-
110- console . log ( `Created dataset with ID ${ dataset . id } with ${ elements . length } comments` ) ;
105+ const datasetID = await gptscriptClient . addDatasetElements ( elements , {
106+ name : `${ owner } _${ repo } _issue_${ issueNumber } _comments` ,
107+ description : `Comments for issue #${ issueNumber } in ${ owner } /${ repo } `
108+ } )
109+ console . log ( `Created dataset with ID ${ datasetID } with ${ elements . length } comments` ) ;
111110 } catch ( e ) {
112111 console . log ( 'Failed to create dataset:' , e ) ;
113112 }
@@ -179,21 +178,18 @@ export async function listPRComments(octokit, owner, repo, prNumber) {
179178
180179 try {
181180 const gptscriptClient = new GPTScript ( ) ;
182- const dataset = await gptscriptClient . createDataset (
183- process . env . GPTSCRIPT_WORKSPACE_ID ,
184- `${ owner } _${ repo } _pr_${ prNumber } _comments` ,
185- `Comments for PR #${ prNumber } in ${ owner } /${ repo } `
186- ) ;
187181 const elements = data . map ( comment => {
188182 return {
189- name : comment . id ,
183+ name : ` ${ comment . id } ` ,
190184 description : '' ,
191- contents : Buffer . from ( `Comment by ${ comment . user . login } : ${ comment . body } - https://github.com/${ owner } /${ repo } /pull/${ prNumber } #issuecomment-${ comment . id } ` )
185+ contents : `Comment by ${ comment . user . login } : ${ comment . body } - https://github.com/${ owner } /${ repo } /pull/${ prNumber } #issuecomment-${ comment . id } `
192186 }
193187 } ) ;
194- await gptscriptClient . addDatasetElements ( process . env . GPTSCRIPT_WORKSPACE_ID , dataset . id , elements ) ;
195-
196- console . log ( `Created dataset with ID ${ dataset . id } with ${ elements . length } comments` ) ;
188+ const datasetID = await gptscriptClient . addDatasetElements ( elements , {
189+ name : `${ owner } _${ repo } _pr_${ prNumber } _comments` ,
190+ description : `Comments for PR #${ prNumber } in ${ owner } /${ repo } `
191+ } )
192+ console . log ( `Created dataset with ID ${ datasetID } with ${ elements . length } comments` ) ;
197193 } catch ( e ) {
198194 console . log ( 'Failed to create dataset:' , e ) ;
199195 }
@@ -219,22 +215,18 @@ export async function listRepos(octokit, owner) {
219215
220216 try {
221217 const gptscriptClient = new GPTScript ( ) ;
222- const dataset = await gptscriptClient . createDataset (
223- process . env . GPTSCRIPT_WORKSPACE_ID ,
224- `${ owner } _github_repos` ,
225- `GitHub repos for ${ owner } `
226- ) ;
227-
228218 const elements = repos . data . map ( repo => {
229219 return {
230- name : repo . id ,
220+ name : ` ${ repo . id } ` ,
231221 description : '' ,
232- contents : Buffer . from ( `${ repo . name } (ID: ${ repo . id } ) - https://github.com/${ owner } /${ repo . name } ` )
222+ contents : `${ repo . name } (ID: ${ repo . id } ) - https://github.com/${ owner } /${ repo . name } `
233223 }
234224 } ) ;
235- await gptscriptClient . addDatasetElements ( process . env . GPTSCRIPT_WORKSPACE_ID , dataset . id , elements ) ;
236-
237- console . log ( `Created dataset with ID ${ dataset . id } with ${ elements . length } repositories` ) ;
225+ const datasetID = await gptscriptClient . addDatasetElements ( elements , {
226+ name : `${ owner } _github_repos` ,
227+ description : `GitHub repos for ${ owner } `
228+ } )
229+ console . log ( `Created dataset with ID ${ datasetID } with ${ elements . length } repositories` ) ;
238230 } catch ( e ) {
239231 console . log ( 'Failed to create dataset:' , e ) ;
240232 }
0 commit comments