Skip to content

Commit b59793d

Browse files
authored
Merge pull request #255 from azooKey/codex/edit-google-form-workflow-for-logging
Log LLM details for Google Form workflow
2 parents a3e94e3 + e096d8c commit b59793d

File tree

2 files changed

+35
-4
lines changed

2 files changed

+35
-4
lines changed

.github/workflows/google_form.yaml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
2-
31
name: Google Form Issue
42

53
on:
@@ -18,10 +16,23 @@ jobs:
1816
- name: Check out repository
1917
uses: actions/checkout@v4
2018
- name: Open issue with form response
19+
id: create
2120
uses: actions/github-script@v7
2221
env:
2322
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2423
with:
2524
script: |
2625
const { createIssueFromForm } = require('./scripts/google_form_issue.js');
2726
await createIssueFromForm({ github, context, core, fetch });
27+
- name: Summarize LLM call
28+
if: always()
29+
run: |
30+
{
31+
echo "LLM API called: ${{ steps.create.outputs.llm_called }}";
32+
if [ -n "${{ steps.create.outputs.llm_error }}" ]; then
33+
echo "Error: ${{ steps.create.outputs.llm_error }}";
34+
fi
35+
if [ -n "${{ steps.create.outputs.llm_toxic }}" ]; then
36+
echo "Toxic verdict: ${{ steps.create.outputs.llm_toxic }}";
37+
fi
38+
} >> "$GITHUB_STEP_SUMMARY"

scripts/google_form_issue.js

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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

84104
module.exports = { createIssueFromForm };

0 commit comments

Comments
 (0)