Skip to content

PDFファイルから問題を自動生成する機能を追加し、READMEを更新#35

Merged
kazuma11121125 merged 1 commit into
mainfrom
dev-gemini
Jun 2, 2026
Merged

PDFファイルから問題を自動生成する機能を追加し、READMEを更新#35
kazuma11121125 merged 1 commit into
mainfrom
dev-gemini

Conversation

@kazuma11121125

Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings June 2, 2026 15:19
@kazuma11121125 kazuma11121125 merged commit 17a2007 into main Jun 2, 2026
1 of 2 checks passed
@codacy-production

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 1 high · 21 medium · 6 minor

Alerts:
⚠ 28 issues (≤ 0 issues of at least minor severity)

Results:
28 new issues

Category Results
Security 20 medium
3 minor
1 high
CodeStyle 3 minor
Complexity 1 medium

View in Codacy

🟢 Metrics 78 complexity · 0 duplication

Metric Results
Complexity 78
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

PDF添付からGemini API経由で暗記問題を自動生成し、Discord Botの問題追加フローに取り込めるようにするPRです。既存の暗記メモリ機能(Excel/手動追加)に対して、PDF入力の導線と依存関係・READMEを追加しています。

Changes:

  • m!add_pdf <title> のプレフィックスコマンドを追加し、PDFから問題を自動生成して保存できるように変更
  • PDFテキスト抽出(pypdf)+ Gemini生成(google-genai)用の処理を Add に追加
  • 依存関係(pypdf / google-genai / jishaku / openpyxl)とREADME手順を更新

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
requirements.txt PDF解析・Gemini・デバッグ等の依存を追加
README.md Gemini APIキー設定とPDF自動生成コマンドの利用手順を追記
memorization_maker/README.md PDF自動生成機能の説明を追記
memorization_maker/base_question_add.py PDF→テキスト抽出→Gemini→問題正規化→保存の処理を追加
cogs/memorization_cog.py m!add_pdf コマンド追加、OWNER_ID定数化など

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +92 to +109
select = question.get("select", [])
if not isinstance(select, list) or len(select) < 2:
continue
select = [str(choice).strip() for choice in select if str(choice).strip()]
if len(select) < 2:
continue

answer = question.get("answer")
if isinstance(answer, str) and answer.isdigit():
answer = int(answer)
try:
answer = int(answer)
except (TypeError, ValueError):
continue
if answer < 0 or answer >= len(select):
continue

normalized.append({"question": question_text, "answer": answer, "mode": 1, "select": select})

return normalized

async def _extract_pdf_text(self, pdf_path: str) -> str:
Comment on lines +181 to +201
try:
extracted_text = await self._extract_pdf_text(temp_path)
# max_questions の範囲を制限(MAX=100)
try:
max_q = int(max_questions)
except Exception:
max_q = 50
if max_q > 100:
max_q = 100
if max_q < 1:
max_q = 1
questions = await asyncio.to_thread(
self._generate_questions_with_gemini,
temp_path,
extracted_text,
api_key,
max_q,
force_mode,
ai_instruction,
)
return questions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants