lionagi 0.8.1__tar.gz → 0.8.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {lionagi-0.8.1 → lionagi-0.8.3}/PKG-INFO +1 -1
- {lionagi-0.8.1 → lionagi-0.8.3}/docs/modules/models.rst +11 -11
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operations/ReAct/ReAct.py +7 -11
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operations/ReAct/utils.py +4 -4
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operatives/action/function_calling.py +12 -2
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operatives/action/tool.py +11 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operatives/models/field_model.py +39 -22
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operatives/models/model_params.py +35 -16
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operatives/models/note.py +84 -45
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operatives/models/operable_model.py +118 -8
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/protocols/messages/instruction.py +104 -51
- lionagi-0.8.3/lionagi/version.py +1 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/prompts/doc_style.md +27 -29
- {lionagi-0.8.1 → lionagi-0.8.3}/pyproject.toml +1 -1
- {lionagi-0.8.1 → lionagi-0.8.3}/uv.lock +1 -1
- lionagi-0.8.1/lionagi/version.py +0 -1
- {lionagi-0.8.1 → lionagi-0.8.3}/.env.example +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/.github/FUNDING.yml +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/.github/dependabot.yml +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/.github/workflows/ci.yml +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/.github/workflows/codeql.yml +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/.github/workflows/docs.yml +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/.github/workflows/release.yml +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/.gitignore +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/.pre-commit-config.yaml +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/CODE_OF_CONDUCT.md +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/CONTRIBUTING.md +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/LICENSE +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/README.md +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/cookbooks/ch01_get_started.md +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/cookbooks/ch02_concepts.md +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/dev_tools/count_code_base_lines.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/docs/Makefile +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/docs/_static/custom.css +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/docs/_templates/layout.html +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/docs/conf.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/docs/index.rst +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/docs/modules/action.rst +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/docs/modules/adapter.rst +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/docs/modules/branch.rst +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/docs/modules/branch_operations.rst +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/docs/modules/concepts.rst +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/docs/modules/element_id.rst +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/docs/modules/event.rst +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/docs/modules/form.rst +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/docs/modules/graph.rst +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/docs/modules/index.rst +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/docs/modules/instruct.rst +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/docs/modules/lib_file.rst +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/docs/modules/lib_nested.rst +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/docs/modules/lib_package.rst +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/docs/modules/lib_schema.rst +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/docs/modules/lib_validate.rst +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/docs/modules/log.rst +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/docs/modules/mail.rst +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/docs/modules/message.rst +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/docs/modules/operative_step.rst +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/docs/modules/pile.rst +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/docs/modules/processor.rst +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/docs/modules/progression.rst +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/docs/modules/service.rst +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/docs/modules/session.rst +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/docs/modules/utils.rst +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/docs/tutorials/get_started.rst +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/docs/tutorials/get_started_pt2.rst +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/docs/tutorials/get_started_pt3.rst +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/docs/tutorials/index.rst +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/__init__.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/_class_registry.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/_errors.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/_types.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/libs/__init__.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/libs/file/__init__.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/libs/file/chunk.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/libs/file/file_ops.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/libs/file/params.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/libs/file/process.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/libs/file/save.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/libs/nested/__init__.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/libs/nested/flatten.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/libs/nested/nfilter.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/libs/nested/nget.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/libs/nested/ninsert.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/libs/nested/nmerge.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/libs/nested/npop.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/libs/nested/nset.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/libs/nested/unflatten.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/libs/nested/utils.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/libs/package/__init__.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/libs/package/imports.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/libs/package/management.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/libs/package/params.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/libs/package/system.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/libs/parse.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/libs/schema/__init__.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/libs/schema/as_readable.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/libs/schema/extract_code_block.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/libs/schema/extract_docstring.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/libs/schema/function_to_schema.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/libs/schema/json_schema.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/libs/token_transform/__init__.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/libs/token_transform/llmlingua.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/libs/token_transform/perplexity.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/libs/token_transform/synthlang.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/libs/validate/__init__.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/libs/validate/common_field_validators.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/libs/validate/fuzzy_match_keys.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/libs/validate/fuzzy_validate_mapping.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/libs/validate/string_similarity.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/libs/validate/validate_boolean.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operations/ReAct/__init__.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operations/__init__.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operations/_act/__init__.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operations/_act/act.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operations/brainstorm/__init__.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operations/brainstorm/brainstorm.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operations/brainstorm/prompt.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operations/chat/__init__.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operations/chat/chat.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operations/communicate/__init__.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operations/communicate/communicate.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operations/instruct/__init__.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operations/instruct/instruct.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operations/interpret/__init__.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operations/interpret/interpret.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operations/manager.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operations/operate/__init__.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operations/operate/operate.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operations/parse/__init__.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operations/parse/parse.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operations/plan/__init__.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operations/plan/plan.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operations/plan/prompt.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operations/select/__init__.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operations/select/select.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operations/select/utils.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operations/translate/__init__.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operations/translate/translate.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operations/types.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operations/utils.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operatives/__init__.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operatives/action/__init__.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operatives/action/manager.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operatives/action/request_response_model.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operatives/action/utils.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operatives/forms/__init__.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operatives/forms/base.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operatives/forms/flow.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operatives/forms/form.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operatives/forms/report.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operatives/instruct/__init__.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operatives/instruct/base.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operatives/instruct/instruct.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operatives/instruct/instruct_collection.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operatives/instruct/node.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operatives/instruct/prompts.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operatives/instruct/reason.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operatives/manager.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operatives/models/__init__.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operatives/models/schema_model.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operatives/operative.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operatives/step.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operatives/strategies/__init__.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operatives/strategies/base.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operatives/strategies/concurrent.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operatives/strategies/concurrent_chunk.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operatives/strategies/concurrent_sequential_chunk.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operatives/strategies/params.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operatives/strategies/sequential.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operatives/strategies/sequential_chunk.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operatives/strategies/sequential_concurrent_chunk.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operatives/strategies/utils.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/operatives/types.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/protocols/__init__.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/protocols/_concepts.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/protocols/adapters/__init__.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/protocols/adapters/adapter.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/protocols/adapters/json_adapter.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/protocols/adapters/pandas_/__init__.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/protocols/adapters/pandas_/csv_adapter.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/protocols/adapters/pandas_/excel_adapter.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/protocols/adapters/pandas_/pd_dataframe_adapter.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/protocols/adapters/pandas_/pd_series_adapter.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/protocols/adapters/types.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/protocols/generic/__init__.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/protocols/generic/element.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/protocols/generic/event.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/protocols/generic/log.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/protocols/generic/pile.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/protocols/generic/processor.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/protocols/generic/progression.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/protocols/graph/__init__.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/protocols/graph/edge.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/protocols/graph/graph.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/protocols/graph/node.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/protocols/mail/__init__.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/protocols/mail/exchange.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/protocols/mail/mail.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/protocols/mail/mailbox.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/protocols/mail/manager.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/protocols/mail/package.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/protocols/messages/__init__.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/protocols/messages/action_request.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/protocols/messages/action_response.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/protocols/messages/assistant_response.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/protocols/messages/base.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/protocols/messages/manager.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/protocols/messages/message.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/protocols/messages/system.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/protocols/messages/templates/README.md +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/protocols/messages/templates/action_request.jinja2 +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/protocols/messages/templates/action_response.jinja2 +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/protocols/messages/templates/assistant_response.jinja2 +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/protocols/messages/templates/instruction_message.jinja2 +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/protocols/messages/templates/system_message.jinja2 +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/protocols/messages/templates/tool_schemas.jinja2 +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/protocols/types.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/service/__init__.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/service/endpoints/__init__.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/service/endpoints/base.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/service/endpoints/chat_completion.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/service/endpoints/match_endpoint.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/service/endpoints/rate_limited_processor.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/service/endpoints/token_calculator.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/service/imodel.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/service/manager.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/service/providers/__init__.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/service/providers/anthropic_/__init__.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/service/providers/anthropic_/messages.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/service/providers/exa_/__init__.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/service/providers/exa_/models.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/service/providers/exa_/search.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/service/providers/exa_/types.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/service/providers/groq_/__init__.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/service/providers/groq_/chat_completions.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/service/providers/openai_/__init__.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/service/providers/openai_/chat_completions.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/service/providers/openrouter_/__init__.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/service/providers/openrouter_/chat_completions.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/service/providers/perplexity_/__init__.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/service/providers/perplexity_/chat_completions.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/service/providers/types.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/service/types.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/session/__init__.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/session/branch.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/session/session.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/settings.py +0 -0
- {lionagi-0.8.1 → lionagi-0.8.3}/lionagi/utils.py +0 -0
@@ -18,7 +18,7 @@ Below is an overview of the major components in this subsystem.
|
|
18
18
|
----------------------------
|
19
19
|
1. FieldModel (``field_model.py``)
|
20
20
|
----------------------------
|
21
|
-
.. module:: lionagi.operatives.
|
21
|
+
.. module:: lionagi.operatives.models.field_model
|
22
22
|
:synopsis: Structured definition of Pydantic fields.
|
23
23
|
|
24
24
|
.. class:: FieldModel
|
@@ -35,7 +35,7 @@ A configurable **field definition** that captures:
|
|
35
35
|
|
36
36
|
**Usage**::
|
37
37
|
|
38
|
-
from lionagi.operatives.
|
38
|
+
from lionagi.operatives.models.field_model import FieldModel
|
39
39
|
|
40
40
|
field = FieldModel(
|
41
41
|
name="age",
|
@@ -50,7 +50,7 @@ A configurable **field definition** that captures:
|
|
50
50
|
----------------------------
|
51
51
|
2. ModelParams (``model_params.py``)
|
52
52
|
----------------------------
|
53
|
-
.. module:: lionagi.operatives.
|
53
|
+
.. module:: lionagi.operatives.models.model_params
|
54
54
|
:synopsis: Dynamically create new Pydantic models.
|
55
55
|
|
56
56
|
.. class:: ModelParams
|
@@ -72,8 +72,8 @@ Finally, call :meth:`create_new_model()` to get a brand-new Pydantic class
|
|
72
72
|
**Example**::
|
73
73
|
|
74
74
|
from pydantic import BaseModel
|
75
|
-
from lionagi.operatives.
|
76
|
-
from lionagi.operatives.
|
75
|
+
from lionagi.operatives.models.model_params import ModelParams
|
76
|
+
from lionagi.operatives.models.field_model import FieldModel
|
77
77
|
|
78
78
|
params = ModelParams(
|
79
79
|
name="DynamicUser",
|
@@ -92,7 +92,7 @@ Finally, call :meth:`create_new_model()` to get a brand-new Pydantic class
|
|
92
92
|
---------------------------
|
93
93
|
3. OperableModel (``operable_model.py``)
|
94
94
|
---------------------------
|
95
|
-
.. module:: lionagi.operatives.
|
95
|
+
.. module:: lionagi.operatives.models.operable_model
|
96
96
|
:synopsis: Extends Pydantic for dynamic field management.
|
97
97
|
|
98
98
|
.. class:: OperableModel
|
@@ -112,7 +112,7 @@ structure remains valid with Pydantic's type checks and serialization logic.
|
|
112
112
|
|
113
113
|
**Example**::
|
114
114
|
|
115
|
-
from lionagi.operatives.
|
115
|
+
from lionagi.operatives.models.operable_model import OperableModel
|
116
116
|
|
117
117
|
class User(OperableModel):
|
118
118
|
name: str = "default_name"
|
@@ -128,7 +128,7 @@ structure remains valid with Pydantic's type checks and serialization logic.
|
|
128
128
|
--------------------------
|
129
129
|
4. Note (``note.py``)
|
130
130
|
--------------------------
|
131
|
-
.. module:: lionagi.operatives.
|
131
|
+
.. module:: lionagi.operatives.models.note
|
132
132
|
:synopsis: A flexible container for nested data.
|
133
133
|
|
134
134
|
.. class:: Note
|
@@ -146,7 +146,7 @@ manually in your code.
|
|
146
146
|
|
147
147
|
**Example**::
|
148
148
|
|
149
|
-
from lionagi.operatives.
|
149
|
+
from lionagi.operatives.models.note import Note
|
150
150
|
|
151
151
|
note = Note(user={"name": "John", "settings": {"theme": "dark"}})
|
152
152
|
name = note.get(["user", "name"]) # "John"
|
@@ -172,7 +172,7 @@ to **forbid** extra fields by default and use enum values. Provides a
|
|
172
172
|
-------------------------
|
173
173
|
6. HashableModel (``hashable_model.py``)
|
174
174
|
-------------------------
|
175
|
-
.. module:: lionagi.
|
175
|
+
.. module:: lionagi.utils
|
176
176
|
:synopsis: Adds hashing to Pydantic models.
|
177
177
|
|
178
178
|
.. class:: HashableModel
|
@@ -187,7 +187,7 @@ they are not inherently hashable.
|
|
187
187
|
|
188
188
|
**Example**::
|
189
189
|
|
190
|
-
from lionagi.
|
190
|
+
from lionagi.utils import HashableModel
|
191
191
|
|
192
192
|
class MyConfig(HashableModel):
|
193
193
|
alpha: float
|
@@ -11,6 +11,8 @@ from lionagi.operatives.types import Instruct
|
|
11
11
|
from lionagi.service.imodel import iModel
|
12
12
|
from lionagi.utils import copy
|
13
13
|
|
14
|
+
from .utils import ReActAnalysis
|
15
|
+
|
14
16
|
if TYPE_CHECKING:
|
15
17
|
from lionagi.session.branch import Branch
|
16
18
|
|
@@ -60,11 +62,9 @@ async def ReAct(
|
|
60
62
|
kwargs_for_operate["actions"] = True
|
61
63
|
kwargs_for_operate["reason"] = True
|
62
64
|
|
63
|
-
# We'll pass the refined instruct_dict plus the user's other kwargs
|
64
|
-
from .utils import ReActAnalysis
|
65
|
-
|
66
65
|
# Step 1: Generate initial ReAct analysis
|
67
66
|
analysis: ReActAnalysis = await branch.operate(
|
67
|
+
instruct=instruct_dict,
|
68
68
|
response_format=ReActAnalysis,
|
69
69
|
tools=tools,
|
70
70
|
tool_schemas=tool_schemas,
|
@@ -83,7 +83,7 @@ async def ReAct(
|
|
83
83
|
while (
|
84
84
|
extension_allowed
|
85
85
|
and analysis.extension_needed
|
86
|
-
and (extensions if
|
86
|
+
and (extensions if max_extensions else 0) > 0
|
87
87
|
):
|
88
88
|
new_instruction = None
|
89
89
|
if extensions == max_extensions:
|
@@ -95,17 +95,13 @@ async def ReAct(
|
|
95
95
|
extensions=extensions
|
96
96
|
)
|
97
97
|
|
98
|
-
# Each expansion uses a fresh copy of instruct_dict + forcibly "reason" + "actions"
|
99
|
-
expanded_kwargs = copy(instruct_dict)
|
100
|
-
expanded_kwargs["instruction"] = new_instruction
|
101
|
-
expanded_kwargs["reason"] = True
|
102
|
-
expanded_kwargs["actions"] = True
|
103
|
-
|
104
98
|
analysis = await branch.operate(
|
99
|
+
instruction=new_instruction,
|
105
100
|
response_format=ReActAnalysis,
|
106
101
|
tools=tools,
|
107
102
|
tool_schemas=tool_schemas,
|
108
|
-
|
103
|
+
reason=True,
|
104
|
+
actions=True,
|
109
105
|
)
|
110
106
|
analyses.append(analysis)
|
111
107
|
|
@@ -10,19 +10,19 @@ from pydantic import BaseModel, Field
|
|
10
10
|
class ReActAnalysis(BaseModel):
|
11
11
|
|
12
12
|
FIRST_EXT_PROMPT: ClassVar[str] = (
|
13
|
-
"You are provided with
|
13
|
+
"You are provided with additional rounds to perform reason action to provide an accurate final answer. you have max another {extensions} rounds. Pleasen continue."
|
14
14
|
)
|
15
15
|
|
16
16
|
CONTINUE_EXT_PROMPT: ClassVar[str] = (
|
17
|
-
"You are provided with another round, you have max another {extensions} rounds"
|
17
|
+
"You are provided with another round, you have max another {extensions} rounds. Please continue."
|
18
18
|
)
|
19
19
|
|
20
20
|
ANSWER_PROMPT: ClassVar[str] = (
|
21
|
-
"given above reason and actions, please provide final answer to the original user request {instruction}"
|
21
|
+
"given above reason and actions, please provide final answer to the original user request:\n\n {instruction}"
|
22
22
|
)
|
23
23
|
|
24
24
|
analysis: str
|
25
25
|
extension_needed: bool = Field(
|
26
26
|
False,
|
27
|
-
description="Set to True if more steps are needed to provide an accurate answer. If True, additional rounds are allowed.",
|
27
|
+
description="Set to True if more steps are needed to provide an accurate answer. If True, additional rounds are allowed. Typically should be set to true if more actions should be taken or planned to be taken. If false, will proceed to provide final answer next.",
|
28
28
|
)
|
@@ -5,7 +5,7 @@
|
|
5
5
|
import asyncio
|
6
6
|
from typing import Any
|
7
7
|
|
8
|
-
from pydantic import Field, model_validator
|
8
|
+
from pydantic import BaseModel, Field, field_validator, model_validator
|
9
9
|
from typing_extensions import Self
|
10
10
|
|
11
11
|
from lionagi.protocols.generic.event import Event, EventStatus
|
@@ -27,12 +27,22 @@ class FunctionCalling(Event):
|
|
27
27
|
exclude=True,
|
28
28
|
)
|
29
29
|
|
30
|
-
arguments: dict[str, Any] = Field(
|
30
|
+
arguments: dict[str, Any] | BaseModel = Field(
|
31
31
|
..., description="Dictionary of arguments to pass to the function"
|
32
32
|
)
|
33
33
|
|
34
|
+
@field_validator("arguments", mode="before")
|
35
|
+
def _validate_argument(cls, value):
|
36
|
+
if isinstance(value, BaseModel):
|
37
|
+
return value.model_dump(exclude_unset=True)
|
38
|
+
return value
|
39
|
+
|
34
40
|
@model_validator(mode="after")
|
35
41
|
def _validate_strict_tool(self) -> Self:
|
42
|
+
if self.func_tool.request_options:
|
43
|
+
args: BaseModel = self.func_tool.request_options(**self.arguments)
|
44
|
+
self.arguments = args.model_dump(exclude_unset=True)
|
45
|
+
|
36
46
|
if self.func_tool.strict_func_call is True:
|
37
47
|
if (
|
38
48
|
not set(self.arguments.keys())
|
@@ -12,6 +12,7 @@ import inspect
|
|
12
12
|
from collections.abc import Callable
|
13
13
|
from typing import Any, TypeAlias
|
14
14
|
|
15
|
+
from openai import BaseModel
|
15
16
|
from pydantic import Field, field_validator, model_validator
|
16
17
|
from typing_extensions import Self
|
17
18
|
|
@@ -49,6 +50,11 @@ class Tool(Element):
|
|
49
50
|
description="Schema describing the function's parameters and structure",
|
50
51
|
)
|
51
52
|
|
53
|
+
request_options: type | None = Field(
|
54
|
+
default=None,
|
55
|
+
description="Optional Pydantic model for validating the function's input",
|
56
|
+
)
|
57
|
+
|
52
58
|
preprocessor: Callable[[Any], Any] | None = Field(
|
53
59
|
default=None,
|
54
60
|
description="Optional function for preprocessing inputs before execution",
|
@@ -88,6 +94,11 @@ class Tool(Element):
|
|
88
94
|
def _validate_tool_schema(self) -> Self:
|
89
95
|
if self.tool_schema is None:
|
90
96
|
self.tool_schema = function_to_schema(self.func_callable)
|
97
|
+
if self.request_options is not None:
|
98
|
+
schema_ = self.request_options.model_json_schema()
|
99
|
+
schema_.pop("title", None)
|
100
|
+
self.tool_schema["function"]["parameters"] = schema_
|
101
|
+
|
91
102
|
return self
|
92
103
|
|
93
104
|
@property
|
@@ -27,23 +27,23 @@ class FieldModel(SchemaModel):
|
|
27
27
|
configuration options including type validation, default values, documentation,
|
28
28
|
and validation rules.
|
29
29
|
|
30
|
-
|
31
|
-
name
|
32
|
-
annotation
|
33
|
-
default
|
34
|
-
default_factory
|
35
|
-
validator
|
36
|
-
validator_kwargs
|
37
|
-
title
|
38
|
-
description
|
39
|
-
examples
|
40
|
-
exclude
|
41
|
-
deprecated
|
42
|
-
frozen
|
43
|
-
alias
|
44
|
-
alias_priority
|
45
|
-
|
46
|
-
|
30
|
+
Args:
|
31
|
+
name: Required field identifier.
|
32
|
+
annotation: Field type annotation. Defaults to Any.
|
33
|
+
default: Default value for the field.
|
34
|
+
default_factory: Function to generate default values.
|
35
|
+
validator: Optional validation function.
|
36
|
+
validator_kwargs: Parameters for validator configuration.
|
37
|
+
title: Human-readable field title.
|
38
|
+
description: Detailed field description.
|
39
|
+
examples: Example values for documentation.
|
40
|
+
exclude: Whether to exclude from serialization.
|
41
|
+
deprecated: Whether the field is deprecated.
|
42
|
+
frozen: Whether the field is immutable.
|
43
|
+
alias: Alternative field name.
|
44
|
+
alias_priority: Priority for alias resolution.
|
45
|
+
|
46
|
+
Examples:
|
47
47
|
>>> field = FieldModel(
|
48
48
|
... name="age",
|
49
49
|
... annotation=int,
|
@@ -129,7 +129,14 @@ class FieldModel(SchemaModel):
|
|
129
129
|
|
130
130
|
@field_validator("validator_kwargs", mode="before")
|
131
131
|
def _validate_validator_kwargs(cls, value):
|
132
|
-
"""Validate validator kwargs.
|
132
|
+
"""Validate validator kwargs.
|
133
|
+
|
134
|
+
Args:
|
135
|
+
value: Validator kwargs to validate.
|
136
|
+
|
137
|
+
Returns:
|
138
|
+
Validated kwargs dictionary.
|
139
|
+
"""
|
133
140
|
return validate_dict_kwargs_params(cls, value)
|
134
141
|
|
135
142
|
@field_validator("validator", mode="before")
|
@@ -140,7 +147,7 @@ class FieldModel(SchemaModel):
|
|
140
147
|
value: Validator function to check.
|
141
148
|
|
142
149
|
Returns:
|
143
|
-
|
150
|
+
Validated validator function.
|
144
151
|
|
145
152
|
Raises:
|
146
153
|
ValueError: If validator is not callable.
|
@@ -151,8 +158,11 @@ class FieldModel(SchemaModel):
|
|
151
158
|
def field_info(self) -> FieldInfo:
|
152
159
|
"""Generate Pydantic FieldInfo from current configuration.
|
153
160
|
|
161
|
+
Converts the current field configuration into a Pydantic FieldInfo object,
|
162
|
+
handling annotation defaults and field attributes.
|
163
|
+
|
154
164
|
Returns:
|
155
|
-
|
165
|
+
Configured Pydantic FieldInfo object.
|
156
166
|
"""
|
157
167
|
annotation = (
|
158
168
|
self.annotation if self.annotation is not UNDEFINED else Any
|
@@ -165,8 +175,12 @@ class FieldModel(SchemaModel):
|
|
165
175
|
def field_validator(self) -> dict[str, Callable] | None:
|
166
176
|
"""Create field validator configuration.
|
167
177
|
|
178
|
+
Generates a validator configuration dictionary if a validator function
|
179
|
+
is defined, otherwise returns None.
|
180
|
+
|
168
181
|
Returns:
|
169
|
-
|
182
|
+
Dictionary mapping validator name to validator function if defined,
|
183
|
+
None otherwise.
|
170
184
|
"""
|
171
185
|
if self.validator is UNDEFINED:
|
172
186
|
return None
|
@@ -181,8 +195,11 @@ class FieldModel(SchemaModel):
|
|
181
195
|
def _validate_defaults(self) -> Self:
|
182
196
|
"""Ensure default value configuration is valid.
|
183
197
|
|
198
|
+
Validates that default and default_factory are not both set, as this
|
199
|
+
would create ambiguity about which default to use.
|
200
|
+
|
184
201
|
Returns:
|
185
|
-
|
202
|
+
The validated model instance.
|
186
203
|
|
187
204
|
Raises:
|
188
205
|
ValueError: If both default and default_factory are set.
|
@@ -39,17 +39,28 @@ class ModelParams(SchemaModel):
|
|
39
39
|
fields, validators, and configurations. It supports inheritance from base
|
40
40
|
models, field exclusion, and custom validation rules.
|
41
41
|
|
42
|
-
|
43
|
-
name
|
44
|
-
parameter_fields
|
45
|
-
base_type
|
46
|
-
field_models
|
47
|
-
exclude_fields
|
48
|
-
field_descriptions
|
49
|
-
inherit_base
|
50
|
-
config_dict
|
51
|
-
doc
|
52
|
-
frozen
|
42
|
+
Args:
|
43
|
+
name: Name for the generated model class.
|
44
|
+
parameter_fields: Field definitions for the model.
|
45
|
+
base_type: Base model class to inherit from.
|
46
|
+
field_models: List of field model definitions.
|
47
|
+
exclude_fields: Fields to exclude from the final model.
|
48
|
+
field_descriptions: Custom descriptions for fields.
|
49
|
+
inherit_base: Whether to inherit from base_type.
|
50
|
+
config_dict: Pydantic model configuration.
|
51
|
+
doc: Docstring for the generated model.
|
52
|
+
frozen: Whether the model should be immutable.
|
53
|
+
|
54
|
+
Examples:
|
55
|
+
>>> params = ModelParams(
|
56
|
+
... name="UserModel",
|
57
|
+
... field_models=[
|
58
|
+
... FieldModel(name="username", annotation=str),
|
59
|
+
... FieldModel(name="age", annotation=int, default=0)
|
60
|
+
... ],
|
61
|
+
... doc="A user model with basic attributes."
|
62
|
+
... )
|
63
|
+
>>> UserModel = params.create_new_model()
|
53
64
|
"""
|
54
65
|
|
55
66
|
name: str | None = Field(
|
@@ -99,9 +110,12 @@ class ModelParams(SchemaModel):
|
|
99
110
|
def use_fields(self) -> dict[str, tuple[type, FieldInfo]]:
|
100
111
|
"""Get field definitions to use in new model.
|
101
112
|
|
113
|
+
Filters and combines fields from parameter_fields and field_models based on
|
114
|
+
the _use_keys set, preparing them for use in model creation.
|
115
|
+
|
102
116
|
Returns:
|
103
|
-
|
104
|
-
|
117
|
+
A dictionary mapping field names to tuples of (type, FieldInfo),
|
118
|
+
containing only the fields that should be included in the new model.
|
105
119
|
"""
|
106
120
|
params = {
|
107
121
|
k: v
|
@@ -233,11 +247,16 @@ class ModelParams(SchemaModel):
|
|
233
247
|
def validate_param_model(self) -> Self:
|
234
248
|
"""Validate complete model configuration.
|
235
249
|
|
236
|
-
|
237
|
-
|
250
|
+
Performs comprehensive validation and setup of the model parameters:
|
251
|
+
1. Updates parameter fields from base type if present
|
252
|
+
2. Merges field models into parameter fields
|
253
|
+
3. Manages field inclusion/exclusion via _use_keys
|
254
|
+
4. Sets up validators from field models
|
255
|
+
5. Applies field descriptions
|
256
|
+
6. Handles model name resolution
|
238
257
|
|
239
258
|
Returns:
|
240
|
-
|
259
|
+
The validated model instance with all configurations applied.
|
241
260
|
"""
|
242
261
|
if self.base_type is not None:
|
243
262
|
self.parameter_fields.update(copy(self.base_type.model_fields))
|
@@ -21,34 +21,33 @@ IndiceType: TypeAlias = str | list[str | int]
|
|
21
21
|
class Note(BaseModel):
|
22
22
|
"""Container for managing nested dictionary data structures.
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
Example:
|
31
|
-
```python
|
32
|
-
note = Note(
|
33
|
-
user={
|
34
|
-
"name": "John",
|
35
|
-
"settings": {
|
36
|
-
"theme": "dark"
|
37
|
-
}
|
38
|
-
}
|
39
|
-
)
|
40
|
-
|
41
|
-
# Access nested data
|
42
|
-
name = note.get(["user", "name"])
|
43
|
-
theme = note["user"]["settings"]["theme"]
|
44
|
-
|
45
|
-
# Update nested structure
|
46
|
-
note.update(["user", "settings"], {"language": "en"})
|
47
|
-
```
|
24
|
+
A flexible container that provides deep nested data access, dictionary-like
|
25
|
+
interface, flattening capabilities, and update operations for managing
|
26
|
+
complex nested data structures.
|
27
|
+
|
28
|
+
Args:
|
29
|
+
**kwargs: Key-value pairs for initial content.
|
48
30
|
|
49
31
|
Attributes:
|
50
|
-
content: Nested dictionary structure
|
51
|
-
model_config: Configuration allowing arbitrary types
|
32
|
+
content: Nested dictionary structure.
|
33
|
+
model_config: Configuration allowing arbitrary types.
|
34
|
+
|
35
|
+
Examples:
|
36
|
+
>>> note = Note(
|
37
|
+
... user={
|
38
|
+
... "name": "John",
|
39
|
+
... "settings": {
|
40
|
+
... "theme": "dark"
|
41
|
+
... }
|
42
|
+
... }
|
43
|
+
... )
|
44
|
+
>>>
|
45
|
+
>>> # Access nested data
|
46
|
+
>>> name = note.get(["user", "name"])
|
47
|
+
>>> theme = note["user"]["settings"]["theme"]
|
48
|
+
>>>
|
49
|
+
>>> # Update nested structure
|
50
|
+
>>> note.update(["user", "settings"], {"language": "en"})
|
52
51
|
"""
|
53
52
|
|
54
53
|
content: dict[str, Any] = Field(
|
@@ -65,7 +64,8 @@ class Note(BaseModel):
|
|
65
64
|
"""Initialize Note with dictionary data.
|
66
65
|
|
67
66
|
Args:
|
68
|
-
**kwargs: Key-value pairs
|
67
|
+
**kwargs: Key-value pairs that will form the initial nested
|
68
|
+
dictionary structure.
|
69
69
|
"""
|
70
70
|
super().__init__()
|
71
71
|
self.content = kwargs
|
@@ -103,15 +103,22 @@ class Note(BaseModel):
|
|
103
103
|
) -> Any:
|
104
104
|
"""Remove and return item from nested structure.
|
105
105
|
|
106
|
+
Removes and returns the value at the specified path in the nested
|
107
|
+
structure. If the path doesn't exist and no default is provided,
|
108
|
+
raises KeyError.
|
109
|
+
|
106
110
|
Args:
|
107
|
-
indices: Path to item
|
108
|
-
|
111
|
+
indices: Path to the item to remove, can be a string for top-level
|
112
|
+
keys or a list for nested access.
|
113
|
+
default: Value to return if the path is not found. If not provided
|
114
|
+
and path is not found, raises KeyError.
|
109
115
|
|
110
116
|
Returns:
|
111
|
-
|
117
|
+
The value that was removed, or the default value if provided and
|
118
|
+
path not found.
|
112
119
|
|
113
120
|
Raises:
|
114
|
-
KeyError: If path not found and no default
|
121
|
+
KeyError: If the path is not found and no default value is provided.
|
115
122
|
"""
|
116
123
|
indices = to_list(indices, flatten=True, dropna=True)
|
117
124
|
return npop(self.content, indices, default)
|
@@ -147,15 +154,21 @@ class Note(BaseModel):
|
|
147
154
|
) -> Any:
|
148
155
|
"""Get value from nested structure at specified indices.
|
149
156
|
|
157
|
+
Retrieves the value at the specified path in the nested structure.
|
158
|
+
If the path doesn't exist and no default is provided, raises KeyError.
|
159
|
+
|
150
160
|
Args:
|
151
|
-
indices: Path to value
|
152
|
-
|
161
|
+
indices: Path to the value, can be a string for top-level keys
|
162
|
+
or a list for nested access.
|
163
|
+
default: Value to return if the path is not found. If not provided
|
164
|
+
and path is not found, raises KeyError.
|
153
165
|
|
154
166
|
Returns:
|
155
|
-
|
167
|
+
The value at the specified path, or the default value if provided
|
168
|
+
and path not found.
|
156
169
|
|
157
170
|
Raises:
|
158
|
-
KeyError: If path not found and no default
|
171
|
+
KeyError: If the path is not found and no default value is provided.
|
159
172
|
"""
|
160
173
|
indices = to_list(indices, flatten=True, dropna=True)
|
161
174
|
return nget(self.content, indices, default)
|
@@ -179,12 +192,18 @@ class Note(BaseModel):
|
|
179
192
|
def values(self, /, flat: bool = False, **kwargs: Any) -> ValuesView:
|
180
193
|
"""Get values of the Note.
|
181
194
|
|
195
|
+
Returns either a view of top-level values or, if flat=True, a view
|
196
|
+
of all values in the flattened nested structure.
|
197
|
+
|
182
198
|
Args:
|
183
|
-
flat: If True,
|
184
|
-
|
199
|
+
flat: If True, returns values from all levels of the nested
|
200
|
+
structure. If False, returns only top-level values.
|
201
|
+
kwargs: Additional options for flattening behavior when flat=True.
|
202
|
+
Common options include coerce_keys and coerce_sequence.
|
185
203
|
|
186
204
|
Returns:
|
187
|
-
|
205
|
+
A ValuesView object containing either top-level values or all
|
206
|
+
values from the flattened structure if flat=True.
|
188
207
|
"""
|
189
208
|
if flat:
|
190
209
|
kwargs["coerce_keys"] = kwargs.get("coerce_keys", False)
|
@@ -219,12 +238,21 @@ class Note(BaseModel):
|
|
219
238
|
) -> None:
|
220
239
|
"""Update nested structure at specified indices.
|
221
240
|
|
241
|
+
Updates the value at the specified path in the nested structure.
|
242
|
+
The behavior depends on the existing value and the update value:
|
243
|
+
- If path doesn't exist: creates it with value (wrapped in list if scalar)
|
244
|
+
- If existing is list: extends with value if list, appends if scalar
|
245
|
+
- If existing is dict: updates with value if dict, raises error if not
|
246
|
+
|
222
247
|
Args:
|
223
|
-
indices:
|
224
|
-
|
248
|
+
indices: Path to the location to update, can be a string for
|
249
|
+
top-level keys or a list for nested access.
|
250
|
+
value: The new value to set. Must be compatible with existing
|
251
|
+
value type (dict for dict, any value for list).
|
225
252
|
|
226
253
|
Raises:
|
227
|
-
ValueError: If trying to update
|
254
|
+
ValueError: If trying to update a dictionary with a non-dictionary
|
255
|
+
value.
|
228
256
|
"""
|
229
257
|
existing = None
|
230
258
|
if not indices:
|
@@ -269,19 +297,26 @@ class Note(BaseModel):
|
|
269
297
|
def __contains__(self, indices: IndiceType) -> bool:
|
270
298
|
"""Check if indices exist in content.
|
271
299
|
|
300
|
+
Implements the 'in' operator for checking path existence in the nested
|
301
|
+
structure.
|
302
|
+
|
272
303
|
Args:
|
273
|
-
indices: Path to check
|
304
|
+
indices: Path to check, can be a string for top-level keys or a
|
305
|
+
list for nested access.
|
274
306
|
|
275
307
|
Returns:
|
276
|
-
True if path exists, False otherwise
|
308
|
+
True if the path exists in the nested structure, False otherwise.
|
277
309
|
"""
|
278
310
|
return self.content.get(indices, UNDEFINED) is not UNDEFINED
|
279
311
|
|
280
312
|
def __len__(self) -> int:
|
281
313
|
"""Get length of content.
|
282
314
|
|
315
|
+
Implements len() function to return the number of top-level keys in
|
316
|
+
the nested structure.
|
317
|
+
|
283
318
|
Returns:
|
284
|
-
|
319
|
+
The number of top-level keys in the content dictionary.
|
285
320
|
"""
|
286
321
|
return len(self.content)
|
287
322
|
|
@@ -305,8 +340,12 @@ class Note(BaseModel):
|
|
305
340
|
def __str__(self) -> str:
|
306
341
|
"""Get string representation of content.
|
307
342
|
|
343
|
+
Implements str() function to provide a simple string representation
|
344
|
+
of the Note's content. Uses the standard dictionary string format.
|
345
|
+
|
308
346
|
Returns:
|
309
|
-
|
347
|
+
A string representation of the content dictionary, showing its
|
348
|
+
current state.
|
310
349
|
"""
|
311
350
|
return str(self.content)
|
312
351
|
|