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

feat: wrap input with delimiters #1789

Closed
wants to merge 1 commit into from

Conversation

aleung
Copy link

@aleung aleung commented Jun 1, 2023

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

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

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

@aleung aleung marked this pull request as ready for review June 1, 2023 16:26
@InitialXKO
Copy link
Contributor

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

@aleung
Copy link
Author

aleung commented Jun 5, 2023

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

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

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

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

image

@Yidadaa
Copy link
Collaborator

Yidadaa commented Jun 16, 2023

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

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

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

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

@aleung
Copy link
Author

aleung commented Jun 19, 2023

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

@Issues-translate-bot
Copy link

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.

@vtea
Copy link

vtea commented Jun 19, 2023

期待

@Issues-translate-bot
Copy link

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


expectations

@Yidadaa
Copy link
Collaborator

Yidadaa commented Jun 23, 2023

#2109

@Yidadaa Yidadaa closed this Jun 23, 2023
@Issues-translate-bot
Copy link

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


#2109

Yidadaa added a commit that referenced this pull request Jun 23, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
feat: close #1789 add user input template
@marioseixas
Copy link

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

Please give some examples of use

@aleung
Copy link
Author

aleung commented Jun 26, 2023

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?

@Yidadaa
Copy link
Collaborator

Yidadaa commented Jun 26, 2023

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

#2144

alchemist139 pushed a commit to alchemist139/ChatGPT-Next-Web that referenced this pull request Sep 21, 2023
gaogao1030 pushed a commit to gaogao1030/ChatGPT-Next-Web that referenced this pull request May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants