lplalbert opened a new pull request, #417:
URL: https://github.com/apache/hugegraph-ai/pull/417
Refs #107 (Tiny Task: fix TODO/FIXME in LLM code)
## What
`rag_requests.py` baked `prompt.answer_prompt` /
`prompt.keywords_extract_prompt` /
`prompt.gremlin_generate_prompt` into the request models' `Query` defaults
at import
time (the file's own `# TODO: import the default value of prompt.*
dynamically`
admitted it), so the `req.x or prompt.x` fallbacks in `rag_api.py` never
resolved the
current `PromptConfig` for omitted fields — callers silently received the
server-start
snapshot even after a runtime prompt update. `KeywordExtract` carried the
same bug
class via its module-level `KEYWORDS_EXTRACT_TPL` snapshot.
## ⚠️ Behavior change (please weigh in)
Omitted API prompt fields now resolve the **current** `PromptConfig` at
request time
instead of the import-time snapshot. Identical in practice unless prompts
are updated
at runtime (demo UI / `update_yaml_file()`) — such updates are now visible
to API calls
that omit the fields. Side effect: the huge prompt strings disappear from
the OpenAPI
field defaults (they now show `null`).
## Changes
- `RAGRequest.answer_prompt/keywords_extract_prompt/gremlin_prompt`,
`GraphRAGRequest.gremlin_prompt`, `GremlinGenerateRequest.gremlin_prompt`
default to
`None`; every call site resolves the live `prompt` object (`rag_api.py`
fallbacks;
`Text2GremlinNode`/`GremlinGenerateSynthesize` already fell back when
given `None`).
- `/text2gremlin` gets the same handler-level `req.x or prompt.x` fallback
as `/rag`
and `/rag/graph`, so all three endpoints resolve uniformly at request time.
- `KeywordExtract` reads `prompt.keywords_extract_prompt` at construction
instead of
the removed import-time `KEYWORDS_EXTRACT_TPL` constant.
- Tests in `test_prompt_config.py` (removes both FIXMEs): omitted fields
resolve the
current `PromptConfig` across `/rag`, `/rag/graph`, `/text2gremlin` and
`KeywordExtract`; runtime-loaded `config_prompt.yaml` extract prompts pass
the same
example/parser contract as the class constants (EN + CN).
## Validation (actually run; offline only)
- red→green (stash-demonstrated): the 4 resolution tests fail on the old
defaults —
failure output shows the import-time prompt strings directly — then 16
passed after
(whole `test_prompt_config.py`)
- `SKIP_EXTERNAL_SERVICES=true uv run pytest src/tests/config/ src/tests/api/
src/tests/operators/llm_op/ src/tests/nodes/` → 351 passed, 3 subtests
passed,
2 failed — the 2 failures are pre-existing on Windows
(`test_external_config.py`
asserts POSIX 0600 file-mode bits) and unrelated to this diff
- `uv run --extra dev ruff format --check .` / `ruff check .` → clean (588
files)
- `uv run --extra dev ty check hugegraph-llm/src/hugegraph_llm` → 271 (same
as
current `main`)
- Real-provider verification: none (offline tests only)
Refs #107
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]