Spaces:
Running
Running
Commit ·
6fbe8fc
1
Parent(s): 2b26635
Refactor attribute response mappings and improve documentation clarity
Browse files- Updated `ATTRIBUTE_RESPONE_MAPPING` to `ATTRIBUTE_RESPONSE_MAPPING` for consistency in naming conventions.
- Enhanced descriptions in the attribute response mapping for better clarity and understanding.
- Corrected variable names from `deutsche_name` to `german_name` across multiple files to standardize terminology.
- Improved docstring in `get_attribute` function to include additional attribute properties, enhancing documentation quality.
agent_ng/tabs/chat_tab.py
CHANGED
|
@@ -44,7 +44,7 @@ class ChatTab:
|
|
| 44 |
"""Create the main chat interface with proper layout"""
|
| 45 |
with gr.Row():
|
| 46 |
with gr.Column(elem_classes=["chat-hints"]):
|
| 47 |
-
gr.Markdown(f"## {self._get_translation(
|
| 48 |
|
| 49 |
gr.Markdown(self._get_translation("welcome_description"))
|
| 50 |
|
|
|
|
| 44 |
"""Create the main chat interface with proper layout"""
|
| 45 |
with gr.Row():
|
| 46 |
with gr.Column(elem_classes=["chat-hints"]):
|
| 47 |
+
gr.Markdown(f"## {self._get_translation('welcome_title')}", elem_classes=["chat-hints-title"])
|
| 48 |
|
| 49 |
gr.Markdown(self._get_translation("welcome_description"))
|
| 50 |
|
tools/attributes_tools/tool_get_attribute.py
CHANGED
|
@@ -13,8 +13,11 @@ def get_attribute(
|
|
| 13 |
dict: {
|
| 14 |
"success": bool - True if the attribute was fetched successfully
|
| 15 |
"status_code": int - HTTP response status code
|
| 16 |
-
"raw_response": dict|str|None - Raw response payload for auditing or payload body (sanitized)
|
| 17 |
"error": str|None - Error message if operation failed
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
}
|
| 19 |
"""
|
| 20 |
|
|
@@ -25,7 +28,7 @@ def get_attribute(
|
|
| 25 |
|
| 26 |
return execute_get_operation(
|
| 27 |
result_model=AttributeResult,
|
| 28 |
-
response_mapping=
|
| 29 |
endpoint=endpoint
|
| 30 |
)
|
| 31 |
|
|
|
|
| 13 |
dict: {
|
| 14 |
"success": bool - True if the attribute was fetched successfully
|
| 15 |
"status_code": int - HTTP response status code
|
|
|
|
| 16 |
"error": str|None - Error message if operation failed
|
| 17 |
+
"attribute property 1": value 1,
|
| 18 |
+
"attribute property 2": value 2,
|
| 19 |
+
...
|
| 20 |
+
"attribute property N": value N
|
| 21 |
}
|
| 22 |
"""
|
| 23 |
|
|
|
|
| 28 |
|
| 29 |
return execute_get_operation(
|
| 30 |
result_model=AttributeResult,
|
| 31 |
+
response_mapping=ATTRIBUTE_RESPONSE_MAPPING,
|
| 32 |
endpoint=endpoint
|
| 33 |
)
|
| 34 |
|
tools/attributes_tools/tools_enum_attribute.py
CHANGED
|
@@ -13,9 +13,9 @@ class PlainEnumValueModel(BaseModel):
|
|
| 13 |
default=None,
|
| 14 |
description="Enum value English name. RU: Английское название значения",
|
| 15 |
)
|
| 16 |
-
|
| 17 |
default=None,
|
| 18 |
-
description="Enum value
|
| 19 |
)
|
| 20 |
color: Optional[str] = Field(
|
| 21 |
default=None,
|
|
@@ -26,10 +26,10 @@ class PlainEnumValueModel(BaseModel):
|
|
| 26 |
def check_at_least_one_name(cls, values):
|
| 27 |
russian = values.russian_name
|
| 28 |
english = values.english_name
|
| 29 |
-
|
| 30 |
|
| 31 |
-
if not any([russian, english,
|
| 32 |
-
raise ValueError("At least one of 'russian_name', 'english_name', or '
|
| 33 |
|
| 34 |
return values
|
| 35 |
|
|
@@ -73,7 +73,7 @@ def convert_plain_to_enum_value(plain: PlainEnumValueModel, attr_system_name: st
|
|
| 73 |
"name": {
|
| 74 |
"ru": plain.russian_name,
|
| 75 |
"en": plain.english_name,
|
| 76 |
-
"de": plain.
|
| 77 |
},
|
| 78 |
"color": plain.color,
|
| 79 |
}
|
|
@@ -103,7 +103,7 @@ def edit_or_create_enum_attribute(
|
|
| 103 |
"system_name": "status_active",
|
| 104 |
"russian_name": "Активен",
|
| 105 |
"english_name": "Active",
|
| 106 |
-
"
|
| 107 |
"color": "#4CAF50"
|
| 108 |
}
|
| 109 |
]
|
|
@@ -164,14 +164,14 @@ if __name__ == "__main__":
|
|
| 164 |
"system_name": "status_active",
|
| 165 |
"russian_name": "Активен",
|
| 166 |
"english_name": "Active",
|
| 167 |
-
"
|
| 168 |
"color": "#4CAF50"
|
| 169 |
},
|
| 170 |
{
|
| 171 |
"system_name": "status_inactive",
|
| 172 |
"russian_name": "Неактивен",
|
| 173 |
"english_name": "Inactive",
|
| 174 |
-
"
|
| 175 |
"color": "#9E9E9E"
|
| 176 |
}
|
| 177 |
]
|
|
|
|
| 13 |
default=None,
|
| 14 |
description="Enum value English name. RU: Английское название значения",
|
| 15 |
)
|
| 16 |
+
german_name: Optional[str] = Field(
|
| 17 |
default=None,
|
| 18 |
+
description="Enum value German name. RU: Немецкое название значения",
|
| 19 |
)
|
| 20 |
color: Optional[str] = Field(
|
| 21 |
default=None,
|
|
|
|
| 26 |
def check_at_least_one_name(cls, values):
|
| 27 |
russian = values.russian_name
|
| 28 |
english = values.english_name
|
| 29 |
+
german = values.german_name
|
| 30 |
|
| 31 |
+
if not any([russian, english, german]):
|
| 32 |
+
raise ValueError("At least one of 'russian_name', 'english_name', or 'german_name' must be provided.")
|
| 33 |
|
| 34 |
return values
|
| 35 |
|
|
|
|
| 73 |
"name": {
|
| 74 |
"ru": plain.russian_name,
|
| 75 |
"en": plain.english_name,
|
| 76 |
+
"de": plain.german_name,
|
| 77 |
},
|
| 78 |
"color": plain.color,
|
| 79 |
}
|
|
|
|
| 103 |
"system_name": "status_active",
|
| 104 |
"russian_name": "Активен",
|
| 105 |
"english_name": "Active",
|
| 106 |
+
"german_name": "Aktiv",
|
| 107 |
"color": "#4CAF50"
|
| 108 |
}
|
| 109 |
]
|
|
|
|
| 164 |
"system_name": "status_active",
|
| 165 |
"russian_name": "Активен",
|
| 166 |
"english_name": "Active",
|
| 167 |
+
"german_name": "Aktiv",
|
| 168 |
"color": "#4CAF50"
|
| 169 |
},
|
| 170 |
{
|
| 171 |
"system_name": "status_inactive",
|
| 172 |
"russian_name": "Неактивен",
|
| 173 |
"english_name": "Inactive",
|
| 174 |
+
"german_name": "Inaktiv",
|
| 175 |
"color": "#9E9E9E"
|
| 176 |
}
|
| 177 |
]
|
tools/tool_utils.py
CHANGED
|
@@ -25,38 +25,38 @@ KEYS_TO_REMOVE_MAPPING = {
|
|
| 25 |
"Boolean": ['isMultiValue', 'isMandatory', 'isOwnership', 'instanceGlobalAlias', 'imageColorType', 'imagePreserveAspectRatio'],
|
| 26 |
"Account": ['isUnique', 'isIndexed', 'isMandatory', 'isOwnership', 'imageColorType', 'imagePreserveAspectRatio']
|
| 27 |
}
|
| 28 |
-
|
| 29 |
-
"owner": "
|
| 30 |
-
"alias": "
|
| 31 |
-
"type": "
|
| 32 |
"format": "Display format",
|
| 33 |
"name": "Name",
|
| 34 |
"description": "Description",
|
| 35 |
-
"isSystem": "Is
|
| 36 |
-
"isDisabled": "
|
| 37 |
-
"isUnique": "Control
|
| 38 |
"isIndexed": "Use to search records",
|
| 39 |
"isTracked": "Write changes to the log",
|
| 40 |
"isDigitGrouping": "Group digits numbers",
|
| 41 |
"isMultiValue": "Store multiple values",
|
| 42 |
"isTitle": "Use as record title",
|
| 43 |
"isCalculated": "Calculate value",
|
| 44 |
-
"isReadonly": "Is
|
| 45 |
-
"expression": "Expression for calculation",
|
| 46 |
"fileFormat": "File extensions filter",
|
| 47 |
-
"
|
| 48 |
"instanceAlias": "Related template system name",
|
| 49 |
"instanceAttributeAlias": "Related attribute system name",
|
| 50 |
"imageColorType": "Rendering color mode",
|
| 51 |
-
"imageWidth": "Image
|
| 52 |
-
"imageHeight": "Image
|
| 53 |
-
"imagePreserveAspectRatio": "Save image aspect
|
| 54 |
"imageXResolution": "X-axis image resolution",
|
| 55 |
"imageYResolution": "Y-axis image resolution",
|
| 56 |
"decimalPlaces": "Number decimal places",
|
| 57 |
"validationMaskRegex": "Custom mask",
|
| 58 |
"variants": "Enum values",
|
| 59 |
-
"linkedRecordTemplate": "Related template
|
| 60 |
}
|
| 61 |
|
| 62 |
def remove_values(
|
|
@@ -216,12 +216,12 @@ def execute_get_operation(
|
|
| 216 |
# Цвет
|
| 217 |
color = variant.get("color", "")
|
| 218 |
|
| 219 |
-
# Форм
|
| 220 |
processed_variants.append({
|
| 221 |
"System name": alias_value,
|
| 222 |
"English name": en_name,
|
| 223 |
"Russian name": ru_name,
|
| 224 |
-
"
|
| 225 |
"Color": color
|
| 226 |
})
|
| 227 |
|
|
@@ -236,15 +236,18 @@ def execute_get_operation(
|
|
| 236 |
new_key = response_mapping.get(key, key)
|
| 237 |
renamed_data[new_key] = value
|
| 238 |
attribute_data = renamed_data
|
|
|
|
|
|
|
| 239 |
|
| 240 |
# Формируем финальный результат
|
| 241 |
final_result = {
|
| 242 |
"success": True,
|
| 243 |
"status_code": result["status_code"],
|
| 244 |
-
"data": attribute_data,
|
| 245 |
"error": None
|
| 246 |
}
|
| 247 |
|
|
|
|
|
|
|
| 248 |
# Валидируем и возвращаем
|
| 249 |
validated = result_model(**final_result)
|
| 250 |
return validated.model_dump()
|
|
|
|
| 25 |
"Boolean": ['isMultiValue', 'isMandatory', 'isOwnership', 'instanceGlobalAlias', 'imageColorType', 'imagePreserveAspectRatio'],
|
| 26 |
"Account": ['isUnique', 'isIndexed', 'isMandatory', 'isOwnership', 'imageColorType', 'imagePreserveAspectRatio']
|
| 27 |
}
|
| 28 |
+
ATTRIBUTE_RESPONSE_MAPPING = {
|
| 29 |
+
"owner": "Parent template system name",
|
| 30 |
+
"alias": "Attribute system name",
|
| 31 |
+
"type": "Attribute type",
|
| 32 |
"format": "Display format",
|
| 33 |
"name": "Name",
|
| 34 |
"description": "Description",
|
| 35 |
+
"isSystem": "Is system",
|
| 36 |
+
"isDisabled": "Archived",
|
| 37 |
+
"isUnique": "Control value uniqueness",
|
| 38 |
"isIndexed": "Use to search records",
|
| 39 |
"isTracked": "Write changes to the log",
|
| 40 |
"isDigitGrouping": "Group digits numbers",
|
| 41 |
"isMultiValue": "Store multiple values",
|
| 42 |
"isTitle": "Use as record title",
|
| 43 |
"isCalculated": "Calculate value",
|
| 44 |
+
"isReadonly": "Is readonly",
|
| 45 |
+
"expression": "Expression for value calculation",
|
| 46 |
"fileFormat": "File extensions filter",
|
| 47 |
+
"uriSchemeFormats": "Allowed URI schemes ",
|
| 48 |
"instanceAlias": "Related template system name",
|
| 49 |
"instanceAttributeAlias": "Related attribute system name",
|
| 50 |
"imageColorType": "Rendering color mode",
|
| 51 |
+
"imageWidth": "Image width",
|
| 52 |
+
"imageHeight": "Image height",
|
| 53 |
+
"imagePreserveAspectRatio": "Save image aspect ratio",
|
| 54 |
"imageXResolution": "X-axis image resolution",
|
| 55 |
"imageYResolution": "Y-axis image resolution",
|
| 56 |
"decimalPlaces": "Number decimal places",
|
| 57 |
"validationMaskRegex": "Custom mask",
|
| 58 |
"variants": "Enum values",
|
| 59 |
+
"linkedRecordTemplate": "Related template ID"
|
| 60 |
}
|
| 61 |
|
| 62 |
def remove_values(
|
|
|
|
| 216 |
# Цвет
|
| 217 |
color = variant.get("color", "")
|
| 218 |
|
| 219 |
+
# Формируем новый элемент
|
| 220 |
processed_variants.append({
|
| 221 |
"System name": alias_value,
|
| 222 |
"English name": en_name,
|
| 223 |
"Russian name": ru_name,
|
| 224 |
+
"German name": de_name,
|
| 225 |
"Color": color
|
| 226 |
})
|
| 227 |
|
|
|
|
| 236 |
new_key = response_mapping.get(key, key)
|
| 237 |
renamed_data[new_key] = value
|
| 238 |
attribute_data = renamed_data
|
| 239 |
+
|
| 240 |
+
|
| 241 |
|
| 242 |
# Формируем финальный результат
|
| 243 |
final_result = {
|
| 244 |
"success": True,
|
| 245 |
"status_code": result["status_code"],
|
|
|
|
| 246 |
"error": None
|
| 247 |
}
|
| 248 |
|
| 249 |
+
final_result = {**attribute_data, **final_result}
|
| 250 |
+
|
| 251 |
# Валидируем и возвращаем
|
| 252 |
validated = result_model(**final_result)
|
| 253 |
return validated.model_dump()
|