Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
纯新手,也只是参考chatgpt的意见大概处理了一下,不过确实能换行输入了。在chatgp.go中把传入的text里的“/n”和“/r”做了替换,程序就可以正确处理换行了。在处理一些其他输入信息的时候还是会有些问题,比如输入一大段c语言代码的时候还是会报错。应该还是转化成JSON格式的时候出了问题。
(注:去问了下chatgpt,现在已经解决了JSON格式化的时候出现的转义问题了)
另外有时候会出现这个问题(我也不太清楚是为什么,所以只是做了一个错误的处理,防止程序因为空指针崩溃):
所以在chatgpt.go的一些地方加了return语句,并且做了一个判断。如果返回“”就给用户发送生成失败,防止程序直接崩溃掉(免得我每次都自己动手去重启程序)。
不过之后没有遇到过上面的那个问题了,所以也没检验过这么做行不行。
(刚刚遇到了,确实行)