Просмотр исходного кода

fix(python-sdk): read nested assistant messages

Yichen Jiang 1 месяц назад
Родитель
Сommit
b9bc1c8a61
2 измененных файлов с 9 добавлено и 2 удалено
  1. 3 1
      python/sdk/src/deepseek_harness/api.py
  2. 6 1
      python/sdk/tests/test_client.py

+ 3 - 1
python/sdk/src/deepseek_harness/api.py

@@ -191,7 +191,9 @@ def final_response(events: list[JsonObject]) -> str:
         data = event.get("data")
         if not isinstance(data, dict):
             continue
-        content = data.get("content")
+        message = data.get("message")
+        content_owner = message if isinstance(message, dict) else data
+        content = content_owner.get("content")
         if not isinstance(content, list):
             continue
         parts: list[str] = []

+ 6 - 1
python/sdk/tests/test_client.py

@@ -46,7 +46,12 @@ for line in sys.stdin:
                 "sessionId": params["sessionId"],
                 "event": {
                     "type": "assistant/message",
-                    "data": {"content": [{"type": "text", "text": "hello from runtime"}]},
+                    "data": {
+                        "message": {
+                            "role": "assistant",
+                            "content": [{"type": "text", "text": "hello from runtime"}],
+                        },
+                    },
                 },
             },
         }), flush=True)