mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-14 11:05:54 +08:00
feat(api): optimize conversation name generation logic in message app (#16917)
Co-authored-by: yuanlong <yuanlong@boco.com.cn> Co-authored-by: crazywoola <427733928@qq.com>
This commit is contained in:
parent
a743d5dc71
commit
5d77730c78
@ -148,6 +148,13 @@ class MessageBasedAppGenerator(BaseAppGenerator):
|
|||||||
# get conversation introduction
|
# get conversation introduction
|
||||||
introduction = self._get_conversation_introduction(application_generate_entity)
|
introduction = self._get_conversation_introduction(application_generate_entity)
|
||||||
|
|
||||||
|
# get conversation name
|
||||||
|
if isinstance(application_generate_entity, AdvancedChatAppGenerateEntity):
|
||||||
|
query = application_generate_entity.query or "New conversation"
|
||||||
|
else:
|
||||||
|
query = next(iter(application_generate_entity.inputs.values()), "New conversation")
|
||||||
|
conversation_name = (query[:20] + "…") if len(query) > 20 else query
|
||||||
|
|
||||||
if not conversation:
|
if not conversation:
|
||||||
conversation = Conversation(
|
conversation = Conversation(
|
||||||
app_id=app_config.app_id,
|
app_id=app_config.app_id,
|
||||||
@ -156,7 +163,7 @@ class MessageBasedAppGenerator(BaseAppGenerator):
|
|||||||
model_id=model_id,
|
model_id=model_id,
|
||||||
override_model_configs=json.dumps(override_model_configs) if override_model_configs else None,
|
override_model_configs=json.dumps(override_model_configs) if override_model_configs else None,
|
||||||
mode=app_config.app_mode.value,
|
mode=app_config.app_mode.value,
|
||||||
name="New conversation",
|
name=conversation_name,
|
||||||
inputs=application_generate_entity.inputs,
|
inputs=application_generate_entity.inputs,
|
||||||
introduction=introduction,
|
introduction=introduction,
|
||||||
system_instruction="",
|
system_instruction="",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user