dify icon indicating copy to clipboard operation
dify copied to clipboard

can't auto generate conversation name,always is New conversation

Open Lyeluo opened this issue 2 years ago • 6 comments

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

0.6.15

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

when i use workflow for chat api to create a conversation ,whether i set auto_generate_name true or false . when i get conversations histroy , got conversation name is "New conversation". Is this a bug? image

✔️ Expected Behavior

get model generated conversation name

❌ Actual Behavior

No response

Lyeluo avatar Aug 06 '24 06:08 Lyeluo

@Lyeluo Hello there! I'm here to help you with bugs, questions, and becoming a contributor. Let's squash those bugs together! 😊

Yes, it appears to be a bug in Dify version 0.6.15. The auto_generate_name parameter in the chat API should control whether the conversation name is auto-generated. If auto_generate_name is set to false, the conversation name should not default to "New conversation". However, if the conversation name is always set to "New conversation" regardless of the auto_generate_name parameter setting, this behavior is inconsistent with the documented functionality [1][2][3].

There have been updates in version 0.6.16 that address issues related to conversation name generation. The _generate_conversation_name method in the MessageCycleManage class includes logic to automatically generate a conversation name if the auto_generate_conversation_name flag is set to True and it is the first message in the conversation [3].

Updating to version 0.6.16 should resolve this issue.

To continue talking to Dosu, mention @dosu.

dosubot[bot] avatar Aug 06 '24 06:08 dosubot[bot]

I think this is a deprecated parameter here, we found it will make the whole conversation slower and consume more tokens. Please use this api /conversations/:conversation_id/name instead. We will phase out this parameter in the future. :)

crazywoola avatar Aug 06 '24 07:08 crazywoola

i got it,thx~

Lyeluo avatar Aug 06 '24 07:08 Lyeluo

i use 1.0.0 version has this bugs,use this api/conversations/:conversation_id/name with parameter "auto_generate": true,

anjingyong avatar Mar 27 '25 11:03 anjingyong

This bug still exists to this day in 1.0.1 version

yjing86 avatar Apr 02 '25 06:04 yjing86

This is because you can't use reasoning LLM model(like DeepSeek-R1). The auto rename feature will invoke system default LLM and expect that it will return a JSON string. Because Reasoning LLM will append <think>...</think> blocks, Dify can't match the output with current regxp.

The relevant code is located at: api/core/llm_generator/llm_generator.py,line 56:

        answer = cast(str, response.message.content)
        cleaned_answer = re.sub(r"^.*(\{.*\}).*$", r"\1", answer, flags=re.DOTALL)
        if cleaned_answer is None:
            return ""
        result_dict = json.loads(cleaned_answer)
        answer = result_dict["Your Output"]
        name = answer.strip()

I think we can solve this problem by cutting the string to get a clean substring. Such as:

if ('</think>' in answer):
  answer = answer.split('</think>')[-1] # just for demostration, not robbust

cleaned_answer = re.sub(r"^.*(\{.*\}).*$", r"\1", answer, flags=re.DOTALL)

hlwz5735 avatar May 08 '25 11:05 hlwz5735