fiuai-sdk-python 0.3.3__tar.gz → 0.3.4__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.
Files changed (24) hide show
  1. {fiuai_sdk_python-0.3.3 → fiuai_sdk_python-0.3.4}/PKG-INFO +1 -1
  2. {fiuai_sdk_python-0.3.3 → fiuai_sdk_python-0.3.4}/pyproject.toml +1 -1
  3. {fiuai_sdk_python-0.3.3 → fiuai_sdk_python-0.3.4}/src/fiuai_sdk_python/setup.py +24 -4
  4. {fiuai_sdk_python-0.3.3 → fiuai_sdk_python-0.3.4}/src/fiuai_sdk_python/type.py +71 -3
  5. {fiuai_sdk_python-0.3.3 → fiuai_sdk_python-0.3.4}/.gitignore +0 -0
  6. {fiuai_sdk_python-0.3.3 → fiuai_sdk_python-0.3.4}/CHANGELOG.md +0 -0
  7. {fiuai_sdk_python-0.3.3 → fiuai_sdk_python-0.3.4}/LICENSE +0 -0
  8. {fiuai_sdk_python-0.3.3 → fiuai_sdk_python-0.3.4}/README.md +0 -0
  9. {fiuai_sdk_python-0.3.3 → fiuai_sdk_python-0.3.4}/src/fiuai_sdk_python/__init__.py +0 -0
  10. {fiuai_sdk_python-0.3.3 → fiuai_sdk_python-0.3.4}/src/fiuai_sdk_python/auth/__init__.py +0 -0
  11. {fiuai_sdk_python-0.3.3 → fiuai_sdk_python-0.3.4}/src/fiuai_sdk_python/auth/header.py +0 -0
  12. {fiuai_sdk_python-0.3.3 → fiuai_sdk_python-0.3.4}/src/fiuai_sdk_python/auth/helper.py +0 -0
  13. {fiuai_sdk_python-0.3.3 → fiuai_sdk_python-0.3.4}/src/fiuai_sdk_python/auth/test_auth.py +0 -0
  14. {fiuai_sdk_python-0.3.3 → fiuai_sdk_python-0.3.4}/src/fiuai_sdk_python/auth/type.py +0 -0
  15. {fiuai_sdk_python-0.3.3 → fiuai_sdk_python-0.3.4}/src/fiuai_sdk_python/bank.py +0 -0
  16. {fiuai_sdk_python-0.3.3 → fiuai_sdk_python-0.3.4}/src/fiuai_sdk_python/client.py +0 -0
  17. {fiuai_sdk_python-0.3.3 → fiuai_sdk_python-0.3.4}/src/fiuai_sdk_python/company.py +0 -0
  18. {fiuai_sdk_python-0.3.3 → fiuai_sdk_python-0.3.4}/src/fiuai_sdk_python/const.py +0 -0
  19. {fiuai_sdk_python-0.3.3 → fiuai_sdk_python-0.3.4}/src/fiuai_sdk_python/error.py +0 -0
  20. {fiuai_sdk_python-0.3.3 → fiuai_sdk_python-0.3.4}/src/fiuai_sdk_python/item.py +0 -0
  21. {fiuai_sdk_python-0.3.3 → fiuai_sdk_python-0.3.4}/src/fiuai_sdk_python/perm.py +0 -0
  22. {fiuai_sdk_python-0.3.3 → fiuai_sdk_python-0.3.4}/src/fiuai_sdk_python/profile.py +0 -0
  23. {fiuai_sdk_python-0.3.3 → fiuai_sdk_python-0.3.4}/src/fiuai_sdk_python/test_all.py +0 -0
  24. {fiuai_sdk_python-0.3.3 → fiuai_sdk_python-0.3.4}/src/fiuai_sdk_python/util.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fiuai_sdk_python
3
- Version: 0.3.3
3
+ Version: 0.3.4
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
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "fiuai_sdk_python"
3
- version = "0.3.3"
3
+ version = "0.3.4"
4
4
  description = "FiuAI Python SDK - 企业级AI服务集成开发工具包"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.12"
@@ -22,6 +22,7 @@ from .type import (
22
22
  Language,
23
23
  DocTypeMeta,
24
24
  DocField,
25
+ DocFieldType,
25
26
  AiRecognitionValue
26
27
  )
27
28
  from typing import List
