forked from fuergaosi233/claude-code-proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix_line2.py
More file actions
26 lines (21 loc) · 1.11 KB
/
fix_line2.py
File metadata and controls
26 lines (21 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import sys
with open("src/services/conversion/response_converter.py", "r") as f:
lines = f.readlines()
# Line numbers are 1-indexed, so line 821 is index 820
line_index = 820 # 0-indexed
if line_index < len(lines):
line = lines[line_index]
# Get the indentation
indent = len(line) - len(line.lstrip())
space_indent = " " * indent
# Replace the line with two lines
lines[line_index] = space_indent + "newline = '\\\\n\\\\n'\n"
# For the yield line, we need to be careful about the braces and quotes
# We'll construct it without using an f-string in this script to avoid issues
yield_line = space_indent + 'yield f"event: {Constants.EVENT_CONTENT_BLOCK_DELTA}}\\ndata: {json.dumps({\'type\': Constants.EVENT_CONTENT_BLOCK_DELTA, \'index\': current_block_index, \'delta\': {\'type\': Constants.DELTA_TEXT, \'text\': newline}}, ensure_ascii=False)}\\n\\n"\n'
lines.insert(line_index + 1, yield_line)
with open("src/services/conversion/response_converter.py", "w") as f:
f.writelines(lines)
print("Fixed line 821")
else:
print(f"Line {line_index + 1} not found!")