Skip to content

fix(llm): use built-in prompts when config_prompt.yaml is empty - #438

Open
iiiiSaber wants to merge 1 commit into
apache:mainfrom
iiiiSaber:fix/empty-prompt-config
Open

iiiiSaber wants to merge 1 commit into
apache:mainfrom
iiiiSaber:fix/empty-prompt-config

Conversation

@iiiiSaber

Copy link
Copy Markdown

Problem

This is a bug of empty configure file (corner case).

An empty or comment-only config_prompt.yaml prevents HugeGraph LLM from starting. PyYAML returns None for a file with no YAML data, and the prompt loader raises AttributeError when it tries to read the overrides with .items().

Fix

Use the built-in prompts for the configured language when PyYAML returns None. Load the defaults in memory and preserve the file contents.

Verification

  • Launched the HugeGraph LLM demo locally with an empty config_prompt.yaml and again with a comment-only file. Before the fix, both launches exited with AttributeError. With the fix, both launches served / and /gradio_api/info with HTTP 200.
  • Passed all 15 tests in test_resource_mounts.py and test_prompt_config.py.
  • Ruff lint and formatting passed.

Refs #166

@github-actions github-actions Bot added the llm label Nov 21, 2026

@imbajin imbajin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Score: 7.5/10 · Confidence: high

Blocking: yes

Summary

Reloading an empty prompt file can retain stale graph settings and prompts instead of built-in defaults.

Evidence

The UI reloads the shared prompt instance; the empty branch resets only five language-dependent fields, leaving prior overrides in instance attributes.

Validation notes

Source-path analysis only; no live UI or external-service test was run.


if data is None:
self._set_language_defaults()
log.info("Prompt file %s is empty; using built-in defaults without writing", yaml_file_path)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reset all prompt overrides on an empty-file reload

When a previously loaded configuration is truncated while the process is running, opening the UI calls this method again on the shared prompt instance. _set_language_defaults() resets only five language-dependent fields, so earlier overrides such as graph_schema, review_graph_prompt, and repair_graph_prompt remain active despite the message that built-in defaults are in use; a subsequent save can write them back. Please reset the persisted fields to their built-in defaults before returning, and cover the populated-to-empty reload.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants