Resources
text2everything_sdk.resources.projects.ProjectsResource
¶
Bases: BaseResource
Client for managing projects in the Text2Everything API.
Projects are the top-level containers for organizing contexts, schema metadata, golden examples, and other resources.
Source code in resources/projects.py
10 11 12 13 14 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 |
|
create(name, description=None, **kwargs)
¶
Create a new project.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Project name |
required |
description
|
Optional[str]
|
Project description |
None
|
**kwargs
|
Additional project fields |
{}
|
Returns:
Type | Description |
---|---|
Project
|
Created Project instance |
Example
project = client.projects.create( ... name="My Project", ... description="A sample project" ... )
Source code in resources/projects.py
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 |
|
delete(project_id)
¶
Delete a project.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_id
|
str
|
The project ID |
required |
Returns:
Type | Description |
---|---|
Dict[str, Any]
|
Deletion confirmation response |
Example
result = client.projects.delete("proj_123") print(result["message"])
Source code in resources/projects.py
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
|
exists(project_id)
¶
Check if a project exists.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_id
|
str
|
The project ID |
required |
Returns:
Type | Description |
---|---|
bool
|
True if project exists, False otherwise |
Example
if client.projects.exists("proj_123"): ... print("Project exists")
Source code in resources/projects.py
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
|
get(project_id)
¶
Get a specific project by ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_id
|
str
|
The project ID |
required |
Returns:
Type | Description |
---|---|
Project
|
Project instance |
Raises:
Type | Description |
---|---|
NotFoundError
|
If project doesn't exist |
Example
project = client.projects.get("proj_123") print(project.name)
Source code in resources/projects.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
|
get_by_name(name)
¶
Get a project by name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Project name to search for |
required |
Returns:
Type | Description |
---|---|
Optional[Project]
|
Project instance if found, None otherwise |
Example
project = client.projects.get_by_name("My Project") if project: ... print(f"Found project: {project.id}")
Source code in resources/projects.py
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
|
list(page=1, per_page=50, search=None)
¶
List all projects.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
page
|
int
|
Page number (default: 1) |
1
|
per_page
|
int
|
Items per page (default: 50) |
50
|
search
|
Optional[str]
|
Search term to filter projects by name |
None
|
Returns:
Type | Description |
---|---|
List[Project]
|
List of Project instances |
Example
projects = client.projects.list() for project in projects: ... print(f"{project.name}: {project.description}")
Source code in resources/projects.py
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 |
|
update(project_id, name=None, description=None, **kwargs)
¶
Update an existing project.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_id
|
str
|
The project ID |
required |
name
|
Optional[str]
|
New project name |
None
|
description
|
Optional[str]
|
New project description |
None
|
**kwargs
|
Additional fields to update |
{}
|
Returns:
Type | Description |
---|---|
Project
|
Updated Project instance |
Example
project = client.projects.update( ... "proj_123", ... name="Updated Name" ... )
Source code in resources/projects.py
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 |
|
text2everything_sdk.resources.contexts.ContextsResource
¶
Bases: BaseResource
Client for managing contexts in the Text2Everything API.
Contexts provide business rules and domain knowledge to improve SQL generation. They can contain text content or structured information that helps the AI understand the business context and generate more accurate SQL queries.
Source code in resources/contexts.py
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 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 |
|
bulk_create(project_id, contexts, parallel=True, max_workers=None, max_concurrent=8, use_connection_isolation=True)
¶
Create multiple contexts with optional parallel execution and rate limiting.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_id
|
str
|
The project ID |
required |
contexts
|
List[Dict[str, Any]]
|
List of context data dictionaries |
required |
parallel
|
bool
|
Whether to execute requests in parallel (default: True) |
True
|
max_workers
|
Optional[int]
|
Maximum number of parallel workers (default: min(16, len(items))) |
None
|
max_concurrent
|
int
|
Maximum number of concurrent requests to prevent server overload (default: 8) |
8
|
use_connection_isolation
|
bool
|
Use isolated HTTP clients for each request to prevent connection conflicts (default: True) |
True
|
Returns:
Type | Description |
---|---|
List[Context]
|
List of created Context instances in the same order as input |
Raises:
Type | Description |
---|---|
ValidationError
|
If any validation fails |
Example
contexts_data = [ ... {"name": "Rule 1", "content": "Business rule 1"}, ... {"name": "Rule 2", "content": "Business rule 2"} ... ]
Parallel execution with rate limiting (default)¶
contexts = client.contexts.bulk_create("proj_123", contexts_data)
Sequential execution¶
contexts = client.contexts.bulk_create("proj_123", contexts_data, parallel=False)
Custom rate limiting¶
contexts = client.contexts.bulk_create("proj_123", contexts_data, max_concurrent=4)
Disable connection isolation for shared connection pool¶
contexts = client.contexts.bulk_create("proj_123", contexts_data, use_connection_isolation=False)
Source code in resources/contexts.py
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 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 |
|
create(project_id, name, content, description=None, is_always_displayed=False, **kwargs)
¶
Create a new context.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_id
|
str
|
The project ID |
required |
name
|
str
|
Context name |
required |
content
|
str
|
Context content (business rules, domain knowledge, etc.) |
required |
description
|
Optional[str]
|
Context description |
None
|
is_always_displayed
|
bool
|
Whether this context should always be included |
False
|
**kwargs
|
Additional context fields |
{}
|
Returns:
Type | Description |
---|---|
Context
|
Created Context instance |
Example
context = client.contexts.create( ... project_id="proj_123", ... name="Business Rules", ... content="Active customers have status = 'active'", ... is_always_displayed=True ... )
Source code in resources/contexts.py
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 |
|
delete(project_id, context_id)
¶
Delete a context.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_id
|
str
|
The project ID |
required |
context_id
|
str
|
The context ID |
required |
Returns:
Type | Description |
---|---|
Dict[str, Any]
|
Deletion confirmation response |
Example
result = client.contexts.delete("proj_123", "ctx_456") print(result["message"])
Source code in resources/contexts.py
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
|
get(project_id, context_id)
¶
Get a specific context by ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_id
|
str
|
The project ID |
required |
context_id
|
str
|
The context ID |
required |
Returns:
Type | Description |
---|---|
Context
|
Context instance |
Raises:
Type | Description |
---|---|
NotFoundError
|
If context doesn't exist |
Example
context = client.contexts.get("proj_123", "ctx_456") print(context.content)
Source code in resources/contexts.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
|
get_by_name(project_id, name)
¶
Get a context by name within a project.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_id
|
str
|
The project ID |
required |
name
|
str
|
Context name to search for |
required |
Returns:
Type | Description |
---|---|
Optional[Context]
|
Context instance if found, None otherwise |
Example
context = client.contexts.get_by_name("proj_123", "Business Rules") if context: ... print(f"Found context: {context.id}")
Source code in resources/contexts.py
372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 |
|
list(project_id, page=1, per_page=50, search=None)
¶
List contexts for a specific project.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_id
|
str
|
The project ID to list contexts for |
required |
page
|
int
|
Page number (default: 1) |
1
|
per_page
|
int
|
Items per page (default: 50) |
50
|
search
|
Optional[str]
|
Search term to filter contexts by name |
None
|
Returns:
Type | Description |
---|---|
List[Context]
|
List of Context instances |
Example
contexts = client.contexts.list(project_id="proj_123") for context in contexts: ... print(f"{context.name}: {context.is_always_displayed}")
Source code in resources/contexts.py
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 |
|
list_always_displayed(project_id)
¶
Get all contexts that are always displayed for a project.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_id
|
str
|
The project ID |
required |
Returns:
Type | Description |
---|---|
List[Context]
|
List of Context instances with is_always_displayed=True |
Example
always_contexts = client.contexts.list_always_displayed("proj_123") print(f"Found {len(always_contexts)} always-displayed contexts")
Source code in resources/contexts.py
394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 |
|
update(project_id, context_id, name=None, content=None, description=None, is_always_displayed=None, **kwargs)
¶
Update an existing context.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_id
|
str
|
The project ID |
required |
context_id
|
str
|
The context ID |
required |
name
|
Optional[str]
|
New context name |
None
|
content
|
Optional[str]
|
New context content |
None
|
description
|
Optional[str]
|
New context description |
None
|
is_always_displayed
|
Optional[bool]
|
Whether this context should always be included |
None
|
**kwargs
|
Additional fields to update |
{}
|
Returns:
Type | Description |
---|---|
Context
|
Updated Context instance |
Example
context = client.contexts.update( ... "proj_123", "ctx_456", ... content="Updated business rules..." ... )
Source code in resources/contexts.py
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 |
|
text2everything_sdk.resources.schema_metadata.SchemaMetadataResource
¶
Bases: BaseResource
Resource for managing schema metadata with nested field validation.
Source code in resources/schema_metadata.py
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 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 |
|
bulk_create(project_id, schema_metadata_list, validate=True, parallel=True, max_workers=None, max_concurrent=8, use_connection_isolation=True)
¶
Create multiple schema metadata items with validation and optional parallel execution.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_id
|
str
|
The project ID |
required |
schema_metadata_list
|
List[Dict[str, Any]]
|
List of schema metadata dictionaries to create |
required |
validate
|
bool
|
Whether to perform nested field validation (default: True) |
True
|
parallel
|
bool
|
Whether to execute requests in parallel (default: True) |
True
|
max_workers
|
Optional[int]
|
Maximum number of parallel workers (default: min(16, len(items))) |
None
|
max_concurrent
|
int
|
Maximum number of concurrent requests (default: 8, rate limiting) |
8
|
use_connection_isolation
|
bool
|
Use isolated HTTP clients for each request to prevent connection conflicts (default: True) |
True
|
Returns:
Type | Description |
---|---|
List[SchemaMetadataResponse]
|
List of created schema metadata in the same order as input |
Raises:
Type | Description |
---|---|
ValidationError
|
If any validation fails and validate=True, or if any creation fails |
Example
schemas = [
{
"name": "table1",
"schema_data": {"table": {"columns": []}},
"description": "First table"
},
{
"name": "dim1",
"schema_data": {"table": {"dimension": {"content": {}}}},
"is_always_displayed": True
}
]
# Parallel execution (default)
results = client.schema_metadata.bulk_create(project_id, schemas)
# Sequential execution
results = client.schema_metadata.bulk_create(project_id, schemas, parallel=False)
# Disable connection isolation for shared connection pool
results = client.schema_metadata.bulk_create(project_id, schemas, use_connection_isolation=False)
Source code in resources/schema_metadata.py
323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 |
|
create(project_id, name, schema_data, description=None, is_always_displayed=False, validate=True, **kwargs)
¶
Create new schema metadata with validation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_id
|
str
|
The project ID to create schema metadata in |
required |
name
|
str
|
Schema metadata name |
required |
schema_data
|
Dict[str, Any]
|
The schema data structure |
required |
description
|
Optional[str]
|
Optional description |
None
|
is_always_displayed
|
bool
|
Whether this schema should always be displayed |
False
|
validate
|
bool
|
Whether to perform nested field validation (default: True) |
True
|
**kwargs
|
Additional schema metadata fields |
{}
|
Returns:
Type | Description |
---|---|
SchemaMetadataResponse
|
The created schema metadata with response details |
Raises:
Type | Description |
---|---|
ValidationError
|
If validation fails and validate=True |
Example
# Create a table schema
result = client.schema_metadata.create(
project_id=project_id,
name="users_table",
description="User information table",
schema_data={
"table": {
"name": "users",
"columns": [
{"name": "id", "type": "integer"},
{"name": "email", "type": "string"}
]
}
},
is_always_displayed=True
)
Source code in resources/schema_metadata.py
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 |
|
delete(project_id, schema_metadata_id)
¶
Delete schema metadata.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_id
|
str
|
The project ID |
required |
schema_metadata_id
|
str
|
The schema metadata ID to delete |
required |
Returns:
Type | Description |
---|---|
bool
|
True if deletion was successful |
Example
success = client.schema_metadata.delete(project_id, schema_metadata_id)
Source code in resources/schema_metadata.py
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 |
|
get(project_id, schema_metadata_id)
¶
Get schema metadata by ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_id
|
str
|
The project ID |
required |
schema_metadata_id
|
str
|
The schema metadata ID |
required |
Returns:
Type | Description |
---|---|
SchemaMetadataResponse
|
The schema metadata details |
Example
schema_metadata = client.schema_metadata.get(project_id, schema_metadata_id)
print(f"Schema type: {detect_schema_type(schema_metadata.schema_data)}")
Source code in resources/schema_metadata.py
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 |
|
get_schema_type(schema_data)
¶
Detect the schema type from schema data structure.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
schema_data
|
Dict[str, Any]
|
The schema data to analyze |
required |
Returns:
Type | Description |
---|---|
Optional[str]
|
The detected schema type or None if unable to detect |
Example
schema_type = client.schema_metadata.get_schema_type(schema_data)
print(f"Detected schema type: {schema_type}")
Source code in resources/schema_metadata.py
306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 |
|
list(project_id, limit=100, offset=0)
¶
List schema metadata for a project.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_id
|
str
|
The project ID |
required |
limit
|
int
|
Maximum number of items to return |
100
|
offset
|
int
|
Number of items to skip |
0
|
Returns:
Type | Description |
---|---|
List[SchemaMetadataResponse]
|
List of schema metadata |
Example
all_schemas = client.schema_metadata.list(project_id)
tables = [s for s in all_schemas if detect_schema_type(s.schema_data) == "table"]
Source code in resources/schema_metadata.py
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
|
list_always_displayed(project_id)
¶
List schema metadata that are marked as always displayed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_id
|
str
|
The project ID |
required |
Returns:
Type | Description |
---|---|
List[SchemaMetadataResponse]
|
List of schema metadata marked as always displayed |
Example
important_schemas = client.schema_metadata.list_always_displayed(project_id)
Source code in resources/schema_metadata.py
524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 |
|
list_by_type(project_id, schema_type)
¶
List schema metadata filtered by type.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_id
|
str
|
The project ID |
required |
schema_type
|
str
|
The schema type to filter by ('table', 'dimension', 'metric', 'relationship') |
required |
Returns:
Type | Description |
---|---|
List[SchemaMetadataResponse]
|
List of schema metadata of the specified type |
Example
# Get all table schemas
tables = client.schema_metadata.list_by_type(project_id, "table")
# Get all metrics
metrics = client.schema_metadata.list_by_type(project_id, "metric")
Source code in resources/schema_metadata.py
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 |
|
update(project_id, schema_metadata_id, name=None, schema_data=None, description=None, is_always_displayed=None, validate=True, **kwargs)
¶
Update schema metadata with validation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_id
|
str
|
The project ID |
required |
schema_metadata_id
|
str
|
The schema metadata ID to update |
required |
name
|
Optional[str]
|
New schema metadata name |
None
|
schema_data
|
Optional[Dict[str, Any]]
|
New schema data structure |
None
|
description
|
Optional[str]
|
New description |
None
|
is_always_displayed
|
Optional[bool]
|
New always displayed setting |
None
|
validate
|
bool
|
Whether to perform nested field validation (default: True) |
True
|
**kwargs
|
Additional fields to update |
{}
|
Returns:
Type | Description |
---|---|
SchemaMetadataResponse
|
The updated schema metadata |
Raises:
Type | Description |
---|---|
ValidationError
|
If validation fails and validate=True |
Example
# Update a dimension schema
result = client.schema_metadata.update(
project_id=project_id,
schema_metadata_id=schema_id,
description="Updated dimension description",
schema_data={
"table": {
"dimension": {
"name": "updated_dimension",
"content": {"type": "categorical", "values": ["A", "B", "C"]}
}
}
}
)
Source code in resources/schema_metadata.py
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 |
|
validate_schema(schema_data, expected_type=None)
¶
Validate schema data structure with nested field checks.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
schema_data
|
Dict[str, Any]
|
The schema data to validate |
required |
expected_type
|
Optional[str]
|
Optional expected schema type |
None
|
Returns:
Type | Description |
---|---|
List[str]
|
List of validation error messages (empty if valid) |
Example
# Validate a table schema
table_data = {
"table": {
"name": "users",
"columns": [{"name": "id", "type": "integer"}]
}
}
errors = client.schema_metadata.validate_schema(table_data, "table")
if not errors:
print("Schema is valid!")
Source code in resources/schema_metadata.py
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 |
|
text2everything_sdk.resources.golden_examples.GoldenExamplesResource
¶
Bases: BaseResource
Resource for managing golden examples (query-SQL pairs).
Source code in resources/golden_examples.py
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 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 |
|
bulk_create(project_id, golden_examples, parallel=True, max_workers=None, max_concurrent=8, use_connection_isolation=True)
¶
Create multiple golden examples with optional parallel execution and rate limiting.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_id
|
str
|
The project ID |
required |
golden_examples
|
List[Dict[str, Any]]
|
List of golden example dictionaries to create |
required |
parallel
|
bool
|
Whether to execute requests in parallel (default: True) |
True
|
max_workers
|
Optional[int]
|
Maximum number of parallel workers (default: min(16, len(items))) |
None
|
max_concurrent
|
int
|
Maximum number of concurrent requests to prevent server overload (default: 8) |
8
|
use_connection_isolation
|
bool
|
Use isolated HTTP clients for each request to prevent connection conflicts (default: True) |
True
|
Returns:
Type | Description |
---|---|
List[GoldenExampleResponse]
|
List of created golden examples in the same order as input |
Raises:
Type | Description |
---|---|
ValidationError
|
If any validation fails |
Example
examples = [
{
"user_query": "How many users?",
"sql_query": "SELECT COUNT(*) FROM users;",
"description": "Count total users"
},
{
"user_query": "How many active users?",
"sql_query": "SELECT COUNT(*) FROM users WHERE active = true;",
"is_always_displayed": True
}
]
# Parallel execution with rate limiting (default)
results = client.golden_examples.bulk_create(project_id, examples)
# Sequential execution
results = client.golden_examples.bulk_create(project_id, examples, parallel=False)
# Custom rate limiting
results = client.golden_examples.bulk_create(project_id, examples, max_concurrent=4)
# Disable connection isolation for shared connection pool
results = client.golden_examples.bulk_create(project_id, examples, use_connection_isolation=False)
Source code in resources/golden_examples.py
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 |
|
create(project_id, user_query, sql_query, description=None, is_always_displayed=False, **kwargs)
¶
Create a new golden example.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_id
|
str
|
The project ID to create the golden example in |
required |
user_query
|
str
|
The natural language query |
required |
sql_query
|
str
|
The corresponding SQL query |
required |
description
|
Optional[str]
|
Optional description of the golden example |
None
|
is_always_displayed
|
bool
|
Whether this example should always be displayed |
False
|
**kwargs
|
Additional golden example fields |
{}
|
Returns:
Type | Description |
---|---|
GoldenExampleResponse
|
The created golden example with response details |
Example
result = client.golden_examples.create(
project_id=project_id,
user_query="How many users do we have?",
sql_query="SELECT COUNT(*) FROM users;",
description="Count total users",
is_always_displayed=True
)
Source code in resources/golden_examples.py
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 |
|
delete(project_id, golden_example_id)
¶
Delete a golden example.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_id
|
str
|
The project ID |
required |
golden_example_id
|
str
|
The golden example ID to delete |
required |
Returns:
Type | Description |
---|---|
bool
|
True if deletion was successful |
Example
success = client.golden_examples.delete(project_id, golden_example_id)
Source code in resources/golden_examples.py
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 |
|
get(project_id, golden_example_id)
¶
Get a golden example by ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_id
|
str
|
The project ID |
required |
golden_example_id
|
str
|
The golden example ID |
required |
Returns:
Type | Description |
---|---|
GoldenExampleResponse
|
The golden example details |
Example
golden_example = client.golden_examples.get(project_id, golden_example_id)
print(f"Query: {golden_example.user_query}")
print(f"SQL: {golden_example.sql_query}")
Source code in resources/golden_examples.py
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 |
|
list(project_id, limit=100, offset=0)
¶
List golden examples for a project.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_id
|
str
|
The project ID |
required |
limit
|
int
|
Maximum number of items to return |
100
|
offset
|
int
|
Number of items to skip |
0
|
Returns:
Type | Description |
---|---|
List[GoldenExampleResponse]
|
List of golden examples |
Example
examples = client.golden_examples.list(project_id)
for example in examples:
print(f"{example.user_query}")
Source code in resources/golden_examples.py
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
|
list_always_displayed(project_id)
¶
List golden examples that are marked as always displayed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_id
|
str
|
The project ID |
required |
Returns:
Type | Description |
---|---|
List[GoldenExampleResponse]
|
List of golden examples marked as always displayed |
Example
important_examples = client.golden_examples.list_always_displayed(project_id)
Source code in resources/golden_examples.py
452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 |
|
search_by_query(project_id, search_term)
¶
Search golden examples by user query text.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_id
|
str
|
The project ID |
required |
search_term
|
str
|
Term to search for in user queries |
required |
Returns:
Type | Description |
---|---|
List[GoldenExampleResponse]
|
List of golden examples matching the search term |
Example
# Find examples related to users
user_examples = client.golden_examples.search_by_query(project_id, "user")
Source code in resources/golden_examples.py
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 |
|
update(project_id, golden_example_id, user_query=None, sql_query=None, description=None, is_always_displayed=None, **kwargs)
¶
Update a golden example.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_id
|
str
|
The project ID |
required |
golden_example_id
|
str
|
The golden example ID to update |
required |
user_query
|
Optional[str]
|
New user query |
None
|
sql_query
|
Optional[str]
|
New SQL query |
None
|
description
|
Optional[str]
|
New description |
None
|
is_always_displayed
|
Optional[bool]
|
New always displayed setting |
None
|
**kwargs
|
Additional fields to update |
{}
|
Returns:
Type | Description |
---|---|
GoldenExampleResponse
|
The updated golden example |
Example
result = client.golden_examples.update(
project_id=project_id,
golden_example_id=example_id,
description="Updated description",
sql_query="SELECT COUNT(*) as total_users FROM users WHERE active = true;"
)
Source code in resources/golden_examples.py
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 |
|
text2everything_sdk.resources.connectors.ConnectorsResource
¶
Bases: BaseResource
Resource for managing database connectors.
Source code in resources/connectors.py
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 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 |
|
create(name, db_type, host, username, password, database, port=None, description=None, config=None, **kwargs)
¶
Create a new database connector.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Connector name |
required |
db_type
|
str
|
Database type (postgres, mysql, sqlserver, snowflake) |
required |
host
|
str
|
Database host |
required |
port
|
Optional[int]
|
Database port |
None
|
username
|
str
|
Database username |
required |
password
|
str
|
Database password |
required |
database
|
str
|
Database name |
required |
description
|
Optional[str]
|
Optional connector description |
None
|
config
|
Optional[dict]
|
Optional additional configuration |
None
|
**kwargs
|
Additional connector fields |
{}
|
Returns:
Type | Description |
---|---|
Connector
|
The created connector |
Example
result = client.connectors.create(
name="Production DB",
description="Main production database",
db_type="postgres",
host="db.example.com",
port=5432,
username="app_user",
password="secure_password",
database="production"
)
Source code in resources/connectors.py
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 |
|
delete(connector_id)
¶
Delete a connector.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
connector_id
|
str
|
The connector ID to delete |
required |
Returns:
Type | Description |
---|---|
bool
|
True if deletion was successful |
Example
success = client.connectors.delete(connector_id)
Source code in resources/connectors.py
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 |
|
get(connector_id)
¶
Get a connector by ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
connector_id
|
str
|
The connector ID |
required |
Returns:
Type | Description |
---|---|
Connector
|
The connector details |
Example
connector = client.connectors.get(connector_id)
print(f"Database: {connector.db_type} at {connector.host}")
Source code in resources/connectors.py
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
|
list(limit=100, offset=0)
¶
List all connectors.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
limit
|
int
|
Maximum number of items to return |
100
|
offset
|
int
|
Number of items to skip |
0
|
Returns:
Type | Description |
---|---|
List[Connector]
|
List of connectors |
Example
connectors = client.connectors.list()
for connector in connectors:
print(f"{connector.name}: {connector.db_type}")
Source code in resources/connectors.py
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
|
list_by_type(db_type)
¶
List connectors by database type.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
db_type
|
str
|
The database type to filter by |
required |
Returns:
Type | Description |
---|---|
List[Connector]
|
List of connectors of the specified type |
Example
postgres_connectors = client.connectors.list_by_type("postgres")
Source code in resources/connectors.py
275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 |
|
test_connection(connector_id)
¶
Test a connector's database connection.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
connector_id
|
str
|
The connector ID to test |
required |
Returns:
Type | Description |
---|---|
bool
|
True if connection is successful |
Raises:
Type | Description |
---|---|
ValidationError
|
If connection fails |
Example
try:
success = client.connectors.test_connection(connector_id)
print("Connection successful!")
except ValidationError as e:
print(f"Connection failed: {e}")
Source code in resources/connectors.py
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 |
|
update(connector_id, name=None, db_type=None, host=None, port=None, username=None, password=None, database=None, description=None, config=None, **kwargs)
¶
Update a connector.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
connector_id
|
str
|
The connector ID to update |
required |
name
|
Optional[str]
|
New connector name |
None
|
r db_type: New database type host: New database host port: New database port username: New database username password: New database password database: New database name description: New connector description config: New additional configuration **kwargs: Additional fields to update
Returns:
Type | Description |
---|---|
Connector
|
The updated connector |
Example
result = client.connectors.update(
connector_id,
description="Updated production database",
port=5433
)
Source code in resources/connectors.py
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 |
|
text2everything_sdk.resources.chat_sessions.ChatSessionsResource
¶
Bases: BaseResource
Resource for managing H2OGPTE chat sessions.
Source code in resources/chat_sessions.py
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 |
|
create(project_id, name=None, custom_tool_id=None, **kwargs)
¶
Create a new H2OGPTE chat session.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_id
|
str
|
The project ID |
required |
name
|
Optional[str]
|
Optional name for the session |
None
|
custom_tool_id
|
Optional[str]
|
Optional custom tool to associate |
None
|
**kwargs
|
Additional session fields |
{}
|
Returns:
Type | Description |
---|---|
ChatSessionResponse
|
The created chat session |
Example
result = client.chat_sessions.create(
project_id=project_id,
name="Data Analysis Session",
custom_tool_id="tool-123"
)
print(f"Session created: {result.id}")
Source code in resources/chat_sessions.py
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 |
|
create_with_tool(project_id, name=None, custom_tool_id=None)
¶
Create a new chat session with an optional custom tool.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_id
|
str
|
The project ID |
required |
name
|
str
|
Optional name for the session |
None
|
custom_tool_id
|
str
|
Optional custom tool to associate |
None
|
Returns:
Type | Description |
---|---|
ChatSessionResponse
|
The created chat session |
Example
session = client.chat_sessions.create_with_tool(
project_id="proj-123",
name="Analysis Session",
custom_tool_id="tool-456"
)
Source code in resources/chat_sessions.py
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 |
|
delete(project_id, session_id)
¶
Delete a H2OGPTE chat session.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_id
|
str
|
The project ID |
required |
session_id
|
str
|
The chat session ID to delete |
required |
Returns:
Type | Description |
---|---|
bool
|
True if deletion was successful |
Example
success = client.chat_sessions.delete(project_id, session_id)
Source code in resources/chat_sessions.py
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 |
|
get_custom_tool(project_id, session_id)
¶
Get the custom tool associated with a chat session.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_id
|
str
|
The project ID |
required |
session_id
|
str
|
The chat session ID |
required |
Returns:
Type | Description |
---|---|
Optional[CustomTool]
|
The associated custom tool, or None if no tool is associated |
Example
tool = client.chat_sessions.get_custom_tool(project_id, session_id)
if tool:
print(f"Associated tool: {tool.name}")
else:
print("No custom tool associated")
Source code in resources/chat_sessions.py
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
|
get_questions(project_id, session_id, limit=10)
¶
Get suggested questions for a chat session.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_id
|
str
|
The project ID |
required |
session_id
|
str
|
The chat session ID |
required |
limit
|
int
|
Maximum number of questions to return |
10
|
Returns:
Type | Description |
---|---|
List[ChatSessionQuestion]
|
List of suggested questions |
Example
questions = client.chat_sessions.get_questions(project_id, session_id)
for question in questions:
print(f"Suggested: {question.question}")
Source code in resources/chat_sessions.py
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
|
list(project_id, offset=0, limit=10)
¶
List recent H2OGPTE chat sessions for a project.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_id
|
str
|
The project ID |
required |
offset
|
int
|
Number of sessions to skip |
0
|
limit
|
int
|
Maximum number of sessions to return |
10
|
Returns:
Type | Description |
---|---|
List[ChatSessionResponse]
|
List of chat sessions |
Example
sessions = client.chat_sessions.list(project_id, limit=20)
for session in sessions:
print(f"{session.name}: {session.id}")
Source code in resources/chat_sessions.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
|
update_custom_tool(project_id, session_id, custom_tool_id=None)
¶
Update the custom tool associated with a chat session.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_id
|
str
|
The project ID |
required |
session_id
|
str
|
The chat session ID |
required |
custom_tool_id
|
str
|
The custom tool ID to associate (None to detach) |
None
|
Returns:
Type | Description |
---|---|
ChatSessionResponse
|
The updated chat session |
Example
# Attach a custom tool
session = client.chat_sessions.update_custom_tool(
project_id, session_id, "tool-456"
)
# Detach custom tool
session = client.chat_sessions.update_custom_tool(
project_id, session_id, None
)
Source code in resources/chat_sessions.py
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 |
|
text2everything_sdk.resources.chat.ChatResource
¶
Bases: BaseResource
Resource for natural language to SQL chat functionality.
Source code in resources/chat.py
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 243 244 245 246 247 248 |
|
chat_to_answer(project_id, chat_session_id, query, connector_id, custom_tool_id=None, use_agent=False, agent_accuracy='medium', auto_add_feedback=None, **kwargs)
¶
Convert natural language query to SQL and execute it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_id
|
str
|
The project ID |
required |
chat_session_id
|
str
|
Target chat session for history/summary context |
required |
query
|
str
|
Natural language query |
required |
connector_id
|
str
|
Required connector ID for SQL execution |
required |
custom_tool_id
|
str
|
Optional custom tool to use |
None
|
use_agent
|
bool
|
Whether to use agent functionality |
False
|
agent_accuracy
|
str
|
Agent accuracy level ("low", "medium", "high") |
'medium'
|
auto_add_feedback
|
dict
|
Optional auto feedback configuration |
None
|
**kwargs
|
Additional chat to answer request fields |
{}
|
Returns:
Type | Description |
---|---|
ChatToAnswerResponse
|
Chat response with SQL, execution results, and optional feedback |
Example
response = client.chat.chat_to_answer(
project_id=project_id,
query="Show me the top 10 customers by revenue",
connector_id="conn-789",
use_agent=True,
agent_accuracy="high"
)
if response.execution_result:
print(f"Query executed in {response.execution_result.execution_time_ms}ms")
print(f"Results: {response.execution_result.result}")
if response.agent_tool_response:
print(f"Agent response: {response.agent_tool_response}")
Source code in resources/chat.py
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 |
|
chat_to_sql(project_id, chat_session_id, query, schema_metadata_id=None, contexts_limit=None, examples_limit=None, **kwargs)
¶
Convert natural language query to SQL.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_id
|
str
|
The project ID |
required |
chat_session_id
|
str
|
Target chat session for history/summary context |
required |
query
|
str
|
Natural language query |
required |
schema_metadata_id
|
str
|
Optional schema metadata ID |
None
|
contexts_limit
|
int
|
Optional limit for contexts |
None
|
examples_limit
|
int
|
Optional limit for examples |
None
|
**kwargs
|
Additional chat request fields |
{}
|
Returns:
Type | Description |
---|---|
ChatResponse
|
Chat response with generated SQL and explanation |
Example
response = client.chat.chat_to_sql(
project_id=project_id,
chat_session_id=chat_session_id,
query="How many active users do we have?",
schema_metadata_id="schema-456",
contexts_limit=5,
examples_limit=3
)
print(f"Generated SQL: {response.sql_query}")
print(f"Explanation: {response.explanation}")
Source code in resources/chat.py
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 |
|
chat_with_agent(project_id, chat_session_id, query, connector_id, custom_tool_id=None, agent_accuracy='medium', **kwargs)
¶
Chat using custom tools and agent functionality.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_id
|
str
|
The project ID |
required |
query
|
str
|
Natural language query |
required |
connector_id
|
str
|
Required connector ID for SQL execution |
required |
custom_tool_id
|
str
|
Optional custom tool to use |
None
|
agent_accuracy
|
str
|
Agent accuracy level ("quick", "basic", "standard", "maximum") |
'medium'
|
**kwargs
|
Additional chat parameters |
{}
|
Returns:
Type | Description |
---|---|
ChatToAnswerResponse
|
Chat response with agent tool response |
Example
response = client.chat.chat_with_agent(
project_id="proj-123",
chat_session_id="chat-abc",
query="Analyze customer churn patterns",
connector_id="conn-123",
custom_tool_id="tool-789",
agent_accuracy="quick|basic|standard|maximum"
)
print(f"Agent response: {response.agent_tool_response}")
Source code in resources/chat.py
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 243 244 245 246 247 248 |
|
chat_with_context(project_id, chat_session_id, query, context_id=None, schema_metadata_id=None, example_id=None, **kwargs)
¶
Chat with specific context, schema, or example.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_id
|
str
|
The project ID |
required |
query
|
str
|
Natural language query |
required |
context_id
|
str
|
Optional specific context to use |
None
|
schema_metadata_id
|
str
|
Optional specific schema metadata to use |
None
|
example_id
|
str
|
Optional specific example to use |
None
|
**kwargs
|
Additional chat parameters |
{}
|
Returns:
Type | Description |
---|---|
ChatResponse
|
Chat response with generated SQL |
Example
response = client.chat.chat_with_context(
project_id="proj-123",
chat_session_id="chat-abc",
query="Count active users",
context_id="ctx-789",
schema_metadata_id="schema-101",
llm="gpt-4",
use_agent=True
)
Source code in resources/chat.py
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 |
|
text2everything_sdk.resources.executions.ExecutionsResource
¶
Bases: BaseResource
Resource for executing SQL queries against database connectors.
Source code in resources/executions.py
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 |
|
execute_from_chat(connector_id, chat_message_id, chat_session_id=None)
¶
Execute SQL from a chat message.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
connector_id
|
str
|
The database connector ID |
required |
chat_message_id
|
str
|
The chat message containing the SQL query |
required |
chat_session_id
|
str
|
Optional chat session ID for context |
None
|
Returns:
Type | Description |
---|---|
SQLExecuteResponse
|
SQL execution response |
Example
result = client.executions.execute_from_chat(
connector_id="conn-123",
chat_message_id="msg-456"
)
Source code in resources/executions.py
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 |
|
execute_query(connector_id, sql_query, chat_session_id=None)
¶
Execute a SQL query directly.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
connector_id
|
str
|
The database connector ID |
required |
sql_query
|
str
|
The SQL query to execute |
required |
chat_session_id
|
str
|
Optional chat session ID for context |
None
|
Returns:
Type | Description |
---|---|
SQLExecuteResponse
|
SQL execution response |
Example
result = client.executions.execute_query(
connector_id="conn-123",
sql_query="SELECT * FROM users WHERE active = true LIMIT 10"
)
print(f"Found {len(result.result.get('data', []))} rows")
Source code in resources/executions.py
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 |
|
execute_sql(connector_id, chat_message_id=None, sql_query=None, chat_session_id=None, **kwargs)
¶
Execute a SQL query using the specified connector.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
connector_id
|
str
|
The database connector ID |
required |
chat_message_id
|
str
|
Optional chat message ID containing SQL query |
None
|
sql_query
|
str
|
Optional SQL query to execute directly |
None
|
chat_session_id
|
str
|
Optional chat session ID for context |
None
|
**kwargs
|
Additional execution request fields |
{}
|
Returns:
Type | Description |
---|---|
SQLExecuteResponse
|
SQL execution response with results and performance metrics |
Example
# Execute SQL from a chat message
result = client.executions.execute_sql(
connector_id="conn-123",
chat_message_id="msg-456"
)
print(f"Execution time: {result.execution_time_ms}ms")
print(f"Result: {result.result}")
# Execute SQL directly
result = client.executions.execute_sql(
connector_id="conn-123",
sql_query="SELECT COUNT(*) FROM users"
)
Source code in resources/executions.py
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 |
|
get_execution(execution_id)
¶
Get execution details by ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
execution_id
|
str
|
The execution ID |
required |
Returns:
Type | Description |
---|---|
Execution
|
Execution details |
Example
execution = client.executions.get_execution("exec-123")
print(f"Query: {execution.sql_query}")
print(f"Time: {execution.execution_time_ms}ms")
Source code in resources/executions.py
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
|
text2everything_sdk.resources.feedback.FeedbackResource
¶
Bases: BaseResource
Resource for managing feedback on chat messages and SQL executions.
Source code in resources/feedback.py
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 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 |
|
create(project_id, chat_message_id, feedback, is_positive, execution_id=None, **kwargs)
¶
Create feedback for a chat message or execution.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_id
|
str
|
The project ID |
required |
chat_message_id
|
str
|
The chat message ID |
required |
feedback
|
str
|
The feedback text |
required |
is_positive
|
bool
|
Whether the feedback is positive |
required |
execution_id
|
Optional[str]
|
Optional execution ID |
None
|
**kwargs
|
Additional feedback fields |
{}
|
Returns:
Type | Description |
---|---|
FeedbackResponse
|
The created feedback with response details |
Example
result = client.feedback.create(
project_id=project_id,
chat_message_id="msg-123",
feedback="The SQL query worked perfectly!",
is_positive=True,
execution_id="exec-456"
)
Source code in resources/feedback.py
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 |
|
create_negative(project_id, chat_message_id, feedback, execution_id=None)
¶
Create negative feedback for a chat message.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_id
|
str
|
The project ID |
required |
chat_message_id
|
str
|
The chat message ID |
required |
feedback_text
|
The feedback text |
required | |
execution_id
|
str
|
Optional execution ID |
None
|
Returns:
Type | Description |
---|---|
FeedbackResponse
|
The created negative feedback |
Example
feedback = client.feedback.create_negative(
project_id="proj-123",
chat_message_id="msg-456",
feedback_text="Query returned incorrect results",
execution_id="exec-789"
)
Source code in resources/feedback.py
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 |
|
create_positive(project_id, chat_message_id, feedback_text, execution_id=None)
¶
Create positive feedback for a chat message.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_id
|
str
|
The project ID |
required |
chat_message_id
|
str
|
The chat message ID |
required |
feedback_text
|
str
|
The feedback text |
required |
execution_id
|
str
|
Optional execution ID |
None
|
Returns:
Type | Description |
---|---|
FeedbackResponse
|
The created positive feedback |
Example
feedback = client.feedback.create_positive(
project_id="proj-123",
chat_message_id="msg-456",
feedback_text="Perfect SQL query!",
execution_id="exec-789"
)
Source code in resources/feedback.py
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 |
|
delete(project_id, feedback_id)
¶
Delete feedback.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_id
|
str
|
The project ID |
required |
feedback_id
|
str
|
The feedback ID to delete |
required |
Returns:
Type | Description |
---|---|
bool
|
True if deletion was successful |
Example
success = client.feedback.delete(project_id, feedback_id)
Source code in resources/feedback.py
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 |
|
get(project_id, feedback_id)
¶
Get feedback by ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_id
|
str
|
The project ID |
required |
feedback_id
|
str
|
The feedback ID |
required |
Returns:
Type | Description |
---|---|
FeedbackResponse
|
The feedback details |
Example
feedback = client.feedback.get(project_id, feedback_id)
print(f"Feedback: {feedback.feedback}")
print(f"Positive: {feedback.is_positive}")
Source code in resources/feedback.py
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 |
|
get_feedback_for_message(project_id, chat_message_id)
¶
Get all feedback for a specific chat message.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_id
|
str
|
The project ID |
required |
chat_message_id
|
str
|
The chat message ID |
required |
Returns:
Type | Description |
---|---|
List[FeedbackResponse]
|
List of feedback for the message |
Example
message_feedback = client.feedback.get_feedback_for_message(
project_id, "msg-123"
)
for feedback in message_feedback:
print(f"Feedback: {feedback.feedback}")
Source code in resources/feedback.py
319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 |
|
list(project_id, limit=100, offset=0)
¶
List feedback for a project.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_id
|
str
|
The project ID |
required |
limit
|
int
|
Maximum number of items to return |
100
|
offset
|
int
|
Number of items to skip |
0
|
Returns:
Type | Description |
---|---|
List[FeedbackResponse]
|
List of feedback items |
Example
feedback_list = client.feedback.list(project_id)
for feedback in feedback_list:
status = "👍" if feedback.is_positive else "👎"
print(f"{status} {feedback.feedback}")
Source code in resources/feedback.py
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
|
list_negative(project_id)
¶
List all negative feedback for a project.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_id
|
str
|
The project ID |
required |
Returns:
Type | Description |
---|---|
List[FeedbackResponse]
|
List of negative feedback items |
Example
negative_feedback = client.feedback.list_negative(project_id)
print(f"Found {len(negative_feedback)} negative feedback items")
Source code in resources/feedback.py
301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 |
|
list_positive(project_id)
¶
List all positive feedback for a project.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_id
|
str
|
The project ID |
required |
Returns:
Type | Description |
---|---|
List[FeedbackResponse]
|
List of positive feedback items |
Example
positive_feedback = client.feedback.list_positive(project_id)
print(f"Found {len(positive_feedback)} positive feedback items")
Source code in resources/feedback.py
283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 |
|
update(project_id, feedback_id, chat_message_id=None, feedback=None, is_positive=None, execution_id=None, **kwargs)
¶
Update feedback.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_id
|
str
|
The project ID |
required |
feedback_id
|
str
|
The feedback ID to update |
required |
chat_message_id
|
Optional[str]
|
New chat message ID |
None
|
feedback
|
Optional[str]
|
New feedback text |
None
|
is_positive
|
Optional[bool]
|
New positive/negative setting |
None
|
execution_id
|
Optional[str]
|
New execution ID |
None
|
**kwargs
|
Additional fields to update |
{}
|
Returns:
Type | Description |
---|---|
FeedbackResponse
|
The updated feedback |
Example
result = client.feedback.update(
project_id=project_id,
feedback_id=feedback_id,
feedback="Updated: The query was excellent!",
is_positive=True
)
Source code in resources/feedback.py
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 |
|
text2everything_sdk.resources.custom_tools.CustomToolsResource
¶
Bases: BaseResource
Resource for managing custom tools with Python script uploads.
Source code in resources/custom_tools.py
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 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 |
|
create(project_id, name, description, files)
¶
Create a new custom tool with uploaded Python script files.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_id
|
str
|
The project ID |
required |
name
|
str
|
Name of the custom tool |
required |
description
|
str
|
Description of the custom tool |
required |
files
|
List[Union[str, Path, BinaryIO]]
|
List of file paths or file objects to upload |
required |
Returns:
Type | Description |
---|---|
CustomTool
|
The created custom tool |
Example
# Upload files by path
tool = client.custom_tools.create(
project_id="proj-123",
name="Data Analysis Tool",
description="Custom tool for advanced data analysis",
files=["analysis.py", "utils.py"]
)
# Upload file objects
with open("script.py", "rb") as f:
tool = client.custom_tools.create(
project_id="proj-123",
name="Script Tool",
description="Custom script tool",
files=[f]
)
Source code in resources/custom_tools.py
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 |
|
create_from_directory(project_id, name, description, directory_path)
¶
Create a custom tool by uploading all Python files from a directory.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_id
|
str
|
The project ID |
required |
name
|
str
|
Name of the custom tool |
required |
description
|
str
|
Description of the custom tool |
required |
directory_path
|
Union[str, Path]
|
Path to directory containing Python files |
required |
Returns:
Type | Description |
---|---|
CustomTool
|
The created custom tool |
Example
tool = client.custom_tools.create_from_directory(
project_id="proj-123",
name="Analysis Suite",
description="Complete data analysis toolkit",
directory_path="./analysis_scripts"
)
Source code in resources/custom_tools.py
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 |
|
delete(project_id, tool_id)
¶
Delete a custom tool and its associated collection.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_id
|
str
|
The project ID |
required |
tool_id
|
str
|
The custom tool ID to delete |
required |
Returns:
Type | Description |
---|---|
bool
|
True if deletion was successful |
Example
success = client.custom_tools.delete(project_id, tool_id)
Source code in resources/custom_tools.py
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 |
|
get(project_id, tool_id)
¶
Get a specific custom tool.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_id
|
str
|
The project ID |
required |
tool_id
|
str
|
The custom tool ID |
required |
Returns:
Type | Description |
---|---|
CustomTool
|
The custom tool details |
Example
tool = client.custom_tools.get(project_id, tool_id)
print(f"Tool: {tool.name}")
print(f"Documents: {len(tool.documents)}")
Source code in resources/custom_tools.py
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
|
list(project_id, limit=100, offset=0)
¶
List all custom tools for a project.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_id
|
str
|
The project ID |
required |
limit
|
int
|
Maximum number of items to return |
100
|
offset
|
int
|
Number of items to skip |
0
|
Returns:
Type | Description |
---|---|
List[CustomTool]
|
List of custom tools |
Example
tools = client.custom_tools.list(project_id)
for tool in tools:
print(f"{tool.name}: {tool.description}")
Source code in resources/custom_tools.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
|
replace_files(project_id, tool_id, files)
¶
Replace all files in a custom tool.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_id
|
str
|
The project ID |
required |
tool_id
|
str
|
The custom tool ID |
required |
files
|
List[Union[str, Path, BinaryIO]]
|
New files to replace existing ones |
required |
Returns:
Type | Description |
---|---|
CustomTool
|
The updated custom tool |
Example
tool = client.custom_tools.replace_files(
project_id, tool_id,
["new_main.py", "new_utils.py"]
)
Source code in resources/custom_tools.py
301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 |
|
update(project_id, tool_id, name=None, description=None, files=None)
¶
Update a custom tool.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_id
|
str
|
The project ID |
required |
tool_id
|
str
|
The custom tool ID to update |
required |
name
|
str
|
Optional new name |
None
|
description
|
str
|
Optional new description |
None
|
files
|
List[Union[str, Path, BinaryIO]]
|
Optional new files to replace existing ones |
None
|
Returns:
Type | Description |
---|---|
CustomTool
|
The updated custom tool |
Example
# Update metadata only
tool = client.custom_tools.update(
project_id, tool_id,
name="Updated Tool Name",
description="Updated description"
)
# Update files
tool = client.custom_tools.update(
project_id, tool_id,
files=["new_script.py", "updated_utils.py"]
)
Source code in resources/custom_tools.py
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 |
|
update_metadata(project_id, tool_id, update_data)
¶
Update only the metadata (name/description) of a custom tool.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_id
|
str
|
The project ID |
required |
tool_id
|
str
|
The custom tool ID |
required |
update_data
|
CustomToolUpdate
|
The metadata updates |
required |
Returns:
Type | Description |
---|---|
CustomTool
|
The updated custom tool |
Example
update_data = CustomToolUpdate(
name="New Tool Name",
description="Updated description"
)
tool = client.custom_tools.update_metadata(project_id, tool_id, update_data)
Source code in resources/custom_tools.py
273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 |
|