Guard protocol generation against context truncation
This commit is contained in:
@@ -20,6 +20,7 @@ if str(REPO_ROOT) not in sys.path:
|
||||
from src.meeting_lab.llm.ollama import DEFAULT_ENDPOINT # noqa: E402
|
||||
from src.meeting_lab.protocol.generate_direct_protocol import ( # noqa: E402
|
||||
DEFAULT_MODEL,
|
||||
DEFAULT_SAFE_INPUT_TOKEN_BUDGET,
|
||||
DirectProtocolResult,
|
||||
generate_direct_protocol,
|
||||
)
|
||||
@@ -35,6 +36,11 @@ def parse_args(argv: list[str] | None = None) -> argparse.Namespace:
|
||||
parser.add_argument("--output-root", type=Path, default=DEFAULT_OUTPUT_ROOT)
|
||||
parser.add_argument("--model", default=DEFAULT_MODEL)
|
||||
parser.add_argument("--ollama-endpoint", default=DEFAULT_ENDPOINT)
|
||||
parser.add_argument(
|
||||
"--safe-input-token-budget",
|
||||
type=int,
|
||||
default=DEFAULT_SAFE_INPUT_TOKEN_BUDGET,
|
||||
)
|
||||
return parser.parse_args(argv)
|
||||
|
||||
|
||||
@@ -64,6 +70,11 @@ def persist_result(run_dir: Path, result: DirectProtocolResult) -> Path:
|
||||
(protocol_dir / "exact_prompt.txt").write_text(result.exact_prompt, encoding="utf-8")
|
||||
write_json(protocol_dir / "raw_response.json", result.raw_response)
|
||||
write_json(protocol_dir / "runtime_metadata.json", result.runtime_metadata)
|
||||
transcript_input = getattr(result, "transcript_input", None)
|
||||
if transcript_input is not None:
|
||||
(protocol_dir / "transcript_input.txt").write_text(
|
||||
transcript_input, encoding="utf-8"
|
||||
)
|
||||
protocol_path = run_dir / "protocol.md"
|
||||
protocol_path.write_text(result.protocol_text, encoding="utf-8")
|
||||
return protocol_path
|
||||
@@ -116,6 +127,7 @@ def run(args: argparse.Namespace) -> tuple[int, Path, Path | None]:
|
||||
preserved_context,
|
||||
model=args.model,
|
||||
endpoint=args.ollama_endpoint,
|
||||
safe_input_token_budget=args.safe_input_token_budget,
|
||||
)
|
||||
protocol_path = persist_result(run_dir, result)
|
||||
metadata["status"] = "completed"
|
||||
|
||||
@@ -19,6 +19,7 @@ from src.meeting_lab.orchestration.mvp import ( # noqa: E402
|
||||
DEFAULT_DIARIZATION_MODEL,
|
||||
DEFAULT_MODEL,
|
||||
DEFAULT_OUTPUT_ROOT,
|
||||
DEFAULT_SAFE_INPUT_TOKEN_BUDGET,
|
||||
MvpMeetingConfig,
|
||||
create_unique_run_dir,
|
||||
run_mvp_meeting,
|
||||
@@ -53,6 +54,12 @@ def parse_args(argv: list[str] | None = None) -> argparse.Namespace:
|
||||
)
|
||||
parser.add_argument("--model", default=DEFAULT_MODEL)
|
||||
parser.add_argument("--ollama-endpoint", default=DEFAULT_ENDPOINT)
|
||||
parser.add_argument(
|
||||
"--protocol-safe-input-token-budget",
|
||||
type=int,
|
||||
default=DEFAULT_SAFE_INPUT_TOKEN_BUDGET,
|
||||
help="Conservative estimated prompt-token limit before any Ollama request.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--diarization",
|
||||
choices=("auto", "gpu", "cpu", "off"),
|
||||
@@ -91,6 +98,7 @@ def config_from_args(args: argparse.Namespace) -> MvpMeetingConfig:
|
||||
threads=args.threads,
|
||||
model=args.model,
|
||||
ollama_endpoint=args.ollama_endpoint,
|
||||
protocol_safe_input_token_budget=args.protocol_safe_input_token_budget,
|
||||
diarization=args.diarization,
|
||||
diarization_runtime=args.diarization_runtime,
|
||||
diarization_container_image=args.diarization_container_image,
|
||||
|
||||
Reference in New Issue
Block a user