autobyteus 1.1.1__tar.gz → 1.1.2__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.
- {autobyteus-1.1.1 → autobyteus-1.1.2}/PKG-INFO +3 -2
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/runtime/agent_runtime.py +1 -4
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/runtime/agent_worker.py +61 -18
- autobyteus-1.1.2/autobyteus/llm/api/deepseek_llm.py +26 -0
- autobyteus-1.1.2/autobyteus/llm/api/grok_llm.py +26 -0
- autobyteus-1.1.2/autobyteus/llm/api/kimi_llm.py +24 -0
- autobyteus-1.1.1/autobyteus/llm/api/deepseek_llm.py → autobyteus-1.1.2/autobyteus/llm/api/openai_compatible_llm.py +39 -34
- autobyteus-1.1.2/autobyteus/llm/api/openai_llm.py +26 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/llm/llm_factory.py +62 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/llm/providers.py +1 -0
- autobyteus-1.1.2/autobyteus/llm/token_counter/kimi_token_counter.py +24 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/llm/token_counter/token_counter_factory.py +3 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/llm/utils/messages.py +3 -3
- autobyteus-1.1.2/autobyteus/tools/usage/parsers/_json_extractor.py +99 -0
- autobyteus-1.1.2/autobyteus/tools/usage/parsers/default_json_tool_usage_parser.py +75 -0
- autobyteus-1.1.2/autobyteus/tools/usage/parsers/default_xml_tool_usage_parser.py +126 -0
- autobyteus-1.1.2/autobyteus/tools/usage/parsers/gemini_json_tool_usage_parser.py +58 -0
- autobyteus-1.1.2/autobyteus/tools/usage/parsers/openai_json_tool_usage_parser.py +146 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus.egg-info/PKG-INFO +3 -2
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus.egg-info/SOURCES.txt +4 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus.egg-info/requires.txt +2 -1
- {autobyteus-1.1.1 → autobyteus-1.1.2}/setup.py +3 -2
- autobyteus-1.1.1/autobyteus/llm/api/grok_llm.py +0 -187
- autobyteus-1.1.1/autobyteus/llm/api/openai_llm.py +0 -154
- autobyteus-1.1.1/autobyteus/tools/usage/parsers/default_json_tool_usage_parser.py +0 -106
- autobyteus-1.1.1/autobyteus/tools/usage/parsers/default_xml_tool_usage_parser.py +0 -136
- autobyteus-1.1.1/autobyteus/tools/usage/parsers/gemini_json_tool_usage_parser.py +0 -66
- autobyteus-1.1.1/autobyteus/tools/usage/parsers/openai_json_tool_usage_parser.py +0 -196
- {autobyteus-1.1.1 → autobyteus-1.1.2}/LICENSE +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/README.md +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/__init__.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/__init__.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/agent.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/bootstrap_steps/__init__.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/bootstrap_steps/agent_bootstrapper.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/bootstrap_steps/agent_runtime_queue_initialization_step.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/bootstrap_steps/base_bootstrap_step.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/bootstrap_steps/system_prompt_processing_step.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/bootstrap_steps/workspace_context_initialization_step.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/context/__init__.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/context/agent_config.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/context/agent_context.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/context/agent_phase_manager.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/context/agent_runtime_state.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/context/phases.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/events/__init__.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/events/agent_events.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/events/agent_input_event_queue_manager.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/events/notifiers.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/events/worker_event_dispatcher.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/exceptions.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/factory/__init__.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/factory/agent_factory.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/group/__init__.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/group/agent_group.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/group/agent_group_context.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/handlers/__init__.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/handlers/approved_tool_invocation_event_handler.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/handlers/base_event_handler.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/handlers/event_handler_registry.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/handlers/generic_event_handler.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/handlers/inter_agent_message_event_handler.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/handlers/lifecycle_event_logger.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/handlers/llm_complete_response_received_event_handler.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/handlers/llm_user_message_ready_event_handler.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/handlers/tool_execution_approval_event_handler.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/handlers/tool_invocation_request_event_handler.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/handlers/tool_result_event_handler.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/handlers/user_input_message_event_handler.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/hooks/__init__.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/hooks/base_phase_hook.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/hooks/hook_definition.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/hooks/hook_meta.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/hooks/hook_registry.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/input_processor/__init__.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/input_processor/base_user_input_processor.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/input_processor/content_prefixing_input_processor.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/input_processor/metadata_appending_input_processor.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/input_processor/passthrough_input_processor.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/input_processor/processor_definition.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/input_processor/processor_meta.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/input_processor/processor_registry.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/llm_response_processor/__init__.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/llm_response_processor/base_processor.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/llm_response_processor/processor_definition.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/llm_response_processor/processor_meta.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/llm_response_processor/processor_registry.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/llm_response_processor/provider_aware_tool_usage_processor.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/message/__init__.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/message/agent_input_user_message.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/message/context_file.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/message/context_file_type.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/message/inter_agent_message.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/message/inter_agent_message_type.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/message/send_message_to.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/phases/__init__.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/phases/discover.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/phases/manager.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/phases/phase_enum.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/phases/transition_decorator.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/phases/transition_info.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/remote_agent.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/runtime/__init__.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/runtime/agent_thread_pool_manager.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/streaming/__init__.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/streaming/agent_event_stream.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/streaming/queue_streamer.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/streaming/stream_event_payloads.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/streaming/stream_events.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/system_prompt_processor/__init__.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/system_prompt_processor/base_processor.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/system_prompt_processor/processor_definition.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/system_prompt_processor/processor_meta.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/system_prompt_processor/processor_registry.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/system_prompt_processor/tool_manifest_injector_processor.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/tool_invocation.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/utils/__init__.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/utils/wait_for_idle.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/workflow/__init__.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/workflow/agentic_workflow.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/workflow/base_agentic_workflow.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/workspace/__init__.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/workspace/base_workspace.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/workspace/workspace_config.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/workspace/workspace_definition.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/workspace/workspace_meta.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/agent/workspace/workspace_registry.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/check_requirements.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/cli/__init__.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/cli/agent_cli.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/cli/cli_display.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/events/__init__.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/events/event_emitter.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/events/event_manager.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/events/event_types.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/llm/__init__.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/llm/api/__init__.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/llm/api/autobyteus_llm.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/llm/api/bedrock_llm.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/llm/api/claude_llm.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/llm/api/gemini_llm.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/llm/api/groq_llm.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/llm/api/mistral_llm.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/llm/api/nvidia_llm.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/llm/api/ollama_llm.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/llm/autobyteus_provider.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/llm/base_llm.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/llm/extensions/__init__.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/llm/extensions/base_extension.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/llm/extensions/extension_registry.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/llm/extensions/token_usage_tracking_extension.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/llm/models.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/llm/ollama_provider.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/llm/ollama_provider_resolver.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/llm/token_counter/__init__.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/llm/token_counter/base_token_counter.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/llm/token_counter/claude_token_counter.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/llm/token_counter/deepseek_token_counter.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/llm/token_counter/mistral_token_counter.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/llm/token_counter/openai_token_counter.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/llm/user_message.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/llm/utils/__init__.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/llm/utils/image_payload_formatter.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/llm/utils/llm_config.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/llm/utils/rate_limiter.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/llm/utils/response_types.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/llm/utils/token_pricing_config.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/llm/utils/token_usage.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/llm/utils/token_usage_tracker.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/person/__init__.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/person/examples/__init__.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/person/examples/sample_persons.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/person/examples/sample_roles.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/person/person.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/person/role.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/prompt/__init__.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/prompt/prompt_builder.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/prompt/prompt_template.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/rpc/__init__.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/rpc/client/__init__.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/rpc/client/abstract_client_connection.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/rpc/client/client_connection_manager.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/rpc/client/sse_client_connection.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/rpc/client/stdio_client_connection.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/rpc/config/__init__.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/rpc/config/agent_server_config.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/rpc/config/agent_server_registry.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/rpc/hosting.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/rpc/protocol.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/rpc/server/__init__.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/rpc/server/agent_server_endpoint.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/rpc/server/base_method_handler.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/rpc/server/method_handlers.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/rpc/server/sse_server_handler.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/rpc/server/stdio_server_handler.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/rpc/server_main.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/rpc/transport_type.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/__init__.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/ask_user_input.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/base_tool.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/bash/__init__.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/bash/bash_executor.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/browser/__init__.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/browser/session_aware/__init__.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/browser/session_aware/browser_session_aware_navigate_to.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/browser/session_aware/browser_session_aware_tool.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/browser/session_aware/browser_session_aware_web_element_trigger.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/browser/session_aware/browser_session_aware_webpage_reader.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/browser/session_aware/browser_session_aware_webpage_screenshot_taker.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/browser/session_aware/factory/__init__.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/browser/session_aware/factory/browser_session_aware_web_element_trigger_factory.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/browser/session_aware/factory/browser_session_aware_webpage_reader_factory.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/browser/session_aware/factory/browser_session_aware_webpage_screenshot_taker_factory.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/browser/session_aware/shared_browser_session.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/browser/session_aware/shared_browser_session_manager.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/browser/session_aware/web_element_action.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/browser/standalone/__init__.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/browser/standalone/factory/__init__.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/browser/standalone/factory/google_search_factory.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/browser/standalone/factory/webpage_reader_factory.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/browser/standalone/factory/webpage_screenshot_taker_factory.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/browser/standalone/google_search_ui.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/browser/standalone/navigate_to.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/browser/standalone/web_page_pdf_generator.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/browser/standalone/webpage_image_downloader.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/browser/standalone/webpage_reader.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/browser/standalone/webpage_screenshot_taker.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/factory/__init__.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/factory/tool_factory.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/file/__init__.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/file/file_reader.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/file/file_writer.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/functional_tool.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/handlers/__init__.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/handlers/shell_handler.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/image_downloader.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/mcp/__init__.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/mcp/call_handlers/__init__.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/mcp/call_handlers/base_handler.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/mcp/call_handlers/sse_handler.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/mcp/call_handlers/stdio_handler.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/mcp/call_handlers/streamable_http_handler.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/mcp/config_service.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/mcp/factory.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/mcp/registrar.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/mcp/schema_mapper.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/mcp/tool.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/mcp/types.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/operation/__init__.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/operation/file_operation.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/operation/file_rename_operation.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/operation/operation.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/operation/shell_operation.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/parameter_schema.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/pdf_downloader.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/registry/__init__.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/registry/tool_definition.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/registry/tool_registry.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/timer.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/tool_category.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/tool_config.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/tool_meta.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/tool_state.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/usage/__init__.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/usage/formatters/__init__.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/usage/formatters/anthropic_json_example_formatter.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/usage/formatters/anthropic_json_schema_formatter.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/usage/formatters/base_formatter.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/usage/formatters/default_json_example_formatter.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/usage/formatters/default_json_schema_formatter.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/usage/formatters/default_xml_example_formatter.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/usage/formatters/default_xml_schema_formatter.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/usage/formatters/gemini_json_example_formatter.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/usage/formatters/gemini_json_schema_formatter.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/usage/formatters/google_json_example_formatter.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/usage/formatters/google_json_schema_formatter.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/usage/formatters/openai_json_example_formatter.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/usage/formatters/openai_json_schema_formatter.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/usage/parsers/__init__.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/usage/parsers/anthropic_xml_tool_usage_parser.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/usage/parsers/base_parser.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/usage/parsers/exceptions.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/usage/parsers/provider_aware_tool_usage_parser.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/usage/providers/__init__.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/usage/providers/json_example_provider.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/usage/providers/json_schema_provider.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/usage/providers/json_tool_usage_parser_provider.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/usage/providers/tool_manifest_provider.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/usage/providers/xml_example_provider.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/usage/providers/xml_schema_provider.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/usage/providers/xml_tool_usage_parser_provider.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/usage/registries/__init__.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/usage/registries/json_example_formatter_registry.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/usage/registries/json_schema_formatter_registry.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/usage/registries/json_tool_usage_parser_registry.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/usage/registries/xml_example_formatter_registry.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/usage/registries/xml_schema_formatter_registry.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/usage/registries/xml_tool_usage_parser_registry.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/tools/utils.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/utils/__init__.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/utils/dynamic_enum.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/utils/file_utils.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/utils/html_cleaner.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/utils/singleton.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/workflow/__init__.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/workflow/simple_task.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/workflow/task.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus/workflow/workflow.py +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus.egg-info/dependency_links.txt +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/autobyteus.egg-info/top_level.txt +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/pyproject.toml +0 -0
- {autobyteus-1.1.1 → autobyteus-1.1.2}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: autobyteus
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.1.2
|
|
4
4
|
Summary: Multi-Agent framework
|
|
5
5
|
Home-page: https://github.com/AutoByteus/autobyteus
|
|
6
6
|
Author: Ryan Zheng
|
|
@@ -26,7 +26,8 @@ Requires-Dist: botocore
|
|
|
26
26
|
Requires-Dist: anthropic==0.37.1
|
|
27
27
|
Requires-Dist: Jinja2
|
|
28
28
|
Requires-Dist: ollama
|
|
29
|
-
Requires-Dist: mistral_common
|
|
29
|
+
Requires-Dist: mistral_common==1.6.3
|
|
30
|
+
Requires-Dist: mistralai==1.5.2
|
|
30
31
|
Requires-Dist: certifi==2025.4.26
|
|
31
32
|
Requires-Dist: numpy==2.2.5
|
|
32
33
|
Requires-Dist: aiohttp
|
|
@@ -120,10 +120,7 @@ class AgentRuntime:
|
|
|
120
120
|
await self.phase_manager.notify_shutdown_initiated()
|
|
121
121
|
await self._worker.stop(timeout=timeout)
|
|
122
122
|
|
|
123
|
-
|
|
124
|
-
cleanup_func = self.context.llm_instance.cleanup
|
|
125
|
-
if asyncio.iscoroutinefunction(cleanup_func): await cleanup_func()
|
|
126
|
-
else: cleanup_func()
|
|
123
|
+
# LLM instance cleanup is now handled by the AgentWorker before its loop closes.
|
|
127
124
|
|
|
128
125
|
await self.phase_manager.notify_final_shutdown_complete()
|
|
129
126
|
logger.info(f"AgentRuntime for '{agent_id}' stop() method completed.")
|
|
@@ -140,19 +140,19 @@ class AgentWorker:
|
|
|
140
140
|
|
|
141
141
|
async def async_run(self) -> None:
|
|
142
142
|
agent_id = self.context.agent_id
|
|
143
|
-
logger.info(f"AgentWorker '{agent_id}' async_run(): Starting.")
|
|
144
|
-
|
|
145
|
-
# --- Direct Initialization ---
|
|
146
|
-
initialization_successful = await self._initialize()
|
|
147
|
-
if not initialization_successful:
|
|
148
|
-
logger.critical(f"AgentWorker '{agent_id}' failed to initialize. Worker is shutting down.")
|
|
149
|
-
if self._async_stop_event and not self._async_stop_event.is_set():
|
|
150
|
-
self._async_stop_event.set()
|
|
151
|
-
return
|
|
152
|
-
|
|
153
|
-
# --- Main Event Loop ---
|
|
154
|
-
logger.info(f"AgentWorker '{agent_id}' initialized successfully. Entering main event loop.")
|
|
155
143
|
try:
|
|
144
|
+
logger.info(f"AgentWorker '{agent_id}' async_run(): Starting.")
|
|
145
|
+
|
|
146
|
+
# --- Direct Initialization ---
|
|
147
|
+
initialization_successful = await self._initialize()
|
|
148
|
+
if not initialization_successful:
|
|
149
|
+
logger.critical(f"AgentWorker '{agent_id}' failed to initialize. Worker is shutting down.")
|
|
150
|
+
if self._async_stop_event and not self._async_stop_event.is_set():
|
|
151
|
+
self._async_stop_event.set()
|
|
152
|
+
return
|
|
153
|
+
|
|
154
|
+
# --- Main Event Loop ---
|
|
155
|
+
logger.info(f"AgentWorker '{agent_id}' initialized successfully. Entering main event loop.")
|
|
156
156
|
while not self._async_stop_event.is_set():
|
|
157
157
|
try:
|
|
158
158
|
queue_event_tuple = await asyncio.wait_for(
|
|
@@ -183,18 +183,61 @@ class AgentWorker:
|
|
|
183
183
|
if self.context.state.input_event_queues:
|
|
184
184
|
await self.context.state.input_event_queues.enqueue_internal_system_event(AgentStoppedEvent())
|
|
185
185
|
|
|
186
|
+
async def _shutdown_sequence(self):
|
|
187
|
+
"""
|
|
188
|
+
The explicit, ordered shutdown sequence for the worker, executed on its own event loop.
|
|
189
|
+
"""
|
|
190
|
+
agent_id = self.context.agent_id
|
|
191
|
+
logger.info(f"AgentWorker '{agent_id}': Running shutdown sequence on worker loop.")
|
|
192
|
+
|
|
193
|
+
# 1. Clean up resources like the LLM instance.
|
|
194
|
+
if self.context.llm_instance and hasattr(self.context.llm_instance, 'cleanup'):
|
|
195
|
+
logger.info(f"AgentWorker '{agent_id}': Running LLM instance cleanup.")
|
|
196
|
+
try:
|
|
197
|
+
cleanup_func = self.context.llm_instance.cleanup
|
|
198
|
+
if asyncio.iscoroutinefunction(cleanup_func):
|
|
199
|
+
await cleanup_func()
|
|
200
|
+
else:
|
|
201
|
+
cleanup_func()
|
|
202
|
+
logger.info(f"AgentWorker '{agent_id}': LLM instance cleanup completed.")
|
|
203
|
+
except Exception as e:
|
|
204
|
+
logger.error(f"AgentWorker '{agent_id}': Error during LLM instance cleanup: {e}", exc_info=True)
|
|
205
|
+
|
|
206
|
+
# 2. Signal the main event loop to stop.
|
|
207
|
+
await self._signal_internal_stop()
|
|
208
|
+
logger.info(f"AgentWorker '{agent_id}': Shutdown sequence completed.")
|
|
209
|
+
|
|
186
210
|
async def stop(self, timeout: float = 10.0) -> None:
|
|
211
|
+
"""
|
|
212
|
+
Gracefully stops the worker by scheduling a final shutdown sequence on its
|
|
213
|
+
event loop, then waiting for the thread to terminate.
|
|
214
|
+
"""
|
|
187
215
|
if not self._is_active or self._stop_initiated:
|
|
188
216
|
return
|
|
217
|
+
|
|
218
|
+
agent_id = self.context.agent_id
|
|
219
|
+
logger.info(f"AgentWorker '{agent_id}': Stop requested.")
|
|
189
220
|
self._stop_initiated = True
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
221
|
+
|
|
222
|
+
# Schedule the explicit shutdown sequence on the worker's loop.
|
|
223
|
+
if self.get_worker_loop():
|
|
224
|
+
future = self.schedule_coroutine_on_worker_loop(self._shutdown_sequence)
|
|
225
|
+
try:
|
|
226
|
+
# Wait for the cleanup and stop signal to be processed.
|
|
227
|
+
future.result(timeout=max(1.0, timeout-1))
|
|
228
|
+
except Exception as e:
|
|
229
|
+
logger.error(f"AgentWorker '{agent_id}': Error during scheduled shutdown sequence: {e}", exc_info=True)
|
|
230
|
+
|
|
231
|
+
# Wait for the main thread future to complete.
|
|
194
232
|
if self._thread_future:
|
|
195
|
-
try:
|
|
196
|
-
|
|
233
|
+
try:
|
|
234
|
+
await asyncio.wait_for(asyncio.wrap_future(self._thread_future), timeout=timeout)
|
|
235
|
+
logger.info(f"AgentWorker '{agent_id}': Worker thread has terminated.")
|
|
236
|
+
except asyncio.TimeoutError:
|
|
237
|
+
logger.warning(f"AgentWorker '{agent_id}': Timeout waiting for worker thread to terminate.")
|
|
238
|
+
|
|
197
239
|
self._is_active = False
|
|
198
240
|
|
|
241
|
+
|
|
199
242
|
def is_alive(self) -> bool:
|
|
200
243
|
return self._thread_future is not None and not self._thread_future.done()
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
from typing import Optional
|
|
3
|
+
from autobyteus.llm.models import LLMModel
|
|
4
|
+
from autobyteus.llm.utils.llm_config import LLMConfig
|
|
5
|
+
from autobyteus.llm.api.openai_compatible_llm import OpenAICompatibleLLM
|
|
6
|
+
|
|
7
|
+
logger = logging.getLogger(__name__)
|
|
8
|
+
|
|
9
|
+
class DeepSeekLLM(OpenAICompatibleLLM):
|
|
10
|
+
def __init__(self, model: LLMModel = None, llm_config: LLMConfig = None):
|
|
11
|
+
# Provide defaults if not specified
|
|
12
|
+
if model is None:
|
|
13
|
+
model = LLMModel['deepseek-chat']
|
|
14
|
+
if llm_config is None:
|
|
15
|
+
llm_config = LLMConfig()
|
|
16
|
+
|
|
17
|
+
super().__init__(
|
|
18
|
+
model=model,
|
|
19
|
+
llm_config=llm_config,
|
|
20
|
+
api_key_env_var="DEEPSEEK_API_KEY",
|
|
21
|
+
base_url="https://api.deepseek.com"
|
|
22
|
+
)
|
|
23
|
+
logger.info(f"DeepSeekLLM initialized with model: {self.model}")
|
|
24
|
+
|
|
25
|
+
async def cleanup(self):
|
|
26
|
+
await super().cleanup()
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
from typing import Optional
|
|
3
|
+
from autobyteus.llm.models import LLMModel
|
|
4
|
+
from autobyteus.llm.utils.llm_config import LLMConfig
|
|
5
|
+
from autobyteus.llm.api.openai_compatible_llm import OpenAICompatibleLLM
|
|
6
|
+
|
|
7
|
+
logger = logging.getLogger(__name__)
|
|
8
|
+
|
|
9
|
+
class GrokLLM(OpenAICompatibleLLM):
|
|
10
|
+
def __init__(self, model: LLMModel = None, llm_config: LLMConfig = None):
|
|
11
|
+
# Provide defaults if not specified
|
|
12
|
+
if model is None:
|
|
13
|
+
model = LLMModel['grok-2-1212']
|
|
14
|
+
if llm_config is None:
|
|
15
|
+
llm_config = LLMConfig()
|
|
16
|
+
|
|
17
|
+
super().__init__(
|
|
18
|
+
model=model,
|
|
19
|
+
llm_config=llm_config,
|
|
20
|
+
api_key_env_var="GROK_API_KEY",
|
|
21
|
+
base_url="https://api.x.ai/v1"
|
|
22
|
+
)
|
|
23
|
+
logger.info(f"GrokLLM initialized with model: {self.model}")
|
|
24
|
+
|
|
25
|
+
async def cleanup(self):
|
|
26
|
+
await super().cleanup()
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
from typing import Optional
|
|
3
|
+
from autobyteus.llm.models import LLMModel
|
|
4
|
+
from autobyteus.llm.utils.llm_config import LLMConfig
|
|
5
|
+
from autobyteus.llm.api.openai_compatible_llm import OpenAICompatibleLLM
|
|
6
|
+
|
|
7
|
+
logger = logging.getLogger(__name__)
|
|
8
|
+
|
|
9
|
+
class KimiLLM(OpenAICompatibleLLM):
|
|
10
|
+
def __init__(self, model: LLMModel = None, llm_config: LLMConfig = None):
|
|
11
|
+
# Provide defaults if not specified
|
|
12
|
+
if model is None:
|
|
13
|
+
# Setting a default Kimi model from the factory ones
|
|
14
|
+
model = LLMModel['kimi-latest']
|
|
15
|
+
if llm_config is None:
|
|
16
|
+
llm_config = LLMConfig()
|
|
17
|
+
|
|
18
|
+
super().__init__(
|
|
19
|
+
model=model,
|
|
20
|
+
llm_config=llm_config,
|
|
21
|
+
api_key_env_var="KIMI_API_KEY",
|
|
22
|
+
base_url="https://api.moonshot.cn/v1"
|
|
23
|
+
)
|
|
24
|
+
logger.info(f"KimiLLM initialized with model: {self.model}")
|
|
@@ -1,37 +1,38 @@
|
|
|
1
1
|
import logging
|
|
2
2
|
import os
|
|
3
|
+
from abc import ABC
|
|
3
4
|
from typing import Optional, List, AsyncGenerator
|
|
4
5
|
from openai import OpenAI
|
|
5
6
|
from openai.types.completion_usage import CompletionUsage
|
|
6
7
|
from openai.types.chat import ChatCompletionChunk
|
|
8
|
+
|
|
7
9
|
from autobyteus.llm.base_llm import BaseLLM
|
|
8
10
|
from autobyteus.llm.models import LLMModel
|
|
9
11
|
from autobyteus.llm.utils.llm_config import LLMConfig
|
|
10
|
-
from autobyteus.llm.utils.messages import MessageRole
|
|
11
12
|
from autobyteus.llm.utils.image_payload_formatter import process_image
|
|
12
13
|
from autobyteus.llm.utils.token_usage import TokenUsage
|
|
13
14
|
from autobyteus.llm.utils.response_types import CompleteResponse, ChunkResponse
|
|
14
15
|
|
|
15
16
|
logger = logging.getLogger(__name__)
|
|
16
17
|
|
|
17
|
-
class
|
|
18
|
-
def __init__(
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
18
|
+
class OpenAICompatibleLLM(BaseLLM, ABC):
|
|
19
|
+
def __init__(
|
|
20
|
+
self,
|
|
21
|
+
model: LLMModel,
|
|
22
|
+
llm_config: LLMConfig,
|
|
23
|
+
api_key_env_var: str,
|
|
24
|
+
base_url: str
|
|
25
|
+
):
|
|
26
|
+
api_key = os.getenv(api_key_env_var)
|
|
27
|
+
if not api_key:
|
|
28
|
+
logger.error(f"{api_key_env_var} environment variable is not set.")
|
|
29
|
+
raise ValueError(f"{api_key_env_var} environment variable is not set.")
|
|
30
|
+
|
|
31
|
+
self.client = OpenAI(api_key=api_key, base_url=base_url)
|
|
32
|
+
logger.info(f"Initialized OpenAI compatible client with base_url: {base_url}")
|
|
33
|
+
|
|
33
34
|
super().__init__(model=model, llm_config=llm_config)
|
|
34
|
-
self.max_tokens = 8000
|
|
35
|
+
self.max_tokens = 8000 # A default, can be overridden by subclass or config
|
|
35
36
|
|
|
36
37
|
def _create_token_usage(self, usage_data: Optional[CompletionUsage]) -> Optional[TokenUsage]:
|
|
37
38
|
"""Convert usage data to TokenUsage format."""
|
|
@@ -48,7 +49,7 @@ class DeepSeekLLM(BaseLLM):
|
|
|
48
49
|
self, user_message: str, image_urls: Optional[List[str]] = None, **kwargs
|
|
49
50
|
) -> CompleteResponse:
|
|
50
51
|
"""
|
|
51
|
-
Sends a non-streaming request to
|
|
52
|
+
Sends a non-streaming request to an OpenAI-compatible API.
|
|
52
53
|
Supports optional reasoning content if provided in the response.
|
|
53
54
|
"""
|
|
54
55
|
content = []
|
|
@@ -70,13 +71,13 @@ class DeepSeekLLM(BaseLLM):
|
|
|
70
71
|
logger.debug(f"Prepared message content: {content}")
|
|
71
72
|
|
|
72
73
|
try:
|
|
73
|
-
logger.info("Sending request to
|
|
74
|
+
logger.info(f"Sending request to {self.model.provider.value} API")
|
|
74
75
|
response = self.client.chat.completions.create(
|
|
75
76
|
model=self.model.value,
|
|
76
77
|
messages=[msg.to_dict() for msg in self.messages],
|
|
77
78
|
max_tokens=self.max_tokens,
|
|
78
79
|
)
|
|
79
|
-
full_message = response.choices.message
|
|
80
|
+
full_message = response.choices[0].message
|
|
80
81
|
|
|
81
82
|
# Extract reasoning_content if present
|
|
82
83
|
reasoning = None
|
|
@@ -95,7 +96,7 @@ class DeepSeekLLM(BaseLLM):
|
|
|
95
96
|
self.add_assistant_message(main_content, reasoning_content=reasoning)
|
|
96
97
|
|
|
97
98
|
token_usage = self._create_token_usage(response.usage)
|
|
98
|
-
logger.info("Received response from
|
|
99
|
+
logger.info(f"Received response from {self.model.provider.value} API with usage data")
|
|
99
100
|
|
|
100
101
|
return CompleteResponse(
|
|
101
102
|
content=main_content,
|
|
@@ -103,14 +104,14 @@ class DeepSeekLLM(BaseLLM):
|
|
|
103
104
|
usage=token_usage
|
|
104
105
|
)
|
|
105
106
|
except Exception as e:
|
|
106
|
-
logger.error(f"Error in
|
|
107
|
-
raise ValueError(f"Error in
|
|
108
|
-
|
|
107
|
+
logger.error(f"Error in {self.model.provider.value} API request: {str(e)}")
|
|
108
|
+
raise ValueError(f"Error in {self.model.provider.value} API request: {str(e)}")
|
|
109
|
+
|
|
109
110
|
async def _stream_user_message_to_llm(
|
|
110
111
|
self, user_message: str, image_urls: Optional[List[str]] = None, **kwargs
|
|
111
112
|
) -> AsyncGenerator[ChunkResponse, None]:
|
|
112
113
|
"""
|
|
113
|
-
Streams the response from
|
|
114
|
+
Streams the response from an OpenAI-compatible API.
|
|
114
115
|
Yields reasoning and content in separate chunks.
|
|
115
116
|
"""
|
|
116
117
|
content = []
|
|
@@ -136,7 +137,7 @@ class DeepSeekLLM(BaseLLM):
|
|
|
136
137
|
accumulated_content = ""
|
|
137
138
|
|
|
138
139
|
try:
|
|
139
|
-
logger.info("Starting streaming request to
|
|
140
|
+
logger.info(f"Starting streaming request to {self.model.provider.value} API")
|
|
140
141
|
stream = self.client.chat.completions.create(
|
|
141
142
|
model=self.model.value,
|
|
142
143
|
messages=[msg.to_dict() for msg in self.messages],
|
|
@@ -147,9 +148,13 @@ class DeepSeekLLM(BaseLLM):
|
|
|
147
148
|
|
|
148
149
|
for chunk in stream:
|
|
149
150
|
chunk: ChatCompletionChunk
|
|
151
|
+
if not chunk.choices:
|
|
152
|
+
continue
|
|
153
|
+
|
|
154
|
+
delta = chunk.choices[0].delta
|
|
150
155
|
|
|
151
|
-
# Process reasoning tokens
|
|
152
|
-
reasoning_chunk = getattr(
|
|
156
|
+
# Process reasoning tokens (if supported by model)
|
|
157
|
+
reasoning_chunk = getattr(delta, "reasoning_content", None)
|
|
153
158
|
if reasoning_chunk:
|
|
154
159
|
accumulated_reasoning += reasoning_chunk
|
|
155
160
|
yield ChunkResponse(
|
|
@@ -158,7 +163,7 @@ class DeepSeekLLM(BaseLLM):
|
|
|
158
163
|
)
|
|
159
164
|
|
|
160
165
|
# Process main content tokens
|
|
161
|
-
main_token =
|
|
166
|
+
main_token = delta.content
|
|
162
167
|
if main_token:
|
|
163
168
|
accumulated_content += main_token
|
|
164
169
|
yield ChunkResponse(
|
|
@@ -178,11 +183,11 @@ class DeepSeekLLM(BaseLLM):
|
|
|
178
183
|
|
|
179
184
|
# After streaming, add the fully accumulated assistant message to history
|
|
180
185
|
self.add_assistant_message(accumulated_content, reasoning_content=accumulated_reasoning)
|
|
181
|
-
logger.info("Completed streaming response from
|
|
186
|
+
logger.info(f"Completed streaming response from {self.model.provider.value} API")
|
|
182
187
|
|
|
183
188
|
except Exception as e:
|
|
184
|
-
logger.error(f"Error in
|
|
185
|
-
raise ValueError(f"Error in
|
|
186
|
-
|
|
189
|
+
logger.error(f"Error in {self.model.provider.value} API streaming: {str(e)}")
|
|
190
|
+
raise ValueError(f"Error in {self.model.provider.value} API streaming: {str(e)}")
|
|
191
|
+
|
|
187
192
|
async def cleanup(self):
|
|
188
193
|
await super().cleanup()
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
from typing import Optional
|
|
3
|
+
from autobyteus.llm.models import LLMModel
|
|
4
|
+
from autobyteus.llm.utils.llm_config import LLMConfig
|
|
5
|
+
from autobyteus.llm.api.openai_compatible_llm import OpenAICompatibleLLM
|
|
6
|
+
|
|
7
|
+
logger = logging.getLogger(__name__)
|
|
8
|
+
|
|
9
|
+
class OpenAILLM(OpenAICompatibleLLM):
|
|
10
|
+
def __init__(self, model: LLMModel = None, llm_config: LLMConfig = None):
|
|
11
|
+
# Provide defaults if not specified
|
|
12
|
+
if model is None:
|
|
13
|
+
model = LLMModel['gpt-4o'] # Use factory access
|
|
14
|
+
if llm_config is None:
|
|
15
|
+
llm_config = LLMConfig()
|
|
16
|
+
|
|
17
|
+
super().__init__(
|
|
18
|
+
model=model,
|
|
19
|
+
llm_config=llm_config,
|
|
20
|
+
api_key_env_var="OPENAI_API_KEY",
|
|
21
|
+
base_url="https://api.openai.com/v1"
|
|
22
|
+
)
|
|
23
|
+
logger.info(f"OpenAILLM initialized with model: {self.model}")
|
|
24
|
+
|
|
25
|
+
async def cleanup(self):
|
|
26
|
+
await super().cleanup()
|
|
@@ -14,6 +14,7 @@ from autobyteus.llm.api.openai_llm import OpenAILLM
|
|
|
14
14
|
from autobyteus.llm.api.ollama_llm import OllamaLLM
|
|
15
15
|
from autobyteus.llm.api.deepseek_llm import DeepSeekLLM
|
|
16
16
|
from autobyteus.llm.api.grok_llm import GrokLLM
|
|
17
|
+
from autobyteus.llm.api.kimi_llm import KimiLLM
|
|
17
18
|
from autobyteus.llm.ollama_provider import OllamaModelProvider
|
|
18
19
|
from autobyteus.utils.singleton import SingletonMeta
|
|
19
20
|
|
|
@@ -239,6 +240,67 @@ class LLMFactory(metaclass=SingletonMeta):
|
|
|
239
240
|
pricing_config=TokenPricingConfig(2.0, 6.0)
|
|
240
241
|
)
|
|
241
242
|
),
|
|
243
|
+
# KIMI Provider Models
|
|
244
|
+
LLMModel(
|
|
245
|
+
name="kimi-latest",
|
|
246
|
+
value="kimi-latest",
|
|
247
|
+
provider=LLMProvider.KIMI,
|
|
248
|
+
llm_class=KimiLLM,
|
|
249
|
+
canonical_name="kimi-latest",
|
|
250
|
+
default_config=LLMConfig(
|
|
251
|
+
pricing_config=TokenPricingConfig(1.38, 4.14)
|
|
252
|
+
)
|
|
253
|
+
),
|
|
254
|
+
LLMModel(
|
|
255
|
+
name="moonshot-v1-8k",
|
|
256
|
+
value="moonshot-v1-8k",
|
|
257
|
+
provider=LLMProvider.KIMI,
|
|
258
|
+
llm_class=KimiLLM,
|
|
259
|
+
canonical_name="moonshot-v1-8k",
|
|
260
|
+
default_config=LLMConfig(
|
|
261
|
+
pricing_config=TokenPricingConfig(0.28, 1.38)
|
|
262
|
+
)
|
|
263
|
+
),
|
|
264
|
+
LLMModel(
|
|
265
|
+
name="moonshot-v1-32k",
|
|
266
|
+
value="moonshot-v1-32k",
|
|
267
|
+
provider=LLMProvider.KIMI,
|
|
268
|
+
llm_class=KimiLLM,
|
|
269
|
+
canonical_name="moonshot-v1-32k",
|
|
270
|
+
default_config=LLMConfig(
|
|
271
|
+
pricing_config=TokenPricingConfig(0.69, 2.76)
|
|
272
|
+
)
|
|
273
|
+
),
|
|
274
|
+
LLMModel(
|
|
275
|
+
name="moonshot-v1-128k",
|
|
276
|
+
value="moonshot-v1-128k",
|
|
277
|
+
provider=LLMProvider.KIMI,
|
|
278
|
+
llm_class=KimiLLM,
|
|
279
|
+
canonical_name="moonshot-v1-128k",
|
|
280
|
+
default_config=LLMConfig(
|
|
281
|
+
pricing_config=TokenPricingConfig(1.38, 4.14)
|
|
282
|
+
)
|
|
283
|
+
),
|
|
284
|
+
LLMModel(
|
|
285
|
+
name="kimi-k2-0711-preview",
|
|
286
|
+
value="kimi-k2-0711-preview",
|
|
287
|
+
provider=LLMProvider.KIMI,
|
|
288
|
+
llm_class=KimiLLM,
|
|
289
|
+
canonical_name="kimi-k2-0711-preview",
|
|
290
|
+
default_config=LLMConfig(
|
|
291
|
+
pricing_config=TokenPricingConfig(0.55, 2.21)
|
|
292
|
+
)
|
|
293
|
+
),
|
|
294
|
+
LLMModel(
|
|
295
|
+
name="kimi-thinking-preview",
|
|
296
|
+
value="kimi-thinking-preview",
|
|
297
|
+
provider=LLMProvider.KIMI,
|
|
298
|
+
llm_class=KimiLLM,
|
|
299
|
+
canonical_name="kimi-thinking-preview",
|
|
300
|
+
default_config=LLMConfig(
|
|
301
|
+
pricing_config=TokenPricingConfig(27.59, 27.59)
|
|
302
|
+
)
|
|
303
|
+
),
|
|
242
304
|
]
|
|
243
305
|
for model in supported_models:
|
|
244
306
|
LLMFactory.register_model(model)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
from typing import TYPE_CHECKING
|
|
2
|
+
from autobyteus.llm.token_counter.openai_token_counter import OpenAITokenCounter
|
|
3
|
+
from autobyteus.llm.models import LLMModel
|
|
4
|
+
|
|
5
|
+
if TYPE_CHECKING:
|
|
6
|
+
from autobyteus.llm.base_llm import BaseLLM
|
|
7
|
+
|
|
8
|
+
class KimiTokenCounter(OpenAITokenCounter):
|
|
9
|
+
"""
|
|
10
|
+
Token counter for Kimi (Moonshot AI) models. Uses the same token counting implementation as OpenAI.
|
|
11
|
+
|
|
12
|
+
This implementation inherits from OpenAITokenCounter as Kimi uses the same tokenization
|
|
13
|
+
approach as OpenAI's models.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
def __init__(self, model: LLMModel, llm: 'BaseLLM' = None):
|
|
17
|
+
"""
|
|
18
|
+
Initialize the Kimi token counter.
|
|
19
|
+
|
|
20
|
+
Args:
|
|
21
|
+
model (LLMModel): The Kimi model to count tokens for.
|
|
22
|
+
llm (BaseLLM, optional): The LLM instance. Defaults to None.
|
|
23
|
+
"""
|
|
24
|
+
super().__init__(model, llm)
|
|
@@ -3,6 +3,7 @@ from autobyteus.llm.token_counter.openai_token_counter import OpenAITokenCounter
|
|
|
3
3
|
from autobyteus.llm.token_counter.claude_token_counter import ClaudeTokenCounter
|
|
4
4
|
from autobyteus.llm.token_counter.mistral_token_counter import MistralTokenCounter
|
|
5
5
|
from autobyteus.llm.token_counter.deepseek_token_counter import DeepSeekTokenCounter
|
|
6
|
+
from autobyteus.llm.token_counter.kimi_token_counter import KimiTokenCounter
|
|
6
7
|
from autobyteus.llm.token_counter.base_token_counter import BaseTokenCounter
|
|
7
8
|
from autobyteus.llm.models import LLMModel
|
|
8
9
|
from autobyteus.llm.providers import LLMProvider
|
|
@@ -31,6 +32,8 @@ def get_token_counter(model: LLMModel, llm: 'BaseLLM') -> BaseTokenCounter:
|
|
|
31
32
|
return DeepSeekTokenCounter(model, llm)
|
|
32
33
|
elif model.provider == LLMProvider.GROK:
|
|
33
34
|
return DeepSeekTokenCounter(model, llm)
|
|
35
|
+
elif model.provider == LLMProvider.KIMI:
|
|
36
|
+
return KimiTokenCounter(model, llm)
|
|
34
37
|
elif model.provider == LLMProvider.OLLAMA:
|
|
35
38
|
return OpenAITokenCounter(model, llm)
|
|
36
39
|
elif model.provider == LLMProvider.GEMINI:
|
|
@@ -20,9 +20,9 @@ class Message:
|
|
|
20
20
|
self.content = content
|
|
21
21
|
self.reasoning_content = reasoning_content # Optional field for reasoning content
|
|
22
22
|
|
|
23
|
-
def to_dict(self) -> Dict[str, Union[str,
|
|
24
|
-
result = {"role": self.role.value, "content": self.content}
|
|
25
|
-
if self.reasoning_content
|
|
23
|
+
def to_dict(self) -> Dict[str, Union[str, List[Dict]]]:
|
|
24
|
+
result: Dict[str, Union[str, List[Dict]]] = {"role": self.role.value, "content": self.content}
|
|
25
|
+
if self.reasoning_content:
|
|
26
26
|
result["reasoning_content"] = self.reasoning_content
|
|
27
27
|
return result
|
|
28
28
|
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import re
|
|
2
|
+
import logging
|
|
3
|
+
from typing import List
|
|
4
|
+
|
|
5
|
+
logger = logging.getLogger(__name__)
|
|
6
|
+
|
|
7
|
+
def _find_json_blobs(text: str) -> List[str]:
|
|
8
|
+
"""
|
|
9
|
+
Robustly finds and extracts all top-level JSON objects or arrays from a string,
|
|
10
|
+
maintaining their original order of appearance. It handles JSON within
|
|
11
|
+
markdown-style code blocks (```json ... ```) and inline JSON.
|
|
12
|
+
|
|
13
|
+
Args:
|
|
14
|
+
text: The string to search for JSON in.
|
|
15
|
+
|
|
16
|
+
Returns:
|
|
17
|
+
A list of strings, where each string is a valid-looking JSON blob,
|
|
18
|
+
ordered as they appeared in the input text.
|
|
19
|
+
"""
|
|
20
|
+
found_blobs = []
|
|
21
|
+
|
|
22
|
+
# 1. Find all markdown blobs first and store them with their start positions.
|
|
23
|
+
markdown_matches = list(re.finditer(r"```(?:json)?\s*([\s\S]+?)\s*```", text))
|
|
24
|
+
for match in markdown_matches:
|
|
25
|
+
content = match.group(1).strip()
|
|
26
|
+
found_blobs.append((match.start(), content))
|
|
27
|
+
|
|
28
|
+
# 2. Create a "masked" version of the text by replacing markdown blocks with spaces.
|
|
29
|
+
# This prevents the inline scanner from finding JSON inside them, while preserving indices.
|
|
30
|
+
masked_text_list = list(text)
|
|
31
|
+
for match in markdown_matches:
|
|
32
|
+
for i in range(match.start(), match.end()):
|
|
33
|
+
masked_text_list[i] = ' '
|
|
34
|
+
masked_text = "".join(masked_text_list)
|
|
35
|
+
|
|
36
|
+
# 3. Scan the masked text for any other JSON using a single pass brace-counter.
|
|
37
|
+
idx = 0
|
|
38
|
+
while idx < len(masked_text):
|
|
39
|
+
start_idx = -1
|
|
40
|
+
|
|
41
|
+
# Find the next opening brace or bracket
|
|
42
|
+
next_brace = masked_text.find('{', idx)
|
|
43
|
+
next_bracket = masked_text.find('[', idx)
|
|
44
|
+
|
|
45
|
+
if next_brace == -1 and next_bracket == -1:
|
|
46
|
+
break # No more JSON starts
|
|
47
|
+
|
|
48
|
+
if next_brace != -1 and (next_bracket == -1 or next_brace < next_bracket):
|
|
49
|
+
start_idx = next_brace
|
|
50
|
+
start_char, end_char = '{', '}'
|
|
51
|
+
else:
|
|
52
|
+
start_idx = next_bracket
|
|
53
|
+
start_char, end_char = '[', ']'
|
|
54
|
+
|
|
55
|
+
brace_count = 1
|
|
56
|
+
in_string = False
|
|
57
|
+
is_escaped = False
|
|
58
|
+
end_idx = -1
|
|
59
|
+
|
|
60
|
+
for i in range(start_idx + 1, len(masked_text)):
|
|
61
|
+
char = masked_text[i]
|
|
62
|
+
|
|
63
|
+
if in_string:
|
|
64
|
+
if is_escaped:
|
|
65
|
+
is_escaped = False
|
|
66
|
+
elif char == '\\':
|
|
67
|
+
is_escaped = True
|
|
68
|
+
elif char == '"':
|
|
69
|
+
in_string = False
|
|
70
|
+
else:
|
|
71
|
+
if char == '"':
|
|
72
|
+
in_string = True
|
|
73
|
+
is_escaped = False
|
|
74
|
+
elif char == '{' or char == '[':
|
|
75
|
+
brace_count += 1
|
|
76
|
+
elif char == '}' or char == ']':
|
|
77
|
+
brace_count -= 1
|
|
78
|
+
|
|
79
|
+
if brace_count == 0:
|
|
80
|
+
if (start_char == '{' and char == '}') or \
|
|
81
|
+
(start_char == '[' and char == ']'):
|
|
82
|
+
end_idx = i
|
|
83
|
+
break
|
|
84
|
+
|
|
85
|
+
if end_idx != -1:
|
|
86
|
+
# We found a blob in the masked text, so its indices are correct
|
|
87
|
+
# for the original text. Extract the blob from the original text.
|
|
88
|
+
blob = text[start_idx : end_idx + 1]
|
|
89
|
+
found_blobs.append((start_idx, blob))
|
|
90
|
+
idx = end_idx + 1
|
|
91
|
+
else:
|
|
92
|
+
# No matching end brace found, move on from the start character.
|
|
93
|
+
idx = start_idx + 1
|
|
94
|
+
|
|
95
|
+
# 4. Sort all found blobs by their start position to ensure correct order
|
|
96
|
+
found_blobs.sort(key=lambda item: item[0])
|
|
97
|
+
|
|
98
|
+
# 5. Return only the content of the blobs
|
|
99
|
+
return [content for _, content in found_blobs]
|