lplalbert commented on code in PR #419:
URL: https://github.com/apache/hugegraph-ai/pull/419#discussion_r4579646212
##########
hugegraph-llm/src/hugegraph_llm/demo/rag_demo/app.py:
##########
@@ -142,6 +123,8 @@ def refresh_ui_config_prompt() -> tuple:
huge_settings.graph_name,
prompt.gremlin_generate_prompt,
)
+ refresh_settings_snapshot()
Review Comment:
Root cause: `refresh_ui_config_prompt` resolved the prompts before reloading
the settings, so `prompt.ensure_yaml_file_exists()` compared the persisted
`LANGUAGE` against the pre-reload `llm_settings.language`. With a language
changed while the app runs, the language check matched the old value, no
regeneration happened, and both the page values and the shared `prompt` object
kept the old language's prompts — while `ui_control_values()` (read after the
reload) already showed the new state.
Structural fix (9113ff9):
- The load handler now calls `refresh_settings_snapshot()` *before*
`prompt.ensure_yaml_file_exists()`, so prompt resolution sees the refreshed
language and the values handed to the page follow it.
- `refresh_settings_snapshot()` now re-resolves the shared prompts whenever
the reload it performs changes the language, so a form render that picks up a
changed language keeps the prompt object in step instead of leaving it behind
until another prompt reload. The sync lives in the shared refresh boundary that
all renders and the load handler go through.
- The `saved_config` fixture points `prompt.llm_settings` at its isolated
settings instance (it had kept the pre-fixture object, diverging from the
production object graph where `prompt.llm_settings is llm_settings`).
Validation: two new contract tests drive the real load handler and the real
Gradio render pipeline with a prompt file generated for English plus an
out-of-band `LANGUAGE=CN` edit — both red before the fix (page and prompt
object keep the English values), green after. Full suite `1299 passed, 12
skipped, 2 failed` (the pre-existing Windows mode-bit pair in
`test_external_config.py`, fails on `main` too). `ruff format --check` / `ruff
check` clean; `ty` 265 -> 265 on the production tree (zero new) and 1 -> 0 on
the touched test files (the shared load-handler helper also removed the
pre-existing `load.fn()` diagnostic).
--
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]