mirror of
https://gitee.com/wanwujie/deer-flow
synced 2026-04-02 22:02:13 +08:00
fix(gateway): accept output_text suggestion blocks (#1238)
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai> Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
This commit is contained in:
@@ -68,7 +68,7 @@ def _extract_response_text(content: object) -> str:
|
||||
for block in content:
|
||||
if isinstance(block, str):
|
||||
parts.append(block)
|
||||
elif isinstance(block, dict) and block.get("type") == "text":
|
||||
elif isinstance(block, dict) and block.get("type") in {"text", "output_text"}:
|
||||
text = block.get("text")
|
||||
if isinstance(text, str):
|
||||
parts.append(text)
|
||||
|
||||
@@ -69,6 +69,24 @@ def test_generate_suggestions_parses_list_block_content(monkeypatch):
|
||||
assert result.suggestions == ["Q1", "Q2"]
|
||||
|
||||
|
||||
def test_generate_suggestions_parses_output_text_block_content(monkeypatch):
|
||||
req = suggestions.SuggestionsRequest(
|
||||
messages=[
|
||||
suggestions.SuggestionMessage(role="user", content="Hi"),
|
||||
suggestions.SuggestionMessage(role="assistant", content="Hello"),
|
||||
],
|
||||
n=2,
|
||||
model_name=None,
|
||||
)
|
||||
fake_model = MagicMock()
|
||||
fake_model.invoke.return_value = MagicMock(content=[{"type": "output_text", "text": '```json\n["Q1", "Q2"]\n```'}])
|
||||
monkeypatch.setattr(suggestions, "create_chat_model", lambda **kwargs: fake_model)
|
||||
|
||||
result = asyncio.run(suggestions.generate_suggestions("t1", req))
|
||||
|
||||
assert result.suggestions == ["Q1", "Q2"]
|
||||
|
||||
|
||||
def test_generate_suggestions_returns_empty_on_model_error(monkeypatch):
|
||||
req = suggestions.SuggestionsRequest(
|
||||
messages=[suggestions.SuggestionMessage(role="user", content="Hi")],
|
||||
|
||||
Reference in New Issue
Block a user