You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The error you're encountering, "Got unknown type role=<PromptMessageRole.TOOL: 'tool'>", indicates that the system is not recognizing the PromptMessageRole.TOOL type. This issue can be traced to the _convert_one_message_to_text function, which raises a ValueError when it encounters an unknown type.
To resolve this, ensure that the PromptMessageRole.TOOL type is correctly handled in the code. Here is the relevant part of the function that needs to be updated:
def_convert_one_message_to_text(self, message: PromptMessage) ->str:
""" Convert a single message to a string. :param message: PromptMessage to convert. :return: String representation of the message. """human_prompt="\n\nuser:"ai_prompt="\n\nmodel:"content=message.contentifisinstance(content, list):
content="".join(
c.dataforcincontentifc.type!=PromptMessageContentType.IMAGE
)
ifisinstance(message, UserPromptMessage):
message_text=f"{human_prompt}{content}"elifisinstance(message, AssistantPromptMessage):
message_text=f"{ai_prompt}{content}"elifisinstance(message, SystemPromptMessage):
message_text=f"{human_prompt}{content}"elifisinstance(message, ToolPromptMessage): # Ensure this case is handledmessage_text=f"{human_prompt}{content}"else:
raiseValueError(f"Got unknown type {message}")
returnmessage_text
Make sure that the ToolPromptMessage type is properly defined and handled in your code. This should prevent the "unknown type" error from occurring during multi-round sessions [1].
Self Checks
Dify version
0.6.11
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'
The text was updated successfully, but these errors were encountered: