dify
dify copied to clipboard
chat conversation name does not generated as expected
Self Checks
- [X] I have searched for existing issues search for existing issues, including closed ones.
- [X] I confirm that I am using English to file this report (我已阅读并同意 Language Policy).
Dify version
0.5.0
Cloud or Self Hosted
Self Hosted (Docker)
Steps to reproduce
always can not generate the conversation name
✔️ Expected Behavior
auto_generate_name should generate the conversation name
❌ Actual Behavior
with debug ,I found the auto_generate_conversation_name=false
INFO:root:s_first_message:True,conversation.mode=chat,extras: {"auto_generate_conversation_name": false}
https://github.com/langgenius/dify/blob/b9b692d71de6d3064065785b4c84b6838ac9d55b/api/events/event_handlers/generate_conversation_name_when_first_message_created.py#L15
@message_was_created.connect
def handle(sender, **kwargs):
message = sender
conversation = kwargs.get('conversation')
is_first_message = kwargs.get('is_first_message')
extras = kwargs.get('extras', {})
logging.info(f"is_first_message:{is_first_message},conversation.mode={conversation.mode},extras: {json.dumps(extras)}")
auto_generate_conversation_name = True
if extras:
auto_generate_conversation_name = extras.get('auto_generate_conversation_name', True)
if auto_generate_conversation_name and is_first_message:
if conversation.mode == 'chat':
app_model = conversation.app
if not app_model:
return
# generate conversation name
try:
name = LLMGenerator.generate_conversation_name(app_model.tenant_id, message.query)
conversation.name = name
except:
pass
db.session.commit()
🤖
Based on the code you've shared, it seems like the auto_generate_conversation_name
flag is set to False
by default. This flag is used to determine whether the conversation name should be automatically generated or not.
In the handle
function, the auto_generate_conversation_name
flag is retrieved from the extras
dictionary. If the extras
dictionary does not contain the auto_generate_conversation_name
key, it defaults to True
. However, in your case, it seems like the extras
dictionary does contain the auto_generate_conversation_name
key and it is set to False
, which is why the conversation name is not being automatically generated.
auto_generate_conversation_name = True
if extras:
auto_generate_conversation_name = extras.get('auto_generate_conversation_name', True)
If you want the conversation name to be automatically generated, you need to ensure that the auto_generate_conversation_name
flag is set to True
in the extras
dictionary when the first message is created.
As for why the auto_generate_conversation_name
flag is set to False
in your case, it could be due to a variety of reasons. For example, it could be a configuration setting in your Docker environment, or it could be a default setting in the Dify version you are using. Without more information, it's hard to say for certain.
I hope this helps! If you have any more questions, feel free to ask.
For more information, you can refer to the following sources:
Sources
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.
Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.
If you want to continue the conversation, start your reply with @dosu-bot.
<Property name='auto_generate_name' type='bool' key='auto_generate_name'>
Auto-generate title, default is `false`.
Can achieve async title generation by calling the conversation rename API and setting `auto_generate` to true.
I found this for api
but in the dify UI, can't find the config for auto_generate_name
may be we should add auto_generate_name
option in the WebApp config
.
and user can config CONVERSATION_TITLE_PROMPT
in model config
The current design is that, except for the App OpenAPI
, the interaction on the Dify UI is initiated by the frontend requesting the chat-messages
API. After receiving the response, the frontend then calls the rename
API to automatically generate the title.
This interaction ensures that there is no blocking sensation caused by the backend executing generate name LLM requests for chat-messages
.
As for the App OpenAPI
, the auto_generate_name
is set to true by default.
This issue has been fixed, please pull the latest code. The front end will actively call the API interface that generates the conversation name.