Skip to content

Fix: Replace manual placeholders to avoid .format() issues in COMMUNITY_REPORT_PROMPT #1901

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

droideronline
Copy link

Description

  • In the community_reports_extractor file Using .format() caused errors because the COMMUNITY_REPORT_PROMPT has other {} braces (e.g., in JSON examples).
  • Python .format() tries to parse those and fails.

Related Issues

#1900

Proposed Changes

  • Switched to using .replace() to manually substitute {input_text} and {max_report_length}.
  • Avoids conflict with embedded braces and ensures prompt generation works correctly.

Checklist

  • I have tested these changes locally.
  • I have reviewed the code changes.
  • I have updated the documentation (if necessary).
  • I have added appropriate unit tests (if applicable).

Additional Notes

  • The error occurred because .format() was used on a prompt where only the input variables ({input_text} and {max_report_length}) were meant to be replaced.
  • Although all non-input curly braces (for JSON structure) were correctly escaped with double brackets {{ }}, using .format() still caused issues due to complex formatting.
  • Replaced .format() with manual .replace() for input_text and max_report_length to fix the problem safely without impacting the rest of the prompt structure.

@droideronline droideronline requested review from a team as code owners April 26, 2025 19:58
@droideronline
Copy link
Author

@AlonsoGuevara Please review the PR when you have time. Thanks!

@natoverse
Copy link
Collaborator

Did you run prompt tuning? It looks like the issue is that prompt tune calls format to insert its variables, reducing the bracket count by one when written back out. Running with default prompts does not exhibit the issue.

We're going to look for a fix on the prompt tuning side so we can retain the use of format

@droideronline
Copy link
Author

Yes, I did manual prompt tuning, understood now it makes sense. Thanks

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.

2 participants