fix: max_tokens set to 1000 for "auto_generate_name"
Summary
Close https://github.com/langgenius/dify/issues/14246
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.
[!Tip] Close issue syntax:
Fixes #<issue number>orResolves #<issue number>, see documentation for more details.
Screenshots
| Before | After |
|---|---|
| ... | ... |
Checklist
[!IMPORTANT]
Please review the checklist below before submitting your pull request.
- [ ] This change requires a documentation update, included: Dify Document
- [x] I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
- [x] I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
- [x] I've updated the documentation accordingly.
- [x] I ran
dev/reformat(backend) andcd web && npx lint-staged(frontend) to appease the lint gods
I actually don't konw is it reasonable to set max_tokens be 1000, just in my case, it worked.
I actually don't konw is it reasonable to set
max_tokensbe1000, just in my case, it worked.
I don't think this is a good idea, because you have more token consumption later.
我实际上不知道这样设置是否合理
max_tokens,1000但就我的情况而言,它有效。
May I ask how the code modification will take effect? I will use it in sequence: docker compose down docker compose pull docker compose up -d The result still doesn't work
I actually don't konw is it reasonable to set
max_tokensbe1000, just in my case, it worked.
@yzztin May I ask how the code modification will take effect? I will use it in sequence: docker compose down docker compose pull docker compose up -d The result still doesn't work
@MrWangChong @littlebox692
If you want to resolve the problem not gracefully, you can change the max_token like me.
Steps for changing code in container:
- use GUI tools go into the dify
apicontainer likevscode docker plugin - find the code in
app/api/core/llm_generator/llm_generator.py, the functions isgenerate_conversation_name() - change the code nearly line 51: (just make the
max_tokensbigger, a num which is enough for you)
original code: prompt_messages=prompts, model_parameters={"max_tokens": 100, "temperature": 1}, stream=False
changed code: prompt_messages=prompts, model_parameters={"max_tokens": 1000, "temperature": 1}, stream=False
restartthe container, but notdown, also you candocker commitit.
But, attention, it's not a good idea like @crazywoola said. What I recommend is waiting the official solution.
@MrWangChong @littlebox692 If you want to resolve the problem not gracefully, you can change the
max_tokenlike me. Steps for changing code in container:
- use GUI tools go into the dify
apicontainer likevscode docker plugin- find the code in
app/api/core/llm_generator/llm_generator.py, the functions isgenerate_conversation_name()- change the code nearly line 51: (just make the
max_tokensbigger, a num which is enough for you)original code: prompt_messages=prompts, model_parameters={"max_tokens": 100, "temperature": 1}, stream=False changed code: prompt_messages=prompts, model_parameters={"max_tokens": 1000, "temperature": 1}, stream=False
restartthe container, but notdown, also you candocker commitit.But, attention, it's not a good idea like @crazywoola said. What I recommend is waiting the official solution.
@yzztin Thank you for your response I am certain that I have modified the max_token and restarted Docker. But it still hasn't taken effect. This problem should only occur with deepseek-r1. I have tried switching to qwen2.5 and deepseek-v2, but still have this issue.
How about truncating the promptMessage text (e.g., [:100]) or making the max token limit configurable by users—or both?
Will this issue be further optimized or fixed?