Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
zjh7890 opened this issue Apr 5, 2024 · 6 comments
Closed

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

zjh7890 opened this issue Apr 5, 2024 · 6 comments
Labels
enhancement New feature or request

Comments

@zjh7890
Copy link

zjh7890 commented Apr 5, 2024

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
Copy link
Member

phodal commented Apr 5, 2024

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

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

val suffixText = document?.text?.substring(lineEndOffset) ?: ""

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

@phodal phodal added the enhancement New feature or request label Apr 5, 2024
@zjh7890
Copy link
Author

zjh7890 commented Apr 5, 2024

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

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

val suffixText = document?.text?.substring(lineEndOffset) ?: ""

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

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

@phodal
Copy link
Member

phodal commented Apr 5, 2024

自定义 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
Copy link
Author

zjh7890 commented Apr 5, 2024

自定义 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
Copy link
Member

phodal commented Apr 6, 2024

cursor 就是光标位置

phodal added a commit that referenced this issue Apr 6, 2024
…mActionBaseIntention.kt` to improve efficiency and readability #136
phodal added a commit that referenced this issue Apr 6, 2024
…ionBaseIntention.kt` to improve efficiency and readability. Introduce a new `ClassStructureVariableResolver` class to handle class context-based variable resolution. #136
@zjh7890
Copy link
Author

zjh7890 commented Apr 6, 2024

可以的,能用

@phodal phodal closed this as completed Apr 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants