Private
Public Access
refactor(ai_client): _send_qwen_result() returns Result[str]
This commit is contained in:
+7
-3
@@ -2420,14 +2420,16 @@ def _list_qwen_models() -> list[str]:
|
|||||||
from src.vendor_capabilities import list_models_for_vendor
|
from src.vendor_capabilities import list_models_for_vendor
|
||||||
return list_models_for_vendor("qwen")
|
return list_models_for_vendor("qwen")
|
||||||
|
|
||||||
def _send_qwen(md_content: str, user_message: str, base_dir: str,
|
def _send_qwen_result(md_content: str, user_message: str, base_dir: str,
|
||||||
file_items: list[dict[str, Any]] | None = None,
|
file_items: list[dict[str, Any]] | None = None,
|
||||||
discussion_history: str = "",
|
discussion_history: str = "",
|
||||||
stream: bool = False,
|
stream: bool = False,
|
||||||
pre_tool_callback: Optional[Callable[[str, str, Optional[Callable[[str], str]]], Optional[str]]] = None,
|
pre_tool_callback: Optional[Callable[[str, str, Optional[Callable[[str], str]]], Optional[str]]] = None,
|
||||||
qa_callback: Optional[Callable[[str], str]] = None,
|
qa_callback: Optional[Callable[[str], str]] = None,
|
||||||
stream_callback: Optional[Callable[[str], None]] = None,
|
stream_callback: Optional[Callable[[str], None]] = None,
|
||||||
patch_callback: Optional[Callable[[str, str], Optional[str]]] = None) -> str:
|
patch_callback: Optional[Callable[[str, str], Optional[str]]] = None) -> Result[str]:
|
||||||
|
from src.qwen_adapter import classify_dashscope_error
|
||||||
|
try:
|
||||||
_ensure_qwen_client()
|
_ensure_qwen_client()
|
||||||
with _qwen_history_lock:
|
with _qwen_history_lock:
|
||||||
user_content = user_message
|
user_content = user_message
|
||||||
@@ -2449,7 +2451,9 @@ def _send_qwen(md_content: str, user_message: str, base_dir: str,
|
|||||||
temperature=_temperature,
|
temperature=_temperature,
|
||||||
top_p=_top_p,
|
top_p=_top_p,
|
||||||
)
|
)
|
||||||
return resp.get("text", "")
|
return Result(data=resp.get("text", ""))
|
||||||
|
except Exception as exc:
|
||||||
|
return Result(data="", errors=[classify_dashscope_error(exc, source="ai_client.qwen")])
|
||||||
|
|
||||||
#endregion: Qwen Provider
|
#endregion: Qwen Provider
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user