Skip to content

Add versioned prompt profiles, output gates, bounded generation concurrency and env-gated LLM client patches - #194

Open
Leon-Algo wants to merge 1 commit into
InternScience:mainfrom
Leon-Algo:pr-b-prompt-profiles-mechanisms
Open

Leon-Algo wants to merge 1 commit into
InternScience:mainfrom
Leon-Algo:pr-b-prompt-profiles-mechanisms

Conversation

@Leon-Algo

Copy link
Copy Markdown

Summary

  • Versioned prompt profiles: graphgen/templates/prompt_profiles.py + BaseGenerator.TEMPLATE_KEY/apply_prompt_profile/template(); all 11 generator build_prompt overrides become instance methods. Profiles are JSON directories structurally validated against the official template constants (fail-closed); built-in example.v1 ships byte-identical official templates as an example. No profile applied → byte-identical official behavior.
  • Generic output-gate registry: graphgen/operators/generate/gates.py with register_gate/GATES and a generic non_empty_answer gate. No domain-specific gates included.
  • Bounded generation concurrency: event-loop semaphore exposed as GenerateService(llm_concurrency=N); default unchanged.
  • GenerateService opt-in options: prompt_profile / output_gate / llm_concurrency — all default to upstream behavior.
  • Env-gated LLM client patches (all off by default): GRAPHGEN_EMPTY_RETRY bounded empty-response retry (rate-limiter re-applied per attempt), GRAPHGEN_EMPTY_EXTRACTION_PREFILL JSON-compatible assistant prefill { for the schema-guided extractor (the previous tuple-format prefill can never parse against json.loads), GRAPHGEN_DISABLE_THINKING for logprob calls, and GRAPHGEN_LLM_ACTOR_MAX_CONCURRENCY Ray actor option + logger-context fallback.
  • Packaging: package_data gains templates/profiles/*/*.json only. Upstream package identity (name/version/url/author) untouched.

Second of three PRs split from #192 per review; no PMS assets, no fork identity. PR A (partitioner test fixes) and PR C (event-entity pipeline, builds on this) follow separately.

Validation

  • pytest tests/unit_tests → 20 passed (profiles 8, gates 3, llm_concurrency 2, openai patches 4, log 1, plus collection checks).
  • pylint --rcfile=.pylintrc baselines/ graphgen/ webui/ → 10.00/10, zero messages (CI gate green; resolves the arguments-differ findings on all generator overrides noted in Add versioned prompt profiles and event-entity generation pipeline #192).

🤖 Generated with Claude Code

- prompt profile:BaseGenerator 新增 TEMPLATE_KEY/apply_prompt_profile/template,
  全部生成器 build_prompt 覆写改为实例方法;prompt_profiles.py 结构校验 +
  fail-closed;内置 example.v1 通用 profile(内容与官方模板逐字一致)
- 输出门注册表:gates.py register_gate/GATES + 内置 non_empty_answer 通用门,
  GenerateService 增加 prompt_profile/output_gate/llm_concurrency 选项
- 生成并发:llm_concurrency.py 事件循环内有界并发包装
- LLM 客户端 4 个 env 门控补丁:GRAPHGEN_EMPTY_RETRY 空响应有界重试、
  GRAPHGEN_EMPTY_EXTRACTION_PREFILL 空抽取 assistant prefill 重试、
  GRAPHGEN_DISABLE_THINKING logprob 调用关思考、可选 assistant_prefill 参数;
  GRAPHGEN_LLM_ACTOR_MAX_CONCURRENCY 提升 Ray actor 并发;logger 空上下文回退
- 未设置任何 env / 选项时行为与官方默认逐字一致;不改动包身份与版本号

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant