feat(question_gen): QuestionGenerator Protocol + 模块公开 API
app/ports.py 追加 QuestionGenerator Protocol(预留 LLM 出题接口)。 app/question_gen/__init__.py re-export load_benchmark 和 stratified_sample。 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -7,6 +7,9 @@ from typing import TYPE_CHECKING, Protocol, runtime_checkable
|
||||
if TYPE_CHECKING:
|
||||
import numpy as np
|
||||
|
||||
from app.tree.index import TreeIndex
|
||||
from core.types import GeneratedQuestion
|
||||
|
||||
|
||||
@runtime_checkable
|
||||
class EmbeddingProvider(Protocol):
|
||||
@@ -29,3 +32,27 @@ class EmbeddingProvider(Protocol):
|
||||
[N, D] ndarray,每行 L2 范数为 1.0。
|
||||
"""
|
||||
...
|
||||
|
||||
|
||||
@runtime_checkable
|
||||
class QuestionGenerator(Protocol):
|
||||
"""LLM 驱动的题目生成端口(预留接口)。
|
||||
|
||||
参数:
|
||||
video_id: 视频标识。
|
||||
task_type: 题型。
|
||||
tree: 视频树索引,提供锚节点上下文。
|
||||
exemplars: 风格示例题目列表。
|
||||
|
||||
返回:
|
||||
生成的单条题目。
|
||||
"""
|
||||
|
||||
async def generate(
|
||||
self,
|
||||
video_id: str,
|
||||
task_type: str,
|
||||
tree: TreeIndex,
|
||||
*,
|
||||
exemplars: list[GeneratedQuestion],
|
||||
) -> GeneratedQuestion: ...
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
"""出题模块 — benchmark 加载与分层采样。"""
|
||||
|
||||
from app.question_gen.loader import load_benchmark, stratified_sample
|
||||
|
||||
__all__ = ["load_benchmark", "stratified_sample"]
|
||||
|
||||
Reference in New Issue
Block a user