fiuai-sdk-python 0.7.1__tar.gz → 0.7.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {fiuai_sdk_python-0.7.1 → fiuai_sdk_python-0.7.2}/PKG-INFO +1 -1
- {fiuai_sdk_python-0.7.1 → fiuai_sdk_python-0.7.2}/pyproject.toml +1 -1
- {fiuai_sdk_python-0.7.1 → fiuai_sdk_python-0.7.2}/src/fiuai_sdk_python/resp.py +51 -3
- {fiuai_sdk_python-0.7.1 → fiuai_sdk_python-0.7.2}/.gitignore +0 -0
- {fiuai_sdk_python-0.7.1 → fiuai_sdk_python-0.7.2}/CHANGELOG.md +0 -0
- {fiuai_sdk_python-0.7.1 → fiuai_sdk_python-0.7.2}/LICENSE +0 -0
- {fiuai_sdk_python-0.7.1 → fiuai_sdk_python-0.7.2}/README.md +0 -0
- {fiuai_sdk_python-0.7.1 → fiuai_sdk_python-0.7.2}/src/fiuai_sdk_python/__init__.py +0 -0
- {fiuai_sdk_python-0.7.1 → fiuai_sdk_python-0.7.2}/src/fiuai_sdk_python/auth/__init__.py +0 -0
- {fiuai_sdk_python-0.7.1 → fiuai_sdk_python-0.7.2}/src/fiuai_sdk_python/auth/context_mgr.py +0 -0
- {fiuai_sdk_python-0.7.1 → fiuai_sdk_python-0.7.2}/src/fiuai_sdk_python/auth/header.py +0 -0
- {fiuai_sdk_python-0.7.1 → fiuai_sdk_python-0.7.2}/src/fiuai_sdk_python/auth/helper.py +0 -0
- {fiuai_sdk_python-0.7.1 → fiuai_sdk_python-0.7.2}/src/fiuai_sdk_python/auth/type.py +0 -0
- {fiuai_sdk_python-0.7.1 → fiuai_sdk_python-0.7.2}/src/fiuai_sdk_python/bank.py +0 -0
- {fiuai_sdk_python-0.7.1 → fiuai_sdk_python-0.7.2}/src/fiuai_sdk_python/client.py +0 -0
- {fiuai_sdk_python-0.7.1 → fiuai_sdk_python-0.7.2}/src/fiuai_sdk_python/company.py +0 -0
- {fiuai_sdk_python-0.7.1 → fiuai_sdk_python-0.7.2}/src/fiuai_sdk_python/config.py +0 -0
- {fiuai_sdk_python-0.7.1 → fiuai_sdk_python-0.7.2}/src/fiuai_sdk_python/const.py +0 -0
- {fiuai_sdk_python-0.7.1 → fiuai_sdk_python-0.7.2}/src/fiuai_sdk_python/context.py +0 -0
- {fiuai_sdk_python-0.7.1 → fiuai_sdk_python-0.7.2}/src/fiuai_sdk_python/datatype.py +0 -0
- {fiuai_sdk_python-0.7.1 → fiuai_sdk_python-0.7.2}/src/fiuai_sdk_python/doctype.py +0 -0
- {fiuai_sdk_python-0.7.1 → fiuai_sdk_python-0.7.2}/src/fiuai_sdk_python/error.py +0 -0
- {fiuai_sdk_python-0.7.1 → fiuai_sdk_python-0.7.2}/src/fiuai_sdk_python/examples/fastapi_integration.py +0 -0
- {fiuai_sdk_python-0.7.1 → fiuai_sdk_python-0.7.2}/src/fiuai_sdk_python/http/__init__.py +0 -0
- {fiuai_sdk_python-0.7.1 → fiuai_sdk_python-0.7.2}/src/fiuai_sdk_python/http/client.py +0 -0
- {fiuai_sdk_python-0.7.1 → fiuai_sdk_python-0.7.2}/src/fiuai_sdk_python/item.py +0 -0
- {fiuai_sdk_python-0.7.1 → fiuai_sdk_python-0.7.2}/src/fiuai_sdk_python/perm.py +0 -0
- {fiuai_sdk_python-0.7.1 → fiuai_sdk_python-0.7.2}/src/fiuai_sdk_python/pkg/cache/__init__.py +0 -0
- {fiuai_sdk_python-0.7.1 → fiuai_sdk_python-0.7.2}/src/fiuai_sdk_python/pkg/cache/redis_manager.py +0 -0
- {fiuai_sdk_python-0.7.1 → fiuai_sdk_python-0.7.2}/src/fiuai_sdk_python/profile.py +0 -0
- {fiuai_sdk_python-0.7.1 → fiuai_sdk_python-0.7.2}/src/fiuai_sdk_python/setup.py +0 -0
- {fiuai_sdk_python-0.7.1 → fiuai_sdk_python-0.7.2}/src/fiuai_sdk_python/type.py +0 -0
- {fiuai_sdk_python-0.7.1 → fiuai_sdk_python-0.7.2}/src/fiuai_sdk_python/util.py +0 -0
- {fiuai_sdk_python-0.7.1 → fiuai_sdk_python-0.7.2}/src/fiuai_sdk_python/utils/__init__.py +0 -0
- {fiuai_sdk_python-0.7.1 → fiuai_sdk_python-0.7.2}/src/fiuai_sdk_python/utils/ids.py +0 -0
- {fiuai_sdk_python-0.7.1 → fiuai_sdk_python-0.7.2}/src/fiuai_sdk_python/utils/logger.py +0 -0
- {fiuai_sdk_python-0.7.1 → fiuai_sdk_python-0.7.2}/src/fiuai_sdk_python/utils/text.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: fiuai_sdk_python
|
|
3
|
-
Version: 0.7.
|
|
3
|
+
Version: 0.7.2
|
|
4
4
|
Summary: FiuAI Python SDK - 企业级AI服务集成开发工具包
|
|
5
5
|
Project-URL: Homepage, https://github.com/fiuai/fiuai-sdk-python
|
|
6
6
|
Project-URL: Documentation, https://github.com/fiuai/fiuai-sdk-python#readme
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
# Copyright (c) 2025 FiuAI
|
|
7
7
|
|
|
8
8
|
import logging
|
|
9
|
+
from httpx import Response
|
|
9
10
|
from typing import List, Dict, Any, Optional, Union
|
|
10
11
|
from pydantic import BaseModel, Field
|
|
11
12
|
|
|
@@ -30,7 +31,41 @@ class ApiResponse(BaseModel):
|
|
|
30
31
|
return self.http_success and self.api_success
|
|
31
32
|
|
|
32
33
|
|
|
33
|
-
def
|
|
34
|
+
def _get_response_body_preview(response: Response, max_chars: int = 300) -> str:
|
|
35
|
+
"""
|
|
36
|
+
安全读取响应体前若干字符,用于错误信息预览。兼容编码问题及中文。
|
|
37
|
+
"""
|
|
38
|
+
try:
|
|
39
|
+
raw = response.content
|
|
40
|
+
if not raw:
|
|
41
|
+
return ""
|
|
42
|
+
text = raw.decode("utf-8", errors="replace")
|
|
43
|
+
text = text.strip()
|
|
44
|
+
if len(text) > max_chars:
|
|
45
|
+
text = text[:max_chars] + "..."
|
|
46
|
+
return text
|
|
47
|
+
except Exception:
|
|
48
|
+
return ""
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def _get_response_body_for_log(response: Response, max_chars: int = 2000) -> str:
|
|
52
|
+
"""
|
|
53
|
+
安全读取完整响应体用于日志,避免编码异常,支持中文。
|
|
54
|
+
"""
|
|
55
|
+
try:
|
|
56
|
+
raw = response.content
|
|
57
|
+
if not raw:
|
|
58
|
+
return "(empty)"
|
|
59
|
+
text = raw.decode("utf-8", errors="replace")
|
|
60
|
+
text = text.strip()
|
|
61
|
+
if len(text) > max_chars:
|
|
62
|
+
text = text[:max_chars] + "...(truncated)"
|
|
63
|
+
return text
|
|
64
|
+
except Exception as ex:
|
|
65
|
+
return f"(decode error: {ex})"
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def parse_response(response: Response) -> ApiResponse:
|
|
34
69
|
"""
|
|
35
70
|
解析HTTP响应,返回结构化的API响应
|
|
36
71
|
|
|
@@ -67,12 +102,25 @@ def parse_response(response) -> ApiResponse:
|
|
|
67
102
|
try:
|
|
68
103
|
response_data = response.json()
|
|
69
104
|
except Exception as e:
|
|
105
|
+
# 安全读取响应体,兼容非 UTF-8 及中文等,便于日志和错误信息完整
|
|
106
|
+
raw_preview = _get_response_body_preview(response, max_chars=300)
|
|
107
|
+
err_msg = f"Invalid JSON response (status={response.status_code}): {e}"
|
|
108
|
+
if raw_preview:
|
|
109
|
+
err_msg += f"; body preview: {raw_preview}"
|
|
110
|
+
else:
|
|
111
|
+
err_msg += "; response body empty (e.g. gateway/upstream error)"
|
|
112
|
+
logger.error(
|
|
113
|
+
"parse_response json failed, status=%s, error=%s, body=%s",
|
|
114
|
+
response.status_code,
|
|
115
|
+
str(e),
|
|
116
|
+
_get_response_body_for_log(response),
|
|
117
|
+
)
|
|
70
118
|
return ApiResponse(
|
|
71
119
|
http_success=True,
|
|
72
120
|
api_success=False,
|
|
73
121
|
status_code=response.status_code,
|
|
74
|
-
error_message=[
|
|
75
|
-
error_code=["API_INVALID_JSON"]
|
|
122
|
+
error_message=[err_msg],
|
|
123
|
+
error_code=["API_INVALID_JSON"],
|
|
76
124
|
)
|
|
77
125
|
|
|
78
126
|
# 检查API业务是否成功
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{fiuai_sdk_python-0.7.1 → fiuai_sdk_python-0.7.2}/src/fiuai_sdk_python/pkg/cache/__init__.py
RENAMED
|
File without changes
|
{fiuai_sdk_python-0.7.1 → fiuai_sdk_python-0.7.2}/src/fiuai_sdk_python/pkg/cache/redis_manager.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|