Skip to content

Commit bfb9737

Browse files
committed
Fix think and answer ordering
1 parent 9ee81b3 commit bfb9737

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/perplexity_advanced_mcp/search_tool.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,11 +210,10 @@ async def ask_perplexity(
210210

211211
# Add reasoning if available
212212
reasoning = response.get("reasoning")
213-
if reasoning is not None:
214-
result += f"<think>\n{reasoning}\n</think>\n\n"
213+
answer = response.get("content", "")
215214

216-
# Add answer
217-
content = response.get("content", "")
218-
result += f"<answer>\n{content}\n</answer>"
215+
reasoning_text = f"<think>\n{reasoning}\n</think>\n\n" if reasoning else ""
216+
answer_text = f"<answer>\n{answer}\n</answer>"
219217

218+
result += reasoning_text + answer_text
220219
return result

0 commit comments

Comments
 (0)