Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions prompt_llm/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
_HISTORY_DIFF_CHAR_CAP = 3000
_HISTORY_ERROR_CHAR_CAP = 1500

ANTI_CHEAT_RULES = """IMPORTANT — Anti-cheat rules (violations will be detected and flagged):
- Only implement functions marked with //TODO; do not modify any other function.
- You may add new helper functions, but do not change existing ones that lack //TODO.
- Every TODO section must be genuinely implemented with real logic.
- Do NOT output hardcoded or fake metric values to pass tests."""


def _truncate_middle(text: str, cap: int) -> str:
"""Trim text to `cap` chars by keeping head and tail and eliding the middle."""
Expand Down Expand Up @@ -198,6 +204,8 @@ def generate_completion_prompt(source_file: str) -> str:
- Follow idiomatic Python and PyTorch practices.
- Do not introduce unnecessary dependencies.

{ANTI_CHEAT_RULES}

The code to be completed is as follows:

{source_content}
Expand Down Expand Up @@ -235,6 +243,8 @@ def generate_completion_prompt(source_file: str) -> str:
- collective algorithms (ring/tree)
- If you introduce a new helper, place it in the specified file(s) only.

{ANTI_CHEAT_RULES}

The code to be completed is as follows:

{source_content}
Expand Down Expand Up @@ -461,6 +471,8 @@ def generate_fix_prompt_from_code(
- Take the earlier failed attempts (if any) into account: do not propose a
patch that is essentially equivalent to one already shown to fail.

{ANTI_CHEAT_RULES}

Do not include any other text.

Please return only the complete {file_type} code, without any additional text, explanations, or markdown formatting.
Expand Down
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ google-genai
matplotlib
openai
tiktoken
tree-sitter
tree-sitter-cpp
tree-sitter-python
Loading