The `auto_generate_name` param doesn't work correctly when `r1` is used as the default model.
Self Checks
- [x] This is only for bug report, if you would like to ask a question, please head to Discussions.
- [x] I have searched for existing issues search for existing issues, including closed ones.
- [x] I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
- [x] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
- [x] Please do not modify this template :) and fill in all the required fields.
Dify version
the latest code from main branch
Cloud or Self Hosted
Self Hosted (Docker), Self Hosted (Source)
Steps to reproduce
- the conversation name is always
New conversationwhen usingr1as default model core.llm_generator.llm_generator.LLMGenerator, the functiongenerate_conversation_name()setmax_tokensbe100when invoke LLM to get conversation name- If the LLM result have the content
<think>, it seems100 tokensis not enough.
- my query is
你好,你是谁? - the result be like:
<think>\n好,我现在需要分析用户的输入,并将其分解为“主题”和“意图”,同时确定输出的语言类型。用户的问题是“你好,你是谁?”,这是一个典型的问候和询问身份的问题。\n\n首先,我观察到用户使用了纯中文,没有夹杂其他语言。因此,语言类型应该是“纯中文”。接下来,分析用户的意图,用户在问候之后询问了我的身份,这属于自我介绍或确认身份的意图。\n\n根据示例,当问题
- as you can see, it didn't output the final result, so got the error
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)when sept to the codejson.loads(cleaned_answer)
✔️ Expected Behavior
- get correct conversation name
❌ Actual Behavior
- the conversation name is always
New conversation
@yzztin Hello! I'm here to help you with any bugs, questions, or contributions. Let's tackle this together!
The issue you're encountering seems to be related to the generate_conversation_name() function in the LLMGenerator class, specifically when using the r1 model. The function sets max_tokens to 100, which might not be sufficient if the LLM's output includes extensive content like <think> tags, leading to incomplete responses and JSON decoding errors [1].
To address this, you might consider increasing the max_tokens parameter to allow the model to generate a more complete response. This could help ensure that the JSON object is fully formed and can be decoded without errors. Adjusting the max_tokens value could provide the necessary space for the model to complete its output, especially when handling complex or verbose responses.
To continue talking to Dosu, mention @dosu.
Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other