Skip to content

Fix/issue 581 prompt template - #688

Closed
sahithkasam wants to merge 1 commit into
fireform-core:developmentfrom
sahithkasam:fix/issue-581-prompt-template
Closed

sahithkasam wants to merge 1 commit into
fireform-core:developmentfrom
sahithkasam:fix/issue-581-prompt-template

Conversation

@sahithkasam

Copy link
Copy Markdown

Fixes #581

Replaces str.format() with string.Template.safe_substitute() so literal braces in prompt examples do not cause errors.

Updates prompt placeholders and documentation, and adds nine regression tests.

Validation: all 154 tests pass. Existing lint issues remain unchanged.

@sahithkasam
sahithkasam changed the base branch from main to development September 22, 2026 17:39
@marcvergees

Copy link
Copy Markdown
Member

Hey @sahithkasam!

Sorry for the delayed response and welcome to FireForm! Since it looks like that you are a new contributor, I wanna welcome you to FireForm. I want to present myself, I'm Marc and I'm a maintainer and a founder of this project. If you wanna hop on a call with us, we have a discord channel and we meet every single Monday in case that you wanna see what are we working on.

We no longer have to care about this problem on the development branch.

Here is why:


1. The Old Implementation Was Completely Replaced

  • The old app/services/llm.py and its prompt templating logic have been removed on development.
  • Form filling and prompt construction are now handled by app/services/form_filler/filler.py.

2. Prompt Building No Longer Uses str.format()

In app/services/form_filler/filler.py:L76-L84:

def build_prompt(narrative, schema):
    user_content = (
        "<incident_narrative>\n"
        + narrative
        + "\n</incident_narrative>\n\n<target_json_schema>\n"
        + json.dumps(schema["properties"], indent=2, ensure_ascii=False)
        + "\n</target_json_schema>"
    )
    return PROMPT.rstrip() + "\n\n" + user_content
  • The prompt file app/services/form_filler/prompt.txt is read as raw text and combined via string concatenation rather than str.format().
  • You can include literal curly braces {} or JSON examples in prompt.txt without causing KeyError or 500 errors.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: Prompt template uses str.format(), so any literal {/} added to prompt.txt 500s every /forms/fill

2 participants