unit-mesh / auto-dev

🧙‍AutoDev: The AI-powered coding wizard(AI 驱动编程助手) with multilingual support 🌐, auto code generation 🏗️, and a helpful bug-slaying assistant 🐞! Customizable prompts 🎨 and a magic Auto Dev/Testing/Document/Agent feature 🧪 included! 🚀
https://ide.unitmesh.cc/
Mozilla Public License 2.0
2.72k stars 314 forks source link

增加打印日志 action 及 gpt prompt 的处理问题 #136

Closed zjh7890 closed 5 months ago

zjh7890 commented 5 months ago

1. 增加打印日志 action

需求就是如题了,打印日志我个人使用的 prompt 是: 你是一个专业的程序员,请在 ${generatedContent} 处打印日志,不需要解释,只需要返回 ${generatedContent} 处生成的内容

import ...

public class A {
    public void someMethod() {
        ${generatedContent}
        return;
    }
}

2. gpt prompt 处理问题,只包含了 prefix

这是想探讨的另一个问题,比如上面我生成日志用的 prompt 实际给出了完整的文件内容和待插入的位置 然后我注意到 auto-dev 的 prompt 其实只包含了光标之前的内容,即 prefix auto-dev 应该是参考了 copilot 并且考虑了 token 的成本问题,不过也会引入一些问题 如 b 站演示视频在代码生成的时候就出现一些重复的花括号 } } suffix 包含的下文或许也包含了些有用的信息 个人认为 auto-dev 是主动触发的 action,不同于 copilot 的换行就会触发,token 用量上是不是可以也稍微放开点。

phodal commented 5 months ago

我理解你要的是 Code complete 中的 Fill in Middle 的功能?

suffix 的代码其实也包含在其中,只是一直没有作为 prompt 来处理:

https://github.com/unit-mesh/auto-dev/blob/90550ed0de0a204c49495867ec3c83e9d5c8db7b/src/main/kotlin/cc/unitmesh/devti/actions/chat/base/ChatBaseAction.kt#L46-L48

可能得看其他人有没有兴趣实现类似的功能? @jialiu-github 有兴趣吗?

zjh7890 commented 5 months ago

我理解你要的是 Code complete 中的 Fill in Middle 的功能?

suffix 的代码其实也包含在其中,只是一直没有作为 prompt 来处理:

https://github.com/unit-mesh/auto-dev/blob/90550ed0de0a204c49495867ec3c83e9d5c8db7b/src/main/kotlin/cc/unitmesh/devti/actions/chat/base/ChatBaseAction.kt#L46-L48

可能得看其他人有没有兴趣实现类似的功能? @jialiu-github 有兴趣吗?

是,或许支持一下自定义 prompt?哈哈

phodal commented 5 months ago

自定义 prompt 中是包含 suffix 的,也就是 afterCursor

https://ide.unitmesh.cc/customize/variables

可以使用自定义 team prompt :https://ide.unitmesh.cc/custom/team-prompts

理论上自定义个人 prompt 也行:

https://ide.unitmesh.cc/custom/action

zjh7890 commented 5 months ago

自定义 prompt 中是包含 suffix 的,也就是 afterCursor

https://ide.unitmesh.cc/customize/variables

可以使用自定义 team prompt :https://ide.unitmesh.cc/custom/team-prompts

理论上自定义个人 prompt 也行:

https://ide.unitmesh.cc/custom/action

哦哦,这个我大致了解了一下,team prompt 好像不会感知到待插入的位置?就是当前光标位置

phodal commented 5 months ago

cursor 就是光标位置

zjh7890 commented 5 months ago

可以的,能用