Documentation for Transformer
lexy_py.transformer.models.Transformer
Bases: TransformerModel
Transformer model
Source code in sdk-python/lexy_py/transformer/models.py
transform_document(document, transformer_params=None, content_only=False)
Synchronously transform a document.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
document |
Document | dict
|
The document to transform. |
required |
transformer_params |
dict
|
The transformer parameters. Defaults to None. |
None
|
content_only |
bool
|
Whether to submit only the document content and not the document itself. Use this option when the transformer doesn't accept Document objects as inputs. Defaults to False. |
False
|
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
A dictionary containing the generated task ID and the result of the transformer. |
Examples:
>>> from lexy_py import LexyClient
>>> lx = LexyClient()
>>> minilm = lx.get_transformer('text.embeddings.minilm')
>>> minilm.transform_document({'content': 'Good morning!'})
{'task_id': '449d9d79-4a57-4191-95d3-9c38955c8ced',
'result': [-0.03085244633257389, 0.028894789516925812, ...]}
Source code in sdk-python/lexy_py/transformer/models.py
lexy_py.transformer.models.TransformerModel
Bases: BaseModel
Transformer model
Parameters:
Name | Type | Description | Default |
---|---|---|---|
transformer_id |
str
|
|
required |
path |
str | None
|
|
None
|
description |
str | None
|
|
None
|
created_at |
datetime | None
|
|
None
|
updated_at |
datetime | None
|
|
None
|
Source code in sdk-python/lexy_py/transformer/models.py
lexy_py.transformer.client.TransformerClient
This class is used to interact with the Lexy Transformer API.
Attributes:
Name | Type | Description |
---|---|---|
aclient |
AsyncClient
|
Asynchronous API client. |
client |
Client
|
Synchronous API client. |
Source code in sdk-python/lexy_py/transformer/client.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 |
|
create_transformer(transformer_id, *, path=None, description=None)
Synchronously create a transformer.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
transformer_id |
str
|
The ID of the transformer to create. |
required |
path |
str
|
The path of the transformer to create. |
None
|
description |
str
|
The description of the transformer to create. |
None
|
Returns:
Name | Type | Description |
---|---|---|
Transformer |
Transformer
|
The created transformer. |
Source code in sdk-python/lexy_py/transformer/client.py
delete_transformer(transformer_id)
Synchronously delete a transformer.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
transformer_id |
str
|
The ID of the transformer to delete. |
required |
Source code in sdk-python/lexy_py/transformer/client.py
get_transformer(transformer_id)
Synchronously get a transformer.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
transformer_id |
str
|
The ID of the transformer to get. |
required |
Returns:
Name | Type | Description |
---|---|---|
Transformer |
Transformer
|
The transformer. |
Source code in sdk-python/lexy_py/transformer/client.py
list_transformers()
Synchronously get a list of all transformers.
Returns:
Type | Description |
---|---|
list[Transformer]
|
list[Transformer]: A list of all transformers. |
Source code in sdk-python/lexy_py/transformer/client.py
transform_document(transformer_id, document, transformer_params=None, content_only=False)
Synchronously transform a document.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
transformer_id |
str
|
The ID of the transformer to use. |
required |
document |
Document | dict
|
The document to transform. |
required |
transformer_params |
dict
|
The transformer parameters. Defaults to None. |
None
|
content_only |
bool
|
Whether to submit only the document content and not the document itself. Use this option when the transformer doesn't accept Document objects as inputs. Defaults to False. |
False
|
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
A dictionary containing the generated task ID and the result of the transformer. |
Examples:
>>> from lexy_py import LexyClient
>>> lx = LexyClient()
>>> lx.transformer.transform_document("text.counter.word_counter", {"content": "Hello world!"})
{'task_id': '65ecd2f7-bac4-4747-9e65-a6d21a72f585', 'result': [2, 'world!']}
Source code in sdk-python/lexy_py/transformer/client.py
update_transformer(transformer_id, *, path=None, description=None)
Synchronously update a transformer.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
transformer_id |
str
|
The ID of the transformer to update. |
required |
path |
str
|
The updated path of the transformer. |
None
|
description |
str
|
The updated description of the transformer. |
None
|
Returns:
Name | Type | Description |
---|---|---|
Transformer |
Transformer
|
The updated transformer. |
Source code in sdk-python/lexy_py/transformer/client.py
acreate_transformer(transformer_id, *, path=None, description=None)
async
Asynchronously create a transformer.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
transformer_id |
str
|
The ID of the transformer to create. |
required |
path |
str
|
The path of the transformer to create. |
None
|
description |
str
|
The description of the transformer to create. |
None
|
Returns:
Name | Type | Description |
---|---|---|
Transformer |
Transformer
|
The created transformer. |
Source code in sdk-python/lexy_py/transformer/client.py
adelete_transformer(transformer_id)
async
Asynchronously delete a transformer.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
transformer_id |
str
|
The ID of the transformer to delete. |
required |
Source code in sdk-python/lexy_py/transformer/client.py
aget_transformer(transformer_id)
async
Asynchronously get a transformer.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
transformer_id |
str
|
The ID of the transformer to get. |
required |
Returns:
Name | Type | Description |
---|---|---|
Transformer |
Transformer
|
The transformer. |
Source code in sdk-python/lexy_py/transformer/client.py
alist_transformers()
async
Asynchronously get a list of all transformers.
Returns:
Type | Description |
---|---|
list[Transformer]
|
list[Transformer]: A list of all transformers. |
Source code in sdk-python/lexy_py/transformer/client.py
aupdate_transformer(transformer_id, *, path=None, description=None)
async
Asynchronously update a transformer.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
transformer_id |
str
|
The ID of the transformer to update. |
required |
path |
str
|
The updated path of the transformer. |
None
|
description |
str
|
The updated description of the transformer. |
None
|
Returns:
Name | Type | Description |
---|---|---|
Transformer |
Transformer
|
The updated transformer. |