chore: 将后端移动到 api/ 目录,准备合并为单仓库
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e172ffc0b3
commit
0591eda56f
244 files changed
No files matched your search
Whitespace-only changes.
Whitespace-only changes.
@@ -0,0 +1,28 @@
|
||||
from django.core.management.base import BaseCommand
|
||||
|
||||
from prompt.models import Conversation
|
||||
from submission.classifier import classify_conversation_messages
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = "为所有缺失 Bloom 等级的用户消息补全分类"
|
||||
|
||||
def add_arguments(self, parser):
|
||||
parser.add_argument(
|
||||
"--force",
|
||||
action="store_true",
|
||||
help="重新分类所有消息(包括已有等级的)",
|
||||
)
|
||||
|
||||
def handle(self, *args, **options):
|
||||
force = options["force"]
|
||||
convs = Conversation.objects.all()
|
||||
total = convs.count()
|
||||
self.stdout.write(f"共 {total} 个对话,开始分类...")
|
||||
|
||||
for i, conv in enumerate(convs, 1):
|
||||
classify_conversation_messages(conv.id, force=force)
|
||||
self.stdout.write(f"[{i}/{total}] {conv}", ending="\r")
|
||||
self.stdout.flush()
|
||||
|
||||
self.stdout.write(self.style.SUCCESS(f"\n完成,处理了 {total} 个对话。"))
|
||||
@@ -0,0 +1,35 @@
|
||||
from django.core.management.base import BaseCommand
|
||||
|
||||
from prompt.models import Message
|
||||
from submission.classifier import classify_message
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = "Classify prompt levels (L1-L6) for user messages using LLM"
|
||||
|
||||
def add_arguments(self, parser):
|
||||
parser.add_argument("--task-id", type=int, help="Only classify messages for this task ID")
|
||||
parser.add_argument("--force", action="store_true", help="Re-classify already classified messages")
|
||||
parser.add_argument("--dry-run", action="store_true", help="Show count without classifying")
|
||||
|
||||
def handle(self, *args, **options):
|
||||
qs = Message.objects.filter(role="user")
|
||||
if options["task_id"]:
|
||||
qs = qs.filter(conversation__task_id=options["task_id"])
|
||||
if not options["force"]:
|
||||
qs = qs.filter(prompt_level__isnull=True)
|
||||
|
||||
ids = list(qs.values_list("id", flat=True))
|
||||
self.stdout.write(f"Found {len(ids)} message(s) to classify.")
|
||||
|
||||
if options["dry_run"]:
|
||||
self.stdout.write("Dry run — no changes made.")
|
||||
return
|
||||
|
||||
for i, mid in enumerate(ids, 1):
|
||||
level = classify_message(mid)
|
||||
self.stdout.write(
|
||||
f"[{i}/{len(ids)}] msg#{mid} → L{level}" if level else f"[{i}/{len(ids)}] msg#{mid} → (skipped)"
|
||||
)
|
||||
|
||||
self.stdout.write(self.style.SUCCESS("Done."))
|
||||
@@ -0,0 +1,27 @@
|
||||
from django.core.management.base import BaseCommand
|
||||
|
||||
from submission.models import Submission
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = "Recalculate score, raw_score, and zone for all rated submissions"
|
||||
|
||||
def add_arguments(self, parser):
|
||||
parser.add_argument("--dry-run", action="store_true", help="Show what would change without saving")
|
||||
|
||||
def handle(self, *args, **options):
|
||||
dry_run = options["dry_run"]
|
||||
qs = Submission.objects.filter(ratings__isnull=False).distinct()
|
||||
total = qs.count()
|
||||
self.stdout.write(f"Found {total} rated submission(s).")
|
||||
|
||||
if dry_run:
|
||||
self.stdout.write("Dry run — no changes made.")
|
||||
return
|
||||
|
||||
for i, s in enumerate(qs, 1):
|
||||
old_score = s.score
|
||||
s.update_score()
|
||||
self.stdout.write(f"[{i}/{total}] {s.user.username}/{s.task.title}: {old_score:.3f} → {s.score:.3f} zone={s.zone}")
|
||||
|
||||
self.stdout.write(self.style.SUCCESS("Done."))
|
||||
Reference in new issue
Block a user