maxkb Exception:'str' object has no attribute 'get'

docker版本,maxkb嵌入第三方,问答偶尔提示 Exception:‘str’ object has no attribute ‘get’ ,请问是什么原因,如何解决。

后台日志有详细报错吗,执行详情方便截图看一下吗,对话日志有正常输出吗

请问docker下面,这个maxkb嵌入第三方的页面的错误日志在哪个文件啊。

这回不出了,买看到错误日志,等我这测试再出我再发一下

docker exec -it maxkb bash;在cd /opt/maxkb/logs下面

直接访问公开链接,也出现这个报错了

2025-09-02 14:27:19 [handle_exception ERROR] ‘str’ object has no attribute ‘get’:Traceback (most recent call last):
File “/opt/py3/lib/python3.11/site-packages/rest_framework/views.py”, line 512, in dispatch
response = handler(request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/opt/maxkb-app/apps/chat/views/chat.py”, line 129, in post
).chat(request.data)
^^^^^^^^^^^^^^^^^^
File “/opt/maxkb-app/apps/chat/serializers/chat.py”, line 338, in chat
return self.chat_simple(chat_info, instance, base_to_response)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/opt/maxkb-app/apps/chat/serializers/chat.py”, line 258, in chat_simple
pipeline_message.run(params)
File “/opt/maxkb-app/apps/application/chat_pipeline/pipeline_manage.py”, line 35, in run
step.run(self)
File “/opt/maxkb-app/apps/application/chat_pipeline/I_base_chat_pipeline.py”, line 152, in run
self._run(manage)
File “/opt/maxkb-app/apps/application/chat_pipeline/step/reset_problem_step/i_reset_problem_step.py”, line 38, in _run
padding_problem = self.execute(**self.context.get(‘step_args’))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/opt/maxkb-app/apps/application/chat_pipeline/step/reset_problem_step/impl/base_reset_problem_step.py”, line 38, in execute
response = chat_model.invoke(message_list)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/opt/py3/lib/python3.11/site-packages/langchain_core/language_models/chat_models.py”, line 395, in invoke
self.generate_prompt(
File “/opt/py3/lib/python3.11/site-packages/langchain_core/language_models/chat_models.py”, line 980, in generate_prompt
return self.generate(prompt_messages, stop=stop, callbacks=callbacks, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/opt/py3/lib/python3.11/site-packages/langchain_core/language_models/chat_models.py”, line 799, in generate
self._generate_with_cache(
File “/opt/py3/lib/python3.11/site-packages/langchain_core/language_models/chat_models.py”, line 1045, in _generate_with_cache
result = self._generate(
^^^^^^^^^^^^^^^
File “/opt/py3/lib/python3.11/site-packages/langchain_ollama/chat_models.py”, line 800, in _generate
final_chunk = self._chat_stream_with_aggregation(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/opt/py3/lib/python3.11/site-packages/langchain_ollama/chat_models.py”, line 735, in _chat_stream_with_aggregation
for chunk in self._iterate_over_stream(messages, stop, **kwargs):
File “/opt/py3/lib/python3.11/site-packages/langchain_ollama/chat_models.py”, line 822, in _iterate_over_stream
for stream_resp in self._create_chat_stream(messages, stop, **kwargs):
File “/opt/py3/lib/python3.11/site-packages/langchain_ollama/chat_models.py”, line 717, in _create_chat_stream
chat_params = self._chat_params(messages, stop, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/opt/py3/lib/python3.11/site-packages/langchain_ollama/chat_models.py”, line 542, in _chat_params
ollama_messages = self._convert_messages_to_ollama_messages(messages)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/opt/py3/lib/python3.11/site-packages/langchain_ollama/chat_models.py”, line 643, in _convert_messages_to_ollama_messages
if content_part.get(“type”) == “text”:
^^^^^^^^^^^^^^^^
AttributeError: ‘str’ object has no attribute ‘get’

看一下完整工作流,目前是什么版本

  1. 部署情况:docker部署的v2.0.2版本,知识库 → 应用(使用本地ollama模型) → web页面访问(使用公开链接)
  2. 问题:进行对话时,第一句回复一般正常,再次提问就回复‘str’ object has no attribute ‘get’
  3. 当前情况:后更换了应用的语言模型(从deepseek-r1:8b更换为qwen3:8b),暂时还没遇到上述问题;又尝试重启服务,再次使用deepseek-r1:8b模型,也正常了,比较奇怪