Environment
src.worksheets.environment
Core environment module for Genie worksheets and runtime management.
This module provides the foundational classes and utilities for managing Genie worksheets, including type handling, context management, and runtime execution. It implements the core functionality for worksheet validation, action execution, and state management.
Classes
GenieValue
A class to represent a value in Genie.
This class wraps primitive values (string, int, float, etc.) with additional functionality like confirmation status tracking.
Attributes:
Name | Type | Description |
---|---|---|
value |
The wrapped primitive value. |
|
confirmed |
bool
|
Whether this value has been confirmed by the user. |
Source code in src/worksheets/environment.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 |
|
Attributes
value
instance-attribute
value = value
confirmed
instance-attribute
confirmed = False
Functions
__init__
__init__(value)
Initialize a GenieValue.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
The primitive value to wrap. |
required |
Source code in src/worksheets/environment.py
44 45 46 47 48 49 50 51 |
|
__repr__
__repr__()
Source code in src/worksheets/environment.py
53 54 |
|
__eq__
__eq__(other)
Source code in src/worksheets/environment.py
56 57 58 59 60 61 |
|
confirm
confirm(confirmed: bool = True)
Mark the value as confirmed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
confirmed
|
bool
|
Whether to mark as confirmed. Defaults to True. |
True
|
Returns:
Name | Type | Description |
---|---|---|
GenieValue |
The confirmed value instance. |
Source code in src/worksheets/environment.py
63 64 65 66 67 68 69 70 71 72 73 |
|
__str__
__str__()
Source code in src/worksheets/environment.py
75 76 |
|
__hash__
__hash__()
Source code in src/worksheets/environment.py
78 79 |
|
GenieResult
Bases: GenieValue
A class to represent results from executions.
This class extends GenieValue to store results from Answer executions or other actions, maintaining references to parent objects.
Attributes:
Name | Type | Description |
---|---|---|
value |
The result value. |
|
parent |
The parent object that produced this result. |
|
parent_var_name |
The variable name of the parent in the context. |
Source code in src/worksheets/environment.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 |
|
Attributes
value
instance-attribute
value = value
confirmed
instance-attribute
confirmed = False
parent
instance-attribute
parent = parent
parent_var_name
instance-attribute
parent_var_name = parent_var_name
Functions
__repr__
__repr__()
Source code in src/worksheets/environment.py
53 54 |
|
__eq__
__eq__(other)
Source code in src/worksheets/environment.py
56 57 58 59 60 61 |
|
confirm
confirm(confirmed: bool = True)
Mark the value as confirmed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
confirmed
|
bool
|
Whether to mark as confirmed. Defaults to True. |
True
|
Returns:
Name | Type | Description |
---|---|---|
GenieValue |
The confirmed value instance. |
Source code in src/worksheets/environment.py
63 64 65 66 67 68 69 70 71 72 73 |
|
__str__
__str__()
Source code in src/worksheets/environment.py
75 76 |
|
__hash__
__hash__()
Source code in src/worksheets/environment.py
78 79 |
|
__init__
__init__(value, parent, parent_var_name)
Initialize a GenieResult.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
The result value. |
required | |
parent
|
The parent object that produced this result. |
required | |
parent_var_name
|
The variable name of the parent in the context. |
required |
Source code in src/worksheets/environment.py
94 95 96 97 98 99 100 101 102 103 104 |
|
__getitem__
__getitem__(item)
Source code in src/worksheets/environment.py
106 107 |
|
GenieREPR
Bases: type
A metaclass to customize string representation of Genie classes.
This metaclass provides custom string representation for classes that use it, maintaining ordered attributes and generating schema representations.
Attributes:
Name | Type | Description |
---|---|---|
_ordered_attributes |
List of ordered attribute names for the class. |
Source code in src/worksheets/environment.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 139 140 |
|
Functions
__new__
__new__(name, bases, dct)
Source code in src/worksheets/environment.py
120 121 122 123 124 |
|
__repr__
__repr__()
Source code in src/worksheets/environment.py
126 127 128 129 130 131 |
|
get_semantic_parser_schema
get_semantic_parser_schema()
Source code in src/worksheets/environment.py
133 134 135 136 137 138 139 140 |
|
GenieField
A class representing a field in a Genie worksheet.
This class handles field definitions, validation, and value management for worksheet fields. It supports various field types, validation rules, and action triggers.
Attributes:
Name | Type | Description |
---|---|---|
slottype |
str
|
The type of the field. |
name |
str
|
The field name. |
question |
str
|
Question to ask when field needs filling. |
description |
str
|
Field description for LLM understanding. |
predicate |
str
|
Condition for field relevance. |
ask |
bool
|
Whether to ask user for this field. |
optional |
bool
|
Whether field is optional. |
actions |
Actions to perform when field is filled. |
|
requires_confirmation |
bool
|
Whether field needs confirmation. |
internal |
bool
|
Whether field is system-managed. |
primary_key |
bool
|
Whether field is a primary key. |
validation |
str
|
Validation criteria. |
parent |
Parent worksheet. |
|
bot |
Associated bot instance. |
Source code in src/worksheets/environment.py
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 |
|
Attributes
predicate
instance-attribute
predicate = predicate
slottype
instance-attribute
slottype = slottype
name
instance-attribute
name = name
question
instance-attribute
question = question
ask
instance-attribute
ask = ask
optional
instance-attribute
optional = optional
actions
instance-attribute
actions = actions
requires_confirmation
instance-attribute
requires_confirmation = requires_confirmation
internal
instance-attribute
internal = internal
description
instance-attribute
description = description
primary_key
instance-attribute
primary_key = primary_key
validation
instance-attribute
validation = validation
parent
instance-attribute
parent = parent
bot
instance-attribute
bot = bot
action_performed
instance-attribute
action_performed = action_performed
_value
instance-attribute
_value = init_value(value)
_confirmed
instance-attribute
_confirmed = confirmed
confirmed
property
writable
confirmed
value
property
writable
value
Functions
__init__
__init__(slottype: str, name: str, question: str = '', description: str = '', predicate: str = '', ask: bool = True, optional: bool = False, actions=None, value=None, requires_confirmation: bool = False, internal: bool = False, primary_key: bool = False, confirmed: bool = False, validation: str | None = None, parent=None, bot=None, action_performed=False, **kwargs)
Source code in src/worksheets/environment.py
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 |
|
__deepcopy__
__deepcopy__(memo)
Source code in src/worksheets/environment.py
263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 |
|
perform_action
perform_action(bot: GenieRuntime, local_context: GenieContext)
Perform the action associated with this field if it hasn't been performed yet.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bot
|
GenieRuntime
|
The bot instance. |
required |
local_context
|
GenieContext
|
The local context for the action. |
required |
Returns:
Name | Type | Description |
---|---|---|
list |
A list of actions performed. |
Source code in src/worksheets/environment.py
284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 |
|
__repr__
__repr__() -> str
Source code in src/worksheets/environment.py
309 310 |
|
schema
schema(value=True)
Generate a schema representation of the field.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
bool
|
Whether to include the value in the schema. Defaults to True. |
True
|
Returns:
Name | Type | Description |
---|---|---|
str |
The schema representation. |
Source code in src/worksheets/environment.py
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 |
|
schema_without_type
schema_without_type(no_none=False)
Generate a schema representation of the field without type information.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
no_none
|
bool
|
Whether to exclude None values. Defaults to False. |
False
|
Returns:
Name | Type | Description |
---|---|---|
str |
The schema representation without type. |
Source code in src/worksheets/environment.py
349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 |
|
init_value
init_value(value: Any)
Initialize a field value with proper validation and wrapping.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
Any
|
The value to initialize. |
required |
Returns:
Name | Type | Description |
---|---|---|
GenieValue |
The initialized value, or None if validation fails. |
Source code in src/worksheets/environment.py
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 |
|
__eq__
__eq__(other)
Source code in src/worksheets/environment.py
449 450 451 452 453 454 |
|
GenieWorksheet
Base class for Genie worksheets.
This class provides the foundation for defining worksheets with fields, actions, and state management. It handles initialization, field management, and action execution.
Attributes:
Name | Type | Description |
---|---|---|
action_performed |
bool
|
Whether worksheet actions have been executed. |
result |
The result of worksheet execution. |
|
random_id |
int
|
Unique identifier for the worksheet instance. |
Source code in src/worksheets/environment.py
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 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 |
|
Attributes
action_performed
instance-attribute
action_performed = False
result
instance-attribute
result = None
random_id
instance-attribute
random_id = 0
Functions
__init__
__init__(**kwargs)
Source code in src/worksheets/environment.py
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 |
|
perform_action
perform_action(bot: GenieRuntime, local_context: GenieContext)
Perform the action associated with this worksheet if it hasn't been performed yet.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bot
|
GenieRuntime
|
The bot instance. |
required |
local_context
|
GenieContext
|
The local context for the action. |
required |
Returns:
Name | Type | Description |
---|---|---|
list |
A list of actions performed. |
Source code in src/worksheets/environment.py
504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 |
|
is_complete
is_complete(bot: GenieRuntime, context: GenieContext) -> bool
Check if the worksheet is complete by evaluating all fields.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bot
|
GenieRuntime
|
The bot instance. |
required |
context
|
GenieContext
|
The context for evaluation. |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if the worksheet is complete, False otherwise. |
Source code in src/worksheets/environment.py
527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 |
|
__repr__
__repr__()
Source code in src/worksheets/environment.py
550 551 552 553 554 555 556 |
|
schema_without_type
schema_without_type(context: GenieContext) -> str
Generate a schema representation of the worksheet without type information.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
context
|
GenieContext
|
The context for the worksheet. |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The schema representation without type. |
Source code in src/worksheets/environment.py
558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 |
|
execute
execute(bot: GenieRuntime, local_context: GenieContext)
Execute the actions associated with this worksheet.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bot
|
GenieRuntime
|
The bot instance. |
required |
local_context
|
GenieContext
|
The local context for execution. |
required |
Source code in src/worksheets/environment.py
646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 |
|
new
classmethod
new(initialize_from_dict: dict)
Source code in src/worksheets/environment.py
676 677 678 |
|
__setattr__
__setattr__(name, value)
Source code in src/worksheets/environment.py
680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 |
|
ask
ask()
This is a hack for when the user asks the system to ask a question from a different worksheet.
We increment the random_id to make sure that the ws is updated and the system with ask the question naturally
Source code in src/worksheets/environment.py
704 705 706 707 708 709 710 |
|
GenieType
Bases: GenieWorksheet
Base class for Genie type definitions.
This class extends GenieWorksheet to provide type-specific functionality and validation. It's used to define custom types in the Genie system.
Attributes:
Name | Type | Description |
---|---|---|
_parent |
Parent object reference. |
Source code in src/worksheets/environment.py
713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 |
|
Attributes
action_performed
instance-attribute
action_performed = False
result
instance-attribute
result = None
random_id
instance-attribute
random_id = 0
_parent
instance-attribute
_parent = None
Functions
perform_action
perform_action(bot: GenieRuntime, local_context: GenieContext)
Perform the action associated with this worksheet if it hasn't been performed yet.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bot
|
GenieRuntime
|
The bot instance. |
required |
local_context
|
GenieContext
|
The local context for the action. |
required |
Returns:
Name | Type | Description |
---|---|---|
list |
A list of actions performed. |
Source code in src/worksheets/environment.py
504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 |
|
__repr__
__repr__()
Source code in src/worksheets/environment.py
550 551 552 553 554 555 556 |
|
schema_without_type
schema_without_type(context: GenieContext) -> str
Generate a schema representation of the worksheet without type information.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
context
|
GenieContext
|
The context for the worksheet. |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The schema representation without type. |
Source code in src/worksheets/environment.py
558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 |
|
execute
execute(bot: GenieRuntime, local_context: GenieContext)
Execute the actions associated with this worksheet.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bot
|
GenieRuntime
|
The bot instance. |
required |
local_context
|
GenieContext
|
The local context for execution. |
required |
Source code in src/worksheets/environment.py
646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 |
|
new
classmethod
new(initialize_from_dict: dict)
Source code in src/worksheets/environment.py
676 677 678 |
|
__setattr__
__setattr__(name, value)
Source code in src/worksheets/environment.py
680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 |
|
ask
ask()
This is a hack for when the user asks the system to ask a question from a different worksheet.
We increment the random_id to make sure that the ws is updated and the system with ask the question naturally
Source code in src/worksheets/environment.py
704 705 706 707 708 709 710 |
|
__init__
__init__(**kwargs)
Source code in src/worksheets/environment.py
723 724 725 |
|
is_complete
is_complete(*args, **kwargs)
Source code in src/worksheets/environment.py
727 728 729 730 731 732 |
|
GenieDB
Bases: GenieWorksheet
Base class for Genie database models.
This class extends GenieWorksheet to provide database-specific functionality and schema management.
Source code in src/worksheets/environment.py
735 736 737 738 739 740 |
|
Attributes
action_performed
instance-attribute
action_performed = False
result
instance-attribute
result = None
random_id
instance-attribute
random_id = 0
Functions
__init__
__init__(**kwargs)
Source code in src/worksheets/environment.py
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 |
|
perform_action
perform_action(bot: GenieRuntime, local_context: GenieContext)
Perform the action associated with this worksheet if it hasn't been performed yet.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bot
|
GenieRuntime
|
The bot instance. |
required |
local_context
|
GenieContext
|
The local context for the action. |
required |
Returns:
Name | Type | Description |
---|---|---|
list |
A list of actions performed. |
Source code in src/worksheets/environment.py
504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 |
|
is_complete
is_complete(bot: GenieRuntime, context: GenieContext) -> bool
Check if the worksheet is complete by evaluating all fields.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bot
|
GenieRuntime
|
The bot instance. |
required |
context
|
GenieContext
|
The context for evaluation. |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if the worksheet is complete, False otherwise. |
Source code in src/worksheets/environment.py
527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 |
|
__repr__
__repr__()
Source code in src/worksheets/environment.py
550 551 552 553 554 555 556 |
|
schema_without_type
schema_without_type(context: GenieContext) -> str
Generate a schema representation of the worksheet without type information.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
context
|
GenieContext
|
The context for the worksheet. |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The schema representation without type. |
Source code in src/worksheets/environment.py
558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 |
|
execute
execute(bot: GenieRuntime, local_context: GenieContext)
Execute the actions associated with this worksheet.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bot
|
GenieRuntime
|
The bot instance. |
required |
local_context
|
GenieContext
|
The local context for execution. |
required |
Source code in src/worksheets/environment.py
646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 |
|
new
classmethod
new(initialize_from_dict: dict)
Source code in src/worksheets/environment.py
676 677 678 |
|
__setattr__
__setattr__(name, value)
Source code in src/worksheets/environment.py
680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 |
|
ask
ask()
This is a hack for when the user asks the system to ask a question from a different worksheet.
We increment the random_id to make sure that the ws is updated and the system with ask the question naturally
Source code in src/worksheets/environment.py
704 705 706 707 708 709 710 |
|
Answer
Bases: GenieWorksheet
Class representing an answer in the Genie system.
This class handles query execution, result management, and parameter tracking for answers to user queries.
Attributes:
Name | Type | Description |
---|---|---|
query |
GenieField
|
The query to execute. |
actions |
Associated actions. |
|
result |
Query execution result. |
|
tables |
Related database tables. |
|
potential_outputs |
Possible output types. |
|
nl_query |
Natural language query. |
|
param_names |
Required parameter names. |
Source code in src/worksheets/environment.py
743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 |
|
Attributes
random_id
instance-attribute
random_id = 0
query
instance-attribute
query = GenieField('str', 'query', value=query)
actions
instance-attribute
actions = Action('>suql_runner(self.query.value, self.required_columns)')
result
instance-attribute
result = None
tables
instance-attribute
tables = tables
potential_outputs
instance-attribute
potential_outputs = []
nl_query
instance-attribute
nl_query = nl_query
param_names
instance-attribute
param_names = []
action_performed
instance-attribute
action_performed = False
required_columns
instance-attribute
required_columns = [name for table in tables for field in get_genie_fields_from_ws(context[table])]
_ordered_attributes
instance-attribute
_ordered_attributes = _ordered_attributes
Functions
perform_action
perform_action(bot: GenieRuntime, local_context: GenieContext)
Perform the action associated with this worksheet if it hasn't been performed yet.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bot
|
GenieRuntime
|
The bot instance. |
required |
local_context
|
GenieContext
|
The local context for the action. |
required |
Returns:
Name | Type | Description |
---|---|---|
list |
A list of actions performed. |
Source code in src/worksheets/environment.py
504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 |
|
is_complete
is_complete(bot: GenieRuntime, context: GenieContext) -> bool
Check if the worksheet is complete by evaluating all fields.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bot
|
GenieRuntime
|
The bot instance. |
required |
context
|
GenieContext
|
The context for evaluation. |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if the worksheet is complete, False otherwise. |
Source code in src/worksheets/environment.py
527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 |
|
__repr__
__repr__()
Source code in src/worksheets/environment.py
550 551 552 553 554 555 556 |
|
schema_without_type
schema_without_type(context: GenieContext) -> str
Generate a schema representation of the worksheet without type information.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
context
|
GenieContext
|
The context for the worksheet. |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The schema representation without type. |
Source code in src/worksheets/environment.py
558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 |
|
new
classmethod
new(initialize_from_dict: dict)
Source code in src/worksheets/environment.py
676 677 678 |
|
__setattr__
__setattr__(name, value)
Source code in src/worksheets/environment.py
680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 |
|
ask
ask()
This is a hack for when the user asks the system to ask a question from a different worksheet.
We increment the random_id to make sure that the ws is updated and the system with ask the question naturally
Source code in src/worksheets/environment.py
704 705 706 707 708 709 710 |
|
__init__
__init__(query, required_params, tables, nl_query)
Source code in src/worksheets/environment.py
759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 |
|
execute
execute(bot: GenieRuntime, local_context: GenieContext)
Execute the actions associated with this answer.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bot
|
GenieRuntime
|
The bot instance. |
required |
local_context
|
GenieContext
|
The local context for the execution. |
required |
Source code in src/worksheets/environment.py
793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 |
|
more_field_info_query
more_field_info_query(bot: GenieRuntime)
Source code in src/worksheets/environment.py
852 853 854 855 856 857 858 859 860 861 862 863 864 |
|
output_in_result
output_in_result(results: list)
Check if the output type is in the results.
Source code in src/worksheets/environment.py
866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 |
|
update
update(query, unfilled_params, tables, query_str)
Update the answer with new parameters and tables.
We are not using this method anymore, but we can keep it for reference.
Source code in src/worksheets/environment.py
884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 |
|
MoreFieldInfo
Bases: GenieWorksheet
Class for managing additional field information requests.
This class handles requests for clarification or additional information about specific fields.
Attributes:
Name | Type | Description |
---|---|---|
api_name |
GenieField
|
Name of the API. |
parameter_name |
GenieField
|
Name of the parameter. |
actions |
Associated actions. |
Source code in src/worksheets/environment.py
918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 |
|
Attributes
result
instance-attribute
result = None
random_id
instance-attribute
random_id = 0
api_name
instance-attribute
api_name = GenieField('str', 'api_name', value=api_name)
parameter_name
instance-attribute
parameter_name = GenieField('str', 'parameter_name', value=parameter_name)
actions
instance-attribute
actions = Action('>answer_clarification_question(self.api_name, self.parameter_name)')
action_performed
instance-attribute
action_performed = False
Functions
perform_action
perform_action(bot: GenieRuntime, local_context: GenieContext)
Perform the action associated with this worksheet if it hasn't been performed yet.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bot
|
GenieRuntime
|
The bot instance. |
required |
local_context
|
GenieContext
|
The local context for the action. |
required |
Returns:
Name | Type | Description |
---|---|---|
list |
A list of actions performed. |
Source code in src/worksheets/environment.py
504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 |
|
is_complete
is_complete(bot: GenieRuntime, context: GenieContext) -> bool
Check if the worksheet is complete by evaluating all fields.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bot
|
GenieRuntime
|
The bot instance. |
required |
context
|
GenieContext
|
The context for evaluation. |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if the worksheet is complete, False otherwise. |
Source code in src/worksheets/environment.py
527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 |
|
__repr__
__repr__()
Source code in src/worksheets/environment.py
550 551 552 553 554 555 556 |
|
schema_without_type
schema_without_type(context: GenieContext) -> str
Generate a schema representation of the worksheet without type information.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
context
|
GenieContext
|
The context for the worksheet. |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The schema representation without type. |
Source code in src/worksheets/environment.py
558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 |
|
execute
execute(bot: GenieRuntime, local_context: GenieContext)
Execute the actions associated with this worksheet.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bot
|
GenieRuntime
|
The bot instance. |
required |
local_context
|
GenieContext
|
The local context for execution. |
required |
Source code in src/worksheets/environment.py
646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 |
|
new
classmethod
new(initialize_from_dict: dict)
Source code in src/worksheets/environment.py
676 677 678 |
|
__setattr__
__setattr__(name, value)
Source code in src/worksheets/environment.py
680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 |
|
ask
ask()
This is a hack for when the user asks the system to ask a question from a different worksheet.
We increment the random_id to make sure that the ws is updated and the system with ask the question naturally
Source code in src/worksheets/environment.py
704 705 706 707 708 709 710 |
|
__init__
__init__(api_name, parameter_name)
Source code in src/worksheets/environment.py
930 931 932 933 934 935 936 |
|
Action
Class for managing worksheet actions.
This class handles action definition, execution, and result management for worksheet operations.
Attributes:
Name | Type | Description |
---|---|---|
action |
The action to perform. |
Source code in src/worksheets/environment.py
939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 |
|
Attributes
action
instance-attribute
action = action
Functions
__init__
__init__(action)
Source code in src/worksheets/environment.py
949 950 |
|
__len__
__len__()
Source code in src/worksheets/environment.py
952 953 |
|
perform
perform(obj: GenieWorksheet, bot: GenieRuntime, local_context: GenieContext) -> list
Perform the action with the given context.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obj
|
GenieWorksheet
|
The worksheet object. |
required |
bot
|
GenieRuntime
|
The bot instance. |
required |
local_context
|
GenieContext
|
The local context. |
required |
Returns:
Name | Type | Description |
---|---|---|
list |
list
|
List of actions performed. |
Source code in src/worksheets/environment.py
955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 |
|
GenieRuntime
Main runtime environment for Genie system.
This class manages the execution environment, including worksheet registration, context management, and action execution.
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
Runtime instance name. |
prompt_dir |
str
|
Directory for prompts. |
args |
Additional arguments. |
|
genie_worksheets |
list
|
Registered worksheets. |
genie_db_models |
list
|
Registered database models. |
starting_prompt |
str
|
Initial system prompt. |
description |
str
|
Runtime description. |
suql_runner |
SQL query runner. |
|
suql_parser |
SQL query parser. |
|
context |
GenieContext
|
Global context. |
dlg_history |
list
|
Dialogue history. |
Source code in src/worksheets/environment.py
1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 |
|
Attributes
prompt_dir
instance-attribute
prompt_dir = prompt_dir
args
instance-attribute
args = args
name
instance-attribute
name = name
genie_worksheets
instance-attribute
genie_worksheets = []
genie_db_models
instance-attribute
genie_db_models = []
starting_prompt
instance-attribute
starting_prompt = starting_prompt
description
instance-attribute
description = description
suql_runner
instance-attribute
suql_runner = suql_runner
suql_parser
instance-attribute
suql_parser = suql_parser
_interpreter
instance-attribute
_interpreter = GenieInterpreter()
context
instance-attribute
context = GenieContext()
local_context_init
instance-attribute
local_context_init = GenieContext()
dlg_history
instance-attribute
dlg_history = []
order_of_actions
instance-attribute
order_of_actions = []
Functions
__init__
__init__(name, prompt_dir, starting_prompt=None, description=None, args=None, api=None, suql_runner=None, suql_parser=None)
Source code in src/worksheets/environment.py
1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 |
|
reset
reset()
Reset the bot's context and state.
Source code in src/worksheets/environment.py
1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 |
|
add_worksheet
add_worksheet(ws: type)
Add a worksheet to the bot's context.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ws
|
type
|
The worksheet class to add. |
required |
Source code in src/worksheets/environment.py
1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 |
|
add_db_model
add_db_model(db_model: type)
Add a database model to the bot's context.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
db_model
|
type
|
The database model class to add. |
required |
Source code in src/worksheets/environment.py
1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 |
|
add_api
add_api(api: Any)
Add an API function to the context.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
api
|
Any
|
The API function or object to add. |
required |
Source code in src/worksheets/environment.py
1131 1132 1133 1134 1135 1136 1137 |
|
geniews
geniews(predicates=None, outputs: GenieWorksheet | dict | None = None, backend_api=None, actions='')
Decorator to define a Genie worksheet.
Source code in src/worksheets/environment.py
1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 |
|
genie_sql
genie_sql(outputs: GenieWorksheet | dict | None = None, actions='')
Decorator to define a Genie database model.
Source code in src/worksheets/environment.py
1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 |
|
execute
execute(code: str, local_context: GenieContext | None = None, sp: bool = False)
Execute the given code in the context of the bot.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
code
|
str
|
The code to execute. |
required |
local_context
|
GenieContext | None
|
Local context to use. Defaults to None. |
None
|
sp
|
bool
|
Whether this is a semantic parser execution. Defaults to False. |
False
|
Source code in src/worksheets/environment.py
1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 |
|
eval
eval(code: str, local_context: GenieContext | None = None) -> Any
Evaluate the given code in the context of the bot.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
code
|
str
|
The code to evaluate. |
required |
local_context
|
GenieContext | None
|
Local context to use. Defaults to None. |
None
|
Returns:
Name | Type | Description |
---|---|---|
Any |
Any
|
The result of the evaluation. |
Source code in src/worksheets/environment.py
1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 |
|
update_from_context
update_from_context(context)
add new variables to the context
Source code in src/worksheets/environment.py
1227 1228 1229 |
|
get_available_worksheets
get_available_worksheets(context)
Get all available worksheets based on their predicates.
Source code in src/worksheets/environment.py
1231 1232 1233 1234 1235 1236 1237 1238 |
|
get_available_dbs
get_available_dbs(context)
Get all available database models based on their predicates.
Source code in src/worksheets/environment.py
1240 1241 1242 1243 1244 1245 1246 1247 |
|
get_all_variables
get_all_variables()
Get all fields (variables) from all worksheets.
Source code in src/worksheets/environment.py
1249 1250 1251 1252 1253 1254 1255 1256 |
|
GenieInterpreter
Interpreter for executing Genie code.
This class provides code execution capabilities within the Genie environment, handling variable resolution and context management.
Source code in src/worksheets/environment.py
1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 |
|
Functions
execute
execute(code, global_context, local_context, sp=False)
Source code in src/worksheets/environment.py
1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 |
|
eval
eval(code, global_context, local_context)
Source code in src/worksheets/environment.py
1296 1297 1298 1299 1300 1301 1302 1303 |
|
GenieContext
Context manager for Genie runtime.
This class manages variable context and agent actions during runtime.
Attributes:
Name | Type | Description |
---|---|---|
context |
dict
|
The context dictionary. |
agent_acts |
Current agent actions. |
Source code in src/worksheets/environment.py
1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 |
|
Attributes
context
instance-attribute
context = context
agent_acts
instance-attribute
agent_acts = None
Functions
__init__
__init__(context: dict = None)
Source code in src/worksheets/environment.py
1316 1317 1318 1319 1320 1321 |
|
reset_agent_acts
reset_agent_acts()
Source code in src/worksheets/environment.py
1323 1324 |
|
update
update(content: dict)
Update the context with new content.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
content
|
dict
|
Dictionary of content to update with. |
required |
Source code in src/worksheets/environment.py
1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 |
|
get
get(key: str) -> Any
Get a value from the context.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key
|
str
|
The key to get. |
required |
Returns:
Name | Type | Description |
---|---|---|
Any |
Any
|
The value associated with the key. |
Source code in src/worksheets/environment.py
1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 |
|
set
set(key: str, value: Any)
Set a value in the context.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key
|
str
|
The key to set. |
required |
value
|
Any
|
The value to set. |
required |
Source code in src/worksheets/environment.py
1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 |
|
delete
delete(key: str)
Delete a key from the context.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key
|
str
|
The key to delete. |
required |
Source code in src/worksheets/environment.py
1374 1375 1376 1377 1378 1379 1380 |
|
TurnContext
Context manager for dialogue turns.
This class manages context for individual dialogue turns.
Attributes:
Name | Type | Description |
---|---|---|
context |
list[GenieContext]
|
List of contexts for each turn. |
Source code in src/worksheets/environment.py
1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 |
|
Attributes
context
instance-attribute
context: list[GenieContext] = []
Functions
__init__
__init__()
Source code in src/worksheets/environment.py
1392 1393 |
|
add_turn_context
add_turn_context(context: GenieContext)
Add a new turn context.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
context
|
GenieContext
|
The context to add for this turn. |
required |
Source code in src/worksheets/environment.py
1395 1396 1397 1398 1399 1400 1401 |
|
AgentAct
Base class for agent actions.
This class serves as the foundation for different types of agent actions in the system.
Source code in src/worksheets/environment.py
1931 1932 1933 1934 1935 1936 |
|
ReportAgentAct
Bases: AgentAct
Action for reporting query results or messages.
This class handles reporting of query results and system messages.
Attributes:
Name | Type | Description |
---|---|---|
query |
GenieField
|
The query being reported. |
message |
The message or result to report. |
|
query_var_name |
Variable name for the query. |
|
message_var_name |
Variable name for the message. |
Source code in src/worksheets/environment.py
1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 |
|
Attributes
query
instance-attribute
query = query
message
instance-attribute
message = message
query_var_name
instance-attribute
query_var_name = query_var_name
message_var_name
instance-attribute
message_var_name = message_var_name
Functions
__init__
__init__(query: GenieField, message: Any, query_var_name=None, message_var_name=None)
Source code in src/worksheets/environment.py
1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 |
|
__repr__
__repr__()
Source code in src/worksheets/environment.py
1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 |
|
__eq__
__eq__(other)
Source code in src/worksheets/environment.py
1975 1976 1977 1978 1979 |
|
AskAgentAct
Bases: AgentAct
Action for requesting information from users.
This class handles user information requests.
Attributes:
Name | Type | Description |
---|---|---|
ws |
GenieWorksheet
|
The worksheet context. |
field |
GenieField
|
The field to ask about. |
ws_name |
Worksheet name override. |
Source code in src/worksheets/environment.py
1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 |
|
Attributes
ws
instance-attribute
ws = ws
field
instance-attribute
field = field
ws_name
instance-attribute
ws_name = ws_name
Functions
__init__
__init__(ws: GenieWorksheet, field: GenieField, ws_name=None)
Source code in src/worksheets/environment.py
1993 1994 1995 1996 |
|
__repr__
__repr__()
Source code in src/worksheets/environment.py
1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 |
|
ProposeAgentAct
Bases: AgentAct
Action for proposing worksheet values.
This class handles proposals for worksheet field values.
Attributes:
Name | Type | Description |
---|---|---|
ws |
GenieWorksheet
|
The worksheet context. |
params |
dict
|
Proposed parameters. |
ws_name |
Worksheet name override. |
Source code in src/worksheets/environment.py
2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 |
|
Attributes
ws
instance-attribute
ws = ws
params
instance-attribute
params = params
ws_name
instance-attribute
ws_name = ws_name
Functions
__init__
__init__(ws: GenieWorksheet, params: dict, ws_name=None)
Source code in src/worksheets/environment.py
2029 2030 2031 2032 |
|
__repr__
__repr__()
Source code in src/worksheets/environment.py
2034 2035 2036 2037 |
|
AskForConfirmationAgentAct
Bases: AgentAct
Action for requesting user confirmation.
This class handles confirmation requests for field values.
Attributes:
Name | Type | Description |
---|---|---|
ws |
GenieWorksheet
|
The worksheet context. |
field |
GenieField
|
The field to confirm. |
ws_name |
Worksheet name override. |
|
field_name |
Field name override. |
|
value |
Value to confirm. |
Source code in src/worksheets/environment.py
2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 |
|
Attributes
ws
instance-attribute
ws = ws
field
instance-attribute
field = field
ws_name
instance-attribute
ws_name = ws_name
field_name
instance-attribute
field_name = field_name
value
instance-attribute
value = None
Functions
__init__
__init__(ws: 'GenieWorksheet', field: 'GenieField', ws_name=None, field_name=None)
Source code in src/worksheets/environment.py
2053 2054 2055 2056 2057 2058 2059 2060 |
|
__repr__
__repr__()
Source code in src/worksheets/environment.py
2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 |
|
AgentActs
Container for managing multiple agent actions.
This class manages collections of agent actions, handling action ordering and compatibility.
Attributes:
Name | Type | Description |
---|---|---|
args |
Arguments for action management. |
|
actions |
list
|
List of agent actions. |
Source code in src/worksheets/environment.py
2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 |
|
Attributes
args
instance-attribute
args = args
actions
instance-attribute
actions = []
Functions
__init__
__init__(args)
Source code in src/worksheets/environment.py
2087 2088 2089 |
|
add
add(action)
Source code in src/worksheets/environment.py
2091 2092 |
|
_add
_add(action)
Source code in src/worksheets/environment.py
2094 2095 2096 |
|
should_add
should_add(incoming_action)
There can be multiple ReportActs, and (multiple propose acts or one ask acts or one confirmation act) but only one of each type of act
Source code in src/worksheets/environment.py
2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 |
|
extend
extend(actions)
Source code in src/worksheets/environment.py
2158 2159 2160 |
|
__iter__
__iter__()
Source code in src/worksheets/environment.py
2162 2163 |
|
__next__
__next__()
Source code in src/worksheets/environment.py
2165 2166 |
|
can_have_other_acts
can_have_other_acts()
Source code in src/worksheets/environment.py
2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 |
|
Functions
validation_check
validation_check(name, value, validation)
Validate a value against specified criteria using LLM.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the field being validated. |
required |
value
|
Any
|
The value to validate. |
required |
validation
|
str
|
The validation criteria. |
required |
Returns:
Name | Type | Description |
---|---|---|
tuple |
A tuple containing: - bool: Whether the value is valid. - str or None: The reason for invalidity, if any. |
Source code in src/worksheets/environment.py
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 |
|
get_genie_fields_from_ws
get_genie_fields_from_ws(obj: GenieWorksheet) -> list[GenieField]
Get all GenieField instances from a GenieWorksheet.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obj
|
GenieWorksheet
|
The worksheet to get fields from. |
required |
Returns:
Type | Description |
---|---|
list[GenieField]
|
list[GenieField]: List of GenieField instances. |
Source code in src/worksheets/environment.py
1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 |
|
execute_query
execute_query(code: str, obj: GenieWorksheet, bot: GenieRuntime, local_context: GenieContext) -> Any
Execute a query in the given context.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
code
|
str
|
The code to execute. |
required |
obj
|
GenieWorksheet
|
The worksheet object. |
required |
bot
|
GenieRuntime
|
The bot instance. |
required |
local_context
|
GenieContext
|
The local context. |
required |
Returns:
Name | Type | Description |
---|---|---|
Any |
Any
|
The result of the query execution. |
Source code in src/worksheets/environment.py
1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 |
|
modify_action_code
modify_action_code(code, obj, bot, local_context)
Source code in src/worksheets/environment.py
1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 |
|
eval_predicates
eval_predicates(predicates: list | str, obj: GenieField | GenieWorksheet, bot: GenieRuntime, local_context: GenieContext) -> bool
Source code in src/worksheets/environment.py
1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 |
|
parse_single_predicate
parse_single_predicate(predicate: str, obj, bot, context) -> bool
Source code in src/worksheets/environment.py
1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 |
|
rewrite_action_code
rewrite_action_code(code, builtin_funcs)
Source code in src/worksheets/environment.py
1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 |
|
same_field
same_field(field1: GenieField, field2: GenieField)
Check if the values and confirmed status are the same for any two GenieField instances.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
field1
|
GenieField
|
The first field to compare. |
required |
field2
|
GenieField
|
The second field to compare. |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
True if the fields are the same, False otherwise. |
Source code in src/worksheets/environment.py
1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 |
|
same_worksheet
same_worksheet(ws1: GenieWorksheet, ws2: GenieWorksheet)
Check if two GenieWorksheet instances are the same.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ws1
|
GenieWorksheet
|
The first worksheet to compare. |
required |
ws2
|
GenieWorksheet
|
The second worksheet to compare. |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
True if the worksheets are the same, False otherwise. |
Source code in src/worksheets/environment.py
1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 |
|
count_number_of_vars
count_number_of_vars(context: dict)
Count the number of variables of the same type in the context.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
context
|
dict
|
The context to count variables in. |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
A dictionary with variable names as keys and their counts as values. |
Source code in src/worksheets/environment.py
1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 |
|
genie_deepcopy
genie_deepcopy(context)
Special deepcopy function for Genie context.
Source code in src/worksheets/environment.py
1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 |
|
get_field_variable_name
get_field_variable_name(obj: GenieWorksheet, context: GenieContext)
Get the variable name of a field in a worksheet.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obj
|
GenieWorksheet
|
The worksheet object. |
required |
context
|
GenieContext
|
The context to search in. |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
The variable name of the field. |
Source code in src/worksheets/environment.py
1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 |
|
collect_all_parents
collect_all_parents(context: GenieContext)
Collect all parent references for GenieField instances in the context.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
context
|
GenieContext
|
The context to collect parents from. |
required |
Source code in src/worksheets/environment.py
1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 |
|
find_all_variables_matching_name
find_all_variables_matching_name(field_name: str, context: GenieContext)
Go through all the variables in the context recursively and return the variables that match the field_name
Source code in src/worksheets/environment.py
1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 |
|
replace_undefined_variables
replace_undefined_variables(code: str, local_context: GenieContext, global_context: GenieContext)
Replace undefined variables in the code with their corresponding values from the context.
Source code in src/worksheets/environment.py
1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 |
|
variable_resolver
variable_resolver(var_name, global_context, local_context)
We need to resolve the variable name since they are stored as
Source code in src/worksheets/environment.py
1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 |
|
select_variable_from_list
select_variable_from_list(variables, value)
Source code in src/worksheets/environment.py
1804 1805 1806 1807 1808 1809 |
|
get_variable_name
get_variable_name(obj: GenieWorksheet, context: GenieContext)
Get the variable name of a worksheet in the context.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obj
|
GenieWorksheet
|
The worksheet object. |
required |
context
|
GenieContext
|
The context to search in. |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
The variable name of the worksheet. |
Source code in src/worksheets/environment.py
1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 |
|
propose
propose(worksheet: GenieWorksheet, params: dict) -> ProposeAgentAct
Create a proposal action.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
worksheet
|
GenieWorksheet
|
The worksheet to propose values for. |
required |
params
|
dict
|
The parameters to propose. |
required |
Returns:
Name | Type | Description |
---|---|---|
ProposeAgentAct |
ProposeAgentAct
|
The created proposal action. |
Source code in src/worksheets/environment.py
1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 |
|
say
say(message: str) -> ReportAgentAct
Create a message report action.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message
|
str
|
The message to report. |
required |
Returns:
Name | Type | Description |
---|---|---|
ReportAgentAct |
ReportAgentAct
|
The created report action. |
Source code in src/worksheets/environment.py
1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 |
|
generate_clarification
generate_clarification(worksheet: GenieWorksheet, field: str) -> str
Generate clarification text for a field.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
worksheet
|
GenieWorksheet
|
The worksheet containing the field. |
required |
field
|
str
|
The name of the field. |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The generated clarification text. |
Source code in src/worksheets/environment.py
1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 |
|
answer_clarification_question
answer_clarification_question(worksheet: GenieField, field: GenieField, context: GenieContext) -> ReportAgentAct
Create a clarification answer action.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
worksheet
|
GenieField
|
The worksheet field. |
required |
field
|
GenieField
|
The field to clarify. |
required |
context
|
GenieContext
|
The context. |
required |
Returns:
Name | Type | Description |
---|---|---|
ReportAgentAct |
ReportAgentAct
|
The created clarification report action. |
Source code in src/worksheets/environment.py
1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 |
|
confirm
confirm(value: Any) -> GenieValue
Create a confirmed value.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
Any
|
The value to confirm. |
required |
Returns:
Name | Type | Description |
---|---|---|
GenieValue |
GenieValue
|
The confirmed value instance. |
Source code in src/worksheets/environment.py
1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 |
|
sanitize_dev_code
sanitize_dev_code(code: str, all_variables: list[str])
Sanitize the developer's code to ensure it doesn't contain any undefined variables.
Source code in src/worksheets/environment.py
2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 |
|
any_open_empty_ws
any_open_empty_ws(turn_context: GenieContext, global_context: GenieContext)
Checks all the worksheets in the context. If there is any worksheet that is available but all the fields are None, then return True else return False
Source code in src/worksheets/environment.py
2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 |
|
find_list_variable
find_list_variable(val, context)
Find the variable name which is a list and the index of the required value in the context.
Source code in src/worksheets/environment.py
2229 2230 2231 2232 2233 2234 2235 2236 |
|