@@ -10,7 +10,12 @@ async function createIssueFromForm({ github, context, core, fetch }) {
1010 const supplement = supplementMatch ? supplementMatch [ 1 ] . trim ( ) : '' ;
1111
1212 let filteredContent = content ;
13+ let llmCalled = false ;
14+ let llmError = null ;
15+ let toxicVerdict = null ;
16+
1317 if ( supplement ) {
18+ llmCalled = true ;
1419 try {
1520 const res = await fetch ( 'https://models.github.ai/inference/chat/completions' , {
1621 method : 'POST' ,
@@ -48,15 +53,20 @@ async function createIssueFromForm({ github, context, core, fetch }) {
4853 const data = await res . json ( ) ;
4954 const msg = data ?. choices ?. [ 0 ] ?. message ?. content ;
5055 const result = JSON . parse ( msg ) ;
56+ toxicVerdict = result . toxic ;
5157 core . info ( `LLM verdict: ${ JSON . stringify ( result ) } ` ) ;
5258 if ( result . toxic ) {
5359 filteredContent = content . replace (
5460 / ^ こ の 単 語 に つ い て 補 足 す べ き 情 報 が あ れ ば 記 載 し て く だ さ い : \s * ( .* ) $ / m,
5561 `この単語について補足すべき情報があれば記載してください: ${ result . cat } `
5662 ) ;
5763 }
64+ } else {
65+ llmError = `HTTP ${ res . status } ` ;
66+ core . warning ( `LLM filtering failed: ${ llmError } ` ) ;
5867 }
5968 } catch ( err ) {
69+ llmError = `${ err } ` ;
6070 core . warning ( `LLM filtering failed: ${ err } ` ) ;
6171 }
6272 }
@@ -71,14 +81,24 @@ async function createIssueFromForm({ github, context, core, fetch }) {
7181 '' ,
7282 '```' ,
7383 filteredContent ,
74- '```'
75- ] . join ( '\n' ) ;
84+ '```' ,
85+ '' ,
86+ '以下はGitHub Actionsの実行ログです' ,
87+ `LLM API called: ${ llmCalled ? 'Yes' : 'No' } ` ,
88+ llmError ? `Error: ${ llmError } ` : null ,
89+ toxicVerdict !== null ? `Toxic verdict: ${ toxicVerdict } ` : null
90+ ] . filter ( Boolean ) . join ( '\n' ) ;
91+
7692 await github . rest . issues . create ( {
7793 owner : context . repo . owner ,
7894 repo : context . repo . repo ,
7995 title,
8096 body
8197 } ) ;
98+
99+ core . setOutput ( 'llm_called' , llmCalled ) ;
100+ if ( llmError ) core . setOutput ( 'llm_error' , llmError ) ;
101+ if ( toxicVerdict !== null ) core . setOutput ( 'llm_toxic' , toxicVerdict ) ;
82102}
83103
84104module . exports = { createIssueFromForm } ;
0 commit comments