glm-4 multi-round session error reporting #4077

Closed
opened 2026-02-21 18:04:38 -05:00 by yindo · 3 comments
Owner

Originally created by @cjdxhjj on GitHub (Jun 13, 2024).

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • Please do not modify this template :) and fill in all the required fields.

Dify version

0.6.10

Cloud or Self Hosted

Self Hosted (Source)

Steps to reproduce

use glm-4 model, talk with llm several times

✔️ Expected Behavior

No response

Actual Behavior

Got unknown type role=<PromptMessageRole.TOOL: 'tool'> content='{"code": "0", "errMsg": null, "data": [{"catalogId": 106, "catalogName": "猪病发病指数", "indexId": 3556, "indexName": "猪瘟", "indexValue": "0.0000", "dataDate": "2024-06-02"}, {"catalogId": 106, "catalogName": "猪病发病指数", "indexId": 3557, "indexName": "流感", "indexValue": "0.0000", "dataDate": "2024-06-02"}, {"catalogId": 106, "catalogName": "猪病发病指数", "indexId": 3558, "indexName": "猪口蹄疫", "indexValue": "0.0000", "dataDate": "2024-06-02"}, {"catalogId": 106, "catalogName": "猪病发病指数", "indexId": 3559, "indexName": "圆环病", "indexValue": "0.0000", "dataDate": "2024-06-02"}, {"catalogId": 106, "catalogName": "猪病发病指数", "indexId": 3560, "indexName": "猪伪狂犬病", "indexValue": "0.0000", "dataDate": "2024-06-02"}, {"catalogId": 106, "catalogName": "猪病发病指数", "indexId": 3561, "indexName": "蓝耳病", "indexValue": "0.0000", "dataDate": "2024-06-02"}, {"catalogId": 106, "catalogName": "猪病发病指数", "indexId": 3562, "indexName": "猪流行性腹泻", "indexValue": "0.0000", "dataDate": "2024-06-02"}, {"catalogId": 106, "catalogName": "猪病发病指数", "indexId": 3563, "indexName": "猪链球菌病", "indexValue": "0.6667", "dataDate": "2024-06-02"}, {"catalogId": 106, "catalogName": "猪病发病指数", "indexId": 3564, "indexName": "猪传染性胸膜肺炎", "indexValue": "0.0000", "dataDate": "2024-06-02"}, {"catalogId": 106, "catalogName": "猪病发病指数", "indexId": 3565, "indexName": "发病指数", "indexValue": "0.0000", "dataDate": "2024-06-02"}, {"catalogId": 106, "catalogName": "猪病发病指数", "indexId": 3592, "indexName": "发病指数", "indexValue": "0.66670000", "dataDate": "2024-06-02"}]}' name='get_aigcbasic_pighealth_widthdata_list_all' tool_call_id='95cdb6fe-5735-43bb-9461-3499c37147a3'

Originally created by @cjdxhjj on GitHub (Jun 13, 2024). ### Self Checks - [X] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [X] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [X] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [X] Please do not modify this template :) and fill in all the required fields. ### Dify version 0.6.10 ### Cloud or Self Hosted Self Hosted (Source) ### Steps to reproduce use glm-4 model, talk with llm several times ### ✔️ Expected Behavior _No response_ ### ❌ Actual Behavior Got unknown type role=<PromptMessageRole.TOOL: 'tool'> content='{"code": "0", "errMsg": null, "data": [{"catalogId": 106, "catalogName": "猪病发病指数", "indexId": 3556, "indexName": "猪瘟", "indexValue": "0.0000", "dataDate": "2024-06-02"}, {"catalogId": 106, "catalogName": "猪病发病指数", "indexId": 3557, "indexName": "流感", "indexValue": "0.0000", "dataDate": "2024-06-02"}, {"catalogId": 106, "catalogName": "猪病发病指数", "indexId": 3558, "indexName": "猪口蹄疫", "indexValue": "0.0000", "dataDate": "2024-06-02"}, {"catalogId": 106, "catalogName": "猪病发病指数", "indexId": 3559, "indexName": "圆环病", "indexValue": "0.0000", "dataDate": "2024-06-02"}, {"catalogId": 106, "catalogName": "猪病发病指数", "indexId": 3560, "indexName": "猪伪狂犬病", "indexValue": "0.0000", "dataDate": "2024-06-02"}, {"catalogId": 106, "catalogName": "猪病发病指数", "indexId": 3561, "indexName": "蓝耳病", "indexValue": "0.0000", "dataDate": "2024-06-02"}, {"catalogId": 106, "catalogName": "猪病发病指数", "indexId": 3562, "indexName": "猪流行性腹泻", "indexValue": "0.0000", "dataDate": "2024-06-02"}, {"catalogId": 106, "catalogName": "猪病发病指数", "indexId": 3563, "indexName": "猪链球菌病", "indexValue": "0.6667", "dataDate": "2024-06-02"}, {"catalogId": 106, "catalogName": "猪病发病指数", "indexId": 3564, "indexName": "猪传染性胸膜肺炎", "indexValue": "0.0000", "dataDate": "2024-06-02"}, {"catalogId": 106, "catalogName": "猪病发病指数", "indexId": 3565, "indexName": "发病指数", "indexValue": "0.0000", "dataDate": "2024-06-02"}, {"catalogId": 106, "catalogName": "猪病发病指数", "indexId": 3592, "indexName": "发病指数", "indexValue": "0.66670000", "dataDate": "2024-06-02"}]}' name='get_aigcbasic_pighealth_widthdata_list_all' tool_call_id='95cdb6fe-5735-43bb-9461-3499c37147a3'
yindo added the 🐞 bug label 2026-02-21 18:04:38 -05:00
yindo closed this issue 2026-02-21 18:04:38 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Jun 13, 2024):