@@ -104,17 +105,26 @@ def _get_meta(client: FiuaiSDK, doctype: str, only_has_prompt: bool = True, show
104
105
  for _f in m["fields"]:
105
106
  field_name = _f["fieldname"]
106
107
  field_type = _f["fieldtype"]
107
- field_prompt = _f.get("field_prompt", "")
108
- options_str = _f.get("options", "")
108
+ field_prompt = _f.get("field_prompt", None)
109
+ options_str = _f.get("options", None)
109
110
  hidden = _f.get("hidden", 0)
110
111
  reqd = _f.get("reqd", 0)
111
112
  read_only = _f.get("read_only", 0)
112
113
  description = _f.get("description", "")
114
+ link_filters = _f.get("link_filters", None)
115
+ precision = _f.get("precision", None)
116
+ length = _f.get("length", None)
113
117
 
114
118
  options = []
119
+
115
120
  match field_type:
116
121
  case "Select":
117
- options = options_str.split("\n")
122
+ if not options_str:
123
+ # raise ValueError(f"empty option str for select field {field_name}")
124
+ # TODO: 解决异常
125
+ options = []
126
+ else:
127
+ options = options_str.split("\n")
118
128
  case "Link":
119
129
  links.append(options_str)
120
130
  options.append(options_str)
@@ -132,10 +142,17 @@ def _get_meta(client: FiuaiSDK, doctype: str, only_has_prompt: bool = True, show
132
142
  continue
133
143
 
134
144
 
145
+ # 将字符串类型的 field_type 转换为 DocFieldType 枚举
146
+ try:
147
+ fieldtype_enum = DocFieldType(field_type)
148
+ except ValueError:
149
+ # 如果找不到对应的枚举值,使用 Data 作为默认值
150
+ fieldtype_enum = DocFieldType.Data
151
+
135
152
  _fields.append(DocField(
136
153
  fieldname=field_name,
137
154
  description=description,
138
- fieldtype=field_type,
155
+ fieldtype=fieldtype_enum,
139
156
  hidden=True if _f.get("hidden", 0) == 1 else False,
140
157
  read_only=True if _f.get("read_only", 0) == 1 else False,
141
158
  reqd=True if _f.get("reqd", 0) == 1 else False,
@@ -144,6 +161,9 @@ def _get_meta(client: FiuaiSDK, doctype: str, only_has_prompt: bool = True, show
144
161
  mandatory=True if _f.get("mandatory", 0) == 1 else False,
145
162
  in_list_view=True if _f.get("in_list_view", 0) == 1 else False,
146
163
  in_mobile_view=True if _f.get("in_mobile_view", 0) == 1 else False,
164
+ link_filters=link_filters,
165
+ precision=precision,
166
+ length=length,
147
167
  # ai_recognition_value=AiRecognitionValue(value=None, confidence=0, ai_comment="")
148
168
  ))
149
169
 
@@ -6,6 +6,7 @@
6
6
  # Copyright (c) 2025 FiuAI
7
7
 
8
8
 
9
+ from token import OP
9
10
  from pydantic import BaseModel, Field, create_model, validator
10
11
  from typing import List, Any, Literal, Dict, Optional, Union, Type
11
12
  from datetime import datetime
@@ -116,6 +117,70 @@ class AiRecognitionValue(BaseModel):
116
117
  editable: bool = Field(description="用户是否可以更改", default=False)
117
118
 
118
119
 
120
+ class DocFieldType(StrEnum):
121
+ """doctype 定义的字段类型"""
122
+
123
+ # 常用
124
+ Data: str = "Data"
125
+ Check: str = "Check"
126
+ # currency 类似float
127
+ Currency: str = "Currency"
128
+ Time: str = "Time"
129
+ Date: str = "Date"
130
+ Datetime: str = "Datetime"
131
+ Int: str = "Int"
132
+ Float: str = "Float"
133
+ Select: str = "Select"
134
+ Link: str = "Link"
135
+ Text: str = "Text"
136
+ Long_Text: str = "Long Text"
137
+ Table: str = "Table"
138
+
139
+ # 其他不常见基础字段类型
140
+ Autocomplete: str = "Autocomplete"
141
+ Attach: str = "Attach"
142
+ Attach_Image: str = "Attach Image"
143
+ Barcode: str = "Barcode"
144
+ Button: str = "Button"
145
+ Code: str = "Code"
146
+ Color: str = "Color"
147
+ Column_Break: str = "Column Break"
148
+
149
+
150
+
151
+
152
+ Duration: str = "Duration"
153
+ Dynamic_Link: str = "Dynamic Link"
154
+
155
+ Fold: str = "Fold"
156
+ Geolocation: str = "Geolocation"
157
+ Heading: str = "Heading"
158
+ Html: str = "HTML"
159
+ Html_Editor: str = "HTML Editor"
160
+ Icon: str = "Icon"
161
+ Image: str = "Image"
162
+
163
+ Json: str = "JSON"
164
+
165
+
166
+ Markdown_Editor: str = "Markdown Editor"
167
+ Password: str = "Password"
168
+ Percent: str = "Percent"
169
+ Phone: str = "Phone"
170
+ Read_Only: str = "Read Only"
171
+ Rating: str = "Rating"
172
+ Section_Break: str = "Section Break"
173
+
174
+ Signature: str = "Signature"
175
+ Small_Text: str = "Small Text"
176
+ Tab_Break: str = "Tab Break"
177
+
178
+ Table_Multi_Select: str = "Table MultiSelect"
179
+
180
+ Text_Editor: str = "Text Editor"
181
+
182
+
183
+
119
184
  class DocField(BaseModel):
120
185
  """
121
186
  frappe 文档字段文档数据
@@ -125,9 +190,12 @@ class DocField(BaseModel):
125
190
  hidden: bool = Field(description="字段是否隐藏")
126
191
  reqd: bool = Field(description="字段是否必填")
127
192
  read_only: bool = Field(description="字段是否只读")
128
- fieldtype: str = Field(description="字段类型,比如Data,Float,Link,etc.")
129
- options: List[str] = Field(description="字段选项,Select类型的字段的枚举值, Link类型字段的Link目标表名")
130
- field_prompt: str = Field(description="字段对应的prompt")
193
+ fieldtype: DocFieldType = Field(description="字段类型,比如Data,Float,Link,etc.")
194
+ options: Optional[List[str]] = Field(description="字段选项,Select类型的字段的枚举值, Link类型字段的Link目标表名", default=None)
195
+ link_filters: Optional[str] = Field(description="Link字段过滤条件,json字符串", default=None)
196
+ length: Optional[int] = Field(description="字段长度限制", default=None)
197
+ precision: Optional[int] = Field(description="浮点数类型时的精度", default=None)
198
+ field_prompt: Optional[str] = Field(description="字段对应的prompt", default=None)
131
199
  mandatory: bool = Field(description="字段是否必填", default=False)
132
200
  in_list_view: bool = Field(description="字段是否在列表视图中显示", default=False)
133
201
  in_mobile_view: bool = Field(description="字段是否在移动端视图中显示", default=False)