Views
No views yet
1<instruction>You are a coding assistant that helps merge code updates, ensuring every modification is fully integrated. Merge all changes from the snippet into the code. Preserve the code's structure, order, comments, and indentation exactly.</instruction>
2
3<fastapply>
4 <code>
5 {original_code}
6 </code>
7 <update>
8 {update_snippet}
9 </update>
10 <finalcode>
11 {merged_result}
12 </finalcode>
13</fastapply><fastapply> blocks for few-shot context learning. Use your stop token as </fastapply>.1export VLLM_ALLOW_RUNTIME_LORA_UPDATING=1
2export VLLM_ALLOW_LONG_MAX_MODEL_LEN=1
3
4vllm serve unsloth/qwen2.5-3b \
5 --gpu-memory-utilization=1 \
6 --port 6002 \
7 --served-model-name="turbopasta" \
8 --trust-remote-code \
9 --max-model-len 8192 \
10 --disable-log-requests \
11 --enable-lora \
12 --lora-modules lora=./dataset/output/turbopasta/lora_model \
13 --max-lora-rank 641import requests
2
3def merge_code(original_code: str, update_snippet: str, vllm_url: str = "http://localhost:6002/v1/completions") -> dict:
4 xml_content = (
5 '<instruction>You are a coding assistant that helps merge code updates, ensuring every modification is fully '
6 'integrated. Merge all changes from the snippet into the code. Preserve the code\'s structure, order, comments, '
7 'and indentation exactly.</instruction>\n'
8 '<fastapply>\n'
9 ' <code>\n'
10 f'{original_code}\n'
11 ' </code>\n'
12 ' <update>\n'
13 f'{update_snippet}\n'
14 ' </update>'
15 )
16
17 response = requests.post(
18 vllm_url,
19 json={
20 "prompt": xml_content,
21 "max_tokens": 6000,
22 "temperature": 0.1,
23 "model": "lora",
24 "stop": ["</fastapply>"]
25 },
26 timeout=30000
27 )
28
29 completion = response.json()["choices"][0]["text"]
30
31 # Parse XML tags
32 import re
33 def extract_tag(tag: str) -> str:
34 match = re.search(f'<{tag}>(.*?)</{tag}>', completion, re.DOTALL)
35 return match.group(1).strip() if match else ""
36
37 return {
38 "merged_code": extract_tag("finalcode")
39 }1from request_processor import RequestProcessor
2
3processor = RequestProcessor(
4 input_file="updates.jsonl",
5 output_file="merged.jsonl",
6 num_threads=24
7)
8processor.process_file()1{
2 "id": "update_id",
3 "original_code": "...",
4 "update_snippet": "...",
5 "file_path": "path/to/file"
6}1{
2 "id": "update_id",
3 "original_code": "...",
4 "update_snippet": "...",
5 "merged_code": "...",
6 "file_path": "path/to/file",
7 "processed_at": "2024-10-24 02:52:33"
8}1{
2 "error": "error message",
3 "processed_at": "timestamp"
4}tail -f merged.jsonl | grep error