To resolve the error with the glm-4 model in a multi-round session using Dify version 0.6.10, self-hosted from the source, when you receive the message about an unknown type role, you need to ensure that the PromptMessage objects you are using have the correct type and role attributes.

In the provided code, PromptMessage is imported from core.model_runtime.entities.message_entities. Ensure that the PromptMessage objects are correctly instantiated with the required attributes.

Here is an example of how to correctly create a PromptMessage:

from core.model_runtime.entities.message_entities import PromptMessage

# Example of creating a PromptMessage
prompt_message = PromptMessage(
    type="user",  # or "system", "assistant", etc.
    role="user",  # or "system", "assistant", etc.
    content="Your message content here"
)

# Ensure you pass a list of such PromptMessage objects to the invoke_llm method
prompt_messages = [prompt_message]

# Example of invoking the LLM
model_instance = ModelManager().get_model_instance(tenant_id, provider, model_type, model)
result = model_instance.invoke_llm(prompt_messages)

Make sure that the type and role attributes are set to valid values that the model expects. The valid values for the role attribute in PromptMessage objects are system, user, assistant, and tool [1]. If the error persists, double-check the values and ensure they match the expected types and roles defined in your model's configuration.

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Jun 13, 2024): <!-- Answer --> To resolve the error with the `glm-4` model in a multi-round session using Dify version 0.6.10, self-hosted from the source, when you receive the message about an unknown type role, you need to ensure that the `PromptMessage` objects you are using have the correct type and role attributes. In the provided code, `PromptMessage` is imported from `core.model_runtime.entities.message_entities`. Ensure that the `PromptMessage` objects are correctly instantiated with the required attributes. Here is an example of how to correctly create a `PromptMessage`: ```python from core.model_runtime.entities.message_entities import PromptMessage # Example of creating a PromptMessage prompt_message = PromptMessage( type="user", # or "system", "assistant", etc. role="user", # or "system", "assistant", etc. content="Your message content here" ) # Ensure you pass a list of such PromptMessage objects to the invoke_llm method prompt_messages = [prompt_message] # Example of invoking the LLM model_instance = ModelManager().get_model_instance(tenant_id, provider, model_type, model) result = model_instance.invoke_llm(prompt_messages) ``` Make sure that the `type` and `role` attributes are set to valid values that the model expects. The valid values for the `role` attribute in `PromptMessage` objects are `system`, `user`, `assistant`, and `tool` <sup>[[1]](https://github.com/langgenius/dify/blob/main/api/core/model_runtime/entities/message_entities.py)</sup>. If the error persists, double-check the values and ensure they match the expected types and roles defined in your model's configuration. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Author
Owner

@crazywoola commented on GitHub (Jun 16, 2024):

I think it should be fixed in v0.6.11

@crazywoola commented on GitHub (Jun 16, 2024): I think it should be fixed in v0.6.11
Author
Owner

@cjdxhjj commented on GitHub (Jun 16, 2024):

@crazywoola it appear in 0.6.11, the bug not fixed!

@cjdxhjj commented on GitHub (Jun 16, 2024): @crazywoola it appear in 0.6.11, the bug not fixed!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#4077