dify icon indicating copy to clipboard operation
dify copied to clipboard

chat conversation name does not generated as expected

Open geosmart opened this issue 1 year ago • 4 comments

Self Checks

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()

geosmart avatar Jan 27 '24 02:01 geosmart

🤖

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.

dosubot[bot] avatar Jan 27 '24 02:01 dosubot[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

geosmart avatar Jan 27 '24 04:01 geosmart

may be we should add auto_generate_name option in the WebApp config.

and user can config CONVERSATION_TITLE_PROMPT in model config

geosmart avatar Jan 27 '24 04:01 geosmart

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.

takatost avatar Jan 27 '24 11:01 takatost

This issue has been fixed, please pull the latest code. The front end will actively call the API interface that generates the conversation name.

iamjoel avatar Feb 04 '24 06:02 iamjoel