我正在使用 Vaadin Flow 在 Windows 11 上测试 Vaadin Copilot AI 功能,并要求它执行以下命令:
Create an empty LocationView class with one button on the screen named 'Test'.
作为回应,我收到一个错误:
Error parsing JSON: Unable to write file - JSON chunk that failed
细节:
2025-04-02T02:17:19.100+03:00 INFO 32644 --- [ctor-http-nio-7] com.vaadin.copilot.ai.AICommandHandler : Parsed JSON: StreamResponse[status=VALIDATION, message=Validation finished, exception=, changes={}, code=1]
2025-04-02T02:17:19.757+03:00 INFO 32644 --- [ctor-http-nio-7] com.vaadin.copilot.ai.AICommandHandler : Parsed JSON: StreamResponse[status=PRE_PROCESS, message=Flow Source modified, exception=, changes={}, code=2]
2025-04-02T02:17:20.478+03:00 INFO 32644 --- [ctor-http-nio-7] com.vaadin.copilot.ai.AICommandHandler : Parsed JSON: StreamResponse[status=EMBEDDING_CONTEXT, message=Embedding context retrieval finished, exception=, changes={}, code=2]
2025-04-02T02:17:22.617+03:00 INFO 32644 --- [ctor-http-nio-7] com.vaadin.copilot.ai.AICommandHandler : Parsed JSON: StreamResponse[status=AI_CALL, message=AI call finished, exception=, changes={}, code=2]
2025-04-02T02:17:22.618+03:00 INFO 32644 --- [ctor-http-nio-7] com.vaadin.copilot.ai.AICommandHandler : Parsed JSON: StreamResponse[status=POST_PROCESS, message=Post-process finished, exception=, changes={src\main\java\ai\example\base\ui\view\LocationView.java=package ai.example.base.ui.view;
import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.router.Route;
@Route("location")
public class LocationView extends VerticalLayout {
public LocationView() {
Button testButton = new Button("Test");
add(testButton);
}
}
}, code=2]
2025-04-02T02:17:22.619+03:00 INFO 32644 --- [ctor-http-nio-7] com.vaadin.copilot.ai.AICommandHandler : PostProcess finished
2025-04-02T02:17:22.620+03:00 ERROR 32644 --- [ctor-http-nio-7] com.vaadin.copilot.ai.AICommandHandler : Error parsing JSON: Unable to write file (src\main\java\ai\example\base\ui\view\LocationView.java) with data from copilot server response - JSON chunk that failed: {"status":"POST_PROCESS","message":"Post-process finished","exception":"","changes":{"src\\main\\java\\ai\\example\\base\\ui\\view\\LocationView.java":"package ai.example.base.ui.view;\n\nimport com.vaadin.flow.component.button.Button;\nimport com.vaadin.flow.component.orderedlayout.VerticalLayout;\nimport com.vaadin.flow.router.Route;\n\n@Route(\"location\")\npublic class LocationView extends VerticalLayout {\n\n public LocationView() {\n Button testButton = new Button(\"Test\");\n add(testButton);\n }\n}\n"},"code":2}
我做错了什么,这可能是什么原因造成的?
Vaadin Copilot 目前不支持创建新文件,并且错误消息具有误导性:(。
为了确保从安全角度妥善处理一切,第一轮不支持是一个相当艰难的决定。
已经存在工作和 PR 来改变这一点并支持创建文件,因此当这个 PR 合并并且新的 copilot 客户端(Vaadin 框架)发布时,这一点可能会发生改变,你可以毫无问题地做到这一点。
如果你有其他问题或想法,请继续在 stackoverflow 或相关存储库中提出。我们会倾听和关注,这非常有帮助!
非常感谢alexanoid。