ChatGPT-Next-Web icon indicating copy to clipboard operation
ChatGPT-Next-Web copied to clipboard

feat: wrap input with delimiters

Open aleung opened this issue 1 year ago • 3 comments

在对话设置中添加输入分隔符配置项,当配置了左右分隔符时,所有的用户输入都会用分隔符包裹。同时结合在系统prompt中指定输入分隔符,可以防止用户输入造成上下文逃逸。

支持了吴恩达公开课中的 tactic 1: use delimiters

Screenshot from 2023-06-02 00-12-39

aleung avatar Jun 01 '23 16:06 aleung

只对特定的系统prompt起作用的话,没必要专门搞个配置项吧。

InitialXKO avatar Jun 05 '23 08:06 InitialXKO

只对特定的系统prompt起作用的话,没必要专门搞个配置项吧。

不是针对特定的prompt啊,任何prompt都可以用,而且这是一个 best practice。例如,一个翻译的bot,如果prompt是:

请将用户输入的文字翻译成英文

当用户输入了一个疑问句,或者是一个指令,AI可能就不会翻译用户的输入,而且回答问题或者执行新指令。用了分隔符,就可以避免这个问题。

image

aleung avatar Jun 05 '23 08:06 aleung

不错的想法,不过使用 options 是否会更好一些?直接列出常见的分隔符就行。

``
''
""
[]
{}
<>

或者干脆做成用户模版预处理,面具内可以指定一个模版字符串来处理用户输入,同时还可以提供更多的预定义模版来注入额外的信息,比如:

现在是 {{time}},用户的输入是 <{{input}}>,使用 {{lang}} 语言回复。

Yidadaa avatar Jun 16 '23 10:06 Yidadaa

对,模板更好。等我迟些有空改一下。

aleung avatar Jun 19 '23 12:06 aleung

Bot detected the issue body's language is not English, translate it automatically.


Yes, templates are better. I'll change it later when I have time.

Issues-translate-bot avatar Jun 19 '23 12:06 Issues-translate-bot

期待

vtea avatar Jun 19 '23 18:06 vtea

Bot detected the issue body's language is not English, translate it automatically.


expectations

Issues-translate-bot avatar Jun 19 '23 18:06 Issues-translate-bot

#2109

Yidadaa avatar Jun 23 '23 16:06 Yidadaa

Bot detected the issue body's language is not English, translate it automatically.


#2109

Issues-translate-bot avatar Jun 23 '23 16:06 Issues-translate-bot

I did not get how to use it do delimiter only certain part of the input message... When I put <{{input}}> on the configs it will delimiter every message I sent with <{{}}> ?

marioseixas avatar Jun 26 '23 02:06 marioseixas

Please give some examples of use

marioseixas avatar Jun 26 '23 02:06 marioseixas

I did not get how to use it do delimiter only certain part of the input message... When I put <{{input}}> on the configs it will delimiter every message I sent with <{{}}> ?

Yes, the purpose of this feature is to wrap whole input message. What's your use case that just part of the input needs to be delimited?

aleung avatar Jun 26 '23 03:06 aleung

hi @marioseixas , let's discuss this issue in a different location.

https://github.com/Yidadaa/ChatGPT-Next-Web/issues/2144

Yidadaa avatar Jun 26 '23 04:06 Yidadaa