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

[Tips] 如何使用用户输入模板 How to use Input Template #2144

Closed
Yidadaa opened this issue Jun 26, 2023 · 14 comments
Closed

[Tips] 如何使用用户输入模板 How to use Input Template #2144

Yidadaa opened this issue Jun 26, 2023 · 14 comments
Labels
documentation Improvements or additions to documentation faq Most asked questions

Comments

@Yidadaa
Copy link
Collaborator

Yidadaa commented Jun 26, 2023

在最近的一次更新中,我增加了 Input Template 这个功能,讨论可以看这里:#1789

image

该配置项可以在全局设置和对话设置中更改,影响的范围也不一样,同时不同的预处理模板,产生的效果也不同。

总而言之,你可以在模板中使用下方的变量:

https://github.com/Yidadaa/ChatGPT-Next-Web/blob/5f7c262759b93c6becc636b7b0cab2a183c956fe/app/store/chat.ts#L110-L116

  • {{model}}: 当前使用的模型名称
  • {{time}}: 当前本地时间
  • {{lang}}: 当前所用语言
  • {{input}}: 用户本次输入

举个例子,在最开始的版本中,我设定的默认模板是:

Act as a virtual assistant powered by model: '{{model}}', now time is {{time}}, response in {{lang}} lang, my input is:'''{{input}}'''

那么如果用户输入了 how are you today?,根据上述模板,发送给 ChatGPT 的内容会变成:

Act as a virtual assistant powered by model: 'gpt-3.5-turbo', now time is 2023/06/26 12:50, response in zh lang, my input is:'''how are you today?'''

然而,这个默认模板会在某些情况下污染用户的预设提示词,所以在当前的版本中,我又改成了最基础的:

https://github.com/Yidadaa/ChatGPT-Next-Web/blob/5f7c262759b93c6becc636b7b0cab2a183c956fe/app/constant.ts#L56

后来,我发现 OpenAI 的网页版 ChatGPT,用的系统提示词是:

You are ChatGPT, a large language model trained by OpenAI.
Knowledge cutoff: 2021-09
Current date: [current date]

所以,我接下来会将此提示词全局注入,来尽可能接近官方的使用体验。

@Issues-translate-bot
Copy link

Issues-translate-bot commented Jun 26, 2023

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


Title: [Tips] How to use Input Template

In the recent update, I added the Input Template feature, which you can review at this link: #1789

image

This configuration item can be changed in both global and dialogue settings, with different ranges of influence. Different pre-processing templates result in different effects.

In short, you can use the following variables in the template:

https://github.com/Yidadaa/ChatGPT-Next-Web/blob/5f7c262759b93c6becc636b7b0cab2a183c956fe/app/store/chat.ts#L110-L116

  • {{model}}: the current model name in use
  • {{time}}: the current local time
  • {{lang}}: the current language in use
  • {{input}}: the user's input

For example, in the initial version, I set the default template as:

Act as a virtual assistant powered by model: '{{model}}', now time is {{time}}, response in {{lang}} lang, my input is:'''{{input}}'''

So if the user enters "how are you today?", according to the above template, the content sent to ChatGPT will be:

Act as a virtual assistant powered by model: 'gpt-3.5-turbo', now time is 2023/06/26 12:50, response in zh lang, my input is:'''how are you today?'''

However, this default template can pollute the user's preset prompt words under certain circumstances. Therefore, in the current version, I changed it to the most basic:

https://github.com/Yidadaa/ChatGPT-Next-Web/blob/5f7c262759b93c6becc636b7b0cab2a183c956fe/app/constant.ts#L56

Later, I found that the system prompt words used by OpenAI's web version of ChatGPT are:

You are ChatGPT, a large language model trained by OpenAI.
Knowledge cutoff: 2021-09
Current date: [current date]

So I will inject this prompt globally next to provide an experience as close as possible to the official one.

@Yidadaa
Copy link
Collaborator Author

Yidadaa commented Jun 26, 2023

OpenAI 网页版所用的 System Prompt 来源(中文链接):https://www.zhihu.com/answer/3090442006

@Issues-translate-bot
Copy link

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


Source of System Prompt used by OpenAI web version (Chinese link): https://www.zhihu.com/answer/3090442006

Yidadaa added a commit that referenced this issue Jun 26, 2023
Yidadaa added a commit that referenced this issue Jun 26, 2023
@Yidadaa
Copy link
Collaborator Author

Yidadaa commented Jun 26, 2023

