Private
Public Access
refactor(ai_client): _send_anthropic_result() returns Result[str]
This commit is contained in:
+3
-3
@@ -1276,7 +1276,7 @@ def _repair_anthropic_history(history: list[dict[str, Any]]) -> None:
|
|||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|
||||||
def _send_anthropic(md_content: str, user_message: str, base_dir: str, file_items: list[dict[str, Any]] | None = None, discussion_history: str = "", pre_tool_callback: Optional[Callable[[str, str, Optional[Callable[[str], str]]], Optional[str]]] = None, qa_callback: Optional[Callable[[str], str]] = None, stream_callback: Optional[Callable[[str], None]] = None, patch_callback: Optional[Callable[[str, str], Optional[str]]] = None) -> str:
|
def _send_anthropic_result(md_content: str, user_message: str, base_dir: str, file_items: list[dict[str, Any]] | None = None, discussion_history: str = "", pre_tool_callback: Optional[Callable[[str, str, Optional[Callable[[str], str]]], Optional[str]]] = None, qa_callback: Optional[Callable[[str], str]] = None, stream_callback: Optional[Callable[[str], None]] = None, patch_callback: Optional[Callable[[str, str], Optional[str]]] = None) -> Result[str]:
|
||||||
"""
|
"""
|
||||||
[C: src/ai_server.py:_handle_send]
|
[C: src/ai_server.py:_handle_send]
|
||||||
"""
|
"""
|
||||||
@@ -1449,13 +1449,13 @@ def _send_anthropic(md_content: str, user_message: str, base_dir: str, file_item
|
|||||||
final_text = "\n\n".join(all_text_parts)
|
final_text = "\n\n".join(all_text_parts)
|
||||||
res = final_text if final_text.strip() else "(No text returned by the model)"
|
res = final_text if final_text.strip() else "(No text returned by the model)"
|
||||||
if monitor.enabled: monitor.end_component("ai_client._send_anthropic")
|
if monitor.enabled: monitor.end_component("ai_client._send_anthropic")
|
||||||
return res
|
return Result(data=res)
|
||||||
except ProviderError:
|
except ProviderError:
|
||||||
if monitor.enabled: monitor.end_component("ai_client._send_anthropic")
|
if monitor.enabled: monitor.end_component("ai_client._send_anthropic")
|
||||||
raise
|
raise
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
if monitor.enabled: monitor.end_component("ai_client._send_anthropic")
|
if monitor.enabled: monitor.end_component("ai_client._send_anthropic")
|
||||||
raise _classify_anthropic_error(exc) from exc
|
return Result(data="", errors=[_classify_anthropic_error(exc, source="ai_client.anthropic")])
|
||||||
|
|
||||||
#endregion: Anthropic Provider
|
#endregion: Anthropic Provider
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user