Closed GeorgeGalway closed 1 week ago
To fix the issue where the prompt generator returns incomplete content when there are too many commands in Dify version 0.6.7~0.7.3, you should set Stop Sequences. This will inform the LLM to stop generating text at specific points, preventing it from producing incomplete content.
Here’s how you can set Stop Sequences:
Identify the specific words, phrases, or characters that should signal the LLM to stop generating text. For example, if you have a prompt like:
Human1: What color is the sky?
Assistant1: The sky is blue.
Human1: What color is fire?
Assistant1: Fire is red.
Human1: What color is soil?
Assistant1:
In the model parameters' Stop Sequences
, input Human1:
, and press the "Tab" key.
This way, the LLM will only respond with one sentence:
Assistant1: Soil is yellow.
And will not generate additional dialogue (i.e., the LLM will stop generating content before reaching the next "Human1:").
By setting the appropriate stop sequences, you can control the output length and ensure that the content generated is complete and as expected [1].
To continue talking to Dosu, mention @dosu.
You can generate longer prompts by setting the env environment variable PROMPT_GENERATION_MAX_TOKENS
in .env
file, the default value is 512
.
You can generate longer prompts by setting the env environment variable
PROMPT_GENERATION_MAX_TOKENS
in.env
file, the default value is512
.
However, configuring it in the env didn’t work, including placing it in the api/.env file and docker/.env file.
I set PROMPT_GENERATION_MAX_TOKENS=2048
works for me. Maybe you should check your docker config file.
Although the generated prompts are shorter and incomplete, they are not the maximum length I set, which may be a problem.
我设置
PROMPT_GENERATION_MAX_TOKENS=2048
成功了。也许你应该检查一下你的 docker 配置文件。
- PROMPT_GENERATION_MAX_TOKENS=2048
- PROMPT_GENERATION_MAX_TOKENS=256
虽然生成的提示比较短而且不完整,但是都不是我设定的最大长度,这可能是一个问题。
Is your env file located at /docker/.env
or /api/.env
?
Self Hosted (Source) depolyment, so i use api/.env
file for configuration
Self Hosted (Source) depolyment, so i use
api/.env
file for configuration
Thanks for getting back to me.
Self Hosted (Docker),regardless of whether it's in /api/.env
or /docker/.env
, the PROMPT_GENERATION_MAX_TOKENS
parameter isn't having any effect.
@crazywoola Could you offer some help?
Self Hosted (Source) depolyment, so i use
api/.env
file for configurationThanks for getting back to me. Self Hosted (Docker),regardless of whether it's in
/api/.env
or/docker/.env
, thePROMPT_GENERATION_MAX_TOKENS
parameter isn't having any effect.
It seems that we also need to configure x-shared-env:
in docker-compose.yaml
to include PROMPT_GENERATION_MAX_TOKENS
, because docker/.env
is on the host machine and does not affect the docker environment. It can only take effect after being transformed through the environment
in docker-compose.yaml
. However, both the .env
file and docker-compose.yaml
in the docker self hosted lack the PROMPT_GENERATION_MAX_TOKENS
parameter, which is a bug.
Self Checks
Dify version
0.6.7~0.7.3
Cloud or Self Hosted
Self Hosted (Docker)
Steps to reproduce
When there are too many commands, the content returned by the prompt generator is incomplete. This issue has been tested and reproduced multiple times.
✔️ Expected Behavior
I expect the prompt generator to return complete content.
❌ Actual Behavior
The content returned by the prompt generator is not exactly what I want, especially the second half, where the examples are incomplete. This leads to poor output quality.