在最新的代码中,我已经注入全局 System Prompt,但只会在不使用面具的情况下启用:

https://github.com/Yidadaa/ChatGPT-Next-Web/blob/1607640bed26dddf670229dd20677af60e9264ec/app/constant.ts#L57-L61

https://github.com/Yidadaa/ChatGPT-Next-Web/blob/1607640bed26dddf670229dd20677af60e9264ec/app/store/chat.ts#L399-L416

@Mydong
Copy link

Mydong commented Jun 27, 2023

在最新的代码中,我已经注入全局 System Prompt,但只会在不使用面具的情况下启用:

https://github.com/Yidadaa/ChatGPT-Next-Web/blob/1607640bed26dddf670229dd20677af60e9264ec/app/constant.ts#L57-L61

https://github.com/Yidadaa/ChatGPT-Next-Web/blob/1607640bed26dddf670229dd20677af60e9264ec/app/store/chat.ts#L399-L416

因此,现在默认的就是这个{{input}} 对吧,日常使用也无需进行修改 是这样子的吧
因为,已经在全局中默认配置了”You are ChatGPT, a large language model trained by OpenAI. “这个。

image

@Issues-translate-bot
Copy link

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


In the latest code, I have injected the global System Prompt, but it will only be enabled without a mask:

https://github.com/Yidadaa/ChatGPT-Next-Web/blob/1607640bed26dddf670229dd20677af60e9264ec/app/constant.ts#L57-L61

https://github.com/Yidadaa/ChatGPT-Next-Web/blob/1607640bed26dddf670229dd20677af60e9264ec/app/store/chat.ts#L399-L416

Therefore, the default is {{input}} right now, and there is no need to modify it for daily use. Is it like this?
Because, "You are ChatGPT, a large language model trained by OpenAI." has been configured globally by default.

image

@Yidadaa
Copy link
Collaborator Author

Yidadaa commented Jun 27, 2023

@Mydong 是的,无需再进行改动。

@Issues-translate-bot
Copy link

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


@Mydong Yes, no further changes needed.

@xihuai18
Copy link

xihuai18 commented Aug 17, 2023

能在用户设置预设system prompt加上{{time}}的注入吗,毕竟这段system prompt也不需要每次输入都加上。

@Issues-translate-bot
Copy link

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


Can the injection of {{time}} be added to the user setting default system prompt

@xihuai18
Copy link

https://github.com/Yidadaa/ChatGPT-Next-Web/blob/5a7ec38ecdb516da0c7f3908ccebc03093f3e5bc/app/store/chat.ts#L390-L400

好像找到了,所以是不是只是预设提示词展示的没有被替换,实际上发送的被替换了?

@Issues-translate-bot
Copy link

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


https://github.com/Yidadaa/ChatGPT-Next-Web/blob/5a7ec38ecdb516da0c7f3908ccebc03093f3e5bc/app/store/chat.ts#L390-L400

It seems to be found, so is it just that the preset prompt words have not been replaced, but the sent ones have been replaced?

alchemist139 pushed a commit to alchemist139/ChatGPT-Next-Web that referenced this issue Sep 21, 2023
alchemist139 pushed a commit to alchemist139/ChatGPT-Next-Web that referenced this issue Sep 21, 2023
chenzeyu pushed a commit to neutronsg/ChatGPT-Next-Web that referenced this issue Nov 8, 2023
@surviveMiao
Copy link

如果我想要按照自己接口的格式进行封装数据,我应该如何进行更改?
例如,我本地API接口的接收格式为:{
"messages": [
{
"role": "user",
"content": "你的相关内容介绍"
}
],
"stream": false,
"model": "Qwen1.5-14B-Chat"
}

那么我应该如何在chatgpt_next_web代码中进行更改?

@Issues-translate-bot
Copy link

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


If I want to encapsulate data according to the format of my own interface, how should I change it?
For example, the receiving format of my local API interface is: {
"messages": [
{
"role": "user",
"content": "Introduction to your relevant content"
}
],
"stream": false,
"model": "Qwen1.5-14B-Chat"
}

So how should I make changes in chatgpt_next_web code?

gaogao1030 pushed a commit to gaogao1030/ChatGPT-Next-Web that referenced this issue May 16, 2024
gaogao1030 pushed a commit to gaogao1030/ChatGPT-Next-Web that referenced this issue May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation faq Most asked questions
Projects
None yet
Development

No branches or pull requests

5 participants