You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Motivation
<!-- Why is this change necessary? -->
# Content
<!-- Please include a summary of the change -->
# Testing
<!-- How was the change tested? -->
# Please check the following before marking your PR as ready for review
- [ ] I have added tests for my changes
- [ ] I have updated the documentation or added new documentation as
needed
---------
Co-authored-by: kopekC <28070492+kopekC@users.noreply.github.com>
Copy file name to clipboardExpand all lines: src/codegen/extensions/langchain/tools.py
+1-2Lines changed: 1 addition & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -119,7 +119,6 @@ class SearchInput(BaseModel):
119
119
description="""The search query to find in the codebase. When ripgrep is available, this will be passed as a ripgrep pattern. For regex searches, set use_regex=True.
120
120
Ripgrep is the preferred method.""",
121
121
)
122
-
target_directories: Optional[list[str]] =Field(default=None, description="Optional list of directories to search in")
123
122
file_extensions: Optional[list[str]] =Field(default=None, description="Optional list of file extensions to search (e.g. ['.py', '.ts'])")
124
123
page: int=Field(default=1, description="Page number to return (1-based, default: 1)")
125
124
files_per_page: int=Field(default=10, description="Number of files to return per page (default: 10)")
Copy file name to clipboardExpand all lines: src/codegen/extensions/tools/relace_edit_prompts.py
+44-6Lines changed: 44 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -2,19 +2,31 @@
2
2
3
3
RELACE_EDIT_PROMPT="""Edit a file using the Relace Instant Apply API.
4
4
5
+
⚠️ IMPORTANT: The 'edit_snippet' parameter must be provided as a direct string, NOT as a dictionary or JSON object.
6
+
For example, use: edit_snippet="// ... code here ..." NOT edit_snippet={"code": "// ... code here ..."}
7
+
DO NOT pass the edit_snippet as a dictionary or JSON object or dictionary with a 'code' key .
8
+
5
9
The Relace Instant Apply API is a high-speed code generation engine optimized for real-time performance at 2000 tokens/second. It splits code generation into two specialized steps:
6
10
7
11
1. Hard Reasoning: Uses SOTA models like Claude for complex code understanding
8
12
2. Fast Integration: Rapidly merges edits into existing code
9
13
10
-
To use this tool, provide:
11
-
1. The path to the file you want to edit
12
-
2. An edit snippet that describes the changes you want to make
14
+
To use this tool effectively, provide:
15
+
1. The path to the file you want to edit (filepath)
16
+
2. An edit snippet that describes the changes you want to make (edit_snippet)
13
17
14
-
The edit snippet should:
18
+
The edit snippet is crucial for successful merging and should follow these guidelines:
15
19
- Include complete code blocks that will appear in the final output
16
-
- Clearly indicate which parts of the code remain unchanged with comments like "// ... rest of code ..."
17
-
- Maintain correct indentation and code structure
20
+
- Clearly indicate which parts of the code remain unchanged with descriptive comments like:
21
+
* "// ... keep existing imports ..."
22
+
* "// ... rest of the class definition ..."
23
+
* "// ... existing function implementations ..."
24
+
- Maintain correct indentation and code structure exactly as it should appear in the final code
25
+
- Use comments to indicate the purpose of your changes (e.g., "// Add new function")
26
+
- For removing sections, provide sufficient context so it's clear what should be removed
27
+
- Focus only on the modifications, not other aspects of the code
28
+
- Preserve language-specific syntax (comment style may vary by language)
29
+
- Include more context than just the minimal changes - surrounding code helps the API understand where and how to apply the edit
18
30
19
31
Example edit snippet:
20
32
```
@@ -28,7 +40,33 @@
28
40
// ... keep existing code ...
29
41
```
30
42
43
+
Another example (Python):
44
+
```
45
+
# ... existing imports ...
46
+
47
+
# Add new helper function
48
+
def validate_input(data):
49
+
'''Validates the input data structure.'''
50
+
if not isinstance(data, dict):
51
+
raise TypeError("Input must be a dictionary")
52
+
if "id" not in data:
53
+
raise ValueError("Input must contain an 'id' field")
54
+
return True
55
+
56
+
# ... rest of the file ...
57
+
```
58
+
31
59
The API will merge your edit snippet with the existing code to produce the final result.
60
+
The API key will be automatically retrieved from the RELACE_API environment variable.
61
+
62
+
Common pitfalls to avoid:
63
+
- Not providing enough context around changes
64
+
- Providing too little surrounding code (include more than just the changed lines)
65
+
- Incorrect indentation in the edit snippet
66
+
- Forgetting to indicate unchanged sections with comments
67
+
- Using inconsistent comment styles
68
+
- Being too vague about where changes should be applied
69
+
- Passing the edit_snippet as a dictionary or JSON object instead of a direct string
32
70
"""
33
71
34
72
RELACE_EDIT_SYSTEM_PROMPT="""You are an expert at creating edit snippets for the Relace Instant Apply API.
0 commit comments