agent/examples/src/exec_fix.ts

32 lines
1.6 KiB
TypeScript
Raw Normal View History

2025-03-30 09:13:46 +08:00
import ws from 'ws';
import { makeClient } from "./common";
async function run() {
let client = await makeClient((data: ws.RawData)=>{
let d = JSON.parse(data.toString())
console.log("------------------------------- msg start -------------------------------")
console.log(d.msg)
console.log("------------------------------- msg end -------------------------------")
})
let selected_text = {
"filepath": "example\\\\game.py", // 文件路径
"range": {
"start": { "line": 33, "character": 0}, // 从33行0字符开始
"end" : { "line": 45, "character": 41} // 到45行41字符结束
},
"text": `def change_direction(new_direction): \n\n\tglobal direction \n\n\tif new_direction == 'left': \n\t\tif direction != 'right': \n\t\t\tdirection = new_direction \n\telif new_direction == 'right': \n\t\tif direction != 'left': \n\t\t\tdirection = new_direction \n\telif new_direction == 'up': \n\t\tif direction != 'down': \n\t\t\tdirection = new_direction \n\telif new_direction == 'down': \n\t\tif direction != 'up': \n\t\t\tdirection = new_direction` // 源码片段
}
let req = {
"cmd" : "exec_fix",
"request_id": 123, // 随机生成 (必填)
"model" : "local deepseek-r1:32b", //(必填)
"stream" : false,
"selected_text": selected_text,
}
client.send(JSON.stringify(req))
}
run()