unique_toolkit 1.32.1__tar.gz → 1.33.1__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.
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/CHANGELOG.md +6 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/PKG-INFO +7 -1
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/pyproject.toml +1 -1
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/__init__.py +12 -6
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/_common/utils/jinja/render.py +7 -1
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/tools/a2a/tool/config.py +77 -1
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/tools/a2a/tool/service.py +67 -3
- unique_toolkit-1.33.1/unique_toolkit/data_extraction/README.md +96 -0
- unique_toolkit-1.33.1/unique_toolkit/data_extraction/__init__.py +11 -0
- unique_toolkit-1.33.1/unique_toolkit/data_extraction/augmented/__init__.py +5 -0
- unique_toolkit-1.33.1/unique_toolkit/data_extraction/augmented/service.py +93 -0
- unique_toolkit-1.33.1/unique_toolkit/data_extraction/base.py +25 -0
- unique_toolkit-1.33.1/unique_toolkit/data_extraction/basic/__init__.py +11 -0
- unique_toolkit-1.33.1/unique_toolkit/data_extraction/basic/config.py +18 -0
- unique_toolkit-1.33.1/unique_toolkit/data_extraction/basic/prompt.py +13 -0
- unique_toolkit-1.33.1/unique_toolkit/data_extraction/basic/service.py +55 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/LICENSE +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/README.md +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/_common/_base_service.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/_common/_time_utils.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/_common/api_calling/human_verification_manager.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/_common/base_model_type_attribute.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/_common/chunk_relevancy_sorter/config.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/_common/chunk_relevancy_sorter/exception.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/_common/chunk_relevancy_sorter/schemas.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/_common/chunk_relevancy_sorter/service.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/_common/chunk_relevancy_sorter/tests/test_service.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/_common/default_language_model.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/_common/docx_generator/__init__.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/_common/docx_generator/config.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/_common/docx_generator/schemas.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/_common/docx_generator/service.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/_common/docx_generator/template/Doc Template.docx +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/_common/endpoint_builder.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/_common/endpoint_requestor.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/_common/exception.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/_common/experimental/endpoint_builder.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/_common/experimental/endpoint_requestor.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/_common/feature_flags/schema.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/_common/pydantic/rjsf_tags.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/_common/pydantic_helpers.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/_common/referencing.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/_common/string_utilities.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/_common/tests/test_referencing.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/_common/tests/test_string_utilities.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/_common/token/image_token_counting.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/_common/token/token_counting.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/_common/utils/__init__.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/_common/utils/files.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/_common/utils/image/encode.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/_common/utils/jinja/helpers.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/_common/utils/jinja/schema.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/_common/utils/jinja/utils.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/_common/utils/structured_output/__init__.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/_common/utils/structured_output/schema.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/_common/utils/write_configuration.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/_common/validate_required_values.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/_common/validators.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/__init__.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/debug_info_manager/debug_info_manager.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/debug_info_manager/test/test_debug_info_manager.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/evaluation/config.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/evaluation/context_relevancy/prompts.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/evaluation/context_relevancy/schema.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/evaluation/context_relevancy/service.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/evaluation/evaluation_manager.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/evaluation/exception.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/evaluation/hallucination/constants.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/evaluation/hallucination/hallucination_evaluation.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/evaluation/hallucination/prompts.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/evaluation/hallucination/service.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/evaluation/hallucination/utils.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/evaluation/output_parser.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/evaluation/schemas.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/evaluation/tests/test_context_relevancy_service.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/evaluation/tests/test_output_parser.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/history_manager/history_construction_with_contents.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/history_manager/history_manager.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/history_manager/loop_token_reducer.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/history_manager/utils.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/message_log_manager/__init__.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/message_log_manager/service.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/postprocessor/postprocessor_manager.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/reference_manager/reference_manager.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/responses_api/__init__.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/responses_api/postprocessors/code_display.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/responses_api/postprocessors/generated_files.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/responses_api/stream_handler.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/short_term_memory_manager/persistent_short_term_memory_manager.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/thinking_manager/thinking_manager.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/tools/__init__.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/tools/a2a/__init__.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/tools/a2a/config.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/tools/a2a/evaluation/__init__.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/tools/a2a/evaluation/_utils.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/tools/a2a/evaluation/config.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/tools/a2a/evaluation/evaluator.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/tools/a2a/evaluation/summarization_user_message.j2 +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/tools/a2a/manager.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/tools/a2a/postprocessing/__init__.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/tools/a2a/postprocessing/_display_utils.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/tools/a2a/postprocessing/_ref_utils.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/tools/a2a/postprocessing/config.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/tools/a2a/postprocessing/display.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/tools/a2a/postprocessing/references.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/tools/a2a/postprocessing/test/test_display.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/tools/a2a/postprocessing/test/test_display_utils.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/tools/a2a/postprocessing/test/test_ref_utils.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/tools/a2a/prompts.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/tools/a2a/response_watcher/__init__.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/tools/a2a/response_watcher/service.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/tools/a2a/tool/__init__.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/tools/a2a/tool/_memory.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/tools/a2a/tool/_schema.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/tools/agent_chunks_hanlder.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/tools/config.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/tools/factory.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/tools/mcp/__init__.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/tools/mcp/manager.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/tools/mcp/models.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/tools/mcp/tool_wrapper.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/tools/openai_builtin/__init__.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/tools/openai_builtin/base.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/tools/openai_builtin/code_interpreter/__init__.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/tools/openai_builtin/code_interpreter/config.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/tools/openai_builtin/code_interpreter/service.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/tools/openai_builtin/manager.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/tools/schemas.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/tools/test/test_mcp_manager.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/tools/test/test_tool_progress_reporter.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/tools/tool.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/tools/tool_manager.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/tools/tool_progress_reporter.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/tools/utils/__init__.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/tools/utils/execution/__init__.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/tools/utils/execution/execution.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/tools/utils/source_handling/__init__.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/tools/utils/source_handling/schema.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/tools/utils/source_handling/source_formatting.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/tools/utils/source_handling/tests/test_source_formatting.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/app/__init__.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/app/dev_util.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/app/fast_api_factory.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/app/init_logging.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/app/init_sdk.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/app/performance/async_tasks.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/app/performance/async_wrapper.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/app/schemas.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/app/unique_settings.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/app/verification.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/app/webhook.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/chat/__init__.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/chat/constants.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/chat/deprecated/service.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/chat/functions.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/chat/rendering.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/chat/responses_api.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/chat/schemas.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/chat/service.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/chat/state.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/chat/utils.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/content/__init__.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/content/constants.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/content/functions.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/content/schemas.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/content/service.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/content/smart_rules.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/content/utils.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/embedding/__init__.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/embedding/constants.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/embedding/functions.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/embedding/schemas.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/embedding/service.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/embedding/utils.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/framework_utilities/__init__.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/framework_utilities/langchain/__init__.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/framework_utilities/langchain/client.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/framework_utilities/langchain/history.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/framework_utilities/openai/__init__.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/framework_utilities/openai/client.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/framework_utilities/openai/message_builder.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/framework_utilities/utils.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/language_model/__init__.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/language_model/_responses_api_utils.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/language_model/builder.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/language_model/constants.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/language_model/default_language_model.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/language_model/functions.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/language_model/infos.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/language_model/prompt.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/language_model/reference.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/language_model/schemas.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/language_model/service.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/language_model/utils.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/protocols/support.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/services/__init__.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/services/chat_service.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/services/knowledge_base.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/short_term_memory/__init__.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/short_term_memory/constants.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/short_term_memory/functions.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/short_term_memory/schemas.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/short_term_memory/service.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/smart_rules/__init__.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/smart_rules/compile.py +0 -0
- {unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/test_utilities/events.py +0 -0
|
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.33.1] - 2025-12-01
|
|
9
|
+
- Add `data_extraction` to unique_toolkit
|
|
10
|
+
|
|
11
|
+
## [1.33.0] - 2025-11-28
|
|
12
|
+
- Add support for system reminders in sub agent responses.
|
|
13
|
+
|
|
8
14
|
## [1.32.1] - 2025-12-01
|
|
9
15
|
- Added documentation for the toolkit,some missing type hints and doc string fixes.
|
|
10
16
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: unique_toolkit
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.33.1
|
|
4
4
|
Summary:
|
|
5
5
|
License: Proprietary
|
|
6
6
|
Author: Cedric Klinkert
|
|
@@ -121,6 +121,12 @@ All notable changes to this project will be documented in this file.
|
|
|
121
121
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
122
122
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
123
123
|
|
|
124
|
+
## [1.33.1] - 2025-12-01
|
|
125
|
+
- Add `data_extraction` to unique_toolkit
|
|
126
|
+
|
|
127
|
+
## [1.33.0] - 2025-11-28
|
|
128
|
+
- Add support for system reminders in sub agent responses.
|
|
129
|
+
|
|
124
130
|
## [1.32.1] - 2025-12-01
|
|
125
131
|
- Added documentation for the toolkit,some missing type hints and doc string fixes.
|
|
126
132
|
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
# Re-export commonly used classes for easier imports
|
|
2
2
|
from unique_toolkit.chat import ChatService
|
|
3
3
|
from unique_toolkit.content import ContentService
|
|
4
|
+
from unique_toolkit.data_extraction import (
|
|
5
|
+
StructuredOutputDataExtractor,
|
|
6
|
+
StructuredOutputDataExtractorConfig,
|
|
7
|
+
)
|
|
4
8
|
from unique_toolkit.embedding import EmbeddingService
|
|
5
9
|
from unique_toolkit.framework_utilities.openai.client import (
|
|
6
10
|
get_async_openai_client,
|
|
@@ -26,17 +30,19 @@ except ImportError:
|
|
|
26
30
|
# You can add other classes you frequently use here as well
|
|
27
31
|
|
|
28
32
|
__all__ = [
|
|
29
|
-
"LanguageModelService",
|
|
30
|
-
"LanguageModelMessages",
|
|
31
|
-
"LanguageModelName",
|
|
32
|
-
"LanguageModelToolDescription",
|
|
33
33
|
"ChatService",
|
|
34
34
|
"ContentService",
|
|
35
35
|
"EmbeddingService",
|
|
36
|
-
"ShortTermMemoryService",
|
|
37
|
-
"KnowledgeBaseService",
|
|
38
36
|
"get_openai_client",
|
|
39
37
|
"get_async_openai_client",
|
|
38
|
+
"KnowledgeBaseService",
|
|
39
|
+
"LanguageModelMessages",
|
|
40
|
+
"LanguageModelName",
|
|
41
|
+
"LanguageModelService",
|
|
42
|
+
"LanguageModelToolDescription",
|
|
43
|
+
"ShortTermMemoryService",
|
|
44
|
+
"StructuredOutputDataExtractor",
|
|
45
|
+
"StructuredOutputDataExtractorConfig",
|
|
40
46
|
]
|
|
41
47
|
|
|
42
48
|
# Add langchain-specific exports if available
|
{unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/_common/utils/jinja/render.py
RENAMED
|
@@ -5,8 +5,14 @@ from jinja2 import Template
|
|
|
5
5
|
from unique_toolkit._common.utils.jinja.schema import Jinja2PromptParams
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
def render_template(
|
|
8
|
+
def render_template(
|
|
9
|
+
template: str, params: Jinja2PromptParams | dict[str, Any] | None = None, **kwargs
|
|
10
|
+
) -> str:
|
|
11
|
+
params = params or {}
|
|
12
|
+
|
|
9
13
|
if isinstance(params, Jinja2PromptParams):
|
|
10
14
|
params = params.model_dump(exclude_none=True, mode="json")
|
|
11
15
|
|
|
16
|
+
params.update(kwargs)
|
|
17
|
+
|
|
12
18
|
return Template(template, lstrip_blocks=True).render(**params)
|
{unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/tools/a2a/tool/config.py
RENAMED
|
@@ -1,10 +1,74 @@
|
|
|
1
|
-
|
|
1
|
+
import re
|
|
2
|
+
from enum import StrEnum
|
|
3
|
+
from typing import Annotated, Generic, Literal, TypeVar
|
|
2
4
|
|
|
3
5
|
from pydantic import Field
|
|
6
|
+
from pydantic.main import BaseModel
|
|
4
7
|
|
|
5
8
|
from unique_toolkit._common.pydantic_helpers import get_configuration_dict
|
|
6
9
|
from unique_toolkit.agentic.tools.schemas import BaseToolConfig
|
|
7
10
|
|
|
11
|
+
|
|
12
|
+
class SubAgentSystemReminderType(StrEnum):
|
|
13
|
+
FIXED = "fixed"
|
|
14
|
+
REGEXP = "regexp"
|
|
15
|
+
REFERENCE = "reference"
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
T = TypeVar("T", bound=SubAgentSystemReminderType)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class SystemReminderConfig(BaseModel, Generic[T]):
|
|
22
|
+
model_config = get_configuration_dict()
|
|
23
|
+
|
|
24
|
+
type: T
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
_SYSTEM_REMINDER_FIELD_DESCRIPTION = """
|
|
28
|
+
The reminder to add to the tool response. The reminder can be a Jinja template and can contain the following placeholders:
|
|
29
|
+
- {{ display_name }}: The display name of the sub agent.
|
|
30
|
+
- {{ tool_name }}: The tool name.
|
|
31
|
+
""".strip()
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class ReferenceSystemReminderConfig(SystemReminderConfig):
|
|
35
|
+
type: Literal[SubAgentSystemReminderType.REFERENCE] = (
|
|
36
|
+
SubAgentSystemReminderType.REFERENCE
|
|
37
|
+
)
|
|
38
|
+
reminder: str = Field(
|
|
39
|
+
default="Rememeber to properly reference EACH fact from sub agent {{ display_name }}'s response with the correct format INLINE.",
|
|
40
|
+
description=_SYSTEM_REMINDER_FIELD_DESCRIPTION,
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class FixedSystemReminderConfig(SystemReminderConfig):
|
|
45
|
+
type: Literal[SubAgentSystemReminderType.FIXED] = SubAgentSystemReminderType.FIXED
|
|
46
|
+
reminder: str = Field(
|
|
47
|
+
description=_SYSTEM_REMINDER_FIELD_DESCRIPTION,
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
_REGEXP_DETECTED_REMINDER_FIELD_DESCRIPTION = """
|
|
52
|
+
The reminder to add to the tool response. The reminder can be a Jinja template and can contain the following placeholders:
|
|
53
|
+
- {{ display_name }}: The display name of the sub agent.
|
|
54
|
+
- {{ tool_name }}: The tool name.
|
|
55
|
+
- {{ text_matches }}: Will be replaced with the portions of the text that triggered the reminder.
|
|
56
|
+
""".strip()
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
class RegExpDetectedSystemReminderConfig(SystemReminderConfig):
|
|
60
|
+
"""A system reminder that is only added if the sub agent response matches a regular expression."""
|
|
61
|
+
|
|
62
|
+
type: Literal[SubAgentSystemReminderType.REGEXP] = SubAgentSystemReminderType.REGEXP
|
|
63
|
+
|
|
64
|
+
regexp: re.Pattern[str] = Field(
|
|
65
|
+
description="The regular expression to use to detect whether the system reminder should be added.",
|
|
66
|
+
)
|
|
67
|
+
reminder: str = Field(
|
|
68
|
+
description=_REGEXP_DETECTED_REMINDER_FIELD_DESCRIPTION,
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
|
|
8
72
|
DEFAULT_PARAM_DESCRIPTION_SUB_AGENT_USER_MESSAGE = """
|
|
9
73
|
This is the message that will be sent to the sub-agent.
|
|
10
74
|
""".strip()
|
|
@@ -80,3 +144,15 @@ class SubAgentToolConfig(BaseToolConfig):
|
|
|
80
144
|
default=False,
|
|
81
145
|
description="If set, the sub-agent response will be interpreted as a list of content chunks.",
|
|
82
146
|
)
|
|
147
|
+
|
|
148
|
+
system_reminders_config: list[
|
|
149
|
+
Annotated[
|
|
150
|
+
FixedSystemReminderConfig
|
|
151
|
+
| RegExpDetectedSystemReminderConfig
|
|
152
|
+
| ReferenceSystemReminderConfig,
|
|
153
|
+
Field(discriminator="type"),
|
|
154
|
+
]
|
|
155
|
+
] = Field(
|
|
156
|
+
default=[],
|
|
157
|
+
description="Configuration for the system reminders to add to the tool response.",
|
|
158
|
+
)
|
{unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/agentic/tools/a2a/tool/service.py
RENAMED
|
@@ -4,7 +4,7 @@ import json
|
|
|
4
4
|
import logging
|
|
5
5
|
import re
|
|
6
6
|
from datetime import datetime
|
|
7
|
-
from typing import override
|
|
7
|
+
from typing import cast, override
|
|
8
8
|
|
|
9
9
|
import unique_sdk
|
|
10
10
|
from pydantic import Field, TypeAdapter, create_model
|
|
@@ -15,6 +15,7 @@ from unique_toolkit._common.referencing import (
|
|
|
15
15
|
remove_all_refs,
|
|
16
16
|
replace_ref_number,
|
|
17
17
|
)
|
|
18
|
+
from unique_toolkit._common.utils.jinja.render import render_template
|
|
18
19
|
from unique_toolkit.agentic.evaluation.schemas import EvaluationMetricName
|
|
19
20
|
from unique_toolkit.agentic.tools.a2a.response_watcher import SubAgentResponseWatcher
|
|
20
21
|
from unique_toolkit.agentic.tools.a2a.tool._memory import (
|
|
@@ -25,6 +26,8 @@ from unique_toolkit.agentic.tools.a2a.tool._schema import (
|
|
|
25
26
|
SubAgentToolInput,
|
|
26
27
|
)
|
|
27
28
|
from unique_toolkit.agentic.tools.a2a.tool.config import (
|
|
29
|
+
RegExpDetectedSystemReminderConfig,
|
|
30
|
+
SubAgentSystemReminderType,
|
|
28
31
|
SubAgentToolConfig,
|
|
29
32
|
)
|
|
30
33
|
from unique_toolkit.agentic.tools.factory import ToolFactory
|
|
@@ -215,12 +218,63 @@ class SubAgentTool(Tool[SubAgentToolConfig]):
|
|
|
215
218
|
)
|
|
216
219
|
|
|
217
220
|
return ToolCallResponse(
|
|
218
|
-
id=tool_call.id,
|
|
221
|
+
id=tool_call.id,
|
|
219
222
|
name=tool_call.name,
|
|
220
|
-
content=
|
|
223
|
+
content=_format_response(
|
|
224
|
+
tool_name=self.name,
|
|
225
|
+
text=content,
|
|
226
|
+
system_reminders=self._get_system_reminders(response),
|
|
227
|
+
),
|
|
221
228
|
content_chunks=content_chunks,
|
|
222
229
|
)
|
|
223
230
|
|
|
231
|
+
def _get_system_reminders(self, message: unique_sdk.Space.Message) -> list[str]:
|
|
232
|
+
reminders = []
|
|
233
|
+
for reminder_config in self.config.system_reminders_config:
|
|
234
|
+
if reminder_config.type == SubAgentSystemReminderType.FIXED:
|
|
235
|
+
reminders.append(
|
|
236
|
+
render_template(
|
|
237
|
+
reminder_config.reminder,
|
|
238
|
+
display_name=self.display_name(),
|
|
239
|
+
tool_name=self.name,
|
|
240
|
+
)
|
|
241
|
+
)
|
|
242
|
+
elif (
|
|
243
|
+
reminder_config.type == SubAgentSystemReminderType.REFERENCE
|
|
244
|
+
and self.config.use_sub_agent_references
|
|
245
|
+
and message["references"] is not None
|
|
246
|
+
and len(message["references"]) > 0
|
|
247
|
+
):
|
|
248
|
+
reminders.append(
|
|
249
|
+
render_template(
|
|
250
|
+
reminder_config.reminder,
|
|
251
|
+
display_name=self.display_name(),
|
|
252
|
+
tool_name=self.name,
|
|
253
|
+
)
|
|
254
|
+
)
|
|
255
|
+
elif (
|
|
256
|
+
reminder_config.type == SubAgentSystemReminderType.REGEXP
|
|
257
|
+
and message["text"] is not None
|
|
258
|
+
):
|
|
259
|
+
reminder_config = cast(
|
|
260
|
+
RegExpDetectedSystemReminderConfig, reminder_config
|
|
261
|
+
)
|
|
262
|
+
text_matches = [
|
|
263
|
+
match.group(0)
|
|
264
|
+
for match in reminder_config.regexp.finditer(message["text"])
|
|
265
|
+
]
|
|
266
|
+
if len(text_matches) > 0:
|
|
267
|
+
reminders.append(
|
|
268
|
+
render_template(
|
|
269
|
+
reminder_config.reminder,
|
|
270
|
+
display_name=self.display_name(),
|
|
271
|
+
tool_name=self.name,
|
|
272
|
+
text_matches=text_matches,
|
|
273
|
+
)
|
|
274
|
+
)
|
|
275
|
+
|
|
276
|
+
return reminders
|
|
277
|
+
|
|
224
278
|
async def _get_chat_id(self) -> str | None:
|
|
225
279
|
if not self.config.reuse_chat:
|
|
226
280
|
return None
|
|
@@ -326,4 +380,14 @@ class SubAgentTool(Tool[SubAgentToolConfig]):
|
|
|
326
380
|
) from e
|
|
327
381
|
|
|
328
382
|
|
|
383
|
+
def _format_response(tool_name: str, text: str, system_reminders: list[str]) -> str:
|
|
384
|
+
if len(system_reminders) == 0:
|
|
385
|
+
return text
|
|
386
|
+
|
|
387
|
+
reponse_key = f"{tool_name} response"
|
|
388
|
+
response = {reponse_key: text, "SYSTEM_REMINDERS": system_reminders}
|
|
389
|
+
|
|
390
|
+
return json.dumps(response, indent=2)
|
|
391
|
+
|
|
392
|
+
|
|
329
393
|
ToolFactory.register_tool(SubAgentTool, SubAgentToolConfig)
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# Data Extraction Module
|
|
2
|
+
|
|
3
|
+
This module provides a flexible framework for extracting structured data from text using language models. It supports both basic and augmented data extraction capabilities.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
The module consists of two main components:
|
|
8
|
+
|
|
9
|
+
1. **Basic Data Extraction**: Uses language models to extract structured data from text based on a provided schema.
|
|
10
|
+
2. **Augmented Data Extraction**: Extends basic extraction by adding extra fields to the output schema while maintaining the original data structure.
|
|
11
|
+
|
|
12
|
+
## Components
|
|
13
|
+
|
|
14
|
+
### Base Classes
|
|
15
|
+
|
|
16
|
+
- `BaseDataExtractor`: Abstract base class that defines the interface for data extraction
|
|
17
|
+
- `BaseDataExtractionResult`: Generic base class for extraction results
|
|
18
|
+
|
|
19
|
+
### Basic Extraction
|
|
20
|
+
|
|
21
|
+
- `StructuredOutputDataExtractor`: Implements basic data extraction using language models
|
|
22
|
+
- `StructuredOutputDataExtractorConfig`: Configuration for the basic extractor
|
|
23
|
+
|
|
24
|
+
### Augmented Extraction
|
|
25
|
+
|
|
26
|
+
- `AugmentedDataExtractor`: Extends basic extraction with additional fields
|
|
27
|
+
- `AugmentedDataExtractionResult`: Result type for augmented extraction
|
|
28
|
+
|
|
29
|
+
## Usage Examples
|
|
30
|
+
|
|
31
|
+
### Basic Data Extraction
|
|
32
|
+
|
|
33
|
+
```python
|
|
34
|
+
from pydantic import BaseModel
|
|
35
|
+
from unique_toolkit._common.data_extraction import StructuredOutputDataExtractor, StructuredOutputDataExtractorConfig
|
|
36
|
+
from unique_toolkit import LanguageModelService
|
|
37
|
+
|
|
38
|
+
# Define your schema
|
|
39
|
+
class PersonInfo(BaseModel):
|
|
40
|
+
name: str
|
|
41
|
+
age: int
|
|
42
|
+
occupation: str
|
|
43
|
+
|
|
44
|
+
# Create the extractor
|
|
45
|
+
config = StructuredOutputDataExtractorConfig()
|
|
46
|
+
lm_service = LanguageModelService() # Configure as needed
|
|
47
|
+
extractor = StructuredOutputDataExtractor(config, lm_service)
|
|
48
|
+
|
|
49
|
+
# Extract data
|
|
50
|
+
text = "John is 30 years old and works as a software engineer."
|
|
51
|
+
result = await extractor.extract_data_from_text(text, PersonInfo)
|
|
52
|
+
print(result.data) # PersonInfo(name="John", age=30, occupation="software engineer")
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Augmented Data Extraction
|
|
56
|
+
|
|
57
|
+
```python
|
|
58
|
+
from pydantic import BaseModel, Field
|
|
59
|
+
from _common.data_extraction import AugmentedDataExtractor, StructuredOutputDataExtractor
|
|
60
|
+
|
|
61
|
+
# Define your base schema
|
|
62
|
+
class PersonInfo(BaseModel):
|
|
63
|
+
name: str
|
|
64
|
+
age: int
|
|
65
|
+
|
|
66
|
+
# Create base extractor
|
|
67
|
+
base_extractor = StructuredOutputDataExtractor(...)
|
|
68
|
+
|
|
69
|
+
# Create augmented extractor with confidence scores
|
|
70
|
+
augmented_extractor = AugmentedDataExtractor(
|
|
71
|
+
base_extractor,
|
|
72
|
+
confidence=float,
|
|
73
|
+
source=("extracted", Field(description="Source of the information"))
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
# Extract data
|
|
77
|
+
text = "John is 30 years old."
|
|
78
|
+
result = await augmented_extractor.extract_data_from_text(text, PersonInfo)
|
|
79
|
+
print(result.data) # Original PersonInfo
|
|
80
|
+
print(result.augmented_data) # Contains additional fields
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Configuration
|
|
84
|
+
|
|
85
|
+
The `StructuredOutputDataExtractorConfig` allows customization of:
|
|
86
|
+
|
|
87
|
+
- Language model selection
|
|
88
|
+
- System and user prompt templates
|
|
89
|
+
- Schema enforcement settings
|
|
90
|
+
|
|
91
|
+
## Best Practices
|
|
92
|
+
|
|
93
|
+
1. Always define clear Pydantic models for your extraction schemas
|
|
94
|
+
2. Use augmented extraction when you need additional metadata
|
|
95
|
+
3. Consider using strict mode for augmented extraction when you want to enforce schema compliance
|
|
96
|
+
4. Customize prompts for better extraction results in specific domains
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
from unique_toolkit.data_extraction.augmented import AugmentedDataExtractor
|
|
2
|
+
from unique_toolkit.data_extraction.basic import (
|
|
3
|
+
StructuredOutputDataExtractor,
|
|
4
|
+
StructuredOutputDataExtractorConfig,
|
|
5
|
+
)
|
|
6
|
+
|
|
7
|
+
__all__ = [
|
|
8
|
+
"StructuredOutputDataExtractor",
|
|
9
|
+
"StructuredOutputDataExtractorConfig",
|
|
10
|
+
"AugmentedDataExtractor",
|
|
11
|
+
]
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
from docxtpl.template import Any
|
|
2
|
+
from pydantic import BaseModel, create_model
|
|
3
|
+
from pydantic.alias_generators import to_pascal
|
|
4
|
+
from pydantic.fields import FieldInfo
|
|
5
|
+
from typing_extensions import override
|
|
6
|
+
|
|
7
|
+
from unique_toolkit.data_extraction.base import (
|
|
8
|
+
BaseDataExtractionResult,
|
|
9
|
+
BaseDataExtractor,
|
|
10
|
+
ExtractionSchema,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def _build_augmented_model_for_field(
|
|
15
|
+
field_name: str,
|
|
16
|
+
field_type: Any | tuple[Any, FieldInfo],
|
|
17
|
+
strict: bool = False,
|
|
18
|
+
**extra_fields: Any | tuple[Any, FieldInfo],
|
|
19
|
+
) -> type[BaseModel]:
|
|
20
|
+
camelized_field_name = to_pascal(field_name)
|
|
21
|
+
|
|
22
|
+
fields = {
|
|
23
|
+
**extra_fields,
|
|
24
|
+
field_name: field_type,
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return create_model(
|
|
28
|
+
f"{camelized_field_name}Value",
|
|
29
|
+
**fields, # type: ignore
|
|
30
|
+
__config__={"extra": "forbid" if strict else "ignore"},
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class AugmentedDataExtractionResult(BaseDataExtractionResult[ExtractionSchema]):
|
|
35
|
+
"""
|
|
36
|
+
Result of data extraction from text using an augmented schema.
|
|
37
|
+
"""
|
|
38
|
+
|
|
39
|
+
augmented_data: BaseModel
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class AugmentedDataExtractor(BaseDataExtractor):
|
|
43
|
+
def __init__(
|
|
44
|
+
self,
|
|
45
|
+
base_data_extractor: BaseDataExtractor,
|
|
46
|
+
strict: bool = False,
|
|
47
|
+
**extra_fields: Any | tuple[Any, FieldInfo],
|
|
48
|
+
):
|
|
49
|
+
self._base_data_extractor = base_data_extractor
|
|
50
|
+
self._extra_fields = extra_fields
|
|
51
|
+
self._strict = strict
|
|
52
|
+
|
|
53
|
+
def _prepare_schema(self, schema: type[ExtractionSchema]) -> type[BaseModel]:
|
|
54
|
+
fields = {}
|
|
55
|
+
|
|
56
|
+
for field_name, field_type in schema.model_fields.items():
|
|
57
|
+
wrapped_field = _build_augmented_model_for_field(
|
|
58
|
+
field_name,
|
|
59
|
+
(field_type.annotation, field_type),
|
|
60
|
+
strict=self._strict,
|
|
61
|
+
**self._extra_fields,
|
|
62
|
+
)
|
|
63
|
+
fields[field_name] = wrapped_field
|
|
64
|
+
|
|
65
|
+
return create_model(
|
|
66
|
+
schema.__name__,
|
|
67
|
+
**fields,
|
|
68
|
+
__config__={"extra": "forbid" if self._strict else "ignore"},
|
|
69
|
+
__doc__=schema.__doc__,
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
def _extract_output(
|
|
73
|
+
self, llm_output: BaseModel, schema: type[ExtractionSchema]
|
|
74
|
+
) -> ExtractionSchema:
|
|
75
|
+
output_data = {
|
|
76
|
+
field_name: getattr(value, field_name) for field_name, value in llm_output
|
|
77
|
+
}
|
|
78
|
+
return schema.model_validate(output_data)
|
|
79
|
+
|
|
80
|
+
@override
|
|
81
|
+
async def extract_data_from_text(
|
|
82
|
+
self, text: str, schema: type[ExtractionSchema]
|
|
83
|
+
) -> AugmentedDataExtractionResult[ExtractionSchema]:
|
|
84
|
+
model_with_extra_fields = self._prepare_schema(schema)
|
|
85
|
+
augmented_data = (
|
|
86
|
+
await self._base_data_extractor.extract_data_from_text(
|
|
87
|
+
text, model_with_extra_fields
|
|
88
|
+
)
|
|
89
|
+
).data
|
|
90
|
+
return AugmentedDataExtractionResult(
|
|
91
|
+
data=self._extract_output(augmented_data, schema),
|
|
92
|
+
augmented_data=augmented_data,
|
|
93
|
+
)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
from abc import ABC, abstractmethod
|
|
2
|
+
from typing import Generic, TypeVar
|
|
3
|
+
|
|
4
|
+
from pydantic import BaseModel
|
|
5
|
+
|
|
6
|
+
ExtractionSchema = TypeVar("ExtractionSchema", bound=BaseModel)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class BaseDataExtractionResult(BaseModel, Generic[ExtractionSchema]):
|
|
10
|
+
"""
|
|
11
|
+
Base class for data extraction results.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
data: ExtractionSchema
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class BaseDataExtractor(ABC):
|
|
18
|
+
"""
|
|
19
|
+
Extract structured data from text.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
@abstractmethod
|
|
23
|
+
async def extract_data_from_text(
|
|
24
|
+
self, text: str, schema: type[ExtractionSchema]
|
|
25
|
+
) -> BaseDataExtractionResult[ExtractionSchema]: ...
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
from unique_toolkit.data_extraction.basic.config import (
|
|
2
|
+
StructuredOutputDataExtractorConfig,
|
|
3
|
+
)
|
|
4
|
+
from unique_toolkit.data_extraction.basic.service import (
|
|
5
|
+
StructuredOutputDataExtractor,
|
|
6
|
+
)
|
|
7
|
+
|
|
8
|
+
__all__ = [
|
|
9
|
+
"StructuredOutputDataExtractorConfig",
|
|
10
|
+
"StructuredOutputDataExtractor",
|
|
11
|
+
]
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from pydantic import BaseModel
|
|
2
|
+
|
|
3
|
+
from unique_toolkit._common.pydantic_helpers import get_configuration_dict
|
|
4
|
+
from unique_toolkit._common.validators import LMI, get_LMI_default_field
|
|
5
|
+
from unique_toolkit.data_extraction.basic.prompt import (
|
|
6
|
+
DEFAULT_DATA_EXTRACTION_SYSTEM_PROMPT,
|
|
7
|
+
DEFAULT_DATA_EXTRACTION_USER_PROMPT,
|
|
8
|
+
)
|
|
9
|
+
from unique_toolkit.language_model.default_language_model import DEFAULT_GPT_4o
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class StructuredOutputDataExtractorConfig(BaseModel):
|
|
13
|
+
model_config = get_configuration_dict()
|
|
14
|
+
|
|
15
|
+
language_model: LMI = get_LMI_default_field(DEFAULT_GPT_4o)
|
|
16
|
+
structured_output_enforce_schema: bool = False
|
|
17
|
+
system_prompt_template: str = DEFAULT_DATA_EXTRACTION_SYSTEM_PROMPT
|
|
18
|
+
user_prompt_template: str = DEFAULT_DATA_EXTRACTION_USER_PROMPT
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
DEFAULT_DATA_EXTRACTION_SYSTEM_PROMPT = """
|
|
2
|
+
You are a thorough and accurate expert in data processing.
|
|
3
|
+
|
|
4
|
+
You will be given some text and an output schema, describing what needs to be extracted from the text.
|
|
5
|
+
You will need to extract the data from the text and return it in the output schema.
|
|
6
|
+
""".strip()
|
|
7
|
+
|
|
8
|
+
DEFAULT_DATA_EXTRACTION_USER_PROMPT = """
|
|
9
|
+
Here is the text to extract data from:
|
|
10
|
+
{{ text }}
|
|
11
|
+
|
|
12
|
+
Please thoroughly extract the data from the text and return it in the output schema.
|
|
13
|
+
""".strip()
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
from typing_extensions import override
|
|
2
|
+
|
|
3
|
+
from unique_toolkit._common.utils.jinja.render import render_template
|
|
4
|
+
from unique_toolkit.data_extraction.base import (
|
|
5
|
+
BaseDataExtractionResult,
|
|
6
|
+
BaseDataExtractor,
|
|
7
|
+
ExtractionSchema,
|
|
8
|
+
)
|
|
9
|
+
from unique_toolkit.data_extraction.basic.config import (
|
|
10
|
+
StructuredOutputDataExtractorConfig,
|
|
11
|
+
)
|
|
12
|
+
from unique_toolkit.language_model import LanguageModelService
|
|
13
|
+
from unique_toolkit.language_model.builder import MessagesBuilder
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class StructuredOutputDataExtractor(BaseDataExtractor):
|
|
17
|
+
"""
|
|
18
|
+
Basic Structured Output Data Extraction.
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
def __init__(
|
|
22
|
+
self,
|
|
23
|
+
config: StructuredOutputDataExtractorConfig,
|
|
24
|
+
language_model_service: LanguageModelService,
|
|
25
|
+
):
|
|
26
|
+
self._config = config
|
|
27
|
+
self._language_model_service = language_model_service
|
|
28
|
+
|
|
29
|
+
@override
|
|
30
|
+
async def extract_data_from_text(
|
|
31
|
+
self, text: str, schema: type[ExtractionSchema]
|
|
32
|
+
) -> BaseDataExtractionResult[ExtractionSchema]:
|
|
33
|
+
messages_builder = (
|
|
34
|
+
MessagesBuilder()
|
|
35
|
+
.system_message_append(self._config.system_prompt_template)
|
|
36
|
+
.user_message_append(
|
|
37
|
+
render_template(
|
|
38
|
+
self._config.user_prompt_template,
|
|
39
|
+
{
|
|
40
|
+
"text": text,
|
|
41
|
+
},
|
|
42
|
+
)
|
|
43
|
+
)
|
|
44
|
+
)
|
|
45
|
+
response = await self._language_model_service.complete_async(
|
|
46
|
+
messages=messages_builder.build(),
|
|
47
|
+
model_name=self._config.language_model.name,
|
|
48
|
+
structured_output_model=schema,
|
|
49
|
+
temperature=0.0,
|
|
50
|
+
structured_output_enforce_schema=self._config.structured_output_enforce_schema,
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
return BaseDataExtractionResult(
|
|
54
|
+
data=schema.model_validate(response.choices[0].message.parsed),
|
|
55
|
+
)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/_common/base_model_type_attribute.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/_common/default_language_model.py
RENAMED
|
File without changes
|
{unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/_common/docx_generator/__init__.py
RENAMED
|
File without changes
|
{unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/_common/docx_generator/config.py
RENAMED
|
File without changes
|
{unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/_common/docx_generator/schemas.py
RENAMED
|
File without changes
|
{unique_toolkit-1.32.1 → unique_toolkit-1.33.1}/unique_toolkit/_common/docx_generator/service.py
RENAMED
|
File without changes
|
|
File without changes
|