Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions .github/workflows/google_form.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


name: Google Form Issue

on:
Expand All @@ -18,10 +16,23 @@ jobs:
- name: Check out repository
uses: actions/checkout@v4
- name: Open issue with form response
id: create
uses: actions/github-script@v7
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
script: |
const { createIssueFromForm } = require('./scripts/google_form_issue.js');
await createIssueFromForm({ github, context, core, fetch });
- name: Summarize LLM call
if: always()
run: |
{
echo "LLM API called: ${{ steps.create.outputs.llm_called }}";
if [ -n "${{ steps.create.outputs.llm_error }}" ]; then
echo "Error: ${{ steps.create.outputs.llm_error }}";
fi
if [ -n "${{ steps.create.outputs.llm_toxic }}" ]; then
echo "Toxic verdict: ${{ steps.create.outputs.llm_toxic }}";
fi
} >> "$GITHUB_STEP_SUMMARY"
24 changes: 22 additions & 2 deletions scripts/google_form_issue.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ async function createIssueFromForm({ github, context, core, fetch }) {
const supplement = supplementMatch ? supplementMatch[1].trim() : '';

let filteredContent = content;
let llmCalled = false;
let llmError = null;
let toxicVerdict = null;

if (supplement) {
llmCalled = true;
try {
const res = await fetch('https://models.github.ai/inference/chat/completions', {
method: 'POST',
Expand Down Expand Up @@ -48,15 +53,20 @@ async function createIssueFromForm({ github, context, core, fetch }) {
const data = await res.json();
const msg = data?.choices?.[0]?.message?.content;
const result = JSON.parse(msg);
toxicVerdict = result.toxic;
core.info(`LLM verdict: ${JSON.stringify(result)}`);
if (result.toxic) {
filteredContent = content.replace(
/^この単語について補足すべき情報があれば記載してください:\s*(.*)$/m,
`この単語について補足すべき情報があれば記載してください: ${result.cat}`
);
}
} else {
llmError = `HTTP ${res.status}`;
core.warning(`LLM filtering failed: ${llmError}`);
}
} catch (err) {
llmError = `${err}`;
core.warning(`LLM filtering failed: ${err}`);
}
}
Expand All @@ -71,14 +81,24 @@ async function createIssueFromForm({ github, context, core, fetch }) {
'',
'```',
filteredContent,
'```'
].join('\n');
'```',
'',
'以下はGitHub Actionsの実行ログです',
`LLM API called: ${llmCalled ? 'Yes' : 'No'}`,
llmError ? `Error: ${llmError}` : null,
toxicVerdict !== null ? `Toxic verdict: ${toxicVerdict}` : null
].filter(Boolean).join('\n');

await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title,
body
});

core.setOutput('llm_called', llmCalled);
if (llmError) core.setOutput('llm_error', llmError);
if (toxicVerdict !== null) core.setOutput('llm_toxic', toxicVerdict);
}

module.exports = { createIssueFromForm };