pipelex 0.1.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.
- pipelex-0.1.1/LICENSE +34 -0
- pipelex-0.1.1/NOTICE +15 -0
- pipelex-0.1.1/PKG-INFO +46 -0
- pipelex-0.1.1/pipelex/__init__.py +7 -0
- pipelex-0.1.1/pipelex/activity_handler.py +131 -0
- pipelex-0.1.1/pipelex/activity_manager.py +59 -0
- pipelex-0.1.1/pipelex/activity_models.py +10 -0
- pipelex-0.1.1/pipelex/cli/__init__.py +0 -0
- pipelex-0.1.1/pipelex/cli/_cli.py +65 -0
- pipelex-0.1.1/pipelex/client/api_client.py +159 -0
- pipelex-0.1.1/pipelex/client/client.py +137 -0
- pipelex-0.1.1/pipelex/client/protocol.py +180 -0
- pipelex-0.1.1/pipelex/cogt/__init__.py +0 -0
- pipelex-0.1.1/pipelex/cogt/anthropic/__init__.py +0 -0
- pipelex-0.1.1/pipelex/cogt/anthropic/anthropic_config.py +42 -0
- pipelex-0.1.1/pipelex/cogt/anthropic/anthropic_factory.py +233 -0
- pipelex-0.1.1/pipelex/cogt/anthropic/anthropic_llms.py +29 -0
- pipelex-0.1.1/pipelex/cogt/anthropic/anthropic_worker.py +107 -0
- pipelex-0.1.1/pipelex/cogt/bedrock/__init__.py +0 -0
- pipelex-0.1.1/pipelex/cogt/bedrock/bedrock_client_aioboto3.py +49 -0
- pipelex-0.1.1/pipelex/cogt/bedrock/bedrock_client_boto3.py +48 -0
- pipelex-0.1.1/pipelex/cogt/bedrock/bedrock_client_protocol.py +16 -0
- pipelex-0.1.1/pipelex/cogt/bedrock/bedrock_config.py +15 -0
- pipelex-0.1.1/pipelex/cogt/bedrock/bedrock_factory.py +60 -0
- pipelex-0.1.1/pipelex/cogt/bedrock/bedrock_message.py +121 -0
- pipelex-0.1.1/pipelex/cogt/bedrock/bedrock_worker.py +71 -0
- pipelex-0.1.1/pipelex/cogt/config_cogt.py +94 -0
- pipelex-0.1.1/pipelex/cogt/content_generation/__init__.py +0 -0
- pipelex-0.1.1/pipelex/cogt/content_generation/assignment_models.py +138 -0
- pipelex-0.1.1/pipelex/cogt/content_generation/content_generator.py +262 -0
- pipelex-0.1.1/pipelex/cogt/content_generation/content_generator_protocol.py +121 -0
- pipelex-0.1.1/pipelex/cogt/content_generation/imgg_generate.py +41 -0
- pipelex-0.1.1/pipelex/cogt/content_generation/jinja2_generate.py +17 -0
- pipelex-0.1.1/pipelex/cogt/content_generation/llm_generate.py +62 -0
- pipelex-0.1.1/pipelex/cogt/exceptions.py +84 -0
- pipelex-0.1.1/pipelex/cogt/fal/__init__.py +0 -0
- pipelex-0.1.1/pipelex/cogt/fal/fal_engine.py +13 -0
- pipelex-0.1.1/pipelex/cogt/fal/fal_factory.py +166 -0
- pipelex-0.1.1/pipelex/cogt/fal/fal_worker.py +98 -0
- pipelex-0.1.1/pipelex/cogt/fal/py.typed +0 -0
- pipelex-0.1.1/pipelex/cogt/image/__init__.py +0 -0
- pipelex-0.1.1/pipelex/cogt/image/generated_image.py +8 -0
- pipelex-0.1.1/pipelex/cogt/image/prompt_image.py +42 -0
- pipelex-0.1.1/pipelex/cogt/image/prompt_image_factory.py +69 -0
- pipelex-0.1.1/pipelex/cogt/imgg/__init__.py +0 -0
- pipelex-0.1.1/pipelex/cogt/imgg/imgg_engine_abstract.py +10 -0
- pipelex-0.1.1/pipelex/cogt/imgg/imgg_engine_factory.py +14 -0
- pipelex-0.1.1/pipelex/cogt/imgg/imgg_handle.py +9 -0
- pipelex-0.1.1/pipelex/cogt/imgg/imgg_job.py +29 -0
- pipelex-0.1.1/pipelex/cogt/imgg/imgg_job_components.py +74 -0
- pipelex-0.1.1/pipelex/cogt/imgg/imgg_job_factory.py +66 -0
- pipelex-0.1.1/pipelex/cogt/imgg/imgg_prompt.py +33 -0
- pipelex-0.1.1/pipelex/cogt/imgg/imgg_worker_abstract.py +88 -0
- pipelex-0.1.1/pipelex/cogt/imgg/imgg_worker_factory.py +66 -0
- pipelex-0.1.1/pipelex/cogt/imgg/imgg_worker_models.py +6 -0
- pipelex-0.1.1/pipelex/cogt/inference/__init__.py +0 -0
- pipelex-0.1.1/pipelex/cogt/inference/inference_job_abstract.py +13 -0
- pipelex-0.1.1/pipelex/cogt/inference/inference_manager.py +136 -0
- pipelex-0.1.1/pipelex/cogt/inference/inference_manager_protocol.py +34 -0
- pipelex-0.1.1/pipelex/cogt/inference/inference_report_delegate.py +9 -0
- pipelex-0.1.1/pipelex/cogt/inference/inference_report_manager.py +228 -0
- pipelex-0.1.1/pipelex/cogt/inference/inference_reporter_abstract.py +17 -0
- pipelex-0.1.1/pipelex/cogt/llm/__init__.py +0 -0
- pipelex-0.1.1/pipelex/cogt/llm/llm_job.py +41 -0
- pipelex-0.1.1/pipelex/cogt/llm/llm_job_components.py +29 -0
- pipelex-0.1.1/pipelex/cogt/llm/llm_job_factory.py +128 -0
- pipelex-0.1.1/pipelex/cogt/llm/llm_models/__init__.py +0 -0
- pipelex-0.1.1/pipelex/cogt/llm/llm_models/llm_deck.py +246 -0
- pipelex-0.1.1/pipelex/cogt/llm/llm_models/llm_deck_abstract.py +62 -0
- pipelex-0.1.1/pipelex/cogt/llm/llm_models/llm_deck_check.py +12 -0
- pipelex-0.1.1/pipelex/cogt/llm/llm_models/llm_engine.py +38 -0
- pipelex-0.1.1/pipelex/cogt/llm/llm_models/llm_engine_blueprint.py +18 -0
- pipelex-0.1.1/pipelex/cogt/llm/llm_models/llm_engine_factory.py +39 -0
- pipelex-0.1.1/pipelex/cogt/llm/llm_models/llm_family.py +129 -0
- pipelex-0.1.1/pipelex/cogt/llm/llm_models/llm_model.py +48 -0
- pipelex-0.1.1/pipelex/cogt/llm/llm_models/llm_model_library.py +124 -0
- pipelex-0.1.1/pipelex/cogt/llm/llm_models/llm_model_provider_abstract.py +33 -0
- pipelex-0.1.1/pipelex/cogt/llm/llm_models/llm_platform.py +75 -0
- pipelex-0.1.1/pipelex/cogt/llm/llm_models/llm_prompting_target.py +8 -0
- pipelex-0.1.1/pipelex/cogt/llm/llm_models/llm_setting.py +85 -0
- pipelex-0.1.1/pipelex/cogt/llm/llm_prompt.py +66 -0
- pipelex-0.1.1/pipelex/cogt/llm/llm_prompt_factory_abstract.py +28 -0
- pipelex-0.1.1/pipelex/cogt/llm/llm_prompt_template.py +165 -0
- pipelex-0.1.1/pipelex/cogt/llm/llm_prompt_template_inputs.py +61 -0
- pipelex-0.1.1/pipelex/cogt/llm/llm_report.py +119 -0
- pipelex-0.1.1/pipelex/cogt/llm/llm_worker_abstract.py +156 -0
- pipelex-0.1.1/pipelex/cogt/llm/llm_worker_factory.py +183 -0
- pipelex-0.1.1/pipelex/cogt/llm/structured_output.py +21 -0
- pipelex-0.1.1/pipelex/cogt/llm/token_category.py +19 -0
- pipelex-0.1.1/pipelex/cogt/mistral/__init__.py +0 -0
- pipelex-0.1.1/pipelex/cogt/mistral/mistral_config.py +18 -0
- pipelex-0.1.1/pipelex/cogt/mistral/mistral_factory.py +121 -0
- pipelex-0.1.1/pipelex/cogt/mistral/mistral_llms.py +16 -0
- pipelex-0.1.1/pipelex/cogt/mistral/mistral_worker.py +93 -0
- pipelex-0.1.1/pipelex/cogt/ocr/__init__.py +0 -0
- pipelex-0.1.1/pipelex/cogt/ocr/mistral_ocr.py +145 -0
- pipelex-0.1.1/pipelex/cogt/ocr/ocr_config.py +9 -0
- pipelex-0.1.1/pipelex/cogt/ocr/ocr_engine_abstract.py +82 -0
- pipelex-0.1.1/pipelex/cogt/ocr/ocr_engine_factory.py +27 -0
- pipelex-0.1.1/pipelex/cogt/ocr/ocr_exceptions.py +6 -0
- pipelex-0.1.1/pipelex/cogt/openai/__init__.py +0 -0
- pipelex-0.1.1/pipelex/cogt/openai/azure_openai_config.py +45 -0
- pipelex-0.1.1/pipelex/cogt/openai/openai_config.py +42 -0
- pipelex-0.1.1/pipelex/cogt/openai/openai_errors.py +5 -0
- pipelex-0.1.1/pipelex/cogt/openai/openai_factory.py +163 -0
- pipelex-0.1.1/pipelex/cogt/openai/openai_func.py +59 -0
- pipelex-0.1.1/pipelex/cogt/openai/openai_llms.py +21 -0
- pipelex-0.1.1/pipelex/cogt/openai/openai_worker.py +147 -0
- pipelex-0.1.1/pipelex/cogt/openai/perplexity_config.py +43 -0
- pipelex-0.1.1/pipelex/cogt/openai/vertexai_config.py +53 -0
- pipelex-0.1.1/pipelex/cogt/py.typed +0 -0
- pipelex-0.1.1/pipelex/config.py +106 -0
- pipelex-0.1.1/pipelex/core/__init__.py +0 -0
- pipelex-0.1.1/pipelex/core/concept.py +111 -0
- pipelex-0.1.1/pipelex/core/concept_factory.py +142 -0
- pipelex-0.1.1/pipelex/core/concept_library.py +125 -0
- pipelex-0.1.1/pipelex/core/concept_native.py +68 -0
- pipelex-0.1.1/pipelex/core/concept_provider_abstract.py +44 -0
- pipelex-0.1.1/pipelex/core/domain.py +26 -0
- pipelex-0.1.1/pipelex/core/domain_library.py +74 -0
- pipelex-0.1.1/pipelex/core/domain_provider_abstract.py +28 -0
- pipelex-0.1.1/pipelex/core/pipe.py +92 -0
- pipelex-0.1.1/pipelex/core/pipe_blueprint.py +67 -0
- pipelex-0.1.1/pipelex/core/pipe_library.py +67 -0
- pipelex-0.1.1/pipelex/core/pipe_output.py +72 -0
- pipelex-0.1.1/pipelex/core/pipe_provider_abstract.py +28 -0
- pipelex-0.1.1/pipelex/core/pipe_run_params.py +154 -0
- pipelex-0.1.1/pipelex/core/stuff.py +160 -0
- pipelex-0.1.1/pipelex/core/stuff_artefact.py +61 -0
- pipelex-0.1.1/pipelex/core/stuff_content.py +377 -0
- pipelex-0.1.1/pipelex/core/stuff_factory.py +160 -0
- pipelex-0.1.1/pipelex/core/working_memory.py +307 -0
- pipelex-0.1.1/pipelex/core/working_memory_factory.py +96 -0
- pipelex-0.1.1/pipelex/exceptions.py +151 -0
- pipelex-0.1.1/pipelex/hub.py +356 -0
- pipelex-0.1.1/pipelex/job_history.py +540 -0
- pipelex-0.1.1/pipelex/job_metadata.py +72 -0
- pipelex-0.1.1/pipelex/libraries/library_config.py +65 -0
- pipelex-0.1.1/pipelex/libraries/library_manager.py +259 -0
- pipelex-0.1.1/pipelex/libraries/llm_deck/base_llm_deck.toml +80 -0
- pipelex-0.1.1/pipelex/libraries/llm_integrations/anthropic.toml +42 -0
- pipelex-0.1.1/pipelex/libraries/llm_integrations/bedrock.toml +29 -0
- pipelex-0.1.1/pipelex/libraries/llm_integrations/mistral.toml +67 -0
- pipelex-0.1.1/pipelex/libraries/llm_integrations/openai.toml +138 -0
- pipelex-0.1.1/pipelex/libraries/llm_integrations/perplexity.toml +24 -0
- pipelex-0.1.1/pipelex/libraries/llm_integrations/vertexai.toml +34 -0
- pipelex-0.1.1/pipelex/libraries/pipelines/image_generation.toml +19 -0
- pipelex-0.1.1/pipelex/libraries/pipelines/images.toml +25 -0
- pipelex-0.1.1/pipelex/libraries/pipelines/questions.py +190 -0
- pipelex-0.1.1/pipelex/libraries/pipelines/questions.toml +292 -0
- pipelex-0.1.1/pipelex/libraries/pipelines/retrieve.py +12 -0
- pipelex-0.1.1/pipelex/libraries/pipelines/retrieve.toml +23 -0
- pipelex-0.1.1/pipelex/libraries/pipelines/text_extraction.py +5 -0
- pipelex-0.1.1/pipelex/libraries/templates/base_templates.toml +15 -0
- pipelex-0.1.1/pipelex/pipe_controllers/__init__.py +0 -0
- pipelex-0.1.1/pipelex/pipe_controllers/pipe_batch.py +161 -0
- pipelex-0.1.1/pipelex/pipe_controllers/pipe_batch_factory.py +53 -0
- pipelex-0.1.1/pipelex/pipe_controllers/pipe_condition.py +152 -0
- pipelex-0.1.1/pipelex/pipe_controllers/pipe_condition_details.py +13 -0
- pipelex-0.1.1/pipelex/pipe_controllers/pipe_condition_factory.py +53 -0
- pipelex-0.1.1/pipelex/pipe_controllers/pipe_parallel.py +108 -0
- pipelex-0.1.1/pipelex/pipe_controllers/pipe_parallel_factory.py +59 -0
- pipelex-0.1.1/pipelex/pipe_controllers/pipe_sequence.py +62 -0
- pipelex-0.1.1/pipelex/pipe_controllers/pipe_sequence_factory.py +46 -0
- pipelex-0.1.1/pipelex/pipe_controllers/sub_pipe.py +92 -0
- pipelex-0.1.1/pipelex/pipe_controllers/sub_pipe_factory.py +41 -0
- pipelex-0.1.1/pipelex/pipe_operators/__init__.py +0 -0
- pipelex-0.1.1/pipelex/pipe_operators/pipe_func.py +68 -0
- pipelex-0.1.1/pipelex/pipe_operators/pipe_func_factory.py +44 -0
- pipelex-0.1.1/pipelex/pipe_operators/pipe_img_gen.py +168 -0
- pipelex-0.1.1/pipelex/pipe_operators/pipe_img_gen_factory.py +64 -0
- pipelex-0.1.1/pipelex/pipe_operators/pipe_jinja2.py +131 -0
- pipelex-0.1.1/pipelex/pipe_operators/pipe_jinja2_factory.py +107 -0
- pipelex-0.1.1/pipelex/pipe_operators/pipe_llm.py +373 -0
- pipelex-0.1.1/pipelex/pipe_operators/pipe_llm_factory.py +164 -0
- pipelex-0.1.1/pipelex/pipe_operators/pipe_llm_prompt.py +258 -0
- pipelex-0.1.1/pipelex/pipe_operators/pipe_ocr.py +69 -0
- pipelex-0.1.1/pipelex/pipe_operators/pipe_ocr_factory.py +47 -0
- pipelex-0.1.1/pipelex/pipe_works/__init__.py +0 -0
- pipelex-0.1.1/pipelex/pipe_works/pipe_feature.py +159 -0
- pipelex-0.1.1/pipelex/pipe_works/pipe_models.py +8 -0
- pipelex-0.1.1/pipelex/pipe_works/pipe_router.py +86 -0
- pipelex-0.1.1/pipelex/pipe_works/pipe_router_job.py +16 -0
- pipelex-0.1.1/pipelex/pipe_works/pipe_router_job_factory.py +31 -0
- pipelex-0.1.1/pipelex/pipe_works/pipe_router_protocol.py +36 -0
- pipelex-0.1.1/pipelex/pipe_works/pipe_wrappers.py +57 -0
- pipelex-0.1.1/pipelex/pipe_works/piped_llm_prompt_factory.py +40 -0
- pipelex-0.1.1/pipelex/pipelex.py +188 -0
- pipelex-0.1.1/pipelex/pipelex.toml +214 -0
- pipelex-0.1.1/pipelex/py.typed +0 -0
- pipelex-0.1.1/pipelex/registry_funcs.py +5 -0
- pipelex-0.1.1/pipelex/registry_models.py +87 -0
- pipelex-0.1.1/pipelex/test_extras/__init__.py +0 -0
- pipelex-0.1.1/pipelex/test_extras/registry_test_models.py +15 -0
- pipelex-0.1.1/pipelex/test_extras/shared_pytest_plugins.py +17 -0
- pipelex-0.1.1/pipelex/tools/__init__.py +0 -0
- pipelex-0.1.1/pipelex/tools/aws/__init__.py +0 -0
- pipelex-0.1.1/pipelex/tools/aws/aws_config.py +61 -0
- pipelex-0.1.1/pipelex/tools/class_registry.py +190 -0
- pipelex-0.1.1/pipelex/tools/config/__init__.py +0 -0
- pipelex-0.1.1/pipelex/tools/config/errors.py +29 -0
- pipelex-0.1.1/pipelex/tools/config/manager.py +227 -0
- pipelex-0.1.1/pipelex/tools/config/models.py +79 -0
- pipelex-0.1.1/pipelex/tools/environment.py +51 -0
- pipelex-0.1.1/pipelex/tools/exceptions.py +30 -0
- pipelex-0.1.1/pipelex/tools/func_registry.py +128 -0
- pipelex-0.1.1/pipelex/tools/log/log.py +375 -0
- pipelex-0.1.1/pipelex/tools/log/log_config.py +106 -0
- pipelex-0.1.1/pipelex/tools/log/log_dispatch.py +318 -0
- pipelex-0.1.1/pipelex/tools/log/log_formatter.py +110 -0
- pipelex-0.1.1/pipelex/tools/log/log_levels.py +55 -0
- pipelex-0.1.1/pipelex/tools/misc/file_fetching_helpers.py +36 -0
- pipelex-0.1.1/pipelex/tools/misc/markdown_helpers.py +65 -0
- pipelex-0.1.1/pipelex/tools/misc/mermaid_helpers.py +43 -0
- pipelex-0.1.1/pipelex/tools/misc/model_helpers.py +171 -0
- pipelex-0.1.1/pipelex/tools/misc/terminal.py +14 -0
- pipelex-0.1.1/pipelex/tools/misc/toml_helpers.py +17 -0
- pipelex-0.1.1/pipelex/tools/misc/tomlkit_helpers.py +20 -0
- pipelex-0.1.1/pipelex/tools/misc/utilities.py +8 -0
- pipelex-0.1.1/pipelex/tools/registry_models.py +27 -0
- pipelex-0.1.1/pipelex/tools/runtime_manager.py +94 -0
- pipelex-0.1.1/pipelex/tools/sandbox_manager.py +31 -0
- pipelex-0.1.1/pipelex/tools/secrets/env_secrets_provider.py +32 -0
- pipelex-0.1.1/pipelex/tools/secrets/secrets_cli.py +35 -0
- pipelex-0.1.1/pipelex/tools/secrets/secrets_errors.py +5 -0
- pipelex-0.1.1/pipelex/tools/secrets/secrets_provider_abstract.py +24 -0
- pipelex-0.1.1/pipelex/tools/serde/__init__.py +0 -0
- pipelex-0.1.1/pipelex/tools/serde/json_decoder.py +245 -0
- pipelex-0.1.1/pipelex/tools/serde/json_encoder.py +216 -0
- pipelex-0.1.1/pipelex/tools/serde/kajson.py +181 -0
- pipelex-0.1.1/pipelex/tools/templating/jinja2_environment.py +82 -0
- pipelex-0.1.1/pipelex/tools/templating/jinja2_errors.py +34 -0
- pipelex-0.1.1/pipelex/tools/templating/jinja2_filters.py +92 -0
- pipelex-0.1.1/pipelex/tools/templating/jinja2_models.py +21 -0
- pipelex-0.1.1/pipelex/tools/templating/jinja2_parsing.py +10 -0
- pipelex-0.1.1/pipelex/tools/templating/jinja2_rendering.py +103 -0
- pipelex-0.1.1/pipelex/tools/templating/jinja2_required_variables.py +62 -0
- pipelex-0.1.1/pipelex/tools/templating/jinja2_template_category.py +26 -0
- pipelex-0.1.1/pipelex/tools/templating/jinja2_template_loader.py +19 -0
- pipelex-0.1.1/pipelex/tools/templating/template_library.py +93 -0
- pipelex-0.1.1/pipelex/tools/templating/template_preprocessor.py +81 -0
- pipelex-0.1.1/pipelex/tools/templating/template_provider_abstract.py +21 -0
- pipelex-0.1.1/pipelex/tools/templating/templating_models.py +37 -0
- pipelex-0.1.1/pipelex/tools/utils/class_structure_utils.py +117 -0
- pipelex-0.1.1/pipelex/tools/utils/file_utils.py +269 -0
- pipelex-0.1.1/pipelex/tools/utils/image_utils.py +85 -0
- pipelex-0.1.1/pipelex/tools/utils/json_utils.py +390 -0
- pipelex-0.1.1/pipelex/tools/utils/module_utils.py +68 -0
- pipelex-0.1.1/pipelex/tools/utils/path_utils.py +215 -0
- pipelex-0.1.1/pipelex/tools/utils/pretty.py +111 -0
- pipelex-0.1.1/pipelex/tools/utils/string_utils.py +198 -0
- pipelex-0.1.1/pipelex/tools/utils/validation_utils.py +52 -0
- pipelex-0.1.1/pipelex_libraries/__init__.py +0 -0
- pipelex-0.1.1/pyproject.toml +236 -0
pipelex-0.1.1/LICENSE
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
ELv2
|
|
2
|
+
|
|
3
|
+
Elastic License 2.0 (ELv2)
|
|
4
|
+
|
|
5
|
+
Acceptance: By using the software, you agree to all of the terms and conditions below.
|
|
6
|
+
|
|
7
|
+
Copyright License: The licensor grants you a non-exclusive, royalty-free, worldwide, non-sublicensable, non-transferable license to use, copy, distribute, make available, and prepare derivative works of the software, in each case subject to the limitations and conditions below
|
|
8
|
+
|
|
9
|
+
Limitations: You may not provide the software to third parties as a hosted or managed service, where the service provides users with access to any substantial set of the features or functionality of the software.
|
|
10
|
+
|
|
11
|
+
You may not move, change, disable, or circumvent the license key functionality in the software, and you may not remove or obscure any functionality in the software that is protected by the license key.
|
|
12
|
+
|
|
13
|
+
You may not alter, remove, or obscure any licensing, copyright, or other notices of the licensor in the software. Any use of the licensor’s trademarks is subject to applicable law.
|
|
14
|
+
|
|
15
|
+
Patents: The licensor grants you a license, under any patent claims the licensor can license, or becomes able to license, to make, have made, use, sell, offer for sale, import and have imported the software, in each case subject to the limitations and conditions in this license. This license does not cover any patent claims that you cause to be infringed by modifications or additions to the software. If you or your company make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.
|
|
16
|
+
|
|
17
|
+
Notices: You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these terms.
|
|
18
|
+
|
|
19
|
+
If you modify the software, you must include in any modified copies of the software prominent notices stating that you have modified the software.
|
|
20
|
+
|
|
21
|
+
No Other Rights: These terms do not imply any licenses other than those expressly granted in these terms.
|
|
22
|
+
|
|
23
|
+
Termination: If you use the software in violation of these terms, such use is not licensed, and your licenses will automatically terminate. If the licensor provides you with a notice of your violation, and you cease all violation of this license no later than 30 days after you receive that notice, your licenses will be reinstated retroactively. However, if you violate these terms after such reinstatement, any additional violation of these terms will cause your licenses to terminate automatically and permanently.
|
|
24
|
+
|
|
25
|
+
No Liability: As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.
|
|
26
|
+
|
|
27
|
+
Definitions:
|
|
28
|
+
- the licensor is the entity offering these terms
|
|
29
|
+
- the software is the software the licensor makes available under these terms, including any portion of it.
|
|
30
|
+
- you refers to the individual or entity agreeing to these terms.
|
|
31
|
+
- your company is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. control means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
|
|
32
|
+
- your licenses are all the licenses granted to you for the software under these terms.
|
|
33
|
+
- use means anything you do with the software requiring one of your licenses.
|
|
34
|
+
- trademark means trademarks, service marks, and similar rights.
|
pipelex-0.1.1/NOTICE
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# NOTICE
|
|
2
|
+
|
|
3
|
+
## Licensing and Attribution
|
|
4
|
+
|
|
5
|
+
This project includes code based on original work "unijson" by Bastien Pietropaoli,
|
|
6
|
+
licensed under the Apache License, Version 2.0. Those portions of the code remain
|
|
7
|
+
subject to the Apache License.
|
|
8
|
+
The concerned code portions are located in the following files:
|
|
9
|
+
pipelex/tools/serde/kajson.py
|
|
10
|
+
pipelex/tools/serde/json_decoder.py
|
|
11
|
+
pipelex/tools/serde/json_encoder.py
|
|
12
|
+
|
|
13
|
+
All modifications of these code portions as well as all other code, modifications,
|
|
14
|
+
and new features © 2023-2024 Pipelex, All rights reserved.
|
|
15
|
+
|
pipelex-0.1.1/PKG-INFO
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: pipelex
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Pipelex is an open-source dev tool based on a simple declarative language that lets you define replicable, structured, composable LLM pipelines.
|
|
5
|
+
License: All Rights Reserved
|
|
6
|
+
Author: Pipelex
|
|
7
|
+
Author-email: contact@pipelex.com
|
|
8
|
+
Requires-Python: >=3.11,<3.12
|
|
9
|
+
Classifier: License :: Other/Proprietary License
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
12
|
+
Provides-Extra: anthropic
|
|
13
|
+
Provides-Extra: bedrock
|
|
14
|
+
Provides-Extra: fal
|
|
15
|
+
Provides-Extra: google
|
|
16
|
+
Provides-Extra: mistralai
|
|
17
|
+
Requires-Dist: PyYAML (>=6.0.2,<7.0.0)
|
|
18
|
+
Requires-Dist: aioboto3 (>=13.4.0,<14.0.0) ; extra == "bedrock"
|
|
19
|
+
Requires-Dist: aiofiles (<24.0)
|
|
20
|
+
Requires-Dist: anthropic (>=0.49.0,<0.50.0) ; extra == "anthropic"
|
|
21
|
+
Requires-Dist: beautifulsoup4 (>=4.12.3,<5.0.0)
|
|
22
|
+
Requires-Dist: boto3 (>=1.34.131,<2.0.0) ; extra == "bedrock"
|
|
23
|
+
Requires-Dist: fal-client (>=0.4.1,<0.5.0) ; extra == "fal"
|
|
24
|
+
Requires-Dist: google-auth-oauthlib (>=1.2.1,<2.0.0) ; extra == "google"
|
|
25
|
+
Requires-Dist: httpx (>=0.27.0,<0.28.0)
|
|
26
|
+
Requires-Dist: instructor (==1.7.2)
|
|
27
|
+
Requires-Dist: jinja2 (>=3.1.4,<4.0.0)
|
|
28
|
+
Requires-Dist: json2html (>=1.3.0,<2.0.0)
|
|
29
|
+
Requires-Dist: markdown (>=3.6,<4.0)
|
|
30
|
+
Requires-Dist: mistralai (==1.5.2) ; extra == "mistralai"
|
|
31
|
+
Requires-Dist: networkx (>=3.4.2,<4.0.0)
|
|
32
|
+
Requires-Dist: openai (>=1.60.1,<2.0.0)
|
|
33
|
+
Requires-Dist: openpyxl (>=3.1.5,<4.0.0)
|
|
34
|
+
Requires-Dist: pandas (>=2.2.3,<3.0.0)
|
|
35
|
+
Requires-Dist: pandas-stubs (>=2.2.3.241126,<3.0.0.0)
|
|
36
|
+
Requires-Dist: pdf2image (==1.17.0)
|
|
37
|
+
Requires-Dist: pillow (>=10.4.0,<11.0.0)
|
|
38
|
+
Requires-Dist: pydantic (==2.10.6)
|
|
39
|
+
Requires-Dist: python-dotenv (>=1.0.1,<2.0.0)
|
|
40
|
+
Requires-Dist: rich (>=13.8.1,<14.0.0)
|
|
41
|
+
Requires-Dist: shortuuid (>=1.0.13,<2.0.0)
|
|
42
|
+
Requires-Dist: toml (>=0.10.2,<0.11.0)
|
|
43
|
+
Requires-Dist: typer (>=0.12.5,<0.13.0)
|
|
44
|
+
Requires-Dist: types-pillow (>=10.2.0.20240822,<11.0.0.0)
|
|
45
|
+
Requires-Dist: typing-extensions (>=4.12.2,<5.0.0)
|
|
46
|
+
Requires-Dist: yattag (>=1.15.2,<2.0.0)
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from typing import Set, cast
|
|
3
|
+
|
|
4
|
+
from pipelex import log
|
|
5
|
+
from pipelex.activity_models import ActivityReport
|
|
6
|
+
from pipelex.config import get_config
|
|
7
|
+
from pipelex.core.stuff import Stuff, StuffContent
|
|
8
|
+
from pipelex.core.stuff_content import (
|
|
9
|
+
HtmlContent,
|
|
10
|
+
ImageContent,
|
|
11
|
+
ListContent,
|
|
12
|
+
MermaidContent,
|
|
13
|
+
NumberContent,
|
|
14
|
+
StructuredContent,
|
|
15
|
+
TextContent,
|
|
16
|
+
)
|
|
17
|
+
from pipelex.tools.misc.file_fetching_helpers import fetch_file_from_url_httpx
|
|
18
|
+
from pipelex.tools.utils.file_utils import save_to_path
|
|
19
|
+
from pipelex.tools.utils.json_utils import save_as_json_to_path
|
|
20
|
+
from pipelex.tools.utils.path_utils import ensure_path
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class ActivityHandlerForResultFiles:
|
|
24
|
+
def __init__(self, result_dir_path: str):
|
|
25
|
+
self.result_dir_path = result_dir_path
|
|
26
|
+
self.images_dir_path = os.path.join(result_dir_path, "images")
|
|
27
|
+
imgg_config = get_config().cogt.imgg_config
|
|
28
|
+
imgg_param_defaults = imgg_config.imgg_param_defaults
|
|
29
|
+
self.image_output_format = imgg_param_defaults.output_format
|
|
30
|
+
self.already_handled_stuff: Set[str] = set()
|
|
31
|
+
|
|
32
|
+
def _generate_stuff_id(self, stuff: Stuff) -> str:
|
|
33
|
+
# Use name if available, otherwise just use code
|
|
34
|
+
name_part = stuff.stuff_name.replace(" ", "_") if stuff.stuff_name else ""
|
|
35
|
+
return f"{name_part}_{stuff.stuff_code}" if name_part else stuff.stuff_code
|
|
36
|
+
|
|
37
|
+
def handle_activity(self, activity_report: ActivityReport) -> None:
|
|
38
|
+
if isinstance(activity_report.content, Stuff):
|
|
39
|
+
the_stuff = activity_report.content
|
|
40
|
+
if the_stuff.stuff_code in self.already_handled_stuff:
|
|
41
|
+
log.info(f"Already handled stuff: {the_stuff.stuff_name}")
|
|
42
|
+
return
|
|
43
|
+
self.handle_stuff(stuff=the_stuff)
|
|
44
|
+
if code := the_stuff.stuff_code:
|
|
45
|
+
self.already_handled_stuff.add(code)
|
|
46
|
+
else:
|
|
47
|
+
log.error(f"Unhandled activity_report: {activity_report}")
|
|
48
|
+
|
|
49
|
+
def handle_stuff(self, stuff: Stuff) -> None:
|
|
50
|
+
# Create a directory for this stuff using its code and name
|
|
51
|
+
stuff_id = self._generate_stuff_id(stuff)
|
|
52
|
+
|
|
53
|
+
# Handle different content types
|
|
54
|
+
if isinstance(stuff.content, TextContent):
|
|
55
|
+
self._handle_text_content(content=stuff.content, stuff_id=stuff_id)
|
|
56
|
+
elif isinstance(stuff.content, NumberContent):
|
|
57
|
+
self._handle_number_content(content=stuff.content, stuff_id=stuff_id)
|
|
58
|
+
elif isinstance(stuff.content, ImageContent):
|
|
59
|
+
self._handle_image_content(content=stuff.content, stuff_id=stuff_id)
|
|
60
|
+
elif isinstance(stuff.content, HtmlContent):
|
|
61
|
+
self._handle_html_content(content=stuff.content, stuff_id=stuff_id)
|
|
62
|
+
elif isinstance(stuff.content, MermaidContent):
|
|
63
|
+
self._handle_mermaid_content(content=stuff.content, stuff_id=stuff_id)
|
|
64
|
+
elif isinstance(stuff.content, StructuredContent):
|
|
65
|
+
self._handle_structured_content(content=stuff.content, stuff_id=stuff_id)
|
|
66
|
+
elif isinstance(stuff.content, ListContent):
|
|
67
|
+
# TODO: check that all items are StuffContent
|
|
68
|
+
self._handle_list_content(content=cast(ListContent[StuffContent], stuff.content), stuff_id=stuff_id) # type: ignore
|
|
69
|
+
else:
|
|
70
|
+
log.error(f"Unhandled stuff content type: {type(stuff.content)}")
|
|
71
|
+
|
|
72
|
+
def _handle_text_content(self, content: TextContent, stuff_id: str) -> None:
|
|
73
|
+
stuff_dir = os.path.join(self.result_dir_path, stuff_id)
|
|
74
|
+
ensure_path(stuff_dir)
|
|
75
|
+
|
|
76
|
+
save_to_path(content.text, os.path.join(stuff_dir, f"{stuff_id}.txt"))
|
|
77
|
+
# Also save rendered versions
|
|
78
|
+
save_to_path(content.rendered_html(), os.path.join(stuff_dir, f"{stuff_id}.html"))
|
|
79
|
+
save_to_path(content.rendered_markdown(), os.path.join(stuff_dir, f"{stuff_id}.md"))
|
|
80
|
+
|
|
81
|
+
def _handle_number_content(self, content: NumberContent, stuff_id: str) -> None:
|
|
82
|
+
stuff_dir = os.path.join(self.result_dir_path, stuff_id)
|
|
83
|
+
ensure_path(stuff_dir)
|
|
84
|
+
save_to_path(str(content.number), os.path.join(stuff_dir, f"{stuff_id}.txt"))
|
|
85
|
+
|
|
86
|
+
def _handle_image_content(self, content: ImageContent, stuff_id: str) -> None:
|
|
87
|
+
# Save the image
|
|
88
|
+
image_path = os.path.join(self.images_dir_path, f"{stuff_id}.{self.image_output_format}")
|
|
89
|
+
if content.url.startswith("http"):
|
|
90
|
+
image_bytes: bytes = fetch_file_from_url_httpx(url=content.url, timeout=10)
|
|
91
|
+
with open(image_path, "wb") as image_file:
|
|
92
|
+
image_file.write(image_bytes)
|
|
93
|
+
else:
|
|
94
|
+
image_path = content.url
|
|
95
|
+
|
|
96
|
+
ensure_path(self.images_dir_path)
|
|
97
|
+
|
|
98
|
+
def _handle_html_content(self, content: HtmlContent, stuff_id: str) -> None:
|
|
99
|
+
stuff_dir = os.path.join(self.result_dir_path, stuff_id)
|
|
100
|
+
ensure_path(stuff_dir)
|
|
101
|
+
# Save the raw HTML
|
|
102
|
+
save_to_path(content.inner_html, os.path.join(stuff_dir, f"{stuff_id}.html"))
|
|
103
|
+
# Save CSS class
|
|
104
|
+
save_to_path(content.css_class, os.path.join(stuff_dir, f"{stuff_id}_css.txt"))
|
|
105
|
+
|
|
106
|
+
def _handle_mermaid_content(self, content: MermaidContent, stuff_id: str) -> None:
|
|
107
|
+
# Save the Mermaid code
|
|
108
|
+
save_to_path(content.mermaid_code, os.path.join(self.result_dir_path, f"{stuff_id}.mmd"))
|
|
109
|
+
|
|
110
|
+
def _handle_structured_content(self, content: StructuredContent, stuff_id: str) -> None:
|
|
111
|
+
stuff_dir = os.path.join(self.result_dir_path, stuff_id)
|
|
112
|
+
ensure_path(stuff_dir)
|
|
113
|
+
# Save the structured content as JSON
|
|
114
|
+
save_as_json_to_path(content, os.path.join(stuff_dir, f"{stuff_id}.json"))
|
|
115
|
+
# Save rendered versions
|
|
116
|
+
save_to_path(content.rendered_markdown(), os.path.join(stuff_dir, f"{stuff_id}.md"))
|
|
117
|
+
|
|
118
|
+
def _handle_list_content(self, content: ListContent[StuffContent], stuff_id: str) -> None:
|
|
119
|
+
stuff_dir = os.path.join(self.result_dir_path, stuff_id)
|
|
120
|
+
ensure_path(stuff_dir)
|
|
121
|
+
# Save each item in the list
|
|
122
|
+
items_dir = os.path.join(stuff_dir, f"{stuff_id}_items")
|
|
123
|
+
ensure_path(items_dir)
|
|
124
|
+
for i, item in enumerate(content.items):
|
|
125
|
+
item_dir = os.path.join(items_dir, f"item_{i}")
|
|
126
|
+
ensure_path(item_dir)
|
|
127
|
+
save_to_path(str(item), os.path.join(item_dir, f"{stuff_id}_item_{i}.txt"))
|
|
128
|
+
|
|
129
|
+
# Save rendered versions of the full list
|
|
130
|
+
save_to_path(content.rendered_markdown(), os.path.join(stuff_dir, f"{stuff_id}.md"))
|
|
131
|
+
save_to_path(content.rendered_json(), os.path.join(stuff_dir, f"{stuff_id}.json"))
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
from typing import ClassVar, Dict, Optional
|
|
2
|
+
|
|
3
|
+
from pydantic import Field
|
|
4
|
+
|
|
5
|
+
from pipelex import log
|
|
6
|
+
from pipelex.activity_models import ActivityCallback, ActivityReport
|
|
7
|
+
from pipelex.tools.exceptions import RootException
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class ActivityManagerError(RootException):
|
|
11
|
+
pass
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class ActivityManager:
|
|
15
|
+
_shared_instance: ClassVar[Optional["ActivityManager"]] = None
|
|
16
|
+
|
|
17
|
+
def __init__(self) -> None:
|
|
18
|
+
if ActivityManager._shared_instance is not None:
|
|
19
|
+
raise RuntimeError("ActivityManager is a singleton. Use get_instance() to access it.")
|
|
20
|
+
super().__init__()
|
|
21
|
+
ActivityManager._shared_instance = self
|
|
22
|
+
self.activity_callbacks: Dict[str, ActivityCallback] = Field(default_factory=dict)
|
|
23
|
+
log.debug("ActivityManager initialized")
|
|
24
|
+
|
|
25
|
+
@classmethod
|
|
26
|
+
def get_instance(cls) -> "ActivityManager":
|
|
27
|
+
if cls._shared_instance is None:
|
|
28
|
+
raise RuntimeError("Shared instance is not set. You must call ActivityManager.setup() once.")
|
|
29
|
+
return cls._shared_instance
|
|
30
|
+
|
|
31
|
+
@classmethod
|
|
32
|
+
def setup(cls) -> "ActivityManager":
|
|
33
|
+
cls._shared_instance = cls()
|
|
34
|
+
cls._shared_instance.activity_callbacks = {}
|
|
35
|
+
return cls._shared_instance
|
|
36
|
+
|
|
37
|
+
@classmethod
|
|
38
|
+
def teardown(cls) -> None:
|
|
39
|
+
if cls._shared_instance is not None:
|
|
40
|
+
cls._shared_instance.reset()
|
|
41
|
+
cls._shared_instance = None
|
|
42
|
+
log.debug("ActivityManager teardown done")
|
|
43
|
+
|
|
44
|
+
def reset(self):
|
|
45
|
+
self.activity_callbacks = {}
|
|
46
|
+
|
|
47
|
+
def add_activity_callback(self, key: str, callback: ActivityCallback):
|
|
48
|
+
if key in self.activity_callbacks:
|
|
49
|
+
log.warning(f"Activity callback with key '{key}' already exists")
|
|
50
|
+
self.activity_callbacks[key] = callback
|
|
51
|
+
|
|
52
|
+
def dispatch_activity(self, activity_report: ActivityReport):
|
|
53
|
+
for key, callback in self.activity_callbacks.items():
|
|
54
|
+
log.dev(f"Dispatching activity to callback '{key}'")
|
|
55
|
+
callback(activity_report)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def get_activity_manager() -> ActivityManager:
|
|
59
|
+
return ActivityManager.get_instance()
|
|
File without changes
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
from typing import Annotated, Optional
|
|
2
|
+
|
|
3
|
+
import typer
|
|
4
|
+
from click import Command, Context
|
|
5
|
+
from typer.core import TyperGroup
|
|
6
|
+
from typing_extensions import override
|
|
7
|
+
|
|
8
|
+
from pipelex import log, pretty_print
|
|
9
|
+
from pipelex.libraries.library_config import LibraryConfig
|
|
10
|
+
from pipelex.pipelex import Pipelex
|
|
11
|
+
from pipelex.tools.config.manager import config_manager
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class PipelexCLI(TyperGroup):
|
|
15
|
+
@override
|
|
16
|
+
def get_command(self, ctx: Context, cmd_name: str) -> Optional[Command]:
|
|
17
|
+
cmd = super().get_command(ctx, cmd_name)
|
|
18
|
+
if cmd is None:
|
|
19
|
+
typer.echo(ctx.get_help())
|
|
20
|
+
ctx.exit(1)
|
|
21
|
+
return cmd
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
app = typer.Typer(
|
|
25
|
+
add_completion=False,
|
|
26
|
+
no_args_is_help=True,
|
|
27
|
+
pretty_exceptions_show_locals=False,
|
|
28
|
+
cls=PipelexCLI,
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
@app.command()
|
|
33
|
+
def init(
|
|
34
|
+
overwrite: Annotated[bool, typer.Option("--overwrite", "-o", help="Warning: If set, existing files will be overwritten.")] = False,
|
|
35
|
+
) -> None:
|
|
36
|
+
"""Initialize pipelex configuration in the current directory."""
|
|
37
|
+
if overwrite:
|
|
38
|
+
typer.echo("Warning: Overwriting existing files.")
|
|
39
|
+
|
|
40
|
+
# Duplicate pipelines and other libraries from the base library
|
|
41
|
+
LibraryConfig.export_libraries(overwrite=overwrite)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
@app.command()
|
|
45
|
+
def run_setup() -> None:
|
|
46
|
+
"""Run the setup sequence."""
|
|
47
|
+
LibraryConfig.export_libraries()
|
|
48
|
+
Pipelex.make()
|
|
49
|
+
log.info("Running setup sequence passed OK.")
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
@app.command()
|
|
53
|
+
def show_config() -> None:
|
|
54
|
+
"""Show the pipelex configuration."""
|
|
55
|
+
try:
|
|
56
|
+
final_config = config_manager.load_config()
|
|
57
|
+
pretty_print(final_config, title=f"Pipelex configuration for project: {config_manager.get_project_name()}")
|
|
58
|
+
except Exception as e:
|
|
59
|
+
typer.echo(f"Error: {e}", err=True)
|
|
60
|
+
raise typer.Exit(1)
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def main() -> None:
|
|
64
|
+
"""Entry point for the pipelex CLI."""
|
|
65
|
+
app()
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
from typing import Any, Optional, cast
|
|
2
|
+
|
|
3
|
+
import httpx
|
|
4
|
+
from typing_extensions import override
|
|
5
|
+
|
|
6
|
+
from pipelex.client.protocol import (
|
|
7
|
+
ApiResponse,
|
|
8
|
+
PipelexProtocol,
|
|
9
|
+
PipeRequest,
|
|
10
|
+
PipeStartResponse,
|
|
11
|
+
PipeStatus,
|
|
12
|
+
)
|
|
13
|
+
from pipelex.tools.environment import get_required_env
|
|
14
|
+
from pipelex.tools.serde import kajson
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class PipelexApiClient(PipelexProtocol):
|
|
18
|
+
"""
|
|
19
|
+
A protocol-compliant client for interacting with Pipelex pipes via API.
|
|
20
|
+
|
|
21
|
+
This client implements the PipelexProtocol interface for pure API communication.
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
def __init__(
|
|
25
|
+
self,
|
|
26
|
+
api_token: str,
|
|
27
|
+
):
|
|
28
|
+
"""
|
|
29
|
+
Initialize the PipelexApiClient.
|
|
30
|
+
|
|
31
|
+
Args:
|
|
32
|
+
api_token: Authentication token for the API
|
|
33
|
+
"""
|
|
34
|
+
self.api_token = api_token
|
|
35
|
+
self.api_base_url = get_required_env("EV_API_BASE_URL")
|
|
36
|
+
|
|
37
|
+
def start_client(self) -> "PipelexApiClient":
|
|
38
|
+
self.client = httpx.AsyncClient(base_url=self.api_base_url, headers={"Authorization": f"Bearer {self.api_token}"})
|
|
39
|
+
return self
|
|
40
|
+
|
|
41
|
+
async def close(self):
|
|
42
|
+
"""Close the HTTP client."""
|
|
43
|
+
await self.client.aclose()
|
|
44
|
+
|
|
45
|
+
async def _make_api_call(self, endpoint: str, request: Optional[str] = None) -> Any:
|
|
46
|
+
"""Make an API call to the Pipelex server.
|
|
47
|
+
|
|
48
|
+
Args:
|
|
49
|
+
endpoint: The API endpoint to call, relative to the base URL
|
|
50
|
+
request: A JSON-formatted string to send as the request body, or None if no body is needed
|
|
51
|
+
|
|
52
|
+
Returns:
|
|
53
|
+
Any: The JSON-decoded response from the server
|
|
54
|
+
|
|
55
|
+
Raises:
|
|
56
|
+
httpx.HTTPError: If the request fails or returns a non-200 status code
|
|
57
|
+
"""
|
|
58
|
+
# Convert JSON string to UTF-8 bytes if not None
|
|
59
|
+
content = request.encode("utf-8") if request is not None else None
|
|
60
|
+
response = await self.client.post(f"/{endpoint}", content=content, headers={"Content-Type": "application/json"}, timeout=120.0)
|
|
61
|
+
response.raise_for_status()
|
|
62
|
+
return response.json()
|
|
63
|
+
|
|
64
|
+
@override
|
|
65
|
+
async def execute_pipe(
|
|
66
|
+
self,
|
|
67
|
+
pipe_code: str,
|
|
68
|
+
request: PipeRequest,
|
|
69
|
+
) -> PipeStatus:
|
|
70
|
+
"""
|
|
71
|
+
Execute a pipe with the given request and wait for completion.
|
|
72
|
+
|
|
73
|
+
This is a blocking operation that does not return until the pipe execution
|
|
74
|
+
is complete. For long-running pipes, consider using start_pipe instead.
|
|
75
|
+
|
|
76
|
+
Args:
|
|
77
|
+
pipe_code: The unique identifier for the pipe to execute
|
|
78
|
+
request: PipeRequest containing memory and output concept
|
|
79
|
+
|
|
80
|
+
Returns:
|
|
81
|
+
PipeStatus with the final execution status and pipe output
|
|
82
|
+
|
|
83
|
+
Raises:
|
|
84
|
+
HTTPException: If the request fails or returns a non-200 status code
|
|
85
|
+
"""
|
|
86
|
+
response = await self._make_api_call(f"pipelex/v1/pipes/{pipe_code}/execute", request=kajson.dumps(request))
|
|
87
|
+
return cast(PipeStatus, kajson.loads(response))
|
|
88
|
+
|
|
89
|
+
@override
|
|
90
|
+
async def start_pipe(
|
|
91
|
+
self,
|
|
92
|
+
pipe_code: str,
|
|
93
|
+
request: PipeRequest,
|
|
94
|
+
) -> PipeStartResponse:
|
|
95
|
+
"""
|
|
96
|
+
Start a pipe execution in the background without waiting for completion.
|
|
97
|
+
|
|
98
|
+
This is a non-blocking operation that returns immediately with an execution ID.
|
|
99
|
+
The execution will continue in the background, and the status can be checked
|
|
100
|
+
using get_pipe_status.
|
|
101
|
+
|
|
102
|
+
Args:
|
|
103
|
+
pipe_code: The unique identifier for the pipe to execute
|
|
104
|
+
request: PipeRequest containing memory and output concept
|
|
105
|
+
|
|
106
|
+
Returns:
|
|
107
|
+
PipeStartResponse with the pipe_execution_id and created_at timestamp
|
|
108
|
+
|
|
109
|
+
Raises:
|
|
110
|
+
HTTPException: If the request fails or returns a non-200 status code
|
|
111
|
+
"""
|
|
112
|
+
response = await self._make_api_call(f"pipelex/v1/pipes/{pipe_code}/start", request=kajson.dumps(request))
|
|
113
|
+
return cast(PipeStartResponse, kajson.loads(response))
|
|
114
|
+
|
|
115
|
+
@override
|
|
116
|
+
async def get_pipe_status(
|
|
117
|
+
self,
|
|
118
|
+
pipe_execution_id: str,
|
|
119
|
+
) -> PipeStatus:
|
|
120
|
+
"""
|
|
121
|
+
Get the current status of a pipe execution.
|
|
122
|
+
|
|
123
|
+
This method allows checking the current status of a pipe execution
|
|
124
|
+
that was started with start_pipe.
|
|
125
|
+
|
|
126
|
+
Args:
|
|
127
|
+
pipe_execution_id: The unique identifier for the pipe execution
|
|
128
|
+
|
|
129
|
+
Returns:
|
|
130
|
+
PipeStatus with the current execution status and pipe output if completed
|
|
131
|
+
|
|
132
|
+
Raises:
|
|
133
|
+
HTTPException: If the request fails or returns a non-200 status code
|
|
134
|
+
"""
|
|
135
|
+
response = await self._make_api_call(f"pipelex/v1/pipes/{pipe_execution_id}/status", request=None)
|
|
136
|
+
return cast(PipeStatus, kajson.loads(response))
|
|
137
|
+
|
|
138
|
+
@override
|
|
139
|
+
async def cancel_pipe(
|
|
140
|
+
self,
|
|
141
|
+
pipe_execution_id: str,
|
|
142
|
+
) -> ApiResponse:
|
|
143
|
+
"""
|
|
144
|
+
Cancel a running pipe execution.
|
|
145
|
+
|
|
146
|
+
This method attempts to cancel a pipe execution that is currently in progress.
|
|
147
|
+
Once cancelled, a pipe cannot be resumed and must be started again if needed.
|
|
148
|
+
|
|
149
|
+
Args:
|
|
150
|
+
pipe_execution_id: The unique identifier for the pipe execution
|
|
151
|
+
|
|
152
|
+
Returns:
|
|
153
|
+
ApiResponse indicating success or failure of the cancellation
|
|
154
|
+
|
|
155
|
+
Raises:
|
|
156
|
+
HTTPException: If the request fails or returns a non-200 status code
|
|
157
|
+
"""
|
|
158
|
+
response = await self._make_api_call(f"pipelex/v1/pipes/{pipe_execution_id}/cancel", request=None)
|
|
159
|
+
return ApiResponse(**response)
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
|
|
3
|
+
from pipelex.client.api_client import PipelexApiClient
|
|
4
|
+
from pipelex.client.protocol import (
|
|
5
|
+
PipeRequest,
|
|
6
|
+
PipeStartResponse,
|
|
7
|
+
PipeState,
|
|
8
|
+
PipeStatus,
|
|
9
|
+
)
|
|
10
|
+
from pipelex.exceptions import ClientAuthenticationError
|
|
11
|
+
from pipelex.pipe_works.pipe_wrappers import execute_pipe
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class PipelexClient:
|
|
15
|
+
"""
|
|
16
|
+
A high-level client for interacting with Pipelex pipes.
|
|
17
|
+
|
|
18
|
+
This client provides a user-friendly interface for executing pipes either locally
|
|
19
|
+
or through the remote API, with automatic handling of both modes.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
def __init__(
|
|
23
|
+
self,
|
|
24
|
+
api_token: Optional[str] = None,
|
|
25
|
+
):
|
|
26
|
+
"""
|
|
27
|
+
Initialize the PipelexClient.
|
|
28
|
+
|
|
29
|
+
Args:
|
|
30
|
+
api_token: Authentication token for the API
|
|
31
|
+
"""
|
|
32
|
+
self.api_token = api_token
|
|
33
|
+
self.api_client: Optional[PipelexApiClient] = None
|
|
34
|
+
|
|
35
|
+
async def start_api_client(self) -> PipelexApiClient:
|
|
36
|
+
"""
|
|
37
|
+
Start the API client.
|
|
38
|
+
"""
|
|
39
|
+
if not self.api_token:
|
|
40
|
+
raise ClientAuthenticationError("API token is required for API execution")
|
|
41
|
+
|
|
42
|
+
self.api_client = PipelexApiClient(api_token=self.api_token).start_client()
|
|
43
|
+
return self.api_client
|
|
44
|
+
|
|
45
|
+
async def close_api_client(self):
|
|
46
|
+
"""
|
|
47
|
+
Close the API client.
|
|
48
|
+
"""
|
|
49
|
+
if self.api_client:
|
|
50
|
+
await self.api_client.close()
|
|
51
|
+
self.api_client = None
|
|
52
|
+
|
|
53
|
+
async def execute_pipe(
|
|
54
|
+
self,
|
|
55
|
+
pipe_code: str,
|
|
56
|
+
pipe_execute_request: PipeRequest,
|
|
57
|
+
use_local_execution: bool = True,
|
|
58
|
+
) -> PipeStatus:
|
|
59
|
+
"""
|
|
60
|
+
Execute a pipe with the given request and wait for completion.
|
|
61
|
+
|
|
62
|
+
Args:
|
|
63
|
+
pipe_code: The code of the pipe to execute
|
|
64
|
+
pipe_execute_request: The request containing memory and output concept
|
|
65
|
+
use_local_execution: Whether to execute locally (True) or via API (False)
|
|
66
|
+
|
|
67
|
+
Returns:
|
|
68
|
+
PipeStatus with execution results and pipe output
|
|
69
|
+
"""
|
|
70
|
+
# Local execution
|
|
71
|
+
if use_local_execution:
|
|
72
|
+
pipe_output = await execute_pipe(
|
|
73
|
+
pipe_code=pipe_code,
|
|
74
|
+
working_memory=pipe_execute_request.memory,
|
|
75
|
+
output_concept_code=pipe_execute_request.output_concept,
|
|
76
|
+
)
|
|
77
|
+
return PipeStatus(
|
|
78
|
+
pipe_execution_id="local",
|
|
79
|
+
pipe_code=pipe_code,
|
|
80
|
+
state=PipeState.COMPLETED,
|
|
81
|
+
pipe_output=pipe_output,
|
|
82
|
+
)
|
|
83
|
+
# api_client = await self.start_api_client()
|
|
84
|
+
# return await api_client.execute_pipe(pipe_code, pipe_execute_request)
|
|
85
|
+
raise NotImplementedError("Pipelex API functionality is coming soon!")
|
|
86
|
+
|
|
87
|
+
async def start_pipe(
|
|
88
|
+
self,
|
|
89
|
+
pipe_code: str,
|
|
90
|
+
pipe_execute_request: PipeRequest,
|
|
91
|
+
) -> PipeStartResponse:
|
|
92
|
+
"""
|
|
93
|
+
Start a pipe execution in the background without waiting for completion.
|
|
94
|
+
|
|
95
|
+
This is a non-blocking operation that returns immediately with an execution ID.
|
|
96
|
+
The execution will continue in the background, and the status can be checked
|
|
97
|
+
using get_pipe_status. Note that this method always uses API execution.
|
|
98
|
+
|
|
99
|
+
Args:
|
|
100
|
+
pipe_code: The code of the pipe to execute
|
|
101
|
+
pipe_execute_request: The request containing memory and output concept
|
|
102
|
+
|
|
103
|
+
Returns:
|
|
104
|
+
PipeStartResponse with the pipe_execution_id and created_at timestamp
|
|
105
|
+
|
|
106
|
+
Raises:
|
|
107
|
+
ValueError: If API token is not provided
|
|
108
|
+
HTTPException: If the API request fails
|
|
109
|
+
"""
|
|
110
|
+
# api_client = await self.start_api_client()
|
|
111
|
+
# return await api_client.start_pipe(pipe_code, pipe_execute_request)
|
|
112
|
+
raise NotImplementedError("Pipelex API functionality is coming soon!")
|
|
113
|
+
|
|
114
|
+
async def get_pipe_status(
|
|
115
|
+
self,
|
|
116
|
+
pipe_execution_id: str,
|
|
117
|
+
) -> PipeStatus:
|
|
118
|
+
"""
|
|
119
|
+
Get the current status of a pipe execution.
|
|
120
|
+
|
|
121
|
+
This method allows checking the current status of a pipe execution
|
|
122
|
+
that was started with start_pipe. Note that this method always uses
|
|
123
|
+
API execution.
|
|
124
|
+
|
|
125
|
+
Args:
|
|
126
|
+
pipe_execution_id: The unique identifier for the pipe execution
|
|
127
|
+
|
|
128
|
+
Returns:
|
|
129
|
+
PipeStatus with the current execution status and pipe output if completed
|
|
130
|
+
|
|
131
|
+
Raises:
|
|
132
|
+
ValueError: If API token is not provided
|
|
133
|
+
HTTPException: If the API request fails or the execution ID is invalid
|
|
134
|
+
"""
|
|
135
|
+
# api_client = await self.start_api_client()
|
|
136
|
+
# return await api_client.get_pipe_status(pipe_execution_id)
|
|
137
|
+
raise NotImplementedError("Pipelex API functionality is coming soon!")
|