├── .devcontainer ├── Dockerfile ├── base.Dockerfile ├── devcontainer.json └── library-scripts │ ├── README.md │ ├── common-debian.sh │ ├── meta.env │ ├── node-debian.sh │ └── python-debian.sh ├── .flake8 ├── .github └── workflows │ ├── docs-publish.yml │ ├── notify-of-release.yml │ ├── python-publish.yml │ ├── test-main.yml │ └── test-staging.yml ├── .gitignore ├── .pre-commit-config.yaml ├── AUTHORS.rst ├── CHANGELOG.rst ├── DEVELOPING.md ├── LICENSE ├── README.md ├── TESTING.md ├── badge.svg ├── docs ├── README.txt ├── api │ ├── Dockerfile │ ├── Makefile │ ├── _static │ │ ├── .gitignore │ │ ├── Steamship-symbol-dark.png │ │ ├── Steamship-symbol-light.png │ │ └── favicon.ico │ ├── api │ │ ├── modules.rst │ │ ├── steamship.agents.examples.rst │ │ ├── steamship.agents.functional.rst │ │ ├── steamship.agents.llms.rst │ │ ├── steamship.agents.mixins.rst │ │ ├── steamship.agents.mixins.transports.rst │ │ ├── steamship.agents.react.rst │ │ ├── steamship.agents.rst │ │ ├── steamship.agents.schema.rst │ │ ├── steamship.agents.service.rst │ │ ├── steamship.agents.tools.audio_transcription.rst │ │ ├── steamship.agents.tools.classification.rst │ │ ├── steamship.agents.tools.conversation_starters.rst │ │ ├── steamship.agents.tools.image_generation.rst │ │ ├── steamship.agents.tools.question_answering.rst │ │ ├── steamship.agents.tools.rst │ │ ├── steamship.agents.tools.search.rst │ │ ├── steamship.agents.tools.speech_generation.rst │ │ ├── steamship.agents.tools.text_generation.rst │ │ ├── steamship.agents.tools.video_generation.rst │ │ ├── steamship.base.rst │ │ ├── steamship.cli.local_server.rst │ │ ├── steamship.cli.rst │ │ ├── steamship.client.rst │ │ ├── steamship.experimental.easy.rst │ │ ├── steamship.experimental.package_starters.rst │ │ ├── steamship.experimental.rst │ │ ├── steamship.invocable.mixins.rst │ │ ├── steamship.invocable.rst │ │ ├── steamship.plugin.blockifier.rst │ │ ├── steamship.plugin.inputs.rst │ │ ├── steamship.plugin.outputs.rst │ │ ├── steamship.plugin.rst │ │ ├── steamship.rst │ │ └── steamship.utils.rst │ ├── authors.rst │ ├── conf.py │ ├── index.rst │ └── license.rst ├── nextra │ ├── .nojekyll │ ├── Dockerfile │ ├── Makefile │ ├── _static │ │ ├── .gitignore │ │ ├── Steamship-symbol-dark.png │ │ ├── Steamship-symbol-light.png │ │ └── favicon.ico │ ├── _templates │ │ └── base.html │ ├── agents │ │ └── index.rst │ ├── api │ │ ├── modules.rst │ │ ├── steamship.agents.examples.rst │ │ ├── steamship.agents.functional.rst │ │ ├── steamship.agents.llms.rst │ │ ├── steamship.agents.mixins.rst │ │ ├── steamship.agents.mixins.transports.rst │ │ ├── steamship.agents.react.rst │ │ ├── steamship.agents.rst │ │ ├── steamship.agents.schema.rst │ │ ├── steamship.agents.service.rst │ │ ├── steamship.agents.tools.audio_transcription.rst │ │ ├── steamship.agents.tools.classification.rst │ │ ├── steamship.agents.tools.conversation_starters.rst │ │ ├── steamship.agents.tools.image_generation.rst │ │ ├── steamship.agents.tools.question_answering.rst │ │ ├── steamship.agents.tools.rst │ │ ├── steamship.agents.tools.search.rst │ │ ├── steamship.agents.tools.speech_generation.rst │ │ ├── steamship.agents.tools.text_generation.rst │ │ ├── steamship.agents.tools.video_generation.rst │ │ ├── steamship.base.rst │ │ ├── steamship.cli.local_server.rst │ │ ├── steamship.cli.rst │ │ ├── steamship.client.rst │ │ ├── steamship.experimental.easy.rst │ │ ├── steamship.experimental.package_starters.rst │ │ ├── steamship.experimental.rst │ │ ├── steamship.invocable.mixins.rst │ │ ├── steamship.invocable.rst │ │ ├── steamship.plugin.blockifier.rst │ │ ├── steamship.plugin.inputs.rst │ │ ├── steamship.plugin.outputs.rst │ │ ├── steamship.plugin.rst │ │ ├── steamship.rst │ │ └── steamship.utils.rst │ ├── authors.rst │ ├── changelog._rst │ ├── conf.py │ ├── configuration │ │ ├── authentication.rst │ │ ├── cli.rst │ │ ├── clients.rst │ │ ├── http.rst │ │ └── index.rst │ ├── data │ │ ├── blocks.rst │ │ ├── file-lifecycle.png │ │ ├── files.rst │ │ ├── index.rst │ │ ├── queries │ │ │ └── index.rst │ │ ├── tags.rst │ │ └── workspaces.rst │ ├── developing │ │ ├── configuration.rst │ │ ├── deploying.rst │ │ ├── environment-setup.rst │ │ ├── index.rst │ │ ├── logs-example.png │ │ ├── monitoring.rst │ │ ├── project-creation.rst │ │ ├── running.rst │ │ ├── steamship-manifest.rst │ │ ├── storing-secrets.rst │ │ ├── tasks-example.png │ │ ├── testing.rst │ │ └── usage-example.png │ ├── embedding-search │ │ └── index.rst │ ├── favicon.ico │ ├── index.rst │ ├── license.rst │ ├── make_markdown.sh │ ├── packages │ │ ├── cookbook │ │ │ ├── adding-configuration.rst │ │ │ ├── article-tagging.rst │ │ │ ├── collecting-and-querying-sentiment.rst │ │ │ ├── how-to-extract-outline-from-markdown.rst │ │ │ ├── index.rst │ │ │ ├── modifying-an-existing-package.rst │ │ │ ├── receiving-webhooks.rst │ │ │ ├── return-audio.rst │ │ │ ├── return-image.rst │ │ │ ├── return-json.rst │ │ │ └── return-text.rst │ │ ├── developing │ │ │ ├── index.rst │ │ │ └── project-structure.rst │ │ ├── index.rst │ │ └── using.rst │ ├── plugins │ │ ├── developing │ │ │ ├── async-plugins.rst │ │ │ ├── blockifiers.rst │ │ │ ├── embedders.rst │ │ │ ├── generators.rst │ │ │ ├── importers.rst │ │ │ ├── index.rst │ │ │ ├── project-structure.rst │ │ │ └── taggers.rst │ │ ├── index.rst │ │ └── using │ │ │ ├── blockifiers │ │ │ ├── index.rst │ │ │ └── using.rst │ │ │ ├── embedders │ │ │ └── index.rst │ │ │ ├── generators │ │ │ ├── dalle.rst │ │ │ ├── gpt4.rst │ │ │ └── index.rst │ │ │ ├── importers │ │ │ ├── index.rst │ │ │ └── using.rst │ │ │ ├── index.rst │ │ │ ├── taggers │ │ │ ├── index.rst │ │ │ └── using.rst │ │ │ └── tasks.rst │ └── rename_link.js └── requirements.txt ├── pyproject.toml ├── requirements.dev.txt ├── requirements.txt ├── scripts ├── build-docs.sh └── create_engine_test_assets.py ├── src └── steamship │ ├── __init__.py │ ├── agents │ ├── __init__.py │ ├── basic_chat.py │ ├── examples │ │ ├── __init__.py │ │ ├── chatgpt_api.py │ │ ├── chatgpt_with_web_and_telegram.py │ │ ├── document_qa_agent.py │ │ ├── example_assistant.py │ │ ├── example_assistant_with_caching.py │ │ ├── example_react_assistant.py │ │ ├── fact_learner.py │ │ └── telegram_bot.py │ ├── functional │ │ ├── __init__.py │ │ ├── functions_based.py │ │ └── output_parser.py │ ├── functions_based.py │ ├── llms │ │ ├── __init__.py │ │ ├── openai.py │ │ └── steamship_llm.py │ ├── logging.py │ ├── mixins │ │ ├── __init__.py │ │ └── transports │ │ │ ├── __init__.py │ │ │ ├── slack.py │ │ │ ├── steamship_widget.py │ │ │ ├── telegram.py │ │ │ └── transport.py │ ├── react │ │ ├── __init__.py │ │ ├── output_parser.py │ │ └── react.py │ ├── schema │ │ ├── __init__.py │ │ ├── action.py │ │ ├── agent.py │ │ ├── cache.py │ │ ├── chathistory.py │ │ ├── context.py │ │ ├── functions.py │ │ ├── llm.py │ │ ├── message_selectors.py │ │ ├── output_parser.py │ │ ├── text_splitters.py │ │ └── tool.py │ ├── service │ │ ├── __init__.py │ │ └── agent_service.py │ ├── tools │ │ ├── __init__.py │ │ ├── audio_transcription │ │ │ ├── __init__.py │ │ │ ├── assembly_speech_to_text_tool.py │ │ │ ├── fetch_audio_urls_from_rss_tool.py │ │ │ └── whisper_speech_to_text_tool.py │ │ ├── base_tools.py │ │ ├── classification │ │ │ ├── __init__.py │ │ │ ├── multiple_choice_tool.py │ │ │ ├── sentiment_analysis_tool.py │ │ │ └── zero_shot_classifier_tool.py │ │ ├── conversation_starters │ │ │ ├── __init__.py │ │ │ └── knock_knock_tool.py │ │ ├── image_generation │ │ │ ├── __init__.py │ │ │ ├── dalle.py │ │ │ ├── google_image_search.py │ │ │ └── stable_diffusion.py │ │ ├── question_answering │ │ │ ├── __init__.py │ │ │ ├── prompt_database_question_answerer.py │ │ │ ├── vector_search_learner_tool.py │ │ │ ├── vector_search_qa_tool.py │ │ │ └── vector_search_tool.py │ │ ├── search │ │ │ ├── __init__.py │ │ │ └── search.py │ │ ├── speech_generation │ │ │ ├── __init__.py │ │ │ └── generate_speech.py │ │ ├── text_generation │ │ │ ├── __init__.py │ │ │ ├── custom_llm_prompt.py │ │ │ ├── image_prompt_generator_tool.py │ │ │ ├── json_object_generator.py │ │ │ ├── personality_tool.py │ │ │ ├── summarize_text_with_prompt_tool.py │ │ │ ├── text_rewrite_tool.py │ │ │ └── text_translation_tool.py │ │ └── video_generation │ │ │ ├── __init__.py │ │ │ └── did_video_generator_tool.py │ └── utils.py │ ├── base │ ├── __init__.py │ ├── client.py │ ├── configuration.py │ ├── environments.py │ ├── error.py │ ├── mime_types.py │ ├── model.py │ ├── package_spec.py │ ├── request.py │ ├── response.py │ └── tasks.py │ ├── cli │ ├── __init__.py │ ├── cli.py │ ├── create_instance.py │ ├── deploy.py │ ├── local_server │ │ ├── __init__.py │ │ ├── handler.py │ │ └── server.py │ ├── login.py │ ├── manifest_init_wizard.py │ ├── requirements_init_wizard.py │ ├── ship_spinner.py │ └── utils.py │ ├── client │ ├── __init__.py │ ├── skill_to_provider.py │ ├── skills.py │ ├── steamship.py │ └── vendors.py │ ├── data │ ├── __init__.py │ ├── block.py │ ├── embeddings.py │ ├── file.py │ ├── invocable_init_status.py │ ├── manifest.py │ ├── operations │ │ ├── __init__.py │ │ ├── blockifier.py │ │ ├── embedder.py │ │ ├── generator.py │ │ └── tagger.py │ ├── package │ │ ├── __init__.py │ │ ├── package.py │ │ ├── package_instance.py │ │ └── package_version.py │ ├── plugin │ │ ├── __init__.py │ │ ├── hosting.py │ │ ├── index_plugin_instance.py │ │ ├── plugin.py │ │ ├── plugin_instance.py │ │ ├── plugin_version.py │ │ └── prompt_generation_plugin_instance.py │ ├── search.py │ ├── tags │ │ ├── __init__.py │ │ ├── tag.py │ │ ├── tag_constants.py │ │ └── tag_utils.py │ ├── user.py │ └── workspace.py │ ├── invocable │ ├── __init__.py │ ├── config.py │ ├── dev_logging_handler.py │ ├── entrypoint.py │ ├── invocable.py │ ├── invocable_localhost.py │ ├── invocable_request.py │ ├── invocable_response.py │ ├── lambda_handler.py │ ├── mixins │ │ ├── __init__.py │ │ ├── blockifier_mixin.py │ │ ├── file_importer_mixin.py │ │ ├── indexer_mixin.py │ │ └── indexer_pipeline_mixin.py │ ├── package_mixin.py │ ├── package_service.py │ ├── paramater_types.py │ └── plugin_service.py │ ├── plugin │ ├── __init__.py │ ├── blockifier │ │ ├── __init__.py │ │ ├── blockifier.py │ │ └── transcriber.py │ ├── capabilities.py │ ├── embedder.py │ ├── file_importer.py │ ├── generator.py │ ├── inputs │ │ ├── __init__.py │ │ ├── block_and_tag_plugin_input.py │ │ ├── export_plugin_input.py │ │ ├── file_import_plugin_input.py │ │ ├── raw_block_and_tag_plugin_input.py │ │ ├── raw_block_and_tag_plugin_input_with_preallocated_blocks.py │ │ ├── raw_data_plugin_input.py │ │ ├── train_plugin_input.py │ │ └── training_parameter_plugin_input.py │ ├── outputs │ │ ├── __init__.py │ │ ├── block_and_tag_plugin_output.py │ │ ├── block_type_plugin_output.py │ │ ├── embedded_items_plugin_output.py │ │ ├── model_checkpoint.py │ │ ├── plugin_output.py │ │ ├── raw_block_and_tag_plugin_output.py │ │ ├── raw_data_plugin_output.py │ │ ├── stream_complete_plugin_output.py │ │ ├── train_plugin_output.py │ │ └── training_parameter_plugin_output.py │ ├── request.py │ ├── streaming_generator.py │ ├── tagger.py │ └── trainable_model.py │ └── utils │ ├── __init__.py │ ├── binary_utils.py │ ├── context_length.py │ ├── file_tags.py │ ├── huggingface_helper.py │ ├── kv_store.py │ ├── metadata.py │ ├── repl.py │ ├── signed_urls.py │ ├── text_chunker.py │ ├── url.py │ ├── utils.py │ └── zip_archives.py └── tests ├── __init__.py ├── assets ├── __init__.py ├── configs │ ├── empty_json.json │ ├── one_string_one_int.json │ └── single_integer.json ├── demo_package_spec.json ├── packages │ ├── __init__.py │ ├── adding_configuration.py │ ├── article_tagging.py │ ├── bad_package.py │ ├── configurable_hello_world.py │ ├── demo_package.py │ ├── echo_test_header.py │ ├── example_project_structure.py │ ├── fancy_types.py │ ├── hello_world.py │ ├── optional_params.py │ ├── package_verifying_instance_init.py │ ├── package_with_failing_instance_init.py │ ├── package_with_instance_init.py │ ├── package_with_mixin_importer.py │ ├── package_with_mixin_indexer_pipeline.py │ ├── package_with_mixins.py │ ├── request_id_plumbing_test_package.py │ ├── requirement_isolation_package.py │ ├── returns_blocks.py │ ├── returns_list.py │ ├── safe_loaded_bad_import.pyignore │ ├── safe_loaded_hello_world.py │ ├── signed_url_package.py │ └── transports │ │ ├── __init__.py │ │ ├── mock_slack_api.py │ │ ├── mock_telegram_api.py │ │ ├── test_transports_agent.py │ │ └── test_web_agent.py ├── palm_tree.png ├── plugins │ ├── __init__.py │ ├── blockifiers │ │ ├── __init__.py │ │ ├── async_blockifier.py │ │ ├── blockifier.py │ │ ├── csv_blockifier.py │ │ └── tsv_blockifier.py │ ├── generators │ │ ├── async_generator.py │ │ ├── plugin_with_instance_init.py │ │ ├── request_id_generator.py │ │ ├── test_generator.py │ │ ├── test_generator_returns_bytes.py │ │ ├── test_image_to_text_generator.py │ │ └── test_streaming_generator.py │ ├── importers │ │ ├── __init__.py │ │ ├── plugin_file_importer.py │ │ ├── plugin_file_importer_by_url.py │ │ ├── plugin_file_importer_python_error.py │ │ └── plugin_file_importer_steamship_error.py │ └── taggers │ │ ├── __init__.py │ │ ├── plugin_configurable_tagger.py │ │ ├── plugin_embedder.py │ │ ├── plugin_logging_tagger.py │ │ ├── plugin_parser.py │ │ ├── plugin_prompt_generator.py │ │ ├── plugin_tagger_bad_import.pyignore │ │ ├── plugin_third_party_trainable_tagger.py │ │ ├── plugin_trainable_tagger.py │ │ └── plugin_trainable_tagger_config.py ├── test.pdf ├── utterances.csv └── utterances.tsv ├── conftest.py └── steamship_tests ├── __init__.py ├── agents ├── __init__.py ├── test_agent_limits.py ├── test_agent_service.py ├── test_agent_with_final_tool.py ├── test_cache.py ├── test_chat_history.py ├── test_function_agent_output_parser.py ├── test_functions_based_agent.py ├── test_message_formatting.py ├── test_openai.py ├── test_qa_agent.py ├── test_react_parse_output.py ├── tools │ ├── __init__.py │ ├── test_dalle_tool.py │ ├── test_fact_learner_tools.py │ ├── test_multiple_choice_tool.py │ └── test_vector_search_qa_tool.py └── transports │ ├── __init__.py │ ├── test_slack.py │ ├── test_telegram.py │ └── test_web.py ├── app ├── __init__.py ├── integration │ ├── __init__.py │ ├── test_adding_configuration.py │ ├── test_article_tagging.py │ ├── test_configurable_package_instance.py │ ├── test_e2e_mixins.py │ ├── test_e2e_mixins_importer_blockifier.py │ ├── test_e2e_mixins_indexer_pipeline.py │ ├── test_example_project_structure.py │ ├── test_get_params.py │ ├── test_header_passing.py │ ├── test_instance_init.py │ ├── test_package_error_visibility.py │ ├── test_package_instance.py │ ├── test_request_id.py │ ├── test_requirements_installation_isolation.py │ ├── test_returns_list.py │ ├── test_safe_hello_world.py │ ├── test_safe_loaded_package_with_bad_import.py │ ├── test_signed_url_package.py │ └── test_use_package.py └── unit │ ├── __init__.py │ ├── test_config_template_extraction.py │ ├── test_demo_app_spec.py │ ├── test_document_qa_example.py │ ├── test_indexer_mixin.py │ ├── test_indexer_pipeline_mixin.py │ ├── test_mixins.py │ ├── test_multi_inheritance.py │ ├── test_response.py │ ├── test_routes_on_superclasses.py │ └── test_training_input.py ├── base ├── __init__.py ├── test_binary_utils.py ├── test_configuration.py ├── test_serialization.py ├── test_steamship_error_serializable.py └── test_task.py ├── client ├── __init__.py ├── operations │ ├── __init__.py │ ├── test_blockify.py │ ├── test_classify.py │ ├── test_convert_ocr.py │ ├── test_embed.py │ ├── test_embed_file.py │ ├── test_embedding_index.py │ ├── test_tag.py │ └── test_tag_file.py ├── test_client.py └── test_task_dependencies.py ├── data ├── __init__.py ├── tags │ ├── __init__.py │ └── test_file_tags.py ├── test_app_version.py ├── test_block.py ├── test_chat.py ├── test_file.py ├── test_img.png ├── test_package.py ├── test_package_version.py ├── test_plugins.py ├── test_task_comments.py ├── test_workspace.py └── utterances.csv ├── experimental └── __init__.py ├── integrations ├── __init__.py ├── test_csv_importer.py ├── test_dalle.py ├── test_did.py ├── test_elevenlabs.py ├── test_google_image_search.py ├── test_google_search.py ├── test_gpt.py ├── test_openai_embedder.py ├── test_pdf_importer.py ├── test_stable_diffusion_2.py ├── test_wikipedia_importer.py └── test_youtube_transcript_importer.py ├── plugin ├── __init__.py ├── integration │ ├── __init__.py │ ├── test_e2e_async_blockifier.py │ ├── test_e2e_async_generator.py │ ├── test_e2e_blockifier.py │ ├── test_e2e_blockifier_markdown.py │ ├── test_e2e_configurable_tagger.py │ ├── test_e2e_corpus_importer.py │ ├── test_e2e_csv_blockifier.py │ ├── test_e2e_embedder.py │ ├── test_e2e_file_importer.py │ ├── test_e2e_file_importer_by_url.py │ ├── test_e2e_generator.py │ ├── test_e2e_get_training_parameters.py │ ├── test_e2e_logging_tagger.py │ ├── test_e2e_prompt_plugin.py │ ├── test_e2e_streaming_generator.py │ ├── test_e2e_tagger.py │ ├── test_e2e_third_party_trainable_tagger.py │ ├── test_e2e_trainable_tagger.py │ ├── test_e2e_tsv_blockifier.py │ ├── test_use_plugin.py │ └── test_use_skill.py └── unit │ ├── __init__.py │ ├── test_blockifier.py │ ├── test_capabilities.py │ ├── test_config_block.py │ ├── test_file_importer.py │ ├── test_response_post_update.py │ ├── test_service.py │ ├── test_tagger.py │ ├── test_trainable_tagger.py │ ├── test_trainable_tagger_config.py │ └── trainable │ ├── __init__.py │ ├── test_model_checkpoints.py │ └── util.py ├── server ├── __init__.py ├── test_package_local.py └── test_task_timeout.py └── utils ├── __init__.py ├── client.py ├── context.py ├── deployables.py ├── file.py ├── fixtures.py ├── random.py ├── test_camel_model.py ├── test_client.py ├── test_enums.py ├── test_kv_store.py ├── test_signed_urls.py ├── test_static_instance_methods.py ├── test_text_chunker.py └── test_zip_archives.py /.devcontainer/Dockerfile: -------------------------------------------------------------------------------- 1 | # [Choice] Python version (use -bullseye variants on local arm64/Apple Silicon): 3, 3.10, 3.9, 3.8, 3.7, 3.6, 3-bullseye, 3.10-bullseye, 3.9-bullseye, 3.8-bullseye, 3.7-bullseye, 3.6-bullseye, 3-buster, 3.10-buster, 3.9-buster, 3.8-buster, 3.7-buster, 3.6-buster 2 | ARG VARIANT=3.9 3 | FROM mcr.microsoft.com/vscode/devcontainers/python:${VARIANT} 4 | 5 | # [Choice] Node.js version: none, lts/*, 16, 14, 12, 10 6 | ARG NODE_VERSION="none" 7 | RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi 8 | 9 | # [Optional] If your pip requirements rarely change, uncomment this section to add them to the image. 10 | # COPY requirements.txt /tmp/pip-tmp/ 11 | # RUN pip3 --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt \ 12 | # && rm -rf /tmp/pip-tmp 13 | 14 | # [Optional] Uncomment this section to install additional OS packages. 15 | # RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ 16 | # && apt-get -y install --no-install-recommends 17 | 18 | # [Optional] Uncomment this line to install global node packages. 19 | # RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g " 2>&1 -------------------------------------------------------------------------------- /.devcontainer/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Steamship Python Client", 3 | "build": { 4 | "dockerfile": "Dockerfile", 5 | "context": "..", 6 | "args": { 7 | "VARIANT": "3.9", 8 | "NODE_VERSION": "lts/*" 9 | } 10 | }, 11 | 12 | "settings": { 13 | "python.defaultInterpreterPath": "/usr/local/bin/python", 14 | "python.linting.enabled": true, 15 | "python.linting.pylintEnabled": true, 16 | "python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8", 17 | "python.formatting.blackPath": "/usr/local/py-utils/bin/black", 18 | "python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf", 19 | "python.linting.banditPath": "/usr/local/py-utils/bin/bandit", 20 | "python.linting.flake8Path": "/usr/local/py-utils/bin/flake8", 21 | "python.linting.mypyPath": "/usr/local/py-utils/bin/mypy", 22 | "python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle", 23 | "python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle", 24 | "python.linting.pylintPath": "/usr/local/py-utils/bin/pylint" 25 | }, 26 | 27 | "extensions": [ 28 | "ms-python.python", 29 | "ms-python.vscode-pylance" 30 | ], 31 | 32 | "postCreateCommand": "pip3 install --user -r requirements.txt", 33 | 34 | "remoteUser": "vscode" 35 | } -------------------------------------------------------------------------------- /.devcontainer/library-scripts/README.md: -------------------------------------------------------------------------------- 1 | # Warning: Folder contents may be replaced 2 | 3 | The contents of this folder will be automatically replaced with a file of the same name in the [vscode-dev-containers](https://github.com/microsoft/vscode-dev-containers) repository's [script-library folder](https://github.com/microsoft/vscode-dev-containers/tree/main/script-library) whenever the repository is packaged. 4 | 5 | To retain your edits, move the file to a different location. You may also delete the files if they are not needed. -------------------------------------------------------------------------------- /.devcontainer/library-scripts/meta.env: -------------------------------------------------------------------------------- 1 | VERSION='dev' 2 | -------------------------------------------------------------------------------- /.flake8: -------------------------------------------------------------------------------- 1 | [flake8] 2 | # http://flake8.pycqa.org/en/latest/user/configuration.html#project-configuration 3 | # https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#line-length 4 | # TODO: https://github.com/PyCQA/flake8/issues/234 5 | doctests = True 6 | ignore = DAR103,E203,E501,FS003,S101,W503,S113 7 | max_line_length = 100 8 | max_complexity = 10 9 | 10 | # https://github.com/terrencepreilly/darglint#flake8 11 | # TODO: https://github.com/terrencepreilly/darglint/issues/130 12 | docstring_style = numpy 13 | strictness = long -------------------------------------------------------------------------------- /.github/workflows/notify-of-release.yml: -------------------------------------------------------------------------------- 1 | name: Publish release summary to discord 2 | 3 | on: 4 | release: 5 | types: [published] 6 | 7 | jobs: 8 | publish-release-summary-to-discord: 9 | runs-on: ubuntu-latest 10 | name: Github Releases To Discord 11 | steps: 12 | - name: Sending message 13 | uses: nhevia/discord-styled-releases@main 14 | with: 15 | webhook_id: ${{ secrets.DISCORD_WEBHOOK_ID }} 16 | webhook_token: ${{ secrets.DISCORD_WEBHOOK_TOKEN }} -------------------------------------------------------------------------------- /AUTHORS.rst: -------------------------------------------------------------------------------- 1 | ============ 2 | Contributors 3 | ============ 4 | 5 | Steamship is made with love from around the world. 6 | 7 | * Ted Benson 8 | * Aaron Vontell 9 | * Dave Kolas 10 | * Enias Cailliau 11 | * Doug Reid 12 | * Max Freundlich 13 | 14 | -------------------------------------------------------------------------------- /CHANGELOG.rst: -------------------------------------------------------------------------------- 1 | ========= 2 | Changelog 3 | ========= 4 | 5 | Version 2.3.31 6 | ************** 7 | 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2022 Steamship, Inc. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | Steamship Logo 4 | 5 | 6 | # Steamship Python SDK 7 | 8 | 🚢 [Steamship](https://steamship.com) is the fastest way to Build, Scale, and Monitor AI Agents. 9 | 10 | This library is for: 11 | - Building and deploying `Agents`, `Packages`, and `Plugins` on Steamship 12 | - Making client calls to a Steamship `Package` from a Python environment 13 | 14 | **Are you trying to build a Bot or Agent? Please check out our starter project and guidebook here:** 15 | 16 | [Multimodal Agent Starter](https://github.com/steamship-core/multimodal-agent-starter) 17 | 18 | [Agent Guidebook](https://www.steamship.com/learn/agent-guidebook) 19 | 20 | **Are you trying to host a LangChain agent you've written? Check out our LangChain compatibility library here:** 21 | 22 | 🚢 🦜️🔗 [Steamship-Langchain](https://github.com/steamship-core/steamship-langchain) 23 | 24 | ## Installing 25 | 26 | Install via pip: 27 | 28 | ``` 29 | pip install steamship 30 | ``` 31 | 32 | ## Documentation 33 | 34 | [Full Documentation](https://docs.steamship.com/) 35 | 36 | ## Support and Discussion 37 | 38 | Email us! support [at] steamship [dot] com. 39 | -------------------------------------------------------------------------------- /docs/api/Dockerfile: -------------------------------------------------------------------------------- 1 | # If you're having trouble building the documentation site on localhost, you can use this Dockerfile 2 | # to build it. 3 | # 4 | # To do that: 5 | # 6 | # 1) Build this docker image from the docs/ folder of the project: 7 | # 8 | # docker build . -t build-docs -f `pwd`/Dockerfile 9 | # 10 | # 2) Run this docker image from the ROOT FOLDER of the project: 11 | # 12 | # docker run --rm -v `pwd`:/project build-docs 13 | 14 | FROM sphinxdoc/sphinx 15 | WORKDIR /project/docs 16 | CMD ["make", "html"] -------------------------------------------------------------------------------- /docs/api/_static/.gitignore: -------------------------------------------------------------------------------- 1 | # Empty directory 2 | -------------------------------------------------------------------------------- /docs/api/_static/Steamship-symbol-dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steamship-core/python-client/62b3f9659fd43ce4fe62103b6488514259d1956f/docs/api/_static/Steamship-symbol-dark.png -------------------------------------------------------------------------------- /docs/api/_static/Steamship-symbol-light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steamship-core/python-client/62b3f9659fd43ce4fe62103b6488514259d1956f/docs/api/_static/Steamship-symbol-light.png -------------------------------------------------------------------------------- /docs/api/_static/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steamship-core/python-client/62b3f9659fd43ce4fe62103b6488514259d1956f/docs/api/_static/favicon.ico -------------------------------------------------------------------------------- /docs/api/api/modules.rst: -------------------------------------------------------------------------------- 1 | steamship 2 | ========= 3 | 4 | .. toctree:: 5 | :maxdepth: 4 6 | 7 | steamship 8 | -------------------------------------------------------------------------------- /docs/api/api/steamship.agents.functional.rst: -------------------------------------------------------------------------------- 1 | steamship.agents.functional package 2 | =================================== 3 | 4 | Submodules 5 | ---------- 6 | 7 | steamship.agents.functional.functions\_based module 8 | --------------------------------------------------- 9 | 10 | .. automodule:: steamship.agents.functional.functions_based 11 | :members: 12 | :undoc-members: 13 | :show-inheritance: 14 | 15 | steamship.agents.functional.output\_parser module 16 | ------------------------------------------------- 17 | 18 | .. automodule:: steamship.agents.functional.output_parser 19 | :members: 20 | :undoc-members: 21 | :show-inheritance: 22 | 23 | Module contents 24 | --------------- 25 | 26 | .. automodule:: steamship.agents.functional 27 | :members: 28 | :undoc-members: 29 | :show-inheritance: 30 | -------------------------------------------------------------------------------- /docs/api/api/steamship.agents.llms.rst: -------------------------------------------------------------------------------- 1 | steamship.agents.llms package 2 | ============================= 3 | 4 | Submodules 5 | ---------- 6 | 7 | steamship.agents.llms.openai module 8 | ----------------------------------- 9 | 10 | .. automodule:: steamship.agents.llms.openai 11 | :members: 12 | :undoc-members: 13 | :show-inheritance: 14 | 15 | Module contents 16 | --------------- 17 | 18 | .. automodule:: steamship.agents.llms 19 | :members: 20 | :undoc-members: 21 | :show-inheritance: 22 | -------------------------------------------------------------------------------- /docs/api/api/steamship.agents.mixins.rst: -------------------------------------------------------------------------------- 1 | steamship.agents.mixins package 2 | =============================== 3 | 4 | Subpackages 5 | ----------- 6 | 7 | .. toctree:: 8 | :maxdepth: 4 9 | 10 | steamship.agents.mixins.transports 11 | 12 | Module contents 13 | --------------- 14 | 15 | .. automodule:: steamship.agents.mixins 16 | :members: 17 | :undoc-members: 18 | :show-inheritance: 19 | -------------------------------------------------------------------------------- /docs/api/api/steamship.agents.mixins.transports.rst: -------------------------------------------------------------------------------- 1 | steamship.agents.mixins.transports package 2 | ========================================== 3 | 4 | Submodules 5 | ---------- 6 | 7 | steamship.agents.mixins.transports.steamship\_widget module 8 | ----------------------------------------------------------- 9 | 10 | .. automodule:: steamship.agents.mixins.transports.steamship_widget 11 | :members: 12 | :undoc-members: 13 | :show-inheritance: 14 | 15 | steamship.agents.mixins.transports.telegram module 16 | -------------------------------------------------- 17 | 18 | .. automodule:: steamship.agents.mixins.transports.telegram 19 | :members: 20 | :undoc-members: 21 | :show-inheritance: 22 | 23 | steamship.agents.mixins.transports.transport module 24 | --------------------------------------------------- 25 | 26 | .. automodule:: steamship.agents.mixins.transports.transport 27 | :members: 28 | :undoc-members: 29 | :show-inheritance: 30 | 31 | Module contents 32 | --------------- 33 | 34 | .. automodule:: steamship.agents.mixins.transports 35 | :members: 36 | :undoc-members: 37 | :show-inheritance: 38 | -------------------------------------------------------------------------------- /docs/api/api/steamship.agents.react.rst: -------------------------------------------------------------------------------- 1 | steamship.agents.react package 2 | ============================== 3 | 4 | Submodules 5 | ---------- 6 | 7 | steamship.agents.react.output\_parser module 8 | -------------------------------------------- 9 | 10 | .. automodule:: steamship.agents.react.output_parser 11 | :members: 12 | :undoc-members: 13 | :show-inheritance: 14 | 15 | steamship.agents.react.react module 16 | ----------------------------------- 17 | 18 | .. automodule:: steamship.agents.react.react 19 | :members: 20 | :undoc-members: 21 | :show-inheritance: 22 | 23 | Module contents 24 | --------------- 25 | 26 | .. automodule:: steamship.agents.react 27 | :members: 28 | :undoc-members: 29 | :show-inheritance: 30 | -------------------------------------------------------------------------------- /docs/api/api/steamship.agents.rst: -------------------------------------------------------------------------------- 1 | steamship.agents package 2 | ======================== 3 | 4 | Subpackages 5 | ----------- 6 | 7 | .. toctree:: 8 | :maxdepth: 4 9 | 10 | steamship.agents.examples 11 | steamship.agents.functional 12 | steamship.agents.llms 13 | steamship.agents.mixins 14 | steamship.agents.react 15 | steamship.agents.schema 16 | steamship.agents.service 17 | steamship.agents.tools 18 | 19 | Submodules 20 | ---------- 21 | 22 | steamship.agents.logging module 23 | ------------------------------- 24 | 25 | .. automodule:: steamship.agents.logging 26 | :members: 27 | :undoc-members: 28 | :show-inheritance: 29 | 30 | steamship.agents.utils module 31 | ----------------------------- 32 | 33 | .. automodule:: steamship.agents.utils 34 | :members: 35 | :undoc-members: 36 | :show-inheritance: 37 | 38 | Module contents 39 | --------------- 40 | 41 | .. automodule:: steamship.agents 42 | :members: 43 | :undoc-members: 44 | :show-inheritance: 45 | -------------------------------------------------------------------------------- /docs/api/api/steamship.agents.service.rst: -------------------------------------------------------------------------------- 1 | steamship.agents.service package 2 | ================================ 3 | 4 | Submodules 5 | ---------- 6 | 7 | steamship.agents.service.agent\_service module 8 | ---------------------------------------------- 9 | 10 | .. automodule:: steamship.agents.service.agent_service 11 | :members: 12 | :undoc-members: 13 | :show-inheritance: 14 | 15 | Module contents 16 | --------------- 17 | 18 | .. automodule:: steamship.agents.service 19 | :members: 20 | :undoc-members: 21 | :show-inheritance: 22 | -------------------------------------------------------------------------------- /docs/api/api/steamship.agents.tools.classification.rst: -------------------------------------------------------------------------------- 1 | steamship.agents.tools.classification package 2 | ============================================= 3 | 4 | Submodules 5 | ---------- 6 | 7 | steamship.agents.tools.classification.sentiment\_analysis\_tool module 8 | ---------------------------------------------------------------------- 9 | 10 | .. automodule:: steamship.agents.tools.classification.sentiment_analysis_tool 11 | :members: 12 | :undoc-members: 13 | :show-inheritance: 14 | 15 | steamship.agents.tools.classification.zero\_shot\_classifier\_tool module 16 | ------------------------------------------------------------------------- 17 | 18 | .. automodule:: steamship.agents.tools.classification.zero_shot_classifier_tool 19 | :members: 20 | :undoc-members: 21 | :show-inheritance: 22 | 23 | Module contents 24 | --------------- 25 | 26 | .. automodule:: steamship.agents.tools.classification 27 | :members: 28 | :undoc-members: 29 | :show-inheritance: 30 | -------------------------------------------------------------------------------- /docs/api/api/steamship.agents.tools.conversation_starters.rst: -------------------------------------------------------------------------------- 1 | steamship.agents.tools.conversation\_starters package 2 | ===================================================== 3 | 4 | Submodules 5 | ---------- 6 | 7 | steamship.agents.tools.conversation\_starters.knock\_knock\_tool module 8 | ----------------------------------------------------------------------- 9 | 10 | .. automodule:: steamship.agents.tools.conversation_starters.knock_knock_tool 11 | :members: 12 | :undoc-members: 13 | :show-inheritance: 14 | 15 | Module contents 16 | --------------- 17 | 18 | .. automodule:: steamship.agents.tools.conversation_starters 19 | :members: 20 | :undoc-members: 21 | :show-inheritance: 22 | -------------------------------------------------------------------------------- /docs/api/api/steamship.agents.tools.image_generation.rst: -------------------------------------------------------------------------------- 1 | steamship.agents.tools.image\_generation package 2 | ================================================ 3 | 4 | Submodules 5 | ---------- 6 | 7 | steamship.agents.tools.image\_generation.dalle module 8 | ----------------------------------------------------- 9 | 10 | .. automodule:: steamship.agents.tools.image_generation.dalle 11 | :members: 12 | :undoc-members: 13 | :show-inheritance: 14 | 15 | steamship.agents.tools.image\_generation.google\_image\_search module 16 | --------------------------------------------------------------------- 17 | 18 | .. automodule:: steamship.agents.tools.image_generation.google_image_search 19 | :members: 20 | :undoc-members: 21 | :show-inheritance: 22 | 23 | steamship.agents.tools.image\_generation.stable\_diffusion module 24 | ----------------------------------------------------------------- 25 | 26 | .. automodule:: steamship.agents.tools.image_generation.stable_diffusion 27 | :members: 28 | :undoc-members: 29 | :show-inheritance: 30 | 31 | Module contents 32 | --------------- 33 | 34 | .. automodule:: steamship.agents.tools.image_generation 35 | :members: 36 | :undoc-members: 37 | :show-inheritance: 38 | -------------------------------------------------------------------------------- /docs/api/api/steamship.agents.tools.rst: -------------------------------------------------------------------------------- 1 | steamship.agents.tools package 2 | ============================== 3 | 4 | Subpackages 5 | ----------- 6 | 7 | .. toctree:: 8 | :maxdepth: 4 9 | 10 | steamship.agents.tools.audio_transcription 11 | steamship.agents.tools.classification 12 | steamship.agents.tools.conversation_starters 13 | steamship.agents.tools.image_generation 14 | steamship.agents.tools.question_answering 15 | steamship.agents.tools.search 16 | steamship.agents.tools.speech_generation 17 | steamship.agents.tools.text_generation 18 | steamship.agents.tools.video_generation 19 | 20 | Submodules 21 | ---------- 22 | 23 | steamship.agents.tools.base\_tools module 24 | ----------------------------------------- 25 | 26 | .. automodule:: steamship.agents.tools.base_tools 27 | :members: 28 | :undoc-members: 29 | :show-inheritance: 30 | 31 | Module contents 32 | --------------- 33 | 34 | .. automodule:: steamship.agents.tools 35 | :members: 36 | :undoc-members: 37 | :show-inheritance: 38 | -------------------------------------------------------------------------------- /docs/api/api/steamship.agents.tools.search.rst: -------------------------------------------------------------------------------- 1 | steamship.agents.tools.search package 2 | ===================================== 3 | 4 | Submodules 5 | ---------- 6 | 7 | steamship.agents.tools.search.search module 8 | ------------------------------------------- 9 | 10 | .. automodule:: steamship.agents.tools.search.search 11 | :members: 12 | :undoc-members: 13 | :show-inheritance: 14 | 15 | Module contents 16 | --------------- 17 | 18 | .. automodule:: steamship.agents.tools.search 19 | :members: 20 | :undoc-members: 21 | :show-inheritance: 22 | -------------------------------------------------------------------------------- /docs/api/api/steamship.agents.tools.speech_generation.rst: -------------------------------------------------------------------------------- 1 | steamship.agents.tools.speech\_generation package 2 | ================================================= 3 | 4 | Submodules 5 | ---------- 6 | 7 | steamship.agents.tools.speech\_generation.generate\_speech module 8 | ----------------------------------------------------------------- 9 | 10 | .. automodule:: steamship.agents.tools.speech_generation.generate_speech 11 | :members: 12 | :undoc-members: 13 | :show-inheritance: 14 | 15 | Module contents 16 | --------------- 17 | 18 | .. automodule:: steamship.agents.tools.speech_generation 19 | :members: 20 | :undoc-members: 21 | :show-inheritance: 22 | -------------------------------------------------------------------------------- /docs/api/api/steamship.agents.tools.video_generation.rst: -------------------------------------------------------------------------------- 1 | steamship.agents.tools.video\_generation package 2 | ================================================ 3 | 4 | Submodules 5 | ---------- 6 | 7 | steamship.agents.tools.video\_generation.did\_video\_generator\_tool module 8 | --------------------------------------------------------------------------- 9 | 10 | .. automodule:: steamship.agents.tools.video_generation.did_video_generator_tool 11 | :members: 12 | :undoc-members: 13 | :show-inheritance: 14 | 15 | Module contents 16 | --------------- 17 | 18 | .. automodule:: steamship.agents.tools.video_generation 19 | :members: 20 | :undoc-members: 21 | :show-inheritance: 22 | -------------------------------------------------------------------------------- /docs/api/api/steamship.cli.local_server.rst: -------------------------------------------------------------------------------- 1 | steamship.cli.local\_server package 2 | =================================== 3 | 4 | Submodules 5 | ---------- 6 | 7 | steamship.cli.local\_server.handler module 8 | ------------------------------------------ 9 | 10 | .. automodule:: steamship.cli.local_server.handler 11 | :members: 12 | :undoc-members: 13 | :show-inheritance: 14 | 15 | steamship.cli.local\_server.server module 16 | ----------------------------------------- 17 | 18 | .. automodule:: steamship.cli.local_server.server 19 | :members: 20 | :undoc-members: 21 | :show-inheritance: 22 | 23 | Module contents 24 | --------------- 25 | 26 | .. automodule:: steamship.cli.local_server 27 | :members: 28 | :undoc-members: 29 | :show-inheritance: 30 | -------------------------------------------------------------------------------- /docs/api/api/steamship.client.rst: -------------------------------------------------------------------------------- 1 | steamship.client package 2 | ======================== 3 | 4 | Submodules 5 | ---------- 6 | 7 | steamship.client.skill\_to\_provider module 8 | ------------------------------------------- 9 | 10 | .. automodule:: steamship.client.skill_to_provider 11 | :members: 12 | :undoc-members: 13 | :show-inheritance: 14 | 15 | steamship.client.skills module 16 | ------------------------------ 17 | 18 | .. automodule:: steamship.client.skills 19 | :members: 20 | :undoc-members: 21 | :show-inheritance: 22 | 23 | steamship.client.steamship module 24 | --------------------------------- 25 | 26 | .. automodule:: steamship.client.steamship 27 | :members: 28 | :undoc-members: 29 | :show-inheritance: 30 | 31 | steamship.client.vendors module 32 | ------------------------------- 33 | 34 | .. automodule:: steamship.client.vendors 35 | :members: 36 | :undoc-members: 37 | :show-inheritance: 38 | 39 | Module contents 40 | --------------- 41 | 42 | .. automodule:: steamship.client 43 | :members: 44 | :undoc-members: 45 | :show-inheritance: 46 | -------------------------------------------------------------------------------- /docs/api/api/steamship.experimental.easy.rst: -------------------------------------------------------------------------------- 1 | steamship.experimental.easy package 2 | =================================== 3 | 4 | Submodules 5 | ---------- 6 | 7 | steamship.experimental.easy.tags module 8 | --------------------------------------- 9 | 10 | .. automodule:: steamship.experimental.easy.tags 11 | :members: 12 | :undoc-members: 13 | :show-inheritance: 14 | 15 | Module contents 16 | --------------- 17 | 18 | .. automodule:: steamship.experimental.easy 19 | :members: 20 | :undoc-members: 21 | :show-inheritance: 22 | -------------------------------------------------------------------------------- /docs/api/api/steamship.experimental.package_starters.rst: -------------------------------------------------------------------------------- 1 | steamship.experimental.package\_starters namespace 2 | ================================================== 3 | 4 | .. py:module:: steamship.experimental.package_starters 5 | 6 | Submodules 7 | ---------- 8 | 9 | steamship.experimental.package\_starters.telegram\_agent module 10 | --------------------------------------------------------------- 11 | 12 | .. automodule:: steamship.experimental.package_starters.telegram_agent 13 | :members: 14 | :undoc-members: 15 | :show-inheritance: 16 | 17 | steamship.experimental.package\_starters.web\_agent module 18 | ---------------------------------------------------------- 19 | 20 | .. automodule:: steamship.experimental.package_starters.web_agent 21 | :members: 22 | :undoc-members: 23 | :show-inheritance: 24 | -------------------------------------------------------------------------------- /docs/api/api/steamship.experimental.rst: -------------------------------------------------------------------------------- 1 | steamship.experimental package 2 | ============================== 3 | 4 | Subpackages 5 | ----------- 6 | 7 | .. toctree:: 8 | :maxdepth: 4 9 | 10 | steamship.experimental.easy 11 | steamship.experimental.package_starters 12 | 13 | Module contents 14 | --------------- 15 | 16 | .. automodule:: steamship.experimental 17 | :members: 18 | :undoc-members: 19 | :show-inheritance: 20 | -------------------------------------------------------------------------------- /docs/api/api/steamship.invocable.mixins.rst: -------------------------------------------------------------------------------- 1 | steamship.invocable.mixins package 2 | ================================== 3 | 4 | Submodules 5 | ---------- 6 | 7 | steamship.invocable.mixins.blockifier\_mixin module 8 | --------------------------------------------------- 9 | 10 | .. automodule:: steamship.invocable.mixins.blockifier_mixin 11 | :members: 12 | :undoc-members: 13 | :show-inheritance: 14 | 15 | steamship.invocable.mixins.file\_importer\_mixin module 16 | ------------------------------------------------------- 17 | 18 | .. automodule:: steamship.invocable.mixins.file_importer_mixin 19 | :members: 20 | :undoc-members: 21 | :show-inheritance: 22 | 23 | steamship.invocable.mixins.indexer\_mixin module 24 | ------------------------------------------------ 25 | 26 | .. automodule:: steamship.invocable.mixins.indexer_mixin 27 | :members: 28 | :undoc-members: 29 | :show-inheritance: 30 | 31 | steamship.invocable.mixins.indexer\_pipeline\_mixin module 32 | ---------------------------------------------------------- 33 | 34 | .. automodule:: steamship.invocable.mixins.indexer_pipeline_mixin 35 | :members: 36 | :undoc-members: 37 | :show-inheritance: 38 | 39 | Module contents 40 | --------------- 41 | 42 | .. automodule:: steamship.invocable.mixins 43 | :members: 44 | :undoc-members: 45 | :show-inheritance: 46 | -------------------------------------------------------------------------------- /docs/api/api/steamship.plugin.blockifier.rst: -------------------------------------------------------------------------------- 1 | steamship.plugin.blockifier package 2 | =================================== 3 | 4 | Submodules 5 | ---------- 6 | 7 | steamship.plugin.blockifier.blockifier module 8 | --------------------------------------------- 9 | 10 | .. automodule:: steamship.plugin.blockifier.blockifier 11 | :members: 12 | :undoc-members: 13 | :show-inheritance: 14 | 15 | steamship.plugin.blockifier.transcriber module 16 | ---------------------------------------------- 17 | 18 | .. automodule:: steamship.plugin.blockifier.transcriber 19 | :members: 20 | :undoc-members: 21 | :show-inheritance: 22 | 23 | Module contents 24 | --------------- 25 | 26 | .. automodule:: steamship.plugin.blockifier 27 | :members: 28 | :undoc-members: 29 | :show-inheritance: 30 | -------------------------------------------------------------------------------- /docs/api/api/steamship.rst: -------------------------------------------------------------------------------- 1 | steamship package 2 | ================= 3 | 4 | Subpackages 5 | ----------- 6 | 7 | .. toctree:: 8 | :maxdepth: 4 9 | 10 | steamship.agents 11 | steamship.base 12 | steamship.cli 13 | steamship.client 14 | steamship.data 15 | steamship.experimental 16 | steamship.invocable 17 | steamship.plugin 18 | steamship.utils 19 | 20 | Module contents 21 | --------------- 22 | 23 | .. automodule:: steamship 24 | :members: 25 | :undoc-members: 26 | :show-inheritance: 27 | -------------------------------------------------------------------------------- /docs/api/authors.rst: -------------------------------------------------------------------------------- 1 | .. _authors: 2 | .. include:: ../../AUTHORS.rst 3 | -------------------------------------------------------------------------------- /docs/api/index.rst: -------------------------------------------------------------------------------- 1 | Contents 2 | ======== 3 | 4 | .. toctree:: 5 | :maxdepth: 4 6 | 7 | Python Client Reference 8 | License 9 | Authors 10 | 11 | 12 | .. _NPM: http://npmjs.com/ 13 | -------------------------------------------------------------------------------- /docs/api/license.rst: -------------------------------------------------------------------------------- 1 | .. _license: 2 | 3 | ==== 4 | License 5 | ==== 6 | 7 | Steamship's Python Client library is published under the MIT license. 8 | 9 | .. include:: ../../LICENSE 10 | -------------------------------------------------------------------------------- /docs/nextra/.nojekyll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steamship-core/python-client/62b3f9659fd43ce4fe62103b6488514259d1956f/docs/nextra/.nojekyll -------------------------------------------------------------------------------- /docs/nextra/Dockerfile: -------------------------------------------------------------------------------- 1 | # If you're having trouble building the documentation site on localhost, you can use this Dockerfile 2 | # to build it. 3 | # 4 | # To do that: 5 | # 6 | # 1) Build this docker image from the docs/ folder of the project: 7 | # 8 | # docker build . -t build-docs -f `pwd`/Dockerfile 9 | # 10 | # 2) Run this docker image from the ROOT FOLDER of the project: 11 | # 12 | # docker run --rm -v `pwd`:/project build-docs 13 | 14 | FROM sphinxdoc/sphinx 15 | WORKDIR /project/docs 16 | CMD ["make", "html"] -------------------------------------------------------------------------------- /docs/nextra/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line, and also 5 | # from the environment for the first two. 6 | SPHINXOPTS ?= 7 | SPHINXBUILD ?= sphinx-build 8 | SOURCEDIR = . 9 | BUILDDIR = _build 10 | 11 | # User-friendly check for sphinx-build 12 | ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $?), 1) 13 | $(error "The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/") 14 | endif 15 | 16 | .PHONY: help clean Makefile 17 | 18 | # Put it first so that "make" without argument is like "make help". 19 | help: 20 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 21 | 22 | markdown: 23 | pip install -r ../../requirements.txt 24 | pip install -r ../../requirements.dev.txt 25 | pip install -r ../requirements.txt 26 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 27 | 28 | ./make_markdown.sh -------------------------------------------------------------------------------- /docs/nextra/_static/.gitignore: -------------------------------------------------------------------------------- 1 | # Empty directory 2 | -------------------------------------------------------------------------------- /docs/nextra/_static/Steamship-symbol-dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steamship-core/python-client/62b3f9659fd43ce4fe62103b6488514259d1956f/docs/nextra/_static/Steamship-symbol-dark.png -------------------------------------------------------------------------------- /docs/nextra/_static/Steamship-symbol-light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steamship-core/python-client/62b3f9659fd43ce4fe62103b6488514259d1956f/docs/nextra/_static/Steamship-symbol-light.png -------------------------------------------------------------------------------- /docs/nextra/_static/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steamship-core/python-client/62b3f9659fd43ce4fe62103b6488514259d1956f/docs/nextra/_static/favicon.ico -------------------------------------------------------------------------------- /docs/nextra/_templates/base.html: -------------------------------------------------------------------------------- 1 | {% extends "!base.html" %} 2 | 3 | {% block extrahead %} 4 | 5 | 10 | 11 | {% endblock extrahead %} 12 | 13 | 14 | {% block body %} 15 | {{ super() }} 16 | 17 | 19 | 20 | {% endblock %} 21 | -------------------------------------------------------------------------------- /docs/nextra/api/modules.rst: -------------------------------------------------------------------------------- 1 | steamship 2 | ========= 3 | 4 | .. toctree:: 5 | :maxdepth: 4 6 | 7 | steamship 8 | -------------------------------------------------------------------------------- /docs/nextra/api/steamship.agents.functional.rst: -------------------------------------------------------------------------------- 1 | steamship.agents.functional package 2 | =================================== 3 | 4 | Submodules 5 | ---------- 6 | 7 | steamship.agents.functional.functions\_based module 8 | --------------------------------------------------- 9 | 10 | .. automodule:: steamship.agents.functional.functions_based 11 | :members: 12 | :undoc-members: 13 | :show-inheritance: 14 | 15 | steamship.agents.functional.output\_parser module 16 | ------------------------------------------------- 17 | 18 | .. automodule:: steamship.agents.functional.output_parser 19 | :members: 20 | :undoc-members: 21 | :show-inheritance: 22 | 23 | Module contents 24 | --------------- 25 | 26 | .. automodule:: steamship.agents.functional 27 | :members: 28 | :undoc-members: 29 | :show-inheritance: 30 | -------------------------------------------------------------------------------- /docs/nextra/api/steamship.agents.llms.rst: -------------------------------------------------------------------------------- 1 | steamship.agents.llms package 2 | ============================= 3 | 4 | Submodules 5 | ---------- 6 | 7 | steamship.agents.llms.openai module 8 | ----------------------------------- 9 | 10 | .. automodule:: steamship.agents.llms.openai 11 | :members: 12 | :undoc-members: 13 | :show-inheritance: 14 | 15 | Module contents 16 | --------------- 17 | 18 | .. automodule:: steamship.agents.llms 19 | :members: 20 | :undoc-members: 21 | :show-inheritance: 22 | -------------------------------------------------------------------------------- /docs/nextra/api/steamship.agents.mixins.rst: -------------------------------------------------------------------------------- 1 | steamship.agents.mixins package 2 | =============================== 3 | 4 | Subpackages 5 | ----------- 6 | 7 | .. toctree:: 8 | :maxdepth: 4 9 | 10 | steamship.agents.mixins.transports 11 | 12 | Module contents 13 | --------------- 14 | 15 | .. automodule:: steamship.agents.mixins 16 | :members: 17 | :undoc-members: 18 | :show-inheritance: 19 | -------------------------------------------------------------------------------- /docs/nextra/api/steamship.agents.mixins.transports.rst: -------------------------------------------------------------------------------- 1 | steamship.agents.mixins.transports package 2 | ========================================== 3 | 4 | Submodules 5 | ---------- 6 | 7 | steamship.agents.mixins.transports.slack module 8 | ----------------------------------------------- 9 | 10 | .. automodule:: steamship.agents.mixins.transports.slack 11 | :members: 12 | :undoc-members: 13 | :show-inheritance: 14 | 15 | steamship.agents.mixins.transports.steamship\_widget module 16 | ----------------------------------------------------------- 17 | 18 | .. automodule:: steamship.agents.mixins.transports.steamship_widget 19 | :members: 20 | :undoc-members: 21 | :show-inheritance: 22 | 23 | steamship.agents.mixins.transports.telegram module 24 | -------------------------------------------------- 25 | 26 | .. automodule:: steamship.agents.mixins.transports.telegram 27 | :members: 28 | :undoc-members: 29 | :show-inheritance: 30 | 31 | steamship.agents.mixins.transports.transport module 32 | --------------------------------------------------- 33 | 34 | .. automodule:: steamship.agents.mixins.transports.transport 35 | :members: 36 | :undoc-members: 37 | :show-inheritance: 38 | 39 | Module contents 40 | --------------- 41 | 42 | .. automodule:: steamship.agents.mixins.transports 43 | :members: 44 | :undoc-members: 45 | :show-inheritance: 46 | -------------------------------------------------------------------------------- /docs/nextra/api/steamship.agents.react.rst: -------------------------------------------------------------------------------- 1 | steamship.agents.react package 2 | ============================== 3 | 4 | Submodules 5 | ---------- 6 | 7 | steamship.agents.react.output\_parser module 8 | -------------------------------------------- 9 | 10 | .. automodule:: steamship.agents.react.output_parser 11 | :members: 12 | :undoc-members: 13 | :show-inheritance: 14 | 15 | steamship.agents.react.react module 16 | ----------------------------------- 17 | 18 | .. automodule:: steamship.agents.react.react 19 | :members: 20 | :undoc-members: 21 | :show-inheritance: 22 | 23 | Module contents 24 | --------------- 25 | 26 | .. automodule:: steamship.agents.react 27 | :members: 28 | :undoc-members: 29 | :show-inheritance: 30 | -------------------------------------------------------------------------------- /docs/nextra/api/steamship.agents.rst: -------------------------------------------------------------------------------- 1 | steamship.agents package 2 | ======================== 3 | 4 | Subpackages 5 | ----------- 6 | 7 | .. toctree:: 8 | :maxdepth: 4 9 | 10 | steamship.agents.examples 11 | steamship.agents.functional 12 | steamship.agents.llms 13 | steamship.agents.mixins 14 | steamship.agents.react 15 | steamship.agents.schema 16 | steamship.agents.service 17 | steamship.agents.tools 18 | 19 | Submodules 20 | ---------- 21 | 22 | steamship.agents.logging module 23 | ------------------------------- 24 | 25 | .. automodule:: steamship.agents.logging 26 | :members: 27 | :undoc-members: 28 | :show-inheritance: 29 | 30 | steamship.agents.utils module 31 | ----------------------------- 32 | 33 | .. automodule:: steamship.agents.utils 34 | :members: 35 | :undoc-members: 36 | :show-inheritance: 37 | 38 | Module contents 39 | --------------- 40 | 41 | .. automodule:: steamship.agents 42 | :members: 43 | :undoc-members: 44 | :show-inheritance: 45 | -------------------------------------------------------------------------------- /docs/nextra/api/steamship.agents.service.rst: -------------------------------------------------------------------------------- 1 | steamship.agents.service package 2 | ================================ 3 | 4 | Submodules 5 | ---------- 6 | 7 | steamship.agents.service.agent\_service module 8 | ---------------------------------------------- 9 | 10 | .. automodule:: steamship.agents.service.agent_service 11 | :members: 12 | :undoc-members: 13 | :show-inheritance: 14 | 15 | Module contents 16 | --------------- 17 | 18 | .. automodule:: steamship.agents.service 19 | :members: 20 | :undoc-members: 21 | :show-inheritance: 22 | -------------------------------------------------------------------------------- /docs/nextra/api/steamship.agents.tools.classification.rst: -------------------------------------------------------------------------------- 1 | steamship.agents.tools.classification package 2 | ============================================= 3 | 4 | Submodules 5 | ---------- 6 | 7 | steamship.agents.tools.classification.sentiment\_analysis\_tool module 8 | ---------------------------------------------------------------------- 9 | 10 | .. automodule:: steamship.agents.tools.classification.sentiment_analysis_tool 11 | :members: 12 | :undoc-members: 13 | :show-inheritance: 14 | 15 | steamship.agents.tools.classification.zero\_shot\_classifier\_tool module 16 | ------------------------------------------------------------------------- 17 | 18 | .. automodule:: steamship.agents.tools.classification.zero_shot_classifier_tool 19 | :members: 20 | :undoc-members: 21 | :show-inheritance: 22 | 23 | Module contents 24 | --------------- 25 | 26 | .. automodule:: steamship.agents.tools.classification 27 | :members: 28 | :undoc-members: 29 | :show-inheritance: 30 | -------------------------------------------------------------------------------- /docs/nextra/api/steamship.agents.tools.conversation_starters.rst: -------------------------------------------------------------------------------- 1 | steamship.agents.tools.conversation\_starters package 2 | ===================================================== 3 | 4 | Submodules 5 | ---------- 6 | 7 | steamship.agents.tools.conversation\_starters.knock\_knock\_tool module 8 | ----------------------------------------------------------------------- 9 | 10 | .. automodule:: steamship.agents.tools.conversation_starters.knock_knock_tool 11 | :members: 12 | :undoc-members: 13 | :show-inheritance: 14 | 15 | Module contents 16 | --------------- 17 | 18 | .. automodule:: steamship.agents.tools.conversation_starters 19 | :members: 20 | :undoc-members: 21 | :show-inheritance: 22 | -------------------------------------------------------------------------------- /docs/nextra/api/steamship.agents.tools.image_generation.rst: -------------------------------------------------------------------------------- 1 | steamship.agents.tools.image\_generation package 2 | ================================================ 3 | 4 | Submodules 5 | ---------- 6 | 7 | steamship.agents.tools.image\_generation.dalle module 8 | ----------------------------------------------------- 9 | 10 | .. automodule:: steamship.agents.tools.image_generation.dalle 11 | :members: 12 | :undoc-members: 13 | :show-inheritance: 14 | 15 | steamship.agents.tools.image\_generation.google\_image\_search module 16 | --------------------------------------------------------------------- 17 | 18 | .. automodule:: steamship.agents.tools.image_generation.google_image_search 19 | :members: 20 | :undoc-members: 21 | :show-inheritance: 22 | 23 | steamship.agents.tools.image\_generation.stable\_diffusion module 24 | ----------------------------------------------------------------- 25 | 26 | .. automodule:: steamship.agents.tools.image_generation.stable_diffusion 27 | :members: 28 | :undoc-members: 29 | :show-inheritance: 30 | 31 | Module contents 32 | --------------- 33 | 34 | .. automodule:: steamship.agents.tools.image_generation 35 | :members: 36 | :undoc-members: 37 | :show-inheritance: 38 | -------------------------------------------------------------------------------- /docs/nextra/api/steamship.agents.tools.rst: -------------------------------------------------------------------------------- 1 | steamship.agents.tools package 2 | ============================== 3 | 4 | Subpackages 5 | ----------- 6 | 7 | .. toctree:: 8 | :maxdepth: 4 9 | 10 | steamship.agents.tools.audio_transcription 11 | steamship.agents.tools.classification 12 | steamship.agents.tools.conversation_starters 13 | steamship.agents.tools.image_generation 14 | steamship.agents.tools.question_answering 15 | steamship.agents.tools.search 16 | steamship.agents.tools.speech_generation 17 | steamship.agents.tools.text_generation 18 | steamship.agents.tools.video_generation 19 | 20 | Submodules 21 | ---------- 22 | 23 | steamship.agents.tools.base\_tools module 24 | ----------------------------------------- 25 | 26 | .. automodule:: steamship.agents.tools.base_tools 27 | :members: 28 | :undoc-members: 29 | :show-inheritance: 30 | 31 | Module contents 32 | --------------- 33 | 34 | .. automodule:: steamship.agents.tools 35 | :members: 36 | :undoc-members: 37 | :show-inheritance: 38 | -------------------------------------------------------------------------------- /docs/nextra/api/steamship.agents.tools.search.rst: -------------------------------------------------------------------------------- 1 | steamship.agents.tools.search package 2 | ===================================== 3 | 4 | Submodules 5 | ---------- 6 | 7 | steamship.agents.tools.search.search module 8 | ------------------------------------------- 9 | 10 | .. automodule:: steamship.agents.tools.search.search 11 | :members: 12 | :undoc-members: 13 | :show-inheritance: 14 | 15 | Module contents 16 | --------------- 17 | 18 | .. automodule:: steamship.agents.tools.search 19 | :members: 20 | :undoc-members: 21 | :show-inheritance: 22 | -------------------------------------------------------------------------------- /docs/nextra/api/steamship.agents.tools.speech_generation.rst: -------------------------------------------------------------------------------- 1 | steamship.agents.tools.speech\_generation package 2 | ================================================= 3 | 4 | Submodules 5 | ---------- 6 | 7 | steamship.agents.tools.speech\_generation.generate\_speech module 8 | ----------------------------------------------------------------- 9 | 10 | .. automodule:: steamship.agents.tools.speech_generation.generate_speech 11 | :members: 12 | :undoc-members: 13 | :show-inheritance: 14 | 15 | Module contents 16 | --------------- 17 | 18 | .. automodule:: steamship.agents.tools.speech_generation 19 | :members: 20 | :undoc-members: 21 | :show-inheritance: 22 | -------------------------------------------------------------------------------- /docs/nextra/api/steamship.agents.tools.video_generation.rst: -------------------------------------------------------------------------------- 1 | steamship.agents.tools.video\_generation package 2 | ================================================ 3 | 4 | Submodules 5 | ---------- 6 | 7 | steamship.agents.tools.video\_generation.did\_video\_generator\_tool module 8 | --------------------------------------------------------------------------- 9 | 10 | .. automodule:: steamship.agents.tools.video_generation.did_video_generator_tool 11 | :members: 12 | :undoc-members: 13 | :show-inheritance: 14 | 15 | Module contents 16 | --------------- 17 | 18 | .. automodule:: steamship.agents.tools.video_generation 19 | :members: 20 | :undoc-members: 21 | :show-inheritance: 22 | -------------------------------------------------------------------------------- /docs/nextra/api/steamship.cli.local_server.rst: -------------------------------------------------------------------------------- 1 | steamship.cli.local\_server package 2 | =================================== 3 | 4 | Submodules 5 | ---------- 6 | 7 | steamship.cli.local\_server.handler module 8 | ------------------------------------------ 9 | 10 | .. automodule:: steamship.cli.local_server.handler 11 | :members: 12 | :undoc-members: 13 | :show-inheritance: 14 | 15 | steamship.cli.local\_server.server module 16 | ----------------------------------------- 17 | 18 | .. automodule:: steamship.cli.local_server.server 19 | :members: 20 | :undoc-members: 21 | :show-inheritance: 22 | 23 | Module contents 24 | --------------- 25 | 26 | .. automodule:: steamship.cli.local_server 27 | :members: 28 | :undoc-members: 29 | :show-inheritance: 30 | -------------------------------------------------------------------------------- /docs/nextra/api/steamship.client.rst: -------------------------------------------------------------------------------- 1 | steamship.client package 2 | ======================== 3 | 4 | Submodules 5 | ---------- 6 | 7 | steamship.client.skill\_to\_provider module 8 | ------------------------------------------- 9 | 10 | .. automodule:: steamship.client.skill_to_provider 11 | :members: 12 | :undoc-members: 13 | :show-inheritance: 14 | 15 | steamship.client.skills module 16 | ------------------------------ 17 | 18 | .. automodule:: steamship.client.skills 19 | :members: 20 | :undoc-members: 21 | :show-inheritance: 22 | 23 | steamship.client.steamship module 24 | --------------------------------- 25 | 26 | .. automodule:: steamship.client.steamship 27 | :members: 28 | :undoc-members: 29 | :show-inheritance: 30 | 31 | steamship.client.vendors module 32 | ------------------------------- 33 | 34 | .. automodule:: steamship.client.vendors 35 | :members: 36 | :undoc-members: 37 | :show-inheritance: 38 | 39 | Module contents 40 | --------------- 41 | 42 | .. automodule:: steamship.client 43 | :members: 44 | :undoc-members: 45 | :show-inheritance: 46 | -------------------------------------------------------------------------------- /docs/nextra/api/steamship.experimental.easy.rst: -------------------------------------------------------------------------------- 1 | steamship.experimental.easy package 2 | =================================== 3 | 4 | Submodules 5 | ---------- 6 | 7 | steamship.experimental.easy.tags module 8 | --------------------------------------- 9 | 10 | .. automodule:: steamship.experimental.easy.tags 11 | :members: 12 | :undoc-members: 13 | :show-inheritance: 14 | 15 | Module contents 16 | --------------- 17 | 18 | .. automodule:: steamship.experimental.easy 19 | :members: 20 | :undoc-members: 21 | :show-inheritance: 22 | -------------------------------------------------------------------------------- /docs/nextra/api/steamship.experimental.package_starters.rst: -------------------------------------------------------------------------------- 1 | steamship.experimental.package\_starters namespace 2 | ================================================== 3 | 4 | .. py:module:: steamship.experimental.package_starters 5 | 6 | Submodules 7 | ---------- 8 | 9 | steamship.experimental.package\_starters.telegram\_agent module 10 | --------------------------------------------------------------- 11 | 12 | .. automodule:: steamship.experimental.package_starters.telegram_agent 13 | :members: 14 | :undoc-members: 15 | :show-inheritance: 16 | 17 | steamship.experimental.package\_starters.web\_agent module 18 | ---------------------------------------------------------- 19 | 20 | .. automodule:: steamship.experimental.package_starters.web_agent 21 | :members: 22 | :undoc-members: 23 | :show-inheritance: 24 | -------------------------------------------------------------------------------- /docs/nextra/api/steamship.experimental.rst: -------------------------------------------------------------------------------- 1 | steamship.experimental package 2 | ============================== 3 | 4 | Subpackages 5 | ----------- 6 | 7 | .. toctree:: 8 | :maxdepth: 4 9 | 10 | steamship.experimental.easy 11 | steamship.experimental.package_starters 12 | 13 | Module contents 14 | --------------- 15 | 16 | .. automodule:: steamship.experimental 17 | :members: 18 | :undoc-members: 19 | :show-inheritance: 20 | -------------------------------------------------------------------------------- /docs/nextra/api/steamship.invocable.mixins.rst: -------------------------------------------------------------------------------- 1 | steamship.invocable.mixins package 2 | ================================== 3 | 4 | Submodules 5 | ---------- 6 | 7 | steamship.invocable.mixins.blockifier\_mixin module 8 | --------------------------------------------------- 9 | 10 | .. automodule:: steamship.invocable.mixins.blockifier_mixin 11 | :members: 12 | :undoc-members: 13 | :show-inheritance: 14 | 15 | steamship.invocable.mixins.file\_importer\_mixin module 16 | ------------------------------------------------------- 17 | 18 | .. automodule:: steamship.invocable.mixins.file_importer_mixin 19 | :members: 20 | :undoc-members: 21 | :show-inheritance: 22 | 23 | steamship.invocable.mixins.indexer\_mixin module 24 | ------------------------------------------------ 25 | 26 | .. automodule:: steamship.invocable.mixins.indexer_mixin 27 | :members: 28 | :undoc-members: 29 | :show-inheritance: 30 | 31 | steamship.invocable.mixins.indexer\_pipeline\_mixin module 32 | ---------------------------------------------------------- 33 | 34 | .. automodule:: steamship.invocable.mixins.indexer_pipeline_mixin 35 | :members: 36 | :undoc-members: 37 | :show-inheritance: 38 | 39 | Module contents 40 | --------------- 41 | 42 | .. automodule:: steamship.invocable.mixins 43 | :members: 44 | :undoc-members: 45 | :show-inheritance: 46 | -------------------------------------------------------------------------------- /docs/nextra/api/steamship.plugin.blockifier.rst: -------------------------------------------------------------------------------- 1 | steamship.plugin.blockifier package 2 | =================================== 3 | 4 | Submodules 5 | ---------- 6 | 7 | steamship.plugin.blockifier.blockifier module 8 | --------------------------------------------- 9 | 10 | .. automodule:: steamship.plugin.blockifier.blockifier 11 | :members: 12 | :undoc-members: 13 | :show-inheritance: 14 | 15 | steamship.plugin.blockifier.transcriber module 16 | ---------------------------------------------- 17 | 18 | .. automodule:: steamship.plugin.blockifier.transcriber 19 | :members: 20 | :undoc-members: 21 | :show-inheritance: 22 | 23 | Module contents 24 | --------------- 25 | 26 | .. automodule:: steamship.plugin.blockifier 27 | :members: 28 | :undoc-members: 29 | :show-inheritance: 30 | -------------------------------------------------------------------------------- /docs/nextra/api/steamship.rst: -------------------------------------------------------------------------------- 1 | steamship package 2 | ================= 3 | 4 | Subpackages 5 | ----------- 6 | 7 | .. toctree:: 8 | :maxdepth: 4 9 | 10 | steamship.agents 11 | steamship.base 12 | steamship.cli 13 | steamship.client 14 | steamship.data 15 | steamship.experimental 16 | steamship.invocable 17 | steamship.plugin 18 | steamship.utils 19 | 20 | Module contents 21 | --------------- 22 | 23 | .. automodule:: steamship 24 | :members: 25 | :undoc-members: 26 | :show-inheritance: 27 | -------------------------------------------------------------------------------- /docs/nextra/authors.rst: -------------------------------------------------------------------------------- 1 | .. _authors: 2 | .. include:: ../../AUTHORS.rst 3 | -------------------------------------------------------------------------------- /docs/nextra/changelog._rst: -------------------------------------------------------------------------------- 1 | .. _changes: 2 | .. include:: ../CHANGELOG.rst 3 | -------------------------------------------------------------------------------- /docs/nextra/configuration/cli.rst: -------------------------------------------------------------------------------- 1 | .. _CLI: 2 | 3 | Steamship CLI 4 | ------------- 5 | 6 | To install the Steamship SDK and CLI, run (preferably in a virtual environment): 7 | 8 | .. code-block:: bash 9 | 10 | pip install steamship 11 | 12 | This will provide access to the ``ship`` command in your shell. It can be used for login and deployment 13 | 14 | Try it out by typing ``ship login`` or see options with ``ship --help``. 15 | 16 | -------------------------------------------------------------------------------- /docs/nextra/configuration/clients.rst: -------------------------------------------------------------------------------- 1 | .. _Clients: 2 | 3 | Steamship Client Libraries 4 | -------------------------- 5 | 6 | .. _Python Client: 7 | 8 | Python Client 9 | ~~~~~~~~~~~~~ 10 | 11 | To install the Steamship Python Client, run: 12 | 13 | .. code-block:: bash 14 | 15 | pip install steamship 16 | 17 | Then, import and use Steamship with: 18 | 19 | .. code-block:: python 20 | 21 | from steamship import Steamship 22 | 23 | ai_package = Steamship.use("package-name") 24 | 25 | Most of this documentation site is Python-centric and will assume operation via that client. 26 | 27 | .. _Typescript Client: 28 | 29 | Typescript Client 30 | ~~~~~~~~~~~~~~~~~ 31 | 32 | .. warning:: 33 | 34 | The Typescript client is alpha quality. 35 | 36 | To install the Steamship Typescript Client, run: 37 | 38 | .. code-block:: bash 39 | 40 | npm install --save @steamship/client 41 | 42 | Then, import and use Steamship with: 43 | 44 | .. code-block:: python 45 | 46 | import {Steamship, Workspace} from '@steamship/client' 47 | 48 | const client = new Steamship() 49 | const instance = await client.use("package") 50 | 51 | Most of this documentation site is Python-centric and will assume operation via that client. 52 | -------------------------------------------------------------------------------- /docs/nextra/configuration/index.rst: -------------------------------------------------------------------------------- 1 | .. _Configuration: 2 | 3 | Configuration 4 | ============= 5 | 6 | Steamship, and the packages you build with it, can be used via our HTTP API, Python Client, or CLI. 7 | 8 | .. toctree:: 9 | :maxdepth: 1 10 | 11 | Authentication 12 | Client Libraries 13 | CLI 14 | HTTP API 15 | -------------------------------------------------------------------------------- /docs/nextra/data/file-lifecycle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steamship-core/python-client/62b3f9659fd43ce4fe62103b6488514259d1956f/docs/nextra/data/file-lifecycle.png -------------------------------------------------------------------------------- /docs/nextra/developing/environment-setup.rst: -------------------------------------------------------------------------------- 1 | Environment Setup 2 | ----------------- 3 | 4 | Steamship plugins are written in Python. 5 | We've standardized on ``venv`` for dependency management, 6 | and every plugin starter template comes with a ``requirements.txt`` and ``requirements.dev.txt`` file describing 7 | its dependencies. 8 | 9 | If you add new dependencies as you develop, it is important that you add them to ``requirements.txt``. 10 | Otherwise they will not be available when you deploy your plugin to the cloud. 11 | 12 | To set up your virtual environment for the first time, run this command from your plugin's root directory: 13 | 14 | .. code-block:: bash 15 | 16 | python3 -m venv .venv 17 | 18 | You can activate your virtual environment by running: 19 | 20 | .. code-block:: bash 21 | 22 | source .venv/bin/activate 23 | 24 | Your first time, or any time you add a dependency, run: 25 | 26 | .. code-block:: bash 27 | 28 | python -m pip install -r requirements.dev.txt 29 | python -m pip install -r requirements.txt 30 | 31 | -------------------------------------------------------------------------------- /docs/nextra/developing/logs-example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steamship-core/python-client/62b3f9659fd43ce4fe62103b6488514259d1956f/docs/nextra/developing/logs-example.png -------------------------------------------------------------------------------- /docs/nextra/developing/project-creation.rst: -------------------------------------------------------------------------------- 1 | Cloning a Starter Package 2 | ------------------------- 3 | 4 | We have several packages available to start from: 5 | 6 | * `Empty Package `_ - Bare-bones starter package shell 7 | * `Prompt API template `_ - Turn a GPT prompt into an API 8 | * `Chat analytics `_ - Cluster chatroom messages into conversations and classify intent and sentiment 9 | * `Ticket Tagging `_ - Tag service tickets with a zero-shot classifier, then transition to a trained model 10 | * `Audio to Markdown `_ - Create a markdown file from an audio transcript, using specific command words 11 | 12 | -------------------------------------------------------------------------------- /docs/nextra/developing/running.rst: -------------------------------------------------------------------------------- 1 | import { Callout } from \'nextra/components\'; 2 | 3 | :: 4 | 5 | Running on Localhost 6 | -------------------- 7 | 8 | To run your project on localhost type: 9 | 10 | .. code-block:: bash 11 | 12 | ship run local 13 | 14 | 15 | An ngrok account is required to run this command. 16 | 17 | 18 | This will start a local instance with a number of ways to interact with it: 19 | 20 | - A Console REPL, which will start immediately in the console. 21 | - An HTTP endpoint, which will be printed to the console 22 | - A Web endpoint, which will be printed to the console 23 | 24 | The output will look like this: 25 | 26 | .. code-block:: bash 27 | 28 | Running your project.. 29 | 30 | 🌎 Public API: https://example.ngrok.org/... 31 | 🌎 Local API: http://localhost:8080/... 32 | 🌎 Web URL: https://steamship:com/debug?https://... 33 | 34 | 💬 Interactive REPL below. 35 | 36 | You: _ 37 | 38 | Localhost caveats 39 | ~~~~~~~~~~~~~~~~~ 40 | 41 | Running on localhost currently does not yet support asynchronous tasks. 42 | In practice, this most often comes up with our ``DocumentIndexerPipelineMixin``, which enables loading in PDFs, YouTube videos, and other large documents for vector storage and retrieval. 43 | 44 | -------------------------------------------------------------------------------- /docs/nextra/developing/storing-secrets.rst: -------------------------------------------------------------------------------- 1 | Storing Secrets 2 | --------------- 3 | 4 | You may wish your plugin instance to store secrets, such as an API key or random seed. 5 | These should never be committed to your plugin's GitHub repository, but they can be easily bundled and loaded automatically during deployment. 6 | 7 | Simply place your secrets in ``src/.steamship/secrets.toml`` and ensure that they are git-ignored. 8 | All default plugin templates should have this file already git-ignored. 9 | For example, your ``secrets.toml`` file might look like this: 10 | 11 | .. code-block:: toml 12 | 13 | api_key = "be#45jdkjdsdfse3" 14 | random_seed = 12345 15 | 16 | Steamship's plugin loader will automatically detect this file and attempt to set any properties on your plugin's 17 | configuration object that have matching keys. 18 | 19 | **Note:** Automated deployments via GitHub-actions will not have this git-ignored file. 20 | To automate deployments that contain secrets, you will need to alter your GitHub Action scripts to create 21 | these files using GitHub Secrets after the checkout but before the deployment. 22 | -------------------------------------------------------------------------------- /docs/nextra/developing/tasks-example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steamship-core/python-client/62b3f9659fd43ce4fe62103b6488514259d1956f/docs/nextra/developing/tasks-example.png -------------------------------------------------------------------------------- /docs/nextra/developing/usage-example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steamship-core/python-client/62b3f9659fd43ce4fe62103b6488514259d1956f/docs/nextra/developing/usage-example.png -------------------------------------------------------------------------------- /docs/nextra/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steamship-core/python-client/62b3f9659fd43ce4fe62103b6488514259d1956f/docs/nextra/favicon.ico -------------------------------------------------------------------------------- /docs/nextra/license.rst: -------------------------------------------------------------------------------- 1 | .. _license: 2 | 3 | ==== 4 | License 5 | ==== 6 | 7 | Steamship's Python Client library is published under the MIT license. 8 | 9 | .. include:: ../../LICENSE 10 | -------------------------------------------------------------------------------- /docs/nextra/packages/cookbook/index.rst: -------------------------------------------------------------------------------- 1 | Package Development Cookbook 2 | ---------------------------- 3 | 4 | .. 5 | TODO: reorganize headings 6 | 7 | Working with Language 8 | ~~~~~~~~~~~~~~~~~~~~~ 9 | 10 | .. toctree:: 11 | :maxdepth: 1 12 | 13 | Collect and query sentiment 14 | 15 | Extract an outline from markdown 16 | 17 | Auto tag articles and query by tag 18 | 19 | 20 | Building Packages 21 | ~~~~~~~~~~~~~~~~~ 22 | 23 | .. toctree:: 24 | :maxdepth: 1 25 | 26 | Modify an existing package 27 | 28 | Make a package or plugin user-configurable 29 | 30 | Receive webhooks from another service 31 | 32 | 33 | Response Types 34 | ~~~~~~~~~~~~~~ 35 | 36 | .. toctree:: 37 | :maxdepth: 1 38 | 39 | Returning Text 40 | 41 | Returning JSON 42 | 43 | Returning Images 44 | 45 | Returning Audio 46 | -------------------------------------------------------------------------------- /docs/nextra/packages/cookbook/return-audio.rst: -------------------------------------------------------------------------------- 1 | Returning Audio from a Package Endpoint 2 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3 | 4 | Package endpoints can serve audio files by returning a ``InvocableResponse[bytes]`` object with the proper MIME Type set. 5 | 6 | API callers will receive a binary response over HTTP with the appropriate ``Content-Type`` header, and Steamship's auto-generated Web UI will wrap the response in an audio player widget. 7 | 8 | .. code-block:: python 9 | 10 | from steamship.base.mime_types import MimeTypes 11 | from steamship.invocable import PackageService, get 12 | 13 | class AudioReturningPackage(PackageService): 14 | """This package demonstrates how to return audio from a Steamship package.""" 15 | 16 | @get("audio_file") 17 | def audio_file(self) -> InvocableResponse[bytes]: 18 | _bytes = None # REPLACE: This should be a Python bytes object with MP4 Audio 19 | return InvocableResponse(_bytes=_bytes, mime_type=MimeTypes.MP4_AUDIO) 20 | -------------------------------------------------------------------------------- /docs/nextra/packages/cookbook/return-image.rst: -------------------------------------------------------------------------------- 1 | Returning an Image from a Package Endpoint 2 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3 | 4 | Package endpoints can serve images by returning a ``InvocableResponse[bytes]`` object with the proper MIME Type set. 5 | 6 | API callers will receive a binary response over HTTP with the appropriate ``Content-Type`` header, and Steamship's auto-generated Web UI will convert the response to an image in the browser. 7 | 8 | .. code-block:: python 9 | 10 | from steamship.base.mime_types import MimeTypes 11 | from steamship.invocable import PackageService, get 12 | 13 | class ImageReturningSteamshipPackage(PackageService): 14 | """This package demonstrates how to return an image from a Steamship package.""" 15 | 16 | @get("image_file") 17 | def image_file(self) -> InvocableResponse[bytes]: 18 | _bytes = None # REPLACE: This should be a Python bytes object with a PNG image 19 | return InvocableResponse(_bytes=_bytes, mime_type=MimeTypes.PNG) 20 | -------------------------------------------------------------------------------- /docs/nextra/packages/cookbook/return-json.rst: -------------------------------------------------------------------------------- 1 | Returning JSON data from a Package Endpoint 2 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3 | 4 | Package endpoints can serve JSON data by returning a python ``dict`` object from a method. 5 | 6 | API callers will receive a JSON response over HTTP with the appropriate ``Content-Type`` header, and Steamship's auto-generated Web UI will convert the JSON response to a formatted web view. 7 | 8 | .. code-block:: python 9 | 10 | from steamship.invocable import PackageService, get 11 | 12 | class JsonReturningSteamshipPackage(PackageService): 13 | """This package demonstrates how to return a JSON object from a Steamship package.""" 14 | 15 | @get("json_object") 16 | def json_object(self) -> dict: 17 | return { 18 | "greeting": "Hello, world!" 19 | } 20 | -------------------------------------------------------------------------------- /docs/nextra/packages/cookbook/return-text.rst: -------------------------------------------------------------------------------- 1 | Returning text data from a Package Endpoint 2 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3 | 4 | Package endpoints can serve text data by returning a python ``str`` object from a method. 5 | 6 | API callers will receive plain text response over HTTP with the appropriate ``Content-Type`` header, and Steamship's auto-generated Web UI will convert the text response to a formatted web view and interpret it as Markdown. 7 | 8 | .. code-block:: python 9 | 10 | from steamship.invocable import PackageService, get 11 | 12 | class TextReturningSteamshipPackage(PackageService): 13 | """This package demonstrates how to return a text object from a Steamship package.""" 14 | 15 | @get("text_object") 16 | def text_object(self) -> str: 17 | return "Hello, world!" 18 | -------------------------------------------------------------------------------- /docs/nextra/plugins/developing/embedders.rst: -------------------------------------------------------------------------------- 1 | .. _DevelopingEmbedders: 2 | 3 | Developing Embedders 4 | -------------------- 5 | 6 | We're excited for you to do this, but we haven't documented it yet! 7 | 8 | `Come chat with us on Discord `_ -------------------------------------------------------------------------------- /docs/nextra/plugins/developing/generators.rst: -------------------------------------------------------------------------------- 1 | .. _DevelopingGenerators: 2 | 3 | Developing Generators 4 | ------------------ 5 | A ``Generator`` takes :ref:`Blocks` as input and creates new ``Blocks`` as output. 6 | 7 | To implement a ``Generator``, your plugin class should inherit from :py:class:`steamship.plugin.generator.Generator` 8 | and implement the abstract ``run`` method: 9 | 10 | .. code-block:: python 11 | def run( 12 | self, request: PluginRequest[RawBlockAndTagPluginInput] 13 | ) -> InvocableResponse[RawBlockAndTagPluginOutput]: 14 | input_blocks = request.data.blocks 15 | 16 | output_blocks = self.do_something_interesting(input_blocks) 17 | 18 | return InvocableResponse(data=RawBlockAndTagPluginOutput(blocks=output_blocks)) 19 | 20 | 21 | For example, an image ``Generator`` could merge the ``text`` from the input blocks and use it to generate an image :py:class:`Block`. 22 | 23 | In addition to the input blocks and instance :ref:`configuration `, Generators can also receive 24 | arbitrary key/value runtime parameters. These are present in ``request.data.options``. 25 | 26 | See `the DALL-E plugin `_ for a working example of a text to image ``Generator``. -------------------------------------------------------------------------------- /docs/nextra/plugins/developing/importers.rst: -------------------------------------------------------------------------------- 1 | .. _DevelopingFileImporters: 2 | 3 | Developing File Importers 4 | ------------------------- 5 | 6 | We're excited for you to do this, but we haven't documented it yet! 7 | 8 | `Come chat with us on Discord `_ 9 | -------------------------------------------------------------------------------- /docs/nextra/plugins/developing/index.rst: -------------------------------------------------------------------------------- 1 | .. _DevelopingPluginsSec: 2 | 3 | Developing Plugins 4 | ~~~~~~~~~~~~~~~~~~ 5 | 6 | Each plugin is a stateless, Python-based microservice that runs in the 7 | cloud and conforms to a strict interface and data model. Plugins may do 8 | work themselves, or they may adapt work done by third-party services for 9 | use with Steamship. 10 | 11 | To implement a plugin, you simply fill in the required abstract methods from the appropriate ``PluginService`` abstract class. 12 | If you've implemented the required abstract methods, you have successfully built a plugin! 13 | 14 | Read more here: 15 | 16 | .. toctree:: 17 | :maxdepth: 1 18 | 19 | Plugin Project Structure 20 | Developing File Importers 21 | Developing Blockifiers 22 | Developing Generators 23 | Developing Taggers 24 | Developing Embedders 25 | 26 | Unlike packages, plugins also offer support for asynchronous work. 27 | This is useful when writing a plugin that, itself, contacts an asynchronous third-party API. 28 | You can find the documentation for that here: 29 | 30 | .. toctree:: 31 | :maxdepth: 1 32 | 33 | Writing Async Plugins 34 | 35 | -------------------------------------------------------------------------------- /docs/nextra/plugins/developing/project-structure.rst: -------------------------------------------------------------------------------- 1 | Plugin Project Structure 2 | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3 | 4 | Your main implementation lives in the ``src/api.py`` file of your project. 5 | This file will have been created for you by the template you selected when starting your project. 6 | 7 | Inside this file, you will find a class that derives from a base class specific to the plugin type. 8 | 9 | From the implementation perspective, think of a plugin as a class that implements an Abstract Base Class that the Steamship Engine knows how to communicate with. 10 | Each plugin type implements an abstract base class with a different contract. 11 | 12 | Consider the following tagger plugin: 13 | 14 | .. code-block:: python 15 | 16 | class TagFileTagger(Tagger): 17 | def run(self, request: PluginRequest[BlockAndTagPluginInput]) -> BlockAndTagPluginOutput: 18 | file = request.data.file 19 | file.tags.append( 20 | Tag.CreateRequest(kind="Demo", name="You've been tagged!") 21 | ) 22 | return BlockAndTagPluginOutput(file=file) 23 | 24 | Once deployed to Steamship, this plugin can be applied to files in Steamship, leaving each one with a tag that can be 25 | queried later. 26 | 27 | You can also :ref:`define configuration parameters` for your plugin. -------------------------------------------------------------------------------- /docs/nextra/plugins/developing/taggers.rst: -------------------------------------------------------------------------------- 1 | .. _DevelopingTaggers: 2 | 3 | Developing Taggers 4 | ------------------ 5 | 6 | We're excited for you to do this, but we haven't documented it yet! 7 | 8 | `Come chat with us on Discord `_ -------------------------------------------------------------------------------- /docs/nextra/plugins/using/blockifiers/index.rst: -------------------------------------------------------------------------------- 1 | .. _Blockifiers: 2 | 3 | *********** 4 | Blockifiers 5 | *********** 6 | 7 | Blockifiers convert data into Steamship’s native :ref:`Block format`. 8 | 9 | - **A Blockifier’s input** is raw bytes. Examples include a PDF, image, 10 | audio, HTML, CSV, JSON-formatted API output, or so on. 11 | - **A Blockifier’s output** is an object in :ref:`Steamship Block format`. 12 | 13 | All data imported into Steamship must be first blockified before it can be used. 14 | 15 | You can use blockifiers when developing Steamship :ref:`packages`, in your own Python app code, 16 | or as one-off functions that convert data in the cloud. 17 | 18 | .. include:: ./using.rst 19 | 20 | -------------------------------------------------------------------------------- /docs/nextra/plugins/using/embedders/index.rst: -------------------------------------------------------------------------------- 1 | .. _Embedders: 2 | 3 | ********* 4 | Embedders 5 | ********* 6 | 7 | .. toctree:: 8 | :maxdepth: 2 9 | 10 | Embedders are a special case of Taggers which convert data into vector format. 11 | 12 | The main reason to use an embedder is to provide data to an :ref:`Embedding Search Index for search `. 13 | -------------------------------------------------------------------------------- /docs/nextra/plugins/using/importers/index.rst: -------------------------------------------------------------------------------- 1 | .. _File Importers: 2 | 3 | ************** 4 | File Importers 5 | ************** 6 | 7 | .. toctree:: 8 | :maxdepth: 2 9 | 10 | File Importers import raw, unprocessed data into Steamship. 11 | 12 | - A File Importer’s input is a URL or raw bytes. 13 | - A File Importer's output is raw bytes plus a MIME type. 14 | 15 | You can use File Importers when developing Steamship packages, in your own Python app code, or as one-off functions that 16 | import data in the cloud. 17 | 18 | .. include:: ./using.rst 19 | 20 | -------------------------------------------------------------------------------- /docs/nextra/plugins/using/importers/using.rst: -------------------------------------------------------------------------------- 1 | Using File Importers 2 | -------------------- 3 | 4 | To use a :ref:`file importer`, create an instance within your workspace and then refer to it when creating a file. 5 | 6 | .. code-block:: python 7 | 8 | # Load a Steamship Worksapce 9 | from steamship import Steamship, File 10 | client = Steamship(workspace="my-workspace-handle") 11 | 12 | # Upload a file 13 | importer = client.use_plugin("file-importer-handle", "instance-handle", config={}) 14 | 15 | # Create a file via that plugin instance. 16 | file = File.create_with_plugin(client, plugin_instance=importer.handle) 17 | 18 | The documentation for the file importer you use will provide instructions about how to pass required arguments to it. 19 | Some require configuration (provided at plugin instance creation time) and others require a URL (provided at file creation time). 20 | 21 | 22 | -------------------------------------------------------------------------------- /docs/nextra/plugins/using/taggers/index.rst: -------------------------------------------------------------------------------- 1 | .. _Taggers: 2 | 3 | ******* 4 | Taggers 5 | ******* 6 | 7 | .. toctree:: 8 | :maxdepth: 2 9 | 10 | Taggers add :ref:`Tags` (annotations) to :ref:`Blocks` (content). These tags can be :ref:`queried ` and composed later. 11 | 12 | .. include:: ./using.rst 13 | 14 | -------------------------------------------------------------------------------- /docs/nextra/plugins/using/tasks.rst: -------------------------------------------------------------------------------- 1 | .. _Tasks: 2 | 3 | Tasks 4 | ===== 5 | Most :ref:`Plugin` operations return a ``Task``. This allows you to conveniently handle the long, 6 | asynchronous aspect of many plugin invocations. 7 | 8 | Waiting on Tasks 9 | ---------------- 10 | If your code does not need to do any other work while the ``Plugin`` is running, you may ``wait()`` on the ``Task``: 11 | 12 | .. code-block:: python 13 | tagger_task = file.tag(tagger.handle) 14 | tagger_task.wait() 15 | 16 | This will make your code poll the Steamship service until either the ``Task`` is complete, or the wait timeout is reached. 17 | 18 | .. note:: 19 | Waiting on the task may time out before the ``Task`` is complete. Don't worry, the ``Task`` is still running on the server. 20 | You can increase the time you wait by passing the ``max_timeout_s`` parameter. 21 | 22 | Returning Tasks from a Package 23 | ------------------------------ 24 | One common pattern when your package does long asynchronous work is to return a ``Task`` id which can 25 | be used later to check on the status of the ``Task``. To check the status of a ``Task`` from its id: 26 | 27 | .. code-block:: python 28 | task = Task.get(client, _id=task_id) 29 | 30 | Once you have a task object again, you can ``wait()`` on it, or check its ``state`` variable. -------------------------------------------------------------------------------- /docs/nextra/rename_link.js: -------------------------------------------------------------------------------- 1 | const readline = require("node:readline"); 2 | 3 | async function main() { 4 | const rl = readline.createInterface({ 5 | input: process.stdin, 6 | }); 7 | 8 | for await (const line of rl) { 9 | // replace all instances of "/../../../steamship/apps/python-docs/pages" with "" 10 | // process a line at a time 11 | process.stdout.write(`${line.replaceAll('/../../../steamship/apps/python-docs/pages', '')}\n`); 12 | } 13 | } 14 | 15 | main(); -------------------------------------------------------------------------------- /docs/requirements.txt: -------------------------------------------------------------------------------- 1 | # Requirements file for ReadTheDocs, check .readthedocs.yml. 2 | # To build the module reference correctly, make sure every external package 3 | # under `install_requires` in `setup.cfg` is also listed here! 4 | sphinx>=3.2.1 5 | # sphinx_rtd_theme 6 | furo 7 | myst-parser 8 | sphinx-copybutton 9 | sphinx-design 10 | sphinx-inline-tabs 11 | sphinx-tabs 12 | Pygments 13 | sphinx-markdown-builder==0.6.3 -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | requests~=2.28.1 2 | pydantic~=1.10.2 3 | aiohttp~=3.8.4 4 | inflection~=0.5.1 5 | fluent-logger~=0.10.0 6 | toml~=0.10.2 7 | click~=8.1.3 8 | semver~=3.0.0 9 | tiktoken~=0.4.0 -------------------------------------------------------------------------------- /scripts/build-docs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | docker run --rm -v `pwd`:/docs --workdir /docs/docs sphinxdoc/sphinx make html -------------------------------------------------------------------------------- /src/steamship/agents/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steamship-core/python-client/62b3f9659fd43ce4fe62103b6488514259d1956f/src/steamship/agents/__init__.py -------------------------------------------------------------------------------- /src/steamship/agents/examples/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steamship-core/python-client/62b3f9659fd43ce4fe62103b6488514259d1956f/src/steamship/agents/examples/__init__.py -------------------------------------------------------------------------------- /src/steamship/agents/examples/chatgpt_api.py: -------------------------------------------------------------------------------- 1 | """Minimum viable AgentService implementation. 2 | 3 | This will result in an agent that effectively acts like ChatGPT. 4 | """ 5 | 6 | from steamship.agents.functional import FunctionsBasedAgent 7 | from steamship.agents.llms.openai import ChatOpenAI 8 | from steamship.agents.service.agent_service import AgentService 9 | from steamship.utils.repl import AgentREPL 10 | 11 | 12 | class MyAssistant(AgentService): 13 | def __init__(self, **kwargs): 14 | super().__init__(**kwargs) 15 | self.set_default_agent(FunctionsBasedAgent(llm=ChatOpenAI(self.client), tools=[])) 16 | 17 | 18 | if __name__ == "__main__": 19 | AgentREPL( 20 | MyAssistant, 21 | agent_package_config={}, 22 | ).run() 23 | -------------------------------------------------------------------------------- /src/steamship/agents/examples/chatgpt_with_web_and_telegram.py: -------------------------------------------------------------------------------- 1 | from steamship.agents.functional import FunctionsBasedAgent 2 | from steamship.agents.llms.openai import ChatOpenAI 3 | from steamship.agents.mixins.transports.steamship_widget import SteamshipWidgetTransport 4 | from steamship.agents.service.agent_service import AgentService 5 | from steamship.utils.repl import AgentREPL 6 | 7 | 8 | class ChatGpt(AgentService): 9 | """Minimal implementation of an Agent that just chats with you via the web.""" 10 | 11 | def __init__(self, **kwargs): 12 | super().__init__(**kwargs) 13 | 14 | # The agent's planner is responsible for making decisions about what to do for a given input. 15 | self.set_default_agent( 16 | FunctionsBasedAgent( 17 | tools=[], 18 | llm=ChatOpenAI(self.client, model_name="gpt-4"), 19 | ) 20 | ) 21 | 22 | # This Mixin provides HTTP endpoints that connects this agent to a web client 23 | self.add_mixin(SteamshipWidgetTransport(client=self.client, agent_service=self)) 24 | 25 | 26 | if __name__ == "__main__": 27 | AgentREPL( 28 | ChatGpt, 29 | agent_package_config={"botToken": "not-a-real-token-for-local-testing"}, 30 | ).run() 31 | -------------------------------------------------------------------------------- /src/steamship/agents/functional/__init__.py: -------------------------------------------------------------------------------- 1 | from .functions_based import FunctionsBasedAgent 2 | from .output_parser import FunctionsBasedOutputParser 3 | 4 | __all__ = [ 5 | "FunctionsBasedAgent", 6 | "FunctionsBasedOutputParser", 7 | ] 8 | -------------------------------------------------------------------------------- /src/steamship/agents/llms/__init__.py: -------------------------------------------------------------------------------- 1 | from .openai import OpenAI 2 | 3 | __all__ = ["OpenAI"] 4 | -------------------------------------------------------------------------------- /src/steamship/agents/mixins/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steamship-core/python-client/62b3f9659fd43ce4fe62103b6488514259d1956f/src/steamship/agents/mixins/__init__.py -------------------------------------------------------------------------------- /src/steamship/agents/mixins/transports/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steamship-core/python-client/62b3f9659fd43ce4fe62103b6488514259d1956f/src/steamship/agents/mixins/transports/__init__.py -------------------------------------------------------------------------------- /src/steamship/agents/react/__init__.py: -------------------------------------------------------------------------------- 1 | from .output_parser import ReACTOutputParser 2 | from .react import ReACTAgent 3 | 4 | __all__ = ["ReACTAgent", "ReACTOutputParser"] 5 | -------------------------------------------------------------------------------- /src/steamship/agents/schema/__init__.py: -------------------------------------------------------------------------------- 1 | from .action import Action, FinishAction 2 | from .agent import Agent, ChatAgent, LLMAgent 3 | from .chathistory import ChatHistory 4 | from .context import AgentContext, EmitFunc, Metadata 5 | from .llm import LLM, ChatLLM 6 | from .output_parser import OutputParser 7 | from .tool import Tool 8 | 9 | __all__ = [ 10 | "Action", 11 | "Agent", 12 | "AgentContext", 13 | "ChatLLM", 14 | "ChatAgent", 15 | "EmitFunc", 16 | "FinishAction", 17 | "Metadata", 18 | "LLM", 19 | "LLMAgent", 20 | "OutputParser", 21 | "Tool", 22 | "ChatHistory", 23 | ] 24 | -------------------------------------------------------------------------------- /src/steamship/agents/schema/action.py: -------------------------------------------------------------------------------- 1 | from typing import List, Optional 2 | 3 | from pydantic import BaseModel 4 | from pydantic.fields import Field 5 | 6 | from steamship import Block 7 | 8 | 9 | class Action(BaseModel): 10 | """Actions represent a binding of a Tool to the inputs supplied to the tool. 11 | 12 | Upon completion, the Action also contains the output of the Tool given the inputs. 13 | """ 14 | 15 | tool: str 16 | """Name of tool used by this action.""" 17 | 18 | input: List[Block] 19 | """Data provided directly to the Tool (full context is passed in run).""" 20 | 21 | output: Optional[List[Block]] 22 | """Any direct output produced by the Tool.""" 23 | 24 | is_final: bool = Field(default=False) 25 | """Whether this Action should be the final action performed in a reasoning loop. 26 | 27 | Setting this to True means that the executing Agent should halt any reasoning. 28 | """ 29 | 30 | 31 | class FinishAction(Action): 32 | """Represents a final selected action in an Agent Execution.""" 33 | 34 | tool = "Agent-FinishAction" 35 | input: List[Block] = [] 36 | is_final = True 37 | -------------------------------------------------------------------------------- /src/steamship/agents/schema/llm.py: -------------------------------------------------------------------------------- 1 | from abc import ABC, abstractmethod 2 | from typing import List, Optional 3 | 4 | from pydantic.main import BaseModel 5 | 6 | from steamship import Block 7 | from steamship.agents.schema.tool import Tool 8 | 9 | 10 | class LLM(BaseModel, ABC): 11 | """LLM wraps large language model-based backends. 12 | 13 | They may be used with LLMAgents in Action selection, or for direct prompt completion.""" 14 | 15 | @abstractmethod 16 | def complete(self, prompt: str, stop: Optional[str] = None, **kwargs) -> List[Block]: 17 | """Completes the provided prompt, stopping when the stop sequeunce is found.""" 18 | pass 19 | 20 | 21 | # TODO(dougreid): should LLM and ConversationalLLM share a common parent? 22 | class ChatLLM(BaseModel, ABC): 23 | """ChatLLM wraps large language model-based backends that use a chat completion style interation. 24 | 25 | They may be used with Agents in Action selection, or for direct prompt completion.""" 26 | 27 | @abstractmethod 28 | def chat(self, messages: List[Block], tools: Optional[List[Tool]], **kwargs) -> List[Block]: 29 | """Sends the set of chat messages to the LLM, returning the next part of the conversation""" 30 | pass 31 | -------------------------------------------------------------------------------- /src/steamship/agents/schema/output_parser.py: -------------------------------------------------------------------------------- 1 | from abc import ABC, abstractmethod 2 | 3 | from pydantic import BaseModel 4 | 5 | from steamship.agents.schema.action import Action 6 | from steamship.agents.schema.context import AgentContext 7 | 8 | 9 | class OutputParser(BaseModel, ABC): 10 | """Used to convert text into Actions. 11 | 12 | Primarily used by LLM-based agents that generate textual descriptions of 13 | selected actions and their inputs. OutputParsers can be used to convert 14 | those descriptions into Action objects for the AgentService to run. 15 | 16 | Example: 17 | - input: "Action: GenerateImage 18 | ActionInput: row-house" 19 | - output: Action("dalle", "row-house") 20 | """ 21 | 22 | @abstractmethod 23 | def parse(self, text: str, context: AgentContext) -> Action: 24 | """Convert text into an Action object.""" 25 | pass 26 | -------------------------------------------------------------------------------- /src/steamship/agents/service/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steamship-core/python-client/62b3f9659fd43ce4fe62103b6488514259d1956f/src/steamship/agents/service/__init__.py -------------------------------------------------------------------------------- /src/steamship/agents/tools/__init__.py: -------------------------------------------------------------------------------- 1 | from .base_tools import ( 2 | AudioBlockifierTool, 3 | AudioGeneratorTool, 4 | GeneratorTool, 5 | ImageBlockifierTool, 6 | ImageGeneratorTool, 7 | ScrapeAndBlockifyTool, 8 | VideoGeneratorTool, 9 | ) 10 | 11 | __all__ = [ 12 | "AudioGeneratorTool", 13 | "AudioBlockifierTool", 14 | "ImageBlockifierTool", 15 | "ImageGeneratorTool", 16 | "GeneratorTool", 17 | "ScrapeAndBlockifyTool", 18 | "VideoGeneratorTool", 19 | ] 20 | -------------------------------------------------------------------------------- /src/steamship/agents/tools/audio_transcription/__init__.py: -------------------------------------------------------------------------------- 1 | from .assembly_speech_to_text_tool import AssemblySpeechToTextTool 2 | from .fetch_audio_urls_from_rss_tool import FetchAudioUrlsFromRssTool 3 | from .whisper_speech_to_text_tool import WhisperSpeechToTextTool 4 | 5 | __all__ = [ 6 | "AssemblySpeechToTextTool", 7 | "FetchAudioUrlsFromRssTool", 8 | "WhisperSpeechToTextTool", 9 | ] 10 | -------------------------------------------------------------------------------- /src/steamship/agents/tools/audio_transcription/assembly_speech_to_text_tool.py: -------------------------------------------------------------------------------- 1 | """Tool for generating images.""" 2 | from steamship import Steamship 3 | from steamship.agents.llms import OpenAI 4 | from steamship.agents.tools import AudioBlockifierTool 5 | from steamship.agents.utils import with_llm 6 | from steamship.utils.repl import ToolREPL 7 | 8 | 9 | class AssemblySpeechToTextTool(AudioBlockifierTool): 10 | """Tool to generate text from audio.""" 11 | 12 | name: str = "AssemblySpeechToTextTool" 13 | human_description: str = "Generates text from spoken audio." 14 | agent_description: str = ( 15 | "Used to generate text from spoken audio. " 16 | "Only use if the user has asked directly for a text version of an audio file. " 17 | "When using this tool, the input should be the audio file. " 18 | "The output is the text." 19 | ) 20 | blockifier_plugin_handle: str = "s2t-blockifier-assembly" 21 | 22 | 23 | if __name__ == "__main__": 24 | tool = AssemblySpeechToTextTool() 25 | # Try on: https://anchor.fm/s/e1369b4c/podcast/play/70381739/https%3A%2F%2Fd3ctxlq1ktw2nl.cloudfront.net%2Fstaging%2F2023-4-14%2Fda96d64d-3c27-3e84-eb63-d5bc55eaf52e.mp3 26 | 27 | with Steamship.temporary_workspace() as client: 28 | ToolREPL(tool).run_with_client(client=client, context=with_llm(llm=OpenAI(client=client))) 29 | -------------------------------------------------------------------------------- /src/steamship/agents/tools/classification/__init__.py: -------------------------------------------------------------------------------- 1 | from .sentiment_analysis_tool import SentimentAnalysisTool 2 | from .zero_shot_classifier_tool import ZeroShotClassifierTool 3 | 4 | __all__ = [ 5 | "SentimentAnalysisTool", 6 | "ZeroShotClassifierTool", 7 | ] 8 | -------------------------------------------------------------------------------- /src/steamship/agents/tools/conversation_starters/__init__.py: -------------------------------------------------------------------------------- 1 | from .knock_knock_tool import KnockKnockTool 2 | 3 | __all__ = ["KnockKnockTool"] 4 | -------------------------------------------------------------------------------- /src/steamship/agents/tools/conversation_starters/knock_knock_tool.py: -------------------------------------------------------------------------------- 1 | from typing import Any, List, Union 2 | 3 | from steamship import Block, Steamship, Task 4 | from steamship.agents.llms import OpenAI 5 | from steamship.agents.schema import AgentContext, Tool 6 | from steamship.agents.utils import with_llm 7 | from steamship.utils.repl import ToolREPL 8 | 9 | 10 | class KnockKnockTool(Tool): 11 | """ 12 | Example tool to illustrate how one might initiate the beginning of a joke. 13 | 14 | Experimentally, the conversational LLM which underlies the agent ought to take over from there on out and 15 | be capable of completing the joke once it's begun. 16 | """ 17 | 18 | name = "KnockKnockTool" 19 | human_description = "Starts a Knock-Knock Joke." 20 | agent_description = "Used to begin telling a Knock Knock joke." 21 | 22 | def run(self, tool_input: List[Block], context: AgentContext) -> Union[List[Block], Task[Any]]: 23 | return [Block(text="Knock-Knock...")] 24 | 25 | 26 | if __name__ == "__main__": 27 | tool = KnockKnockTool() 28 | with Steamship.temporary_workspace() as client: 29 | ToolREPL(tool).run_with_client(client=client, context=with_llm(llm=OpenAI(client=client))) 30 | -------------------------------------------------------------------------------- /src/steamship/agents/tools/image_generation/__init__.py: -------------------------------------------------------------------------------- 1 | from .dalle import DalleTool 2 | from .google_image_search import GoogleImageSearchTool 3 | from .stable_diffusion import StableDiffusionTool 4 | 5 | __all__ = [ 6 | "DalleTool", 7 | "GoogleImageSearchTool", 8 | "StableDiffusionTool", 9 | ] 10 | -------------------------------------------------------------------------------- /src/steamship/agents/tools/image_generation/dalle.py: -------------------------------------------------------------------------------- 1 | """Tool for generating images.""" 2 | from steamship import Steamship 3 | from steamship.agents.llms import OpenAI 4 | from steamship.agents.tools import ImageGeneratorTool 5 | from steamship.agents.utils import with_llm 6 | from steamship.utils.repl import ToolREPL 7 | 8 | 9 | class DalleTool(ImageGeneratorTool): 10 | """Tool to generate images from text using OpenAI's DALL-E.""" 11 | 12 | name: str = "DalleTool" 13 | human_description: str = "Generates an image from text." 14 | agent_description = ( 15 | "Used to generate still images from text prompts. Only use if the user has asked directly for an " 16 | "image. When using this tool, the input should be a plain text string that describes, " 17 | "in detail, the desired image." 18 | ) 19 | generator_plugin_handle: str = "dall-e" 20 | generator_plugin_config: dict = {"n": 1, "size": "256x256"} 21 | 22 | 23 | if __name__ == "__main__": 24 | tool = DalleTool() 25 | with Steamship.temporary_workspace() as client: 26 | ToolREPL(tool).run_with_client(client=client, context=with_llm(llm=OpenAI(client=client))) 27 | -------------------------------------------------------------------------------- /src/steamship/agents/tools/image_generation/google_image_search.py: -------------------------------------------------------------------------------- 1 | """Tool for generating images.""" 2 | from steamship import Steamship 3 | from steamship.agents.llms import OpenAI 4 | from steamship.agents.tools import ImageGeneratorTool 5 | from steamship.agents.utils import with_llm 6 | from steamship.utils.repl import ToolREPL 7 | 8 | 9 | class GoogleImageSearchTool(ImageGeneratorTool): 10 | """Tool to generate images from text by using Google Image Search.""" 11 | 12 | name: str = "GoogleImageSearchTool" 13 | human_description: str = "Fetches an image from Google Image Search." 14 | agent_description = ( 15 | "Used to retrieve an image of a well known object, person, place, or idea. Only use if the user has asked directly for an image. " 16 | "Input: a plain text string that describes an object, person, place, or idea. " 17 | "Output: an image of that thing." 18 | ) 19 | generator_plugin_handle: str = "google-image-search" 20 | generator_plugin_config: dict = {} 21 | 22 | 23 | if __name__ == "__main__": 24 | tool = GoogleImageSearchTool() 25 | with Steamship.temporary_workspace() as client: 26 | ToolREPL(tool).run_with_client(client=client, context=with_llm(llm=OpenAI(client=client))) 27 | -------------------------------------------------------------------------------- /src/steamship/agents/tools/image_generation/stable_diffusion.py: -------------------------------------------------------------------------------- 1 | """Tool for generating images.""" 2 | from steamship import Steamship 3 | from steamship.agents.llms import OpenAI 4 | from steamship.agents.tools import ImageGeneratorTool 5 | from steamship.agents.utils import with_llm 6 | from steamship.utils.repl import ToolREPL 7 | 8 | 9 | class StableDiffusionTool(ImageGeneratorTool): 10 | """Tool to generate images from text using StableDiffusion.""" 11 | 12 | name: str = "StableDiffusionTool" 13 | human_description: str = "Generates an image from text." 14 | agent_description = ( 15 | "Used to generate images from text prompts. Only use if the user has asked directly for an image. " 16 | "When using this tool, the input should be a plain text string that describes, " 17 | "in detail, the desired image." 18 | ) 19 | generator_plugin_handle: str = "stable-diffusion" 20 | generator_plugin_config: dict = {"n": 1} 21 | 22 | 23 | if __name__ == "__main__": 24 | tool = StableDiffusionTool() 25 | with Steamship.temporary_workspace() as client: 26 | ToolREPL(tool).run_with_client(client=client, context=with_llm(llm=OpenAI(client=client))) 27 | -------------------------------------------------------------------------------- /src/steamship/agents/tools/question_answering/__init__.py: -------------------------------------------------------------------------------- 1 | from .prompt_database_question_answerer import PromptDatabaseQATool 2 | from .vector_search_learner_tool import VectorSearchLearnerTool 3 | from .vector_search_qa_tool import VectorSearchQATool 4 | 5 | __all__ = ["PromptDatabaseQATool", "VectorSearchQATool", "VectorSearchLearnerTool"] 6 | -------------------------------------------------------------------------------- /src/steamship/agents/tools/search/__init__.py: -------------------------------------------------------------------------------- 1 | from .search import SearchTool 2 | 3 | __all__ = ["SearchTool"] 4 | -------------------------------------------------------------------------------- /src/steamship/agents/tools/speech_generation/__init__.py: -------------------------------------------------------------------------------- 1 | from .generate_speech import GenerateSpeechTool 2 | 3 | __all__ = ["GenerateSpeechTool"] 4 | -------------------------------------------------------------------------------- /src/steamship/agents/tools/speech_generation/generate_speech.py: -------------------------------------------------------------------------------- 1 | """Tool for generating images.""" 2 | from steamship import Steamship 3 | from steamship.agents.llms import OpenAI 4 | from steamship.agents.tools import AudioGeneratorTool 5 | from steamship.agents.utils import with_llm 6 | from steamship.utils.repl import ToolREPL 7 | 8 | 9 | class GenerateSpeechTool(AudioGeneratorTool): 10 | """Tool to generate audio from text.""" 11 | 12 | name: str = "GenerateSpokenAudio" 13 | human_description: str = "Generates spoken audio from text." 14 | agent_description: str = ( 15 | "Used to generate spoken audio from text prompts. Only use if the user has asked directly for a " 16 | "an audio version of output. When using this tool, the input should be a plain text string containing the " 17 | "content to be spoken." 18 | ) 19 | generator_plugin_handle: str = "elevenlabs" 20 | 21 | 22 | if __name__ == "__main__": 23 | tool = GenerateSpeechTool() 24 | with Steamship.temporary_workspace() as client: 25 | ToolREPL(tool).run_with_client(client=client, context=with_llm(llm=OpenAI(client=client))) 26 | -------------------------------------------------------------------------------- /src/steamship/agents/tools/text_generation/__init__.py: -------------------------------------------------------------------------------- 1 | from .image_prompt_generator_tool import ImagePromptGeneratorTool 2 | from .json_object_generator import JsonObjectGeneratorTool 3 | from .personality_tool import PersonalityTool 4 | from .summarize_text_with_prompt_tool import SummarizeTextWithPromptTool 5 | from .text_rewrite_tool import TextRewritingTool 6 | from .text_translation_tool import TextTranslationTool 7 | 8 | __all__ = [ 9 | "ImagePromptGeneratorTool", 10 | "PersonalityTool", 11 | "SummarizeTextWithPromptTool", 12 | "TextRewritingTool", 13 | "TextTranslationTool", 14 | "JsonObjectGeneratorTool", 15 | ] 16 | -------------------------------------------------------------------------------- /src/steamship/agents/tools/video_generation/__init__.py: -------------------------------------------------------------------------------- 1 | from .did_video_generator_tool import DIDVideoGeneratorTool 2 | 3 | __all__ = [ 4 | "DIDVideoGeneratorTool", 5 | ] 6 | -------------------------------------------------------------------------------- /src/steamship/base/__init__.py: -------------------------------------------------------------------------------- 1 | from .configuration import Configuration 2 | from .environments import RuntimeEnvironments, check_environment 3 | from .error import SteamshipError 4 | from .mime_types import MimeTypes 5 | from .tasks import Task, TaskState 6 | 7 | __all__ = [ 8 | "Configuration", 9 | "SteamshipError", 10 | "Task", 11 | "TaskState", 12 | "MimeTypes", 13 | "RuntimeEnvironments", 14 | "check_environment", 15 | ] 16 | -------------------------------------------------------------------------------- /src/steamship/base/model.py: -------------------------------------------------------------------------------- 1 | import re 2 | from typing import TypeVar 3 | 4 | import inflection 5 | from pydantic import BaseModel 6 | from pydantic.generics import GenericModel 7 | 8 | T = TypeVar("T") # Declare type variable 9 | 10 | 11 | def to_camel(s: str) -> str: 12 | s = re.sub("_(url)$", lambda m: f"_{m.group(1).upper()}", s) 13 | return inflection.camelize(s, uppercase_first_letter=False) 14 | 15 | 16 | class CamelModel(BaseModel): 17 | def __init__(self, **kwargs): 18 | kwargs = {k: v for k, v in kwargs.items() if v is not None} 19 | super().__init__(**kwargs) 20 | 21 | class Config: 22 | alias_generator = to_camel 23 | allow_population_by_field_name = True 24 | # Populate enum values with their value, rather than the raw enum. Important to serialise model.dict() 25 | use_enum_values = True 26 | 27 | 28 | class GenericCamelModel(CamelModel, GenericModel): 29 | pass 30 | -------------------------------------------------------------------------------- /src/steamship/base/request.py: -------------------------------------------------------------------------------- 1 | from enum import Enum 2 | from typing import Optional 3 | 4 | from steamship.base.model import CamelModel 5 | 6 | 7 | class Request(CamelModel): 8 | pass 9 | 10 | 11 | class GetRequest(Request): 12 | id: str = None 13 | handle: str = None 14 | 15 | 16 | class CreateRequest(Request): 17 | id: str = None 18 | handle: str = None 19 | 20 | 21 | class UpdateRequest(Request): 22 | id: str = None 23 | handle: str = None 24 | 25 | 26 | class IdentifierRequest(Request): 27 | id: str = None 28 | handle: str = None 29 | 30 | 31 | class SortOrder(str, Enum): 32 | ASC = "ASC" 33 | DESC = "DESC" 34 | 35 | 36 | class ListRequest(Request): 37 | page_size: Optional[int] 38 | page_token: Optional[str] 39 | sort_order: Optional[SortOrder] = SortOrder.DESC 40 | 41 | 42 | class DeleteRequest(Request): 43 | id: str 44 | -------------------------------------------------------------------------------- /src/steamship/base/response.py: -------------------------------------------------------------------------------- 1 | from typing import Optional 2 | 3 | from steamship.base.model import CamelModel 4 | 5 | 6 | class Response(CamelModel): 7 | pass 8 | 9 | 10 | class ListResponse(Response): 11 | next_page_token: Optional[str] 12 | -------------------------------------------------------------------------------- /src/steamship/cli/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steamship-core/python-client/62b3f9659fd43ce4fe62103b6488514259d1956f/src/steamship/cli/__init__.py -------------------------------------------------------------------------------- /src/steamship/cli/local_server/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steamship-core/python-client/62b3f9659fd43ce4fe62103b6488514259d1956f/src/steamship/cli/local_server/__init__.py -------------------------------------------------------------------------------- /src/steamship/cli/requirements_init_wizard.py: -------------------------------------------------------------------------------- 1 | import click 2 | 3 | import steamship 4 | 5 | 6 | def requirements_init_wizard(): 7 | click.secho( 8 | "Steamship uses requirements.txt to specify dependencies. You do not currently have a requirements.txt in this directory.", 9 | fg="yellow", 10 | ) 11 | if not click.confirm("Would you like to create one automatically?", default=True): 12 | click.secho("Please manually create a requirements.txt and try again.") 13 | click.get_current_context().abort() 14 | 15 | with open("requirements.txt", "w") as requirements_file: 16 | requirements_file.write(f"steamship=={steamship.__version__}\n") 17 | 18 | click.secho( 19 | "Created a requirements.txt with the steamship dependency. If you need others, they must be added manually." 20 | ) 21 | -------------------------------------------------------------------------------- /src/steamship/client/__init__.py: -------------------------------------------------------------------------------- 1 | from .steamship import Steamship 2 | 3 | __all__ = ["Steamship"] 4 | -------------------------------------------------------------------------------- /src/steamship/client/skills.py: -------------------------------------------------------------------------------- 1 | from enum import Enum 2 | 3 | 4 | class Skill(str, Enum): 5 | ENTITIES = "entities" 6 | SUMMARY = "summary" 7 | SENTIMENTS = "sentiments" 8 | EMOTIONS = "emotions" 9 | TOPICS = "topics" 10 | HIGHLIGHTS = "highlights" 11 | KEYWORDS = "keywords" 12 | -------------------------------------------------------------------------------- /src/steamship/client/vendors.py: -------------------------------------------------------------------------------- 1 | from enum import Enum 2 | 3 | 4 | class Vendor(str, Enum): 5 | OneAI = "one-ai" 6 | -------------------------------------------------------------------------------- /src/steamship/data/__init__.py: -------------------------------------------------------------------------------- 1 | from .block import Block 2 | from .embeddings import EmbeddingIndex 3 | from .file import File 4 | from .package import Package, PackageInstance, PackageVersion 5 | from .plugin import Plugin, PluginInstance, PluginVersion 6 | from .tags import DocTag, GenerationTag, Tag, TagKind, TagValueKey, TokenTag 7 | from .workspace import Workspace 8 | 9 | __all__ = [ 10 | "Package", 11 | "PackageInstance", 12 | "PackageVersion", 13 | "Block", 14 | "EmbeddingIndex", 15 | "File", 16 | "GenerationTag", 17 | "Plugin", 18 | "PluginInstance", 19 | "PluginVersion", 20 | "Workspace", 21 | "DocTag", 22 | "Tag", 23 | "TagKind", 24 | "TokenTag", 25 | "TagValueKey", 26 | ] 27 | -------------------------------------------------------------------------------- /src/steamship/data/invocable_init_status.py: -------------------------------------------------------------------------------- 1 | from enum import Enum 2 | 3 | 4 | class InvocableInitStatus(str, Enum): 5 | NOT_NEEDED = "notNeeded" 6 | INITIALIZING = "initializing" 7 | COMPLETE = "complete" 8 | FAILED = "failed" 9 | -------------------------------------------------------------------------------- /src/steamship/data/operations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steamship-core/python-client/62b3f9659fd43ce4fe62103b6488514259d1956f/src/steamship/data/operations/__init__.py -------------------------------------------------------------------------------- /src/steamship/data/operations/blockifier.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from steamship.base.request import Request 4 | 5 | 6 | class BlockifyRequest(Request): 7 | type: str = None 8 | plugin_instance: str = None 9 | id: str = None 10 | handle: str = None 11 | name: str = None 12 | -------------------------------------------------------------------------------- /src/steamship/data/operations/embedder.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from typing import Dict, List 4 | 5 | from steamship.base.request import Request 6 | 7 | 8 | class EmbedRequest(Request): 9 | docs: List[str] 10 | plugin_instance: str 11 | metadata: Dict = None 12 | -------------------------------------------------------------------------------- /src/steamship/data/operations/tagger.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from steamship.base.request import Request 4 | from steamship.base.response import Response 5 | 6 | from ..file import File 7 | 8 | 9 | class TagRequest(Request): 10 | type: str = None 11 | id: str = None 12 | name: str = None 13 | handle: str = None 14 | plugin_instance: str = None 15 | file: File = None 16 | 17 | 18 | class TagResponse(Response): 19 | file: File = None 20 | -------------------------------------------------------------------------------- /src/steamship/data/package/__init__.py: -------------------------------------------------------------------------------- 1 | from .package import Package 2 | from .package_instance import PackageInstance 3 | from .package_version import PackageVersion 4 | 5 | __all__ = [ 6 | "Package", 7 | "PackageInstance", 8 | "PackageVersion", 9 | ] 10 | -------------------------------------------------------------------------------- /src/steamship/data/plugin/__init__.py: -------------------------------------------------------------------------------- 1 | from .hosting import HostingCpu, HostingEnvironment, HostingMemory, HostingTimeout, HostingType 2 | from .plugin import Plugin, PluginAdapterType, PluginTargetType, PluginType 3 | from .plugin_instance import PluginInstance 4 | from .plugin_version import PluginVersion 5 | 6 | __all__ = [ 7 | "Plugin", 8 | "PluginVersion", 9 | "PluginInstance", 10 | "HostingMemory", 11 | "HostingTimeout", 12 | "HostingCpu", 13 | "HostingEnvironment", 14 | "HostingType", 15 | "PluginType", 16 | "PluginAdapterType", 17 | "PluginTargetType", 18 | ] 19 | -------------------------------------------------------------------------------- /src/steamship/data/search.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | import json 4 | from json import JSONDecodeError 5 | from typing import Any 6 | 7 | from steamship.base.model import CamelModel 8 | 9 | 10 | class Hit(CamelModel): 11 | id: str = None 12 | index: int = None 13 | index_source: str = None 14 | value: str = None 15 | score: float = None 16 | external_id: str = None 17 | external_type: str = None 18 | metadata: Any = None 19 | query: str = None 20 | 21 | def __init__(self, **kwargs): 22 | super().__init__(**kwargs) 23 | metadata = kwargs.get("metadata") 24 | if metadata is not None: 25 | try: 26 | self.metadata = json.loads(metadata) 27 | except JSONDecodeError: 28 | pass 29 | -------------------------------------------------------------------------------- /src/steamship/data/tags/__init__.py: -------------------------------------------------------------------------------- 1 | from .tag import Tag 2 | from .tag_constants import DocTag, GenerationTag, TagKind, TagValueKey, TokenTag 3 | 4 | __all__ = [ 5 | "DocTag", 6 | "Tag", 7 | "TagKind", 8 | "TokenTag", 9 | "TagValueKey", 10 | "GenerationTag", 11 | ] 12 | -------------------------------------------------------------------------------- /src/steamship/data/tags/tag_utils.py: -------------------------------------------------------------------------------- 1 | from typing import List, Optional 2 | 3 | from steamship.data.tags.tag import Tag 4 | 5 | 6 | def get_tag( 7 | tags: Optional[List[Tag]], kind: Optional[str] = None, name: Optional[str] = None 8 | ) -> Optional[Tag]: 9 | """Return the first tag of a list with the provided kind & name.""" 10 | for tag in tags or []: 11 | if (kind is None or tag.kind == kind) and (name is None or tag.name == name): 12 | return tag 13 | return None 14 | 15 | 16 | def get_tag_value_key( 17 | tags: Optional[List[Tag]], key: str, kind: Optional[str] = None, name: Optional[str] = None 18 | ) -> Optional[any]: 19 | """Return the value key from the first tag of a list with the provided kind & name.""" 20 | if tag := get_tag(tags, kind=kind, name=name): 21 | return (tag.value or {}).get(key) 22 | return None 23 | -------------------------------------------------------------------------------- /src/steamship/data/user.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from typing import Any, Type 4 | 5 | from pydantic import BaseModel, Field 6 | 7 | from steamship.base.client import Client 8 | from steamship.base.model import CamelModel 9 | 10 | 11 | class User(CamelModel): 12 | client: Client = Field(None, exclude=True) 13 | id: str = None 14 | handle: str = None 15 | 16 | @classmethod 17 | def parse_obj(cls: Type[BaseModel], obj: Any) -> BaseModel: 18 | # TODO (enias): This needs to be solved at the engine side 19 | obj = obj["user"] if "user" in obj else obj 20 | return super().parse_obj(obj) 21 | 22 | @staticmethod 23 | def current(client: Client) -> User: 24 | return client.get("account/current", expect=User) 25 | -------------------------------------------------------------------------------- /src/steamship/invocable/__init__.py: -------------------------------------------------------------------------------- 1 | from .config import Config 2 | from .invocable import Invocable, get, post 3 | from .invocable_request import InvocableRequest, Invocation, InvocationContext, LoggingConfig 4 | from .invocable_response import InvocableResponse 5 | from .lambda_handler import create_handler, safe_handler 6 | from .package_service import PackageService 7 | from .paramater_types import fileurl, longstr 8 | 9 | __all__ = [ 10 | "Invocable", 11 | "create_handler", 12 | "Config", 13 | "Invocation", 14 | "InvocableRequest", 15 | "InvocableResponse", 16 | "get", 17 | "post", 18 | "InvocationContext", 19 | "LoggingConfig", 20 | "PackageService", 21 | "safe_handler", 22 | "longstr", 23 | "fileurl", 24 | ] 25 | -------------------------------------------------------------------------------- /src/steamship/invocable/entrypoint.py: -------------------------------------------------------------------------------- 1 | """ 2 | This class is necessary to be able to please the entrypoints of both localstack and AWS. 3 | 4 | If we set the entrypoint directly to steamship.invocable.safe_handler (imported in the init 5 | from lambda_handler), AWS is happy, but localstack is not because it tries to read steamship.invocable as a py file, 6 | not a module. 7 | 8 | If we set the entrypoint to steamship.invocable.lambda_handler.safe_handler, Localstack is happy, but AWS 9 | is not, because it tries to read lambda_handler first, which imports things from steamship.invocable, which imports 10 | things from lambda_handler. 11 | 12 | By adding this file which basically no-ops safe_handler into steamship.invocable.entrypoint.safe_handler, both are 13 | happy. 14 | 15 | """ 16 | 17 | from steamship.invocable import safe_handler 18 | 19 | _ = safe_handler # No op line so that my "unused" import does not get removed. 20 | -------------------------------------------------------------------------------- /src/steamship/invocable/invocable_localhost.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steamship-core/python-client/62b3f9659fd43ce4fe62103b6488514259d1956f/src/steamship/invocable/invocable_localhost.py -------------------------------------------------------------------------------- /src/steamship/invocable/mixins/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steamship-core/python-client/62b3f9659fd43ce4fe62103b6488514259d1956f/src/steamship/invocable/mixins/__init__.py -------------------------------------------------------------------------------- /src/steamship/invocable/package_mixin.py: -------------------------------------------------------------------------------- 1 | from abc import ABC 2 | 3 | 4 | class PackageMixin(ABC): 5 | def instance_init(self): 6 | """The instance init method will be called ONCE by the engine when a new instance of a package or plugin has been created. By default, this does nothing.""" 7 | pass 8 | -------------------------------------------------------------------------------- /src/steamship/invocable/paramater_types.py: -------------------------------------------------------------------------------- 1 | class longstr(str): # noqa: N801 2 | """Long string functions mostly as a type annotation for the web.""" 3 | 4 | pass 5 | 6 | 7 | class fileurl(str): # noqa: N801 8 | """Type alias that, if used in a package method argument, will cause a file upload widget to appear.""" 9 | 10 | pass 11 | -------------------------------------------------------------------------------- /src/steamship/plugin/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steamship-core/python-client/62b3f9659fd43ce4fe62103b6488514259d1956f/src/steamship/plugin/__init__.py -------------------------------------------------------------------------------- /src/steamship/plugin/blockifier/__init__.py: -------------------------------------------------------------------------------- 1 | from .blockifier import Blockifier 2 | from .transcriber import Transcriber 3 | 4 | __all__ = ["Blockifier", "Transcriber"] 5 | -------------------------------------------------------------------------------- /src/steamship/plugin/blockifier/blockifier.py: -------------------------------------------------------------------------------- 1 | from abc import ABC, abstractmethod 2 | 3 | from steamship.invocable import InvocableResponse, post 4 | from steamship.invocable.plugin_service import PluginRequest, PluginService 5 | from steamship.plugin.inputs.raw_data_plugin_input import RawDataPluginInput 6 | from steamship.plugin.outputs.block_and_tag_plugin_output import BlockAndTagPluginOutput 7 | 8 | # Note! 9 | # ===== 10 | # 11 | # This is the PLUGIN IMPLEMENTOR's View of a Blockifier. 12 | # 13 | # If you are using the Steamship Client, you probably want steamship.client.operations.converter instead 14 | # of this file. 15 | # 16 | 17 | 18 | class Blockifier(PluginService[RawDataPluginInput, BlockAndTagPluginOutput], ABC): 19 | @abstractmethod 20 | def run( 21 | self, request: PluginRequest[RawDataPluginInput] 22 | ) -> InvocableResponse[BlockAndTagPluginOutput]: 23 | raise NotImplementedError() 24 | 25 | @post("blockify") 26 | def run_endpoint(self, **kwargs) -> InvocableResponse[BlockAndTagPluginOutput]: 27 | """Exposes the Corpus Importer's `run` operation to the Steamship Engine via the expected HTTP path POST /import""" 28 | return self.run(PluginRequest[RawDataPluginInput].parse_obj(kwargs)) 29 | -------------------------------------------------------------------------------- /src/steamship/plugin/embedder.py: -------------------------------------------------------------------------------- 1 | from abc import ABC, abstractmethod 2 | 3 | from steamship.invocable import InvocableResponse, post 4 | from steamship.invocable.plugin_service import PluginRequest, PluginService 5 | from steamship.plugin.inputs.block_and_tag_plugin_input import BlockAndTagPluginInput 6 | from steamship.plugin.outputs.embedded_items_plugin_output import EmbeddedItemsPluginOutput 7 | 8 | 9 | # Note! 10 | # ===== 11 | # 12 | # This is the PLUGIN IMPLEMENTOR's View of an Embedder. 13 | # 14 | # If you are using the Steamship Client, you probably want steamship.client.operations.embedder instead 15 | # of this file. 16 | # 17 | class Embedder(PluginService[BlockAndTagPluginInput, EmbeddedItemsPluginOutput], ABC): 18 | @abstractmethod 19 | def run( 20 | self, request: PluginRequest[BlockAndTagPluginInput] 21 | ) -> InvocableResponse[EmbeddedItemsPluginOutput]: 22 | raise NotImplementedError() 23 | 24 | @post("tag") 25 | def run_endpoint(self, **kwargs) -> InvocableResponse[EmbeddedItemsPluginOutput]: 26 | """Exposes the Embedder's `run` operation to the Steamship Engine via the expected HTTP path POST /tag""" 27 | return self.run(PluginRequest[BlockAndTagPluginInput](**kwargs)) 28 | -------------------------------------------------------------------------------- /src/steamship/plugin/file_importer.py: -------------------------------------------------------------------------------- 1 | from abc import ABC, abstractmethod 2 | 3 | from steamship.invocable import InvocableResponse, post 4 | from steamship.invocable.plugin_service import PluginRequest, PluginService 5 | from steamship.plugin.inputs.file_import_plugin_input import FileImportPluginInput 6 | from steamship.plugin.outputs.raw_data_plugin_output import RawDataPluginOutput 7 | 8 | 9 | # Note! 10 | # ===== 11 | # 12 | # This is the PLUGIN IMPLEMENTOR's View of a File Importer. 13 | # 14 | # If you are using the Steamship Client, you probably want steamship.client.operations.file_importer instead 15 | # of this file. 16 | # 17 | class FileImporter(PluginService[FileImportPluginInput, RawDataPluginOutput], ABC): 18 | @abstractmethod 19 | def run( 20 | self, request: PluginRequest[FileImportPluginInput] 21 | ) -> InvocableResponse[RawDataPluginOutput]: 22 | raise NotImplementedError() 23 | 24 | @post("import") 25 | def run_endpoint(self, **kwargs) -> InvocableResponse[RawDataPluginOutput]: 26 | """Exposes the File Importer's `run` operation to the Steamship Engine via the expected HTTP path POST /import""" 27 | return self.run(PluginRequest[FileImportPluginInput](**kwargs)) 28 | -------------------------------------------------------------------------------- /src/steamship/plugin/inputs/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steamship-core/python-client/62b3f9659fd43ce4fe62103b6488514259d1956f/src/steamship/plugin/inputs/__init__.py -------------------------------------------------------------------------------- /src/steamship/plugin/inputs/block_and_tag_plugin_input.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from steamship import File 4 | from steamship.base import SteamshipError 5 | from steamship.base.model import CamelModel 6 | from steamship.utils.signed_urls import url_to_json 7 | 8 | 9 | class BlockAndTagPluginInput(CamelModel): 10 | file: File = None 11 | 12 | def __init__(self, **kwargs): 13 | if url := kwargs.get("url"): 14 | # If `url` was provided, we assume that some or all of the new object's parameterization exists 15 | # at that location, encoded as JSON. We fetch it, parse as JSON, and fold into the kwarg dict. 16 | result = url_to_json(url) 17 | if not isinstance(result, dict): 18 | raise SteamshipError( 19 | message=f"BlockAndTagPluginInput received a URL that resolved to {type(result)}. Needed a `dict`" 20 | ) 21 | kwargs.update(result) 22 | 23 | super().__init__(**kwargs) 24 | -------------------------------------------------------------------------------- /src/steamship/plugin/inputs/export_plugin_input.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from steamship.base.model import CamelModel 4 | 5 | 6 | class ExportPluginInput(CamelModel): 7 | plugin_instance: str = None 8 | id: str = None 9 | handle: str = None 10 | type: str = None 11 | filename: str = None 12 | query: str = None 13 | -------------------------------------------------------------------------------- /src/steamship/plugin/inputs/file_import_plugin_input.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from steamship.base.model import CamelModel 4 | 5 | 6 | class FileImportPluginInput(CamelModel): 7 | value: str = None 8 | data: str = None 9 | url: str = None 10 | plugin_instance: str = None 11 | mime_type: str = None 12 | -------------------------------------------------------------------------------- /src/steamship/plugin/inputs/raw_block_and_tag_plugin_input.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from typing import List, Optional 4 | 5 | from steamship import Block 6 | from steamship.base import SteamshipError 7 | from steamship.base.model import CamelModel 8 | from steamship.utils.signed_urls import url_to_json 9 | 10 | 11 | class RawBlockAndTagPluginInput(CamelModel): 12 | blocks: List[Block] 13 | options: Optional[dict] 14 | 15 | def __init__(self, **kwargs): 16 | if url := kwargs.get("url"): 17 | # If `url` was provided, we assume that some or all of the new object's parameterization exists 18 | # at that location, encoded as JSON. We fetch it, parse as JSON, and fold into the kwarg dict. 19 | result = url_to_json(url) 20 | if not isinstance(result, dict): 21 | raise SteamshipError( 22 | message=f"BlockAndTagPluginInput received a URL that resolved to {type(result)}. Needed a `dict`" 23 | ) 24 | kwargs.update(result) 25 | 26 | super().__init__(**kwargs) 27 | -------------------------------------------------------------------------------- /src/steamship/plugin/inputs/raw_block_and_tag_plugin_input_with_preallocated_blocks.py: -------------------------------------------------------------------------------- 1 | from typing import List 2 | 3 | from steamship import Block 4 | from steamship.plugin.inputs.raw_block_and_tag_plugin_input import RawBlockAndTagPluginInput 5 | 6 | 7 | class RawBlockAndTagPluginInputWithPreallocatedBlocks(RawBlockAndTagPluginInput): 8 | output_blocks: List[Block] 9 | -------------------------------------------------------------------------------- /src/steamship/plugin/inputs/train_plugin_input.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from typing import Optional 4 | 5 | from pydantic import Field 6 | 7 | from steamship.base.model import CamelModel 8 | 9 | 10 | class TrainPluginInput(CamelModel): 11 | """ 12 | This is the object passed as input to a trainable operation, stored as the `input` field of a `train` task. 13 | """ 14 | 15 | plugin_instance: str 16 | 17 | # How may epochs of trainable to perform, if relevant and supported 18 | training_epochs: Optional[int] = None 19 | 20 | # How much data to hold out for testing & reporting, if relevant and supported. 21 | testing_holdout_percent: Optional[float] = None 22 | 23 | # An optional seed for the train-test split 24 | test_split_seed: Optional[int] = None 25 | 26 | # Arbitrary key-valued data to provide to the particular `modelName` trainer. 27 | training_params: Optional[dict] = None 28 | 29 | # Arbitrary key-valued data to provide to the inference runner in the TrainPluginOutput object. 30 | # The trainable process will have the opportunity to amend this before writing it to the output 31 | inference_params: Optional[dict] = None 32 | 33 | # A pre-signed URL at which the trainable data can be found 34 | training_data_url: Optional[str] = Field(None, alias="trainingDataUrl") 35 | -------------------------------------------------------------------------------- /src/steamship/plugin/inputs/training_parameter_plugin_input.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from typing import Dict, Optional 4 | 5 | from steamship.base.model import CamelModel 6 | from steamship.plugin.inputs.export_plugin_input import ExportPluginInput 7 | 8 | 9 | class TrainingParameterPluginInput(CamelModel): 10 | # The plugin instance handle that should perform the training. 11 | plugin_instance: Optional[str] = None 12 | # An export request to produce the training data file, if training data is required. 13 | export_plugin_input: Optional[ExportPluginInput] = None 14 | 15 | # How many epochs to train (if supported by the supplied `pluginInstance`) 16 | training_epochs: Optional[int] = None 17 | 18 | # How much of the data to hold out for testing (if supported by the supplied `pluginInstance`) 19 | testing_holdout_percent: Optional[float] = None 20 | 21 | # Random seed for performing the train/test split (if supported by the supplied `pluginInstance`) 22 | test_split_seed: Optional[int] = None 23 | 24 | # Custom training-time parameters, specific to the pluginInstance 25 | training_params: Optional[Dict] = None 26 | 27 | # Custom inference-time parameters, specific to the pluginInstance 28 | inference_params: Optional[Dict] = None 29 | -------------------------------------------------------------------------------- /src/steamship/plugin/outputs/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steamship-core/python-client/62b3f9659fd43ce4fe62103b6488514259d1956f/src/steamship/plugin/outputs/__init__.py -------------------------------------------------------------------------------- /src/steamship/plugin/outputs/block_and_tag_plugin_output.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from steamship.data.file import File 4 | from steamship.plugin.outputs.plugin_output import PluginOutput 5 | 6 | 7 | class BlockAndTagPluginOutput(PluginOutput): 8 | file: File = None 9 | -------------------------------------------------------------------------------- /src/steamship/plugin/outputs/block_type_plugin_output.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from typing import List 4 | 5 | from steamship.plugin.outputs.plugin_output import PluginOutput 6 | 7 | 8 | class BlockTypePluginOutput(PluginOutput): 9 | block_types_to_create: List[str] 10 | -------------------------------------------------------------------------------- /src/steamship/plugin/outputs/embedded_items_plugin_output.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from typing import List 4 | 5 | from steamship.plugin.outputs.plugin_output import PluginOutput 6 | 7 | 8 | class EmbeddedItemsPluginOutput(PluginOutput): 9 | embeddings: List[List[float]] 10 | -------------------------------------------------------------------------------- /src/steamship/plugin/outputs/raw_block_and_tag_plugin_output.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from typing import List 4 | 5 | from steamship.data.file import Block 6 | from steamship.plugin.outputs.plugin_output import PluginOutput 7 | 8 | 9 | class RawBlockAndTagPluginOutput(PluginOutput): 10 | blocks: List[Block] 11 | -------------------------------------------------------------------------------- /src/steamship/plugin/outputs/stream_complete_plugin_output.py: -------------------------------------------------------------------------------- 1 | from steamship.plugin.outputs.plugin_output import PluginOutput 2 | 3 | 4 | class StreamCompletePluginOutput(PluginOutput): 5 | pass 6 | -------------------------------------------------------------------------------- /src/steamship/plugin/outputs/train_plugin_output.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from steamship.plugin.outputs.plugin_output import PluginOutput 4 | 5 | 6 | class TrainPluginOutput(PluginOutput): 7 | """ 8 | This is the object produced by a completed trainable operation, stored as the `output` field of a `train` task. 9 | """ 10 | 11 | # The PluginInstance ID being trained 12 | plugin_instance_id: str = None 13 | 14 | # This should always represent the most recent snapshot of the model in Steamship 15 | # It is the output of ModelCheckpoint.archive_path_in_steamship 16 | archive_path: str = None 17 | 18 | # Arbitrary key-valued data to provide to the `run` method when this plugin is Run. 19 | inference_params: dict = None 20 | 21 | # Arbitrary key-valued data to provide information about training status or training results. 22 | training_progress: dict = None # For tracking the progress (e.g. 3 / 40 epochs completed) 23 | training_results: dict = None # For tracking accuracy (e.g. f1=0.8) 24 | -------------------------------------------------------------------------------- /src/steamship/utils/__init__.py: -------------------------------------------------------------------------------- 1 | """Collection of utility functions.""" 2 | -------------------------------------------------------------------------------- /src/steamship/utils/file_tags.py: -------------------------------------------------------------------------------- 1 | from steamship import File, Steamship, SteamshipError, Tag 2 | 3 | 4 | def update_file_status(client: Steamship, file: File, status: str) -> None: 5 | file = file.refresh() 6 | status_tags = [tag for tag in file.tags if tag.kind == "status"] 7 | for status_tag in status_tags: 8 | try: 9 | status_tag.client = client 10 | status_tag.delete() 11 | except SteamshipError: 12 | pass 13 | 14 | Tag.create(client, file_id=file.id, kind="status", name=status) 15 | -------------------------------------------------------------------------------- /src/steamship/utils/metadata.py: -------------------------------------------------------------------------------- 1 | import hashlib 2 | import json 3 | from typing import Dict, List, Optional, Union 4 | 5 | Metadata = Union[int, float, bool, str, List, Dict] 6 | 7 | 8 | def str_to_metadata(s: str) -> Optional[Metadata]: 9 | if s is None: 10 | return None 11 | return json.loads(s) 12 | 13 | 14 | def metadata_to_str(m: Metadata) -> Optional[str]: 15 | if m is None: 16 | return None 17 | return json.dumps(m) 18 | 19 | 20 | def hash_dict(d: Dict) -> str: 21 | """Returns the MD5 hash of a dictionary.""" 22 | dhash = hashlib.md5() # noqa: S303, S324 23 | encoded = json.dumps(d, sort_keys=True).encode() 24 | dhash.update(encoded) 25 | return dhash.hexdigest() 26 | -------------------------------------------------------------------------------- /src/steamship/utils/text_chunker.py: -------------------------------------------------------------------------------- 1 | import logging 2 | 3 | 4 | def chunk_text(text: str, chunk_size: int = 200, chunk_overlap: int = 50): 5 | """Chunk text for embedding and insertion into an embedding index.""" 6 | if chunk_size < 1: 7 | logging.warning(f"chunk_size was f{chunk_size}. Setting to 200") 8 | chunk_size = 200 9 | 10 | if chunk_overlap < 0: 11 | logging.warning(f"chunk_overlap was f{chunk_overlap}. Setting to 0") 12 | chunk_overlap = 0 13 | 14 | if chunk_overlap > chunk_size: 15 | logging.warning(f"chunk_size was f{chunk_size}. Setting to chunk_size - 1 of {chunk_size}") 16 | chunk_overlap = chunk_size - 1 if chunk_size > 1 else 1 17 | 18 | step_size = chunk_size - chunk_overlap 19 | 20 | for i in range(0, len(text), step_size): 21 | yield text[i : i + chunk_size] 22 | -------------------------------------------------------------------------------- /src/steamship/utils/url.py: -------------------------------------------------------------------------------- 1 | import logging 2 | from enum import Enum 3 | from os import environ 4 | from typing import Optional 5 | 6 | 7 | class Verb(str, Enum): 8 | GET = "GET" 9 | POST = "POST" 10 | 11 | 12 | def is_local(base: str) -> bool: 13 | """Check if we are running the client locally.""" 14 | return any( 15 | local_base in base 16 | for local_base in ("localhost", "127.0.0.1", "0:0:0:0", "host.docker.internal", "/test:") 17 | ) 18 | 19 | 20 | def apply_localstack_url_fix(url: Optional[str]) -> Optional[str]: 21 | logging.debug(f"URL {url}") 22 | localstack_hostname = environ.get("LOCALSTACK_HOSTNAME") 23 | if url and localstack_hostname is not None and localstack_hostname != "localhost": 24 | for host in ["127.0.0.1", "host.docker.internal", "localstack"]: 25 | url = url.replace(host, localstack_hostname) 26 | logging.info(f"Replacing domain {host} in {url} with {localstack_hostname}") 27 | return url 28 | -------------------------------------------------------------------------------- /src/steamship/utils/utils.py: -------------------------------------------------------------------------------- 1 | import uuid 2 | from typing import Any, Dict, Optional 3 | 4 | from steamship.utils.metadata import hash_dict 5 | 6 | 7 | def safe_get(d: Dict, key: str, default: Any = None) -> Optional[Any]: 8 | """Safely a value from dictionairy using a specific key""" 9 | return d.get(key, default) or default 10 | 11 | 12 | def format_uri(uri: Optional[str]) -> Optional[str]: 13 | if uri is not None and not uri.endswith("/"): 14 | uri += "/" 15 | return uri 16 | 17 | 18 | def create_instance_handle( 19 | invocable_handle: str, version_handle: str, invocable_config: Optional[Dict[str, Any]] 20 | ) -> str: 21 | """Create an instance handle deterministically from package/plugin metadata and configuration.""" 22 | return f"{invocable_handle}-{hash_dict({**invocable_config, 'version': version_handle})}" 23 | 24 | 25 | def is_valid_uuid4(candidate: str) -> bool: 26 | try: 27 | _ = uuid.UUID(candidate, version=4) 28 | return True 29 | except Exception: 30 | return False 31 | -------------------------------------------------------------------------------- /tests/__init__.py: -------------------------------------------------------------------------------- 1 | """Collection of unit steamship_tests and integration steamship_tests for the steamship client.""" 2 | from pathlib import Path 3 | 4 | ROOT_PATH = Path(__file__).parent.parent 5 | VENV_PATH = ROOT_PATH / ".venv" 6 | SRC_PATH = ROOT_PATH / "src" 7 | TEST_PATH = Path(__file__).parent 8 | TEST_ASSETS_PATH = TEST_PATH / "assets" 9 | APPS_PATH = TEST_ASSETS_PATH / "packages" 10 | PLUGINS_PATH = TEST_ASSETS_PATH / "plugins" 11 | -------------------------------------------------------------------------------- /tests/assets/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steamship-core/python-client/62b3f9659fd43ce4fe62103b6488514259d1956f/tests/assets/__init__.py -------------------------------------------------------------------------------- /tests/assets/configs/empty_json.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /tests/assets/configs/one_string_one_int.json: -------------------------------------------------------------------------------- 1 | { 2 | "string_a": "String A", 3 | "int_a": 1 4 | } -------------------------------------------------------------------------------- /tests/assets/configs/single_integer.json: -------------------------------------------------------------------------------- 1 | 3 -------------------------------------------------------------------------------- /tests/assets/packages/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steamship-core/python-client/62b3f9659fd43ce4fe62103b6488514259d1956f/tests/assets/packages/__init__.py -------------------------------------------------------------------------------- /tests/assets/packages/bad_package.py: -------------------------------------------------------------------------------- 1 | from typing import Any, Dict 2 | 3 | from steamship import Steamship 4 | from steamship.invocable import Invocable 5 | 6 | 7 | class BadPackage(Invocable): 8 | """Bad Package should not start when deployed.""" 9 | 10 | def __init__(self, client: Steamship = None, config: Dict[str, Any] = None): 11 | super().__init__(client, config) 12 | raise RuntimeError("this should fail immediately") 13 | -------------------------------------------------------------------------------- /tests/assets/packages/echo_test_header.py: -------------------------------------------------------------------------------- 1 | import json 2 | 3 | from steamship.invocable import PackageService, get 4 | 5 | 6 | class EchoTestHeader(PackageService): 7 | @get("echo_test_header") 8 | def echo_test_header(self) -> str: 9 | return json.dumps(self.context.headers) 10 | -------------------------------------------------------------------------------- /tests/assets/packages/example_project_structure.py: -------------------------------------------------------------------------------- 1 | from steamship.invocable import InvocableResponse, PackageService, get, post 2 | 3 | # This is reflected in the docs as Package Project Structure. If you have to change it 4 | # for SDK changes, make sure to update the docs as well. 5 | 6 | 7 | class MyPackage(PackageService): 8 | @get("say_hello") 9 | def _method_name_need_not_match(self, name: str = None) -> InvocableResponse: 10 | return InvocableResponse(string=f"Hello, {name}") 11 | 12 | @post("do_something") 13 | def do_something(self, number: int = None) -> InvocableResponse: 14 | return InvocableResponse(json={"number": number}) 15 | -------------------------------------------------------------------------------- /tests/assets/packages/fancy_types.py: -------------------------------------------------------------------------------- 1 | from enum import Enum 2 | 3 | from steamship.invocable import InvocableResponse, PackageService, longstr, post 4 | 5 | 6 | class DropdownValue(str, Enum): 7 | VALUE1 = "value1" 8 | VALUE2 = "value2" 9 | 10 | 11 | class FancyTypes(PackageService): 12 | @post("enum_route") 13 | def enum_route(self, dropdown_value: DropdownValue) -> InvocableResponse: 14 | return InvocableResponse(string=f"You picked {dropdown_value}") 15 | 16 | @post("long_string_route") 17 | def long_string_route(self, long_long_string: longstr) -> InvocableResponse: 18 | return InvocableResponse(string=f"You gave me a long string {long_long_string}") 19 | -------------------------------------------------------------------------------- /tests/assets/packages/hello_world.py: -------------------------------------------------------------------------------- 1 | from steamship.invocable import InvocableResponse, PackageService, get, post 2 | from steamship.invocable.lambda_handler import create_safe_handler 3 | 4 | 5 | class HelloWorld(PackageService): 6 | @post("greet") 7 | def greet(self, name: str = "Person") -> InvocableResponse: 8 | return InvocableResponse(string=f"Hello, {name}") 9 | 10 | @get("workspace") 11 | def workspace(self) -> InvocableResponse: 12 | return InvocableResponse(string=self.client.config.workspace_id) 13 | 14 | 15 | handler = create_safe_handler(known_invocable_for_testing=HelloWorld) 16 | -------------------------------------------------------------------------------- /tests/assets/packages/optional_params.py: -------------------------------------------------------------------------------- 1 | from enum import Enum 2 | from typing import Optional 3 | 4 | from steamship.invocable import InvocableResponse, PackageService, post 5 | 6 | 7 | class DropdownValue(str, Enum): 8 | VALUE1 = "value1" 9 | VALUE2 = "value2" 10 | 11 | 12 | class OptionalParams(PackageService): 13 | @post("enum_route") 14 | def enum_route( 15 | self, dropdown_value: Optional[DropdownValue] = DropdownValue.VALUE1 16 | ) -> InvocableResponse: 17 | return InvocableResponse(string=f"You picked {dropdown_value}") 18 | -------------------------------------------------------------------------------- /tests/assets/packages/package_verifying_instance_init.py: -------------------------------------------------------------------------------- 1 | from steamship import File, Tag 2 | from steamship.invocable import Invocable, InvocableResponse, post 3 | 4 | 5 | class PackageWithInstanceInit(Invocable): 6 | def instance_init(self): 7 | """Creates a file in the workspace to indicate that it's been called""" 8 | File.create( 9 | client=self.client, content="", tags=[Tag(kind="test", name=self.context.invocable_url)] 10 | ) 11 | 12 | @post("was_init_called") 13 | def was_init_called(self) -> InvocableResponse: 14 | """Verifies that init was called by finding the created file""" 15 | for file in File.list(self.client).files: 16 | for tag in file.tags: 17 | if tag.kind == "test": 18 | return InvocableResponse(data=tag.name) 19 | return InvocableResponse(data="NOPE") 20 | -------------------------------------------------------------------------------- /tests/assets/packages/package_with_failing_instance_init.py: -------------------------------------------------------------------------------- 1 | from steamship import SteamshipError 2 | from steamship.invocable import Invocable, InvocableResponse, post 3 | 4 | 5 | class PackageWithFailingInstanceInit(Invocable): 6 | def instance_init(self): 7 | raise SteamshipError("oh noes I failed") 8 | 9 | @post("say_ok") 10 | def say_ok(self) -> InvocableResponse: 11 | return InvocableResponse(data="OK") 12 | -------------------------------------------------------------------------------- /tests/assets/packages/package_with_instance_init.py: -------------------------------------------------------------------------------- 1 | import logging 2 | 3 | from steamship.invocable import Invocable, InvocableResponse, post 4 | 5 | 6 | class PackageWithInstanceInit(Invocable): 7 | def instance_init(self): 8 | logging.info(f"Init called with URL: {self.context.invocable_url}") 9 | 10 | @post("was_init_called") 11 | def was_init_called(self) -> InvocableResponse: 12 | return InvocableResponse(data="OK") 13 | -------------------------------------------------------------------------------- /tests/assets/packages/package_with_mixin_importer.py: -------------------------------------------------------------------------------- 1 | from steamship import File 2 | from steamship.invocable import PackageService, post 3 | from steamship.invocable.mixins.blockifier_mixin import BlockifierMixin 4 | from steamship.invocable.mixins.file_importer_mixin import FileImporterMixin 5 | from steamship.invocable.mixins.indexer_mixin import IndexerMixin 6 | 7 | 8 | class PackageWithImporterMixin(PackageService): 9 | def __init__(self, **kwargs): 10 | super().__init__(**kwargs) 11 | self.add_mixin(FileImporterMixin(self.client)) 12 | self.add_mixin(BlockifierMixin(self.client)) 13 | self.add_mixin(IndexerMixin(self.client)) 14 | 15 | @post("get_file") 16 | def get_file(self, id: str) -> File: 17 | file = File.get(self.client, _id=id) 18 | return file 19 | -------------------------------------------------------------------------------- /tests/assets/packages/package_with_mixin_indexer_pipeline.py: -------------------------------------------------------------------------------- 1 | from steamship import File 2 | from steamship.invocable import PackageService, post 3 | from steamship.invocable.mixins.indexer_pipeline_mixin import IndexerPipelineMixin 4 | 5 | 6 | class PackageWithIndexerPipelineMixin(PackageService): 7 | def __init__(self, **kwargs): 8 | super().__init__(**kwargs) 9 | self.add_mixin(IndexerPipelineMixin(self.client, self)) 10 | 11 | @post("get_file") 12 | def get_file(self, id: str) -> File: 13 | file = File.get(self.client, _id=id) 14 | return file 15 | -------------------------------------------------------------------------------- /tests/assets/packages/package_with_mixins.py: -------------------------------------------------------------------------------- 1 | from steamship.invocable import InvocableResponse, PackageService, post 2 | from steamship.invocable.package_mixin import PackageMixin 3 | 4 | 5 | class TestMixin(PackageMixin): 6 | 7 | suffix: str 8 | instance_init_called: bool = False 9 | 10 | def __init__(self, suffix: str): 11 | self.suffix = suffix 12 | 13 | def instance_init(self): 14 | self.instance_init_called = True 15 | 16 | @post("test_mixin_route", public=True) 17 | def test_mixin_route(self, text: str) -> InvocableResponse: 18 | _ = text 19 | return InvocableResponse(data=f"mixin {self.suffix}") 20 | 21 | 22 | class PackageWithMixin(PackageService): 23 | 24 | USED_MIXIN_CLASSES = [TestMixin] 25 | 26 | def __init__(self, **kwargs): 27 | super(PackageWithMixin, self).__init__(**kwargs) 28 | self.add_mixin( 29 | TestMixin("yo") 30 | ) # We add instances of mixins, not the class, in case we need to parameterize their inits 31 | 32 | @post("test_package_route") 33 | def test_package_route(self) -> InvocableResponse: 34 | return InvocableResponse(data="package") 35 | -------------------------------------------------------------------------------- /tests/assets/packages/requirement_isolation_package.py: -------------------------------------------------------------------------------- 1 | from steamship.invocable import PackageService, get 2 | 3 | 4 | class RequirementIsolationPackage(PackageService): 5 | """This package is specially designed to allow testing of requirements installation isolation. It should NOT be 6 | used as a template for any development.""" 7 | 8 | @get("try_pillow") 9 | def try_pillow(self) -> str: 10 | import PIL 11 | 12 | return PIL.__name__ 13 | 14 | @get("try_pandas") 15 | def try_pandas(self) -> str: 16 | import pandas 17 | 18 | return pandas.__name__ 19 | -------------------------------------------------------------------------------- /tests/assets/packages/returns_blocks.py: -------------------------------------------------------------------------------- 1 | from steamship import Block, File 2 | from steamship.invocable import PackageService, post 3 | 4 | 5 | class ReturnsBlocks(PackageService): 6 | @post("/blocks") 7 | def blocks(self) -> [str]: 8 | f = File.create( 9 | self.client, 10 | blocks=[ 11 | Block(text="test block 1"), 12 | Block(text="test block 2"), 13 | Block(text="test block 3"), 14 | ], 15 | ) 16 | return f.blocks 17 | -------------------------------------------------------------------------------- /tests/assets/packages/returns_list.py: -------------------------------------------------------------------------------- 1 | from steamship.invocable import Invocable, post 2 | 3 | 4 | class ReturnsList(Invocable): 5 | @post("gimme_a_list") 6 | def gimme_a_list(self) -> [str]: 7 | return ["here's", "a", "list"] 8 | -------------------------------------------------------------------------------- /tests/assets/packages/safe_loaded_bad_import.pyignore: -------------------------------------------------------------------------------- 1 | # Weird file extension necessary because otherwise pytest will choke when scanning this file. 2 | 3 | from steamship.invocable import Invocable, InvocableResponse, get, post 4 | import somethingthatclearlydoesnotexist # Clearly it is intentional that this does not exist 5 | 6 | class BadImportHelloWorld(Invocable): 7 | @post("greet") 8 | def greet(self, name: str = "Person") -> InvocableResponse: 9 | return InvocableResponse(string=f"Goodbye, {name}") 10 | 11 | @get("workspace") 12 | def workspace(self) -> InvocableResponse: 13 | return InvocableResponse(string=self.client.config.workspace_id) 14 | 15 | 16 | -------------------------------------------------------------------------------- /tests/assets/packages/safe_loaded_hello_world.py: -------------------------------------------------------------------------------- 1 | import logging 2 | 3 | from steamship.invocable import Invocable, InvocableResponse, get, post 4 | 5 | 6 | class HelloWorld(Invocable): 7 | @post("greet") 8 | def greet(self, name: str = "Person") -> InvocableResponse: 9 | logging.info("Invoked greet; internal to helloworld", extra={"foo": "bar"}) 10 | return InvocableResponse(string=f"Hello, {name}") 11 | 12 | @get("workspace") 13 | def workspace(self) -> InvocableResponse: 14 | return InvocableResponse(string=self.client.config.workspace_id) 15 | -------------------------------------------------------------------------------- /tests/assets/packages/transports/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steamship-core/python-client/62b3f9659fd43ce4fe62103b6488514259d1956f/tests/assets/packages/transports/__init__.py -------------------------------------------------------------------------------- /tests/assets/packages/transports/test_web_agent.py: -------------------------------------------------------------------------------- 1 | from typing import Any, Dict 2 | 3 | from steamship import Block, Steamship 4 | from steamship.agents.mixins.transports.steamship_widget import SteamshipWidgetTransport 5 | from steamship.agents.schema import Action, Agent, AgentContext, FinishAction 6 | from steamship.agents.service.agent_service import AgentService 7 | from steamship.invocable import InvocationContext 8 | 9 | 10 | class TestAgent(Agent): 11 | def __init__(self): 12 | super(TestAgent, self).__init__(tools=[]) 13 | 14 | def next_action(self, context: AgentContext) -> Action: 15 | input_text = context.chat_history.last_user_message.text 16 | return FinishAction(output=[Block(text=f"Response to: {input_text}")], context=context) 17 | 18 | 19 | class TestTelegramAgent(AgentService): 20 | 21 | agent: Agent 22 | 23 | def __init__( 24 | self, client: Steamship, config: Dict[str, Any] = None, context: InvocationContext = None 25 | ): 26 | super().__init__(client=client, config=config, context=context) 27 | self.set_default_agent(TestAgent()) 28 | self.add_mixin(SteamshipWidgetTransport(client=client, agent_service=self)) 29 | -------------------------------------------------------------------------------- /tests/assets/palm_tree.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steamship-core/python-client/62b3f9659fd43ce4fe62103b6488514259d1956f/tests/assets/palm_tree.png -------------------------------------------------------------------------------- /tests/assets/plugins/__init__.py: -------------------------------------------------------------------------------- 1 | """Collection of plugins built using the Steamship framework.""" 2 | -------------------------------------------------------------------------------- /tests/assets/plugins/blockifiers/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steamship-core/python-client/62b3f9659fd43ce4fe62103b6488514259d1956f/tests/assets/plugins/blockifiers/__init__.py -------------------------------------------------------------------------------- /tests/assets/plugins/blockifiers/tsv_blockifier.py: -------------------------------------------------------------------------------- 1 | """CSV Blockifier - Steamship Plugin.""" 2 | 3 | from typing import Any, Dict 4 | 5 | from assets.plugins.blockifiers.csv_blockifier import CsvBlockifier 6 | 7 | from steamship.invocable import InvocationContext, create_handler 8 | from steamship.plugin.blockifier.blockifier import Blockifier 9 | 10 | 11 | class TsvBlockifier(CsvBlockifier, Blockifier): 12 | """Converts TSV into Tagged Steamship Blocks. 13 | 14 | Implementation is only here to demonstrate how plugins can be built through inheritance. 15 | """ 16 | 17 | def __init__( 18 | self, client=None, config: Dict[str, Any] = None, context: InvocationContext = None 19 | ): 20 | super().__init__(client, config, context) 21 | self.config.delimiter = "\t" 22 | 23 | 24 | handler = create_handler(TsvBlockifier) 25 | -------------------------------------------------------------------------------- /tests/assets/plugins/generators/plugin_with_instance_init.py: -------------------------------------------------------------------------------- 1 | import json 2 | from typing import List 3 | 4 | from steamship import Block 5 | from steamship.invocable import InvocableResponse 6 | from steamship.plugin.generator import Generator 7 | from steamship.plugin.inputs.raw_block_and_tag_plugin_input import RawBlockAndTagPluginInput 8 | from steamship.plugin.outputs.raw_block_and_tag_plugin_output import RawBlockAndTagPluginOutput 9 | from steamship.plugin.request import PluginRequest 10 | 11 | 12 | class TestGeneratorWithInit(Generator): 13 | def instance_init(self): 14 | pass 15 | 16 | def run( 17 | self, request: PluginRequest[RawBlockAndTagPluginInput] 18 | ) -> InvocableResponse[RawBlockAndTagPluginOutput]: 19 | result: List[Block] = [] 20 | 21 | for block in request.data.blocks: 22 | result.append(Block(text=block.text[::-1])) 23 | 24 | if request.data.options is not None: 25 | result.append(Block(text=json.dumps(request.data.options))) 26 | 27 | return InvocableResponse(data=RawBlockAndTagPluginOutput(blocks=result)) 28 | -------------------------------------------------------------------------------- /tests/assets/plugins/generators/request_id_generator.py: -------------------------------------------------------------------------------- 1 | from steamship import Block 2 | from steamship.invocable import InvocableResponse 3 | from steamship.plugin.generator import Generator 4 | from steamship.plugin.inputs.raw_block_and_tag_plugin_input import RawBlockAndTagPluginInput 5 | from steamship.plugin.outputs.plugin_output import UsageReport 6 | from steamship.plugin.outputs.raw_block_and_tag_plugin_output import RawBlockAndTagPluginOutput 7 | from steamship.plugin.request import PluginRequest 8 | 9 | 10 | class RequestIDGenerator(Generator): 11 | # Just generate a block with the request ID as the text. 12 | def run( 13 | self, request: PluginRequest[RawBlockAndTagPluginInput] 14 | ) -> InvocableResponse[RawBlockAndTagPluginOutput]: 15 | return InvocableResponse( 16 | data=RawBlockAndTagPluginOutput( 17 | blocks=[Block(text=self.client.config.request_id)], 18 | usage=[UsageReport.run_tokens(5)], 19 | ) 20 | ) 21 | -------------------------------------------------------------------------------- /tests/assets/plugins/generators/test_generator.py: -------------------------------------------------------------------------------- 1 | import json 2 | from typing import List 3 | 4 | from steamship import Block 5 | from steamship.invocable import InvocableResponse 6 | from steamship.plugin.generator import Generator 7 | from steamship.plugin.inputs.raw_block_and_tag_plugin_input import RawBlockAndTagPluginInput 8 | from steamship.plugin.outputs.plugin_output import UsageReport 9 | from steamship.plugin.outputs.raw_block_and_tag_plugin_output import RawBlockAndTagPluginOutput 10 | from steamship.plugin.request import PluginRequest 11 | 12 | 13 | class TestGenerator(Generator): 14 | def run( 15 | self, request: PluginRequest[RawBlockAndTagPluginInput] 16 | ) -> InvocableResponse[RawBlockAndTagPluginOutput]: 17 | result: List[Block] = [] 18 | 19 | for block in request.data.blocks: 20 | result.append(Block(text=block.text[::-1])) 21 | 22 | if request.data.options is not None: 23 | result.append(Block(text=json.dumps(request.data.options))) 24 | 25 | return InvocableResponse( 26 | data=RawBlockAndTagPluginOutput(blocks=result, usage=[UsageReport.run_tokens(5)]) 27 | ) 28 | -------------------------------------------------------------------------------- /tests/assets/plugins/generators/test_generator_returns_bytes.py: -------------------------------------------------------------------------------- 1 | from steamship import Block, MimeTypes 2 | from steamship.data.block import BlockUploadType 3 | from steamship.invocable import InvocableResponse 4 | from steamship.plugin.generator import Generator 5 | from steamship.plugin.inputs.raw_block_and_tag_plugin_input import RawBlockAndTagPluginInput 6 | from steamship.plugin.outputs.plugin_output import UsageReport 7 | from steamship.plugin.outputs.raw_block_and_tag_plugin_output import RawBlockAndTagPluginOutput 8 | from steamship.plugin.request import PluginRequest 9 | 10 | TEST_BYTES_STRING = "Test MP3 bytes" 11 | 12 | 13 | class TestGeneratorReturnsBytes(Generator): 14 | def run( 15 | self, request: PluginRequest[RawBlockAndTagPluginInput] 16 | ) -> InvocableResponse[RawBlockAndTagPluginOutput]: 17 | 18 | _bytes = TEST_BYTES_STRING.encode("utf-8") 19 | result = [ 20 | Block(upload_bytes=_bytes, mime_type=MimeTypes.MP3, upload_type=BlockUploadType.FILE) 21 | ] 22 | 23 | return InvocableResponse( 24 | data=RawBlockAndTagPluginOutput(blocks=result, usage=[UsageReport.run_tokens(5)]) 25 | ) 26 | -------------------------------------------------------------------------------- /tests/assets/plugins/generators/test_image_to_text_generator.py: -------------------------------------------------------------------------------- 1 | from steamship import Block, MimeTypes 2 | from steamship.invocable import InvocableResponse 3 | from steamship.plugin.generator import Generator 4 | from steamship.plugin.inputs.raw_block_and_tag_plugin_input import RawBlockAndTagPluginInput 5 | from steamship.plugin.outputs.plugin_output import UsageReport 6 | from steamship.plugin.outputs.raw_block_and_tag_plugin_output import RawBlockAndTagPluginOutput 7 | from steamship.plugin.request import PluginRequest 8 | 9 | 10 | class TestGenerator(Generator): 11 | def run( 12 | self, request: PluginRequest[RawBlockAndTagPluginInput] 13 | ) -> InvocableResponse[RawBlockAndTagPluginOutput]: 14 | image_blocks = 0 15 | fetched_raw = 0 16 | for block in request.data.blocks: 17 | if block.mime_type == MimeTypes.PNG: 18 | image_blocks += 1 19 | _ = block.raw() 20 | fetched_raw += 1 21 | 22 | output_text = f"Found {image_blocks} image blocks and fetched data from {fetched_raw}" 23 | return InvocableResponse( 24 | data=RawBlockAndTagPluginOutput( 25 | blocks=[Block(text=output_text)], usage=[UsageReport.run_units(1)] 26 | ) 27 | ) 28 | -------------------------------------------------------------------------------- /tests/assets/plugins/importers/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steamship-core/python-client/62b3f9659fd43ce4fe62103b6488514259d1956f/tests/assets/plugins/importers/__init__.py -------------------------------------------------------------------------------- /tests/assets/plugins/importers/plugin_file_importer.py: -------------------------------------------------------------------------------- 1 | from steamship import MimeTypes, Tag 2 | from steamship.invocable import InvocableResponse, create_handler 3 | from steamship.invocable.plugin_service import PluginRequest 4 | from steamship.plugin.file_importer import FileImporter 5 | from steamship.plugin.inputs.file_import_plugin_input import FileImportPluginInput 6 | from steamship.plugin.outputs.raw_data_plugin_output import RawDataPluginOutput 7 | 8 | # Note: this aligns with the same document in the internal Engine test. 9 | HANDLE = "test-importer-plugin-v1" 10 | TEST_H1 = "A Poem" 11 | TEST_S1 = "Roses are red." 12 | TEST_S2 = "Violets are blue." 13 | TEST_S3 = "Sugar is sweet, and I love you." 14 | TEST_DOC = f"# {TEST_H1}\n\n{TEST_S1} {TEST_S2}\n\n{TEST_S3}\n" 15 | 16 | 17 | class TestFileImporterPlugin(FileImporter): 18 | def run( 19 | self, request: PluginRequest[FileImportPluginInput] 20 | ) -> InvocableResponse[RawDataPluginOutput]: 21 | return InvocableResponse( 22 | data=RawDataPluginOutput( 23 | string=TEST_DOC, 24 | mime_type=MimeTypes.MKD, 25 | tags=[Tag(kind="test-kind", name="test-name")], 26 | ) 27 | ) 28 | 29 | 30 | handler = create_handler(TestFileImporterPlugin) 31 | -------------------------------------------------------------------------------- /tests/assets/plugins/importers/plugin_file_importer_by_url.py: -------------------------------------------------------------------------------- 1 | from steamship import MimeTypes 2 | from steamship.invocable import InvocableResponse, create_handler 3 | from steamship.invocable.plugin_service import PluginRequest 4 | from steamship.plugin.file_importer import FileImporter 5 | from steamship.plugin.inputs.file_import_plugin_input import FileImportPluginInput 6 | from steamship.plugin.outputs.raw_data_plugin_output import RawDataPluginOutput 7 | 8 | # Note: this aligns with the same document in the internal Engine test. 9 | HANDLE = "test-importer-plugin-v1" 10 | TEST_H1 = "A Poem" 11 | TEST_S1 = "Roses are red." 12 | TEST_S2 = "Violets are blue." 13 | TEST_S3 = "Sugar is sweet, and I love you." 14 | TEST_DOC = f"# {TEST_H1}\n\n{TEST_S1} {TEST_S2}\n\n{TEST_S3}\n" 15 | 16 | 17 | class TestFileImporterPlugin(FileImporter): 18 | def run( 19 | self, request: PluginRequest[FileImportPluginInput] 20 | ) -> InvocableResponse[RawDataPluginOutput]: 21 | bytes = (100000 * TEST_DOC).encode("utf-8") 22 | return InvocableResponse(data=RawDataPluginOutput(_bytes=bytes, mime_type=MimeTypes.MKD)) 23 | 24 | 25 | handler = create_handler(TestFileImporterPlugin) 26 | -------------------------------------------------------------------------------- /tests/assets/plugins/importers/plugin_file_importer_python_error.py: -------------------------------------------------------------------------------- 1 | from steamship.invocable import InvocableResponse, create_handler 2 | from steamship.invocable.plugin_service import PluginRequest 3 | from steamship.plugin.file_importer import FileImporter 4 | from steamship.plugin.inputs.file_import_plugin_input import FileImportPluginInput 5 | from steamship.plugin.outputs.raw_data_plugin_output import RawDataPluginOutput 6 | 7 | 8 | class TestFileImporterPythonErrorPlugin(FileImporter): 9 | def run( 10 | self, request: PluginRequest[FileImportPluginInput] 11 | ) -> InvocableResponse[RawDataPluginOutput]: 12 | raise Exception("TestFileImporterPythonErrorPlugin") 13 | 14 | 15 | handler = create_handler(TestFileImporterPythonErrorPlugin) 16 | -------------------------------------------------------------------------------- /tests/assets/plugins/importers/plugin_file_importer_steamship_error.py: -------------------------------------------------------------------------------- 1 | from steamship import SteamshipError 2 | from steamship.invocable import InvocableResponse, create_handler 3 | from steamship.invocable.plugin_service import PluginRequest 4 | from steamship.plugin.file_importer import FileImporter 5 | from steamship.plugin.inputs.file_import_plugin_input import FileImportPluginInput 6 | from steamship.plugin.outputs.raw_data_plugin_output import RawDataPluginOutput 7 | 8 | 9 | class TestFileImporterSteamshipErrorPlugin(FileImporter): 10 | def run( 11 | self, request: PluginRequest[FileImportPluginInput] 12 | ) -> InvocableResponse[RawDataPluginOutput]: 13 | raise SteamshipError(message="TestFileImporterSteamshipErrorPlugin") 14 | 15 | 16 | handler = create_handler(TestFileImporterSteamshipErrorPlugin) 17 | -------------------------------------------------------------------------------- /tests/assets/plugins/taggers/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steamship-core/python-client/62b3f9659fd43ce4fe62103b6488514259d1956f/tests/assets/plugins/taggers/__init__.py -------------------------------------------------------------------------------- /tests/assets/plugins/taggers/plugin_logging_tagger.py: -------------------------------------------------------------------------------- 1 | import logging 2 | 3 | from steamship.invocable import InvocableResponse, create_handler 4 | from steamship.invocable.plugin_service import PluginRequest 5 | from steamship.plugin.inputs.block_and_tag_plugin_input import BlockAndTagPluginInput 6 | from steamship.plugin.outputs.block_and_tag_plugin_output import BlockAndTagPluginOutput 7 | from steamship.plugin.tagger import Tagger 8 | 9 | 10 | class TestLoggingTaggerPlugin(Tagger): 11 | def run( 12 | self, request: PluginRequest[BlockAndTagPluginInput] 13 | ) -> InvocableResponse[BlockAndTagPluginOutput]: 14 | logging.info("A remote logging log") 15 | file = request.data.file 16 | if request.data is not None: 17 | ret = InvocableResponse(data=BlockAndTagPluginOutput(file=file)) 18 | logging.info(f"Ret: {ret}") 19 | return ret 20 | 21 | 22 | handler = create_handler(TestLoggingTaggerPlugin) 23 | -------------------------------------------------------------------------------- /tests/assets/plugins/taggers/plugin_tagger_bad_import.pyignore: -------------------------------------------------------------------------------- 1 | # Weird file extension necessary because otherwise pytest will choke when scanning this file. 2 | 3 | from steamship.invocable import InvocableResponse 4 | from steamship.invocable.plugin_service import PluginRequest 5 | from steamship.plugin.inputs.block_and_tag_plugin_input import BlockAndTagPluginInput 6 | from steamship.plugin.outputs.block_and_tag_plugin_output import BlockAndTagPluginOutput 7 | from steamship.plugin.tagger import Tagger 8 | 9 | import somethingthatclearlydoesnotexist # Clearly it is intentional that this does not exist 10 | 11 | class TestTaggerPluginBadImport(Tagger): 12 | def run( 13 | self, request: PluginRequest[BlockAndTagPluginInput] 14 | ) -> InvocableResponse[BlockAndTagPluginOutput]: 15 | file = request.data.file 16 | return InvocableResponse(data=BlockAndTagPluginOutput(file=file)) 17 | -------------------------------------------------------------------------------- /tests/assets/test.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steamship-core/python-client/62b3f9659fd43ce4fe62103b6488514259d1956f/tests/assets/test.pdf -------------------------------------------------------------------------------- /tests/assets/utterances.csv: -------------------------------------------------------------------------------- 1 | Message,Category 2 | I want a coupon,Coupon 3 | How do I make a product return?,Return 4 | Hi,Greeting 5 | Hello,Greeting 6 | Hey do you have any discounts?,Coupon -------------------------------------------------------------------------------- /tests/assets/utterances.tsv: -------------------------------------------------------------------------------- 1 | Message Category 2 | I want a coupon Coupon 3 | How do I make a product return? Return 4 | Hi Greeting 5 | Hello Greeting 6 | Hey do you have any discounts? Coupon -------------------------------------------------------------------------------- /tests/conftest.py: -------------------------------------------------------------------------------- 1 | """ 2 | Pytest reads this file in before doing any work. Read more about conftest.py under: 3 | - https://docs.pytest.org/en/stable/fixture.html 4 | - https://docs.pytest.org/en/stable/writing_plugins.html 5 | """ 6 | 7 | import sys 8 | from pathlib import Path 9 | 10 | # Make sure `steamship_tests` is on the PYTHONPATH. Otherwise cross-test imports (e.g. to util libraries) will fail. 11 | sys.path.append(str(Path(__file__).parent.absolute())) 12 | 13 | from steamship_tests.utils.fixtures import client, invocable_handler # noqa: F401, E402 14 | -------------------------------------------------------------------------------- /tests/steamship_tests/__init__.py: -------------------------------------------------------------------------------- 1 | """Collection of unit steamship_tests and integration steamship_tests for the steamship client.""" 2 | from pathlib import Path 3 | 4 | ROOT_PATH = Path(__file__).parent.parent.parent 5 | VENV_PATH = ROOT_PATH / ".venv" 6 | SRC_PATH = ROOT_PATH / "src" 7 | TEST_PATH = Path(__file__).parent.parent 8 | TEST_ASSETS_PATH = TEST_PATH / "assets" 9 | PACKAGES_PATH = TEST_ASSETS_PATH / "packages" 10 | PLUGINS_PATH = TEST_ASSETS_PATH / "plugins" 11 | -------------------------------------------------------------------------------- /tests/steamship_tests/agents/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steamship-core/python-client/62b3f9659fd43ce4fe62103b6488514259d1956f/tests/steamship_tests/agents/__init__.py -------------------------------------------------------------------------------- /tests/steamship_tests/agents/test_function_agent_output_parser.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from steamship import Block, File, Steamship 4 | from steamship.agents.functional import FunctionsBasedOutputParser 5 | from steamship.agents.schema import AgentContext, FinishAction 6 | 7 | 8 | @pytest.mark.usefixtures("client") 9 | def test_output_block_ids_are_converted(client: Steamship): 10 | context = AgentContext() 11 | context.client = client 12 | block_id = File.create(client, blocks=[Block(text="test")]).blocks[0].id 13 | test_text = f"Here is an image of an anteater: Block({block_id})." 14 | 15 | output_formatter = FunctionsBasedOutputParser() 16 | result = output_formatter.parse(test_text, context) 17 | 18 | assert isinstance(result, FinishAction) 19 | assert len(result.output) == 2 20 | assert result.output[1].id == block_id 21 | -------------------------------------------------------------------------------- /tests/steamship_tests/agents/test_qa_agent.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from steamship import Steamship 4 | from steamship.agents.examples.document_qa_agent import ExampleDocumentQAService 5 | 6 | 7 | @pytest.mark.usefixtures("client") 8 | def test_qa_agent_inits(client: Steamship): 9 | agent = ExampleDocumentQAService(client=client) 10 | assert agent is not None 11 | -------------------------------------------------------------------------------- /tests/steamship_tests/agents/tools/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steamship-core/python-client/62b3f9659fd43ce4fe62103b6488514259d1956f/tests/steamship_tests/agents/tools/__init__.py -------------------------------------------------------------------------------- /tests/steamship_tests/agents/tools/test_fact_learner_tools.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | from steamship_tests import SRC_PATH 3 | from steamship_tests.utils.deployables import deploy_package 4 | 5 | from steamship import Block, Steamship 6 | 7 | 8 | @pytest.mark.usefixtures("client") 9 | def test_fact_learner_agent_service(client: Steamship): 10 | 11 | agent_path = SRC_PATH / "steamship/agents/examples/fact_learner.py" 12 | with deploy_package(client, agent_path, wait_for_init=True) as (_, _, agent): 13 | 14 | agent.invoke("prompt", prompt="please remember that my name is Inigo Montoya") 15 | agent.invoke("prompt", prompt="please remember that I am skilled swordsman") 16 | 17 | answer_blocks = agent.invoke("prompt", prompt="Is my name Inigo?") 18 | assert len(answer_blocks) == 1 19 | assert "yes" in Block(**answer_blocks[0]).text.lower() 20 | 21 | answer_blocks = agent.invoke("prompt", prompt="what do I know how to do well?") 22 | assert len(answer_blocks) == 1 23 | assert "sword" in Block(**answer_blocks[0]).text.lower() 24 | -------------------------------------------------------------------------------- /tests/steamship_tests/agents/tools/test_multiple_choice_tool.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from steamship import Block, Steamship 4 | from steamship.agents.llms import OpenAI 5 | from steamship.agents.schema import AgentContext 6 | from steamship.agents.tools.classification.multiple_choice_tool import MultipleChoiceTool 7 | from steamship.agents.utils import with_llm 8 | 9 | TESTS = [ 10 | ("Pencil", "Other"), 11 | ("America", "Countries,USA"), 12 | ("Ham sandwich", "Food,Lunch"), 13 | ] 14 | 15 | 16 | @pytest.mark.parametrize(("x", "gold"), TESTS) 17 | @pytest.mark.usefixtures("client") 18 | def test_multiple_choice_tool(client: Steamship, x, gold): 19 | """Tests that we can inspect the package and mixin routes""" 20 | tool = MultipleChoiceTool() 21 | context = with_llm( 22 | OpenAI(client=client), 23 | AgentContext.get_or_create(client=client, context_keys={"id": "test"}), 24 | ) 25 | 26 | res = tool.run([Block(text=x)], context) 27 | assert len(res) == 1 28 | assert res[0].text == gold 29 | -------------------------------------------------------------------------------- /tests/steamship_tests/agents/transports/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steamship-core/python-client/62b3f9659fd43ce4fe62103b6488514259d1956f/tests/steamship_tests/agents/transports/__init__.py -------------------------------------------------------------------------------- /tests/steamship_tests/agents/transports/test_web.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | from steamship_tests import PACKAGES_PATH 3 | from steamship_tests.utils.deployables import deploy_package 4 | 5 | from steamship import Steamship 6 | 7 | 8 | @pytest.mark.usefixtures("client") 9 | def test_web(client: Steamship): 10 | 11 | web_agent_path = PACKAGES_PATH / "transports" / "test_web_agent.py" 12 | 13 | with deploy_package(client, web_agent_path, wait_for_init=True) as (_, _, web_instance): 14 | 15 | response = web_instance.invoke("answer", question="test") 16 | assert response[0].get("text") == "Response to: test" 17 | 18 | # Test multiple times since we previously had issues on subsequent calls 19 | response = web_instance.invoke("answer", question="test2") 20 | assert response[0].get("text") == "Response to: test2" 21 | 22 | response = web_instance.invoke("answer", question="test3") 23 | assert response[0].get("text") == "Response to: test3" 24 | -------------------------------------------------------------------------------- /tests/steamship_tests/app/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steamship-core/python-client/62b3f9659fd43ce4fe62103b6488514259d1956f/tests/steamship_tests/app/__init__.py -------------------------------------------------------------------------------- /tests/steamship_tests/app/integration/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steamship-core/python-client/62b3f9659fd43ce4fe62103b6488514259d1956f/tests/steamship_tests/app/integration/__init__.py -------------------------------------------------------------------------------- /tests/steamship_tests/app/integration/test_e2e_mixins.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | from steamship_tests import PACKAGES_PATH 3 | from steamship_tests.utils.deployables import deploy_package 4 | 5 | from steamship import Steamship 6 | 7 | 8 | @pytest.mark.usefixtures("client") 9 | def test_mixin_and_package_invocation(client: Steamship): 10 | demo_package_path = PACKAGES_PATH / "package_with_mixins.py" 11 | 12 | with deploy_package(client, demo_package_path, wait_for_init=True) as (_, _, instance): 13 | mixin_response = instance.invoke("test_mixin_route", text="test") 14 | assert mixin_response == "mixin yo" 15 | 16 | package_response = instance.invoke("test_package_route") 17 | assert package_response == "package" 18 | -------------------------------------------------------------------------------- /tests/steamship_tests/app/integration/test_example_project_structure.py: -------------------------------------------------------------------------------- 1 | from steamship_tests import PACKAGES_PATH 2 | from steamship_tests.utils.deployables import deploy_package 3 | from steamship_tests.utils.fixtures import get_steamship_client 4 | 5 | from steamship.utils.url import Verb 6 | 7 | 8 | def test_example_project_structure(): 9 | 10 | client = get_steamship_client() 11 | demo_package_path = PACKAGES_PATH / "example_project_structure.py" 12 | 13 | with deploy_package(client, demo_package_path, wait_for_init=True) as (_, _, instance): 14 | response = instance.invoke("say_hello", verb=Verb.GET) 15 | assert response is not None 16 | assert response == "Hello, None" 17 | 18 | response = instance.invoke("say_hello", verb=Verb.GET, name="Testy") 19 | assert response is not None 20 | assert response == "Hello, Testy" 21 | 22 | response = instance.invoke("do_something") 23 | assert response is not None 24 | assert response == {"number": None} 25 | 26 | response = instance.invoke("do_something", number=3) 27 | assert response is not None 28 | assert response == {"number": 3} 29 | -------------------------------------------------------------------------------- /tests/steamship_tests/app/integration/test_get_params.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | from steamship_tests import PACKAGES_PATH 3 | from steamship_tests.utils.deployables import deploy_package 4 | 5 | from steamship import Steamship 6 | from steamship.utils.url import Verb 7 | 8 | 9 | @pytest.mark.usefixtures("client") 10 | def test_get_param_decoding(client: Steamship): 11 | demo_package_path = PACKAGES_PATH / "demo_package.py" 12 | 13 | with deploy_package(client, demo_package_path) as (package, version, instance): 14 | result = instance.invoke("greet", verb=Verb.GET, name="A test with spaces") 15 | assert result == "Hello, A test with spaces!" 16 | -------------------------------------------------------------------------------- /tests/steamship_tests/app/integration/test_header_passing.py: -------------------------------------------------------------------------------- 1 | import json 2 | 3 | import pytest 4 | import requests 5 | from steamship_tests import PACKAGES_PATH 6 | from steamship_tests.utils.deployables import deploy_package 7 | 8 | from steamship import Steamship 9 | 10 | 11 | @pytest.mark.usefixtures("client") 12 | def test_instance_init_is_called_on_package(client: Steamship): 13 | demo_package_path = PACKAGES_PATH / "echo_test_header.py" 14 | 15 | with deploy_package(client, demo_package_path) as (_, _, instance): 16 | url = instance.invocation_url + "/echo_test_header" 17 | response = requests.get( 18 | url, 19 | headers={ 20 | "authorization": f"bearer {client.config.api_key.get_secret_value()}", 21 | "test1": "testValue1", 22 | "test2": "testValue2", 23 | }, 24 | ) 25 | result = json.loads(response.text) 26 | assert result is not None 27 | assert result["test1"] == "testValue1" 28 | assert result["test2"] == "testValue2" 29 | -------------------------------------------------------------------------------- /tests/steamship_tests/app/integration/test_package_error_visibility.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | from assets.packages.demo_package import TestPackage 3 | 4 | ERROR_NO_METHOD = "No handler for POST method_doesnt_exist available." 5 | ERROR_STEAMSHIP_ERROR = "[ERROR - POST raise_steamship_error] raise_steamship_error" 6 | ERROR_PYTHON_ERROR = "[ERROR - POST raise_python_error] raise_python_error" 7 | 8 | 9 | @pytest.mark.parametrize("invocable_handler", [TestPackage], indirect=True) 10 | def test_instance_invoke_unit(invocable_handler): 11 | """Test that the handler returns the proper errors""" 12 | 13 | response = invocable_handler("POST", "method_doesnt_exist") 14 | assert response.get("status", {}).get("statusMessage", "") == ERROR_NO_METHOD 15 | 16 | response = invocable_handler("POST", "raise_steamship_error") 17 | assert response.get("status", {}).get("statusMessage", "") == ERROR_STEAMSHIP_ERROR 18 | 19 | response = invocable_handler("POST", "raise_python_error") 20 | assert response.get("status", {}).get("statusMessage", "") == ERROR_PYTHON_ERROR 21 | -------------------------------------------------------------------------------- /tests/steamship_tests/app/integration/test_request_id.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | from steamship_tests import PACKAGES_PATH, PLUGINS_PATH 3 | from steamship_tests.utils.deployables import deploy_package, deploy_plugin 4 | 5 | from steamship import Steamship 6 | 7 | 8 | @pytest.mark.usefixtures("client") 9 | def test_get_param_decoding(client: Steamship): 10 | request_id_package_path = PACKAGES_PATH / "request_id_plumbing_test_package.py" 11 | request_id_plugin_path = PLUGINS_PATH / "generators" / "request_id_generator.py" 12 | 13 | with deploy_package(client, request_id_package_path) as (package, version, instance): 14 | with deploy_plugin(client, request_id_plugin_path, plugin_type="generator") as ( 15 | plugin, 16 | _, 17 | _, 18 | ): 19 | result = instance.invoke("requestids", plugin_handle=plugin.handle) 20 | package_request_id = result.get("packageRequestId") 21 | plugin_request_id = result.get("pluginRequestId") 22 | invoke_later_request_id = result.get("invokeLaterRequestId") 23 | assert package_request_id is not None 24 | assert package_request_id == plugin_request_id 25 | assert package_request_id == invoke_later_request_id 26 | -------------------------------------------------------------------------------- /tests/steamship_tests/app/integration/test_returns_list.py: -------------------------------------------------------------------------------- 1 | from steamship_tests import PACKAGES_PATH 2 | from steamship_tests.utils.deployables import deploy_package 3 | from steamship_tests.utils.fixtures import get_steamship_client 4 | 5 | 6 | def test_returns_list(): 7 | 8 | client = get_steamship_client() 9 | demo_package_path = PACKAGES_PATH / "returns_list.py" 10 | 11 | with deploy_package(client, demo_package_path) as (_, _, instance): 12 | response = instance.invoke("gimme_a_list") 13 | assert response is not None 14 | assert len(response) == 3 15 | assert response == ["here's", "a", "list"] 16 | -------------------------------------------------------------------------------- /tests/steamship_tests/app/integration/test_safe_hello_world.py: -------------------------------------------------------------------------------- 1 | from steamship_tests import PACKAGES_PATH 2 | from steamship_tests.utils.deployables import deploy_package 3 | from steamship_tests.utils.fixtures import get_steamship_client 4 | 5 | 6 | def test_safe_loaded_hello_world(): 7 | 8 | client = get_steamship_client() 9 | demo_package_path = PACKAGES_PATH / "safe_loaded_hello_world.py" 10 | 11 | with deploy_package(client, demo_package_path) as (_, _, instance): 12 | response = instance.invoke("greet") 13 | assert response is not None 14 | assert response == "Hello, Person" 15 | -------------------------------------------------------------------------------- /tests/steamship_tests/app/integration/test_safe_loaded_package_with_bad_import.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | from steamship_tests import PACKAGES_PATH 3 | from steamship_tests.utils.deployables import deploy_package 4 | from steamship_tests.utils.fixtures import get_steamship_client 5 | 6 | from steamship import SteamshipError 7 | 8 | 9 | def test_safe_loaded_package_with_bad_import(): 10 | client = get_steamship_client() 11 | demo_package_path = PACKAGES_PATH / "safe_loaded_bad_import.pyignore" 12 | 13 | with pytest.raises(SteamshipError) as error: 14 | with deploy_package(client, demo_package_path) as (_, _, instance): 15 | pass # Shouldn't get here! 16 | assert error is not None 17 | assert "No module named 'somethingthatclearlydoesnotexist'" in error.value.message 18 | -------------------------------------------------------------------------------- /tests/steamship_tests/app/unit/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steamship-core/python-client/62b3f9659fd43ce4fe62103b6488514259d1956f/tests/steamship_tests/app/unit/__init__.py -------------------------------------------------------------------------------- /tests/steamship_tests/app/unit/test_document_qa_example.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from steamship import Steamship 4 | from steamship.agents.examples.document_qa_agent import ExampleDocumentQAService 5 | from steamship.utils.url import Verb 6 | 7 | 8 | @pytest.mark.usefixtures("client") 9 | def test_indexer_pipeline_mixin(client: Steamship): 10 | package_class = ExampleDocumentQAService 11 | 12 | post_routes = package_class._package_spec.method_mappings[Verb.POST] 13 | assert "/index_text" in post_routes # from indexer mixin 14 | assert "/index_url" in post_routes # From indexer pipeline mixin 15 | assert "/blockify_file" in post_routes # From blockifier mixin 16 | assert "/import_url" in post_routes # from file importer mixin 17 | -------------------------------------------------------------------------------- /tests/steamship_tests/app/unit/test_indexer_mixin.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from steamship import Steamship 4 | from steamship.invocable.mixins.indexer_mixin import IndexerMixin 5 | 6 | 7 | @pytest.mark.usefixtures("client") 8 | def test_indexer_mixin_and_qa_tool(client: Steamship): 9 | """Tests that we can inspect the package and mixin routes""" 10 | indexer = IndexerMixin(client) 11 | assert indexer.index_text("Mario was a very fun game.") 12 | res = indexer.search_index("Mario") 13 | assert res.items 14 | assert len(res.items) == 1 15 | item = res.items[0] 16 | assert item.tag.text == "Mario was a very fun game." 17 | assert item.tag.value == {} 18 | 19 | assert indexer.index_text("Sonic was also pretty good.", metadata={"sega": True}) 20 | res = indexer.search_index("Sonic") 21 | assert res.items 22 | assert len(res.items) == 2 23 | item = res.items[0] 24 | assert item.tag.text == "Sonic was also pretty good." 25 | assert item.tag.value 26 | assert item.tag.value.get("sega", True) 27 | -------------------------------------------------------------------------------- /tests/steamship_tests/app/unit/test_indexer_pipeline_mixin.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from steamship import File, Steamship 4 | from steamship.invocable import PackageService 5 | from steamship.invocable.mixins.indexer_pipeline_mixin import IndexerPipelineMixin 6 | 7 | 8 | @pytest.mark.usefixtures("client") 9 | def test_set_file_status(client: Steamship): 10 | """Tests that we can inspect the package and mixin routes""" 11 | file = File.create(client, content="hi") 12 | invocable = PackageService() 13 | pipeline = IndexerPipelineMixin(client, invocable) 14 | pipeline.set_file_status(file_id=file.id, status="FOO") 15 | file = file.refresh() 16 | 17 | assert len(file.tags) == 1 18 | tag = file.tags[0] 19 | assert tag.kind == "status" 20 | assert tag.name == "FOO" 21 | -------------------------------------------------------------------------------- /tests/steamship_tests/app/unit/test_response.py: -------------------------------------------------------------------------------- 1 | from typing import Any 2 | 3 | from steamship.base.mime_types import MimeTypes 4 | from steamship.data.file import File 5 | from steamship.invocable import InvocableResponse 6 | from steamship.plugin.outputs.block_and_tag_plugin_output import BlockAndTagPluginOutput 7 | 8 | 9 | def check_mime(d: dict, mime: str): 10 | assert d.get("http", {}).get("headers", {}).get("Content-Type") == mime 11 | 12 | 13 | def check_type(d: dict, t: Any): 14 | data = d.get("data") 15 | assert isinstance(data, t) 16 | 17 | 18 | def check_val(d: dict, val: Any): 19 | data = d.get("data") 20 | assert data == val 21 | 22 | 23 | def test_text_response(): 24 | r = InvocableResponse.from_obj("Hi there") 25 | d = r.dict() 26 | check_mime(d, MimeTypes.TXT) 27 | check_type(d, str) 28 | check_val(d, "Hi there") 29 | 30 | 31 | def test_dict_response(): 32 | r = InvocableResponse.from_obj({"a": 1}) 33 | d = r.dict() 34 | check_mime(d, MimeTypes.JSON) 35 | check_type(d, dict) 36 | check_val(d, {"a": 1}) 37 | 38 | 39 | def test_resp_response(): 40 | o = BlockAndTagPluginOutput(file=File(value="Foo", blocks=[], tags=[])) 41 | r = InvocableResponse(json=o) 42 | d = r.dict() 43 | check_mime(d, MimeTypes.JSON) 44 | check_type(d, dict) 45 | check_val(d, o.dict(by_alias=True)) 46 | -------------------------------------------------------------------------------- /tests/steamship_tests/app/unit/test_training_input.py: -------------------------------------------------------------------------------- 1 | from steamship.plugin.inputs.train_plugin_input import TrainPluginInput 2 | 3 | 4 | def test_training_input(): 5 | input = TrainPluginInput.parse_obj({"pluginInstance": "test", "trainingDataUrl": "test"}) 6 | assert input.training_data_url == "test" 7 | -------------------------------------------------------------------------------- /tests/steamship_tests/base/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steamship-core/python-client/62b3f9659fd43ce4fe62103b6488514259d1956f/tests/steamship_tests/base/__init__.py -------------------------------------------------------------------------------- /tests/steamship_tests/base/test_steamship_error_serializable.py: -------------------------------------------------------------------------------- 1 | import msgpack 2 | 3 | from steamship import SteamshipError 4 | from steamship.invocable.lambda_handler import encode_exception 5 | 6 | 7 | def test_serialize_steamship_error(): 8 | error = SteamshipError("Oh noes! An error happened!") 9 | serialized = msgpack.packb(error, default=encode_exception) 10 | assert ( 11 | serialized 12 | == b'\xd9t{"message": "Oh noes! An error happened!", "internalMessage": null, "suggestion": null, "code": null, "error": null}' 13 | ) 14 | 15 | 16 | def test_serialize_steamship_error_with_nested_error(): 17 | nested_error = AttributeError("A nested error!") 18 | error = SteamshipError("Oh noes! An error happened!", error=nested_error) 19 | serialized = msgpack.packb(error, default=encode_exception) 20 | assert ( 21 | serialized 22 | == b'\xd9\x81{"message": "Oh noes! An error happened!", "internalMessage": null, "suggestion": null, "code": null, "error": "A nested error!"}' 23 | ) 24 | 25 | 26 | def test_serialize_non_steamship_error(): 27 | error = AttributeError("An attribute error!") 28 | serialized = msgpack.packb(error, default=encode_exception) 29 | assert serialized == b"\xd9?exception_class: AttributeError, args: ('An attribute error!',)" 30 | -------------------------------------------------------------------------------- /tests/steamship_tests/client/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steamship-core/python-client/62b3f9659fd43ce4fe62103b6488514259d1956f/tests/steamship_tests/client/__init__.py -------------------------------------------------------------------------------- /tests/steamship_tests/client/operations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steamship-core/python-client/62b3f9659fd43ce4fe62103b6488514259d1956f/tests/steamship_tests/client/operations/__init__.py -------------------------------------------------------------------------------- /tests/steamship_tests/client/operations/test_convert_ocr.py: -------------------------------------------------------------------------------- 1 | # from os import path 2 | # 3 | # from steamship import MimeTypes 4 | # 5 | # from .helpers import _random_name, _steamship 6 | # 7 | # 8 | # def test_image_upload(): 9 | # steamship = get_steamship_client() 10 | # test_filename = path.join( 11 | # path.dirname(path.realpath(__file__)), 12 | # 'test_img.png' 13 | # ) 14 | # with open(test_filename, "rb") as f: 15 | # name_c = "{}.png".format(_random_name()) 16 | # c = steamship.upload( 17 | # name=name_c, 18 | # content=f 19 | # ).data 20 | # assert (c.id is not None) 21 | # assert (c.name == name_c) 22 | # assert (c.mimeType == MimeTypes.PNG) 23 | # 24 | # blockifyResp = c.blockify(plugin="ocr_ms_vision_default") 25 | # assert (blockifyResp.error is None) 26 | # blockifyResp.wait() 27 | # assert (blockifyResp.data is not None) 28 | # 29 | # q1 = c.query().data 30 | # assert (len(q1.blocks) == 3) 31 | # 32 | # c.delete() 33 | -------------------------------------------------------------------------------- /tests/steamship_tests/data/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steamship-core/python-client/62b3f9659fd43ce4fe62103b6488514259d1956f/tests/steamship_tests/data/__init__.py -------------------------------------------------------------------------------- /tests/steamship_tests/data/tags/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steamship-core/python-client/62b3f9659fd43ce4fe62103b6488514259d1956f/tests/steamship_tests/data/tags/__init__.py -------------------------------------------------------------------------------- /tests/steamship_tests/data/test_app_version.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steamship-core/python-client/62b3f9659fd43ce4fe62103b6488514259d1956f/tests/steamship_tests/data/test_app_version.py -------------------------------------------------------------------------------- /tests/steamship_tests/data/test_img.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steamship-core/python-client/62b3f9659fd43ce4fe62103b6488514259d1956f/tests/steamship_tests/data/test_img.png -------------------------------------------------------------------------------- /tests/steamship_tests/data/test_package.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from steamship import Package, Steamship, SteamshipError 4 | 5 | 6 | @pytest.mark.usefixtures("client") 7 | def test_package_create(client: Steamship): 8 | _ = Package.create(client) 9 | 10 | 11 | @pytest.mark.usefixtures("client") 12 | def test_plugin_delete(client: Steamship): 13 | 14 | package = Package.create( 15 | client=client, 16 | is_public=False, 17 | ) 18 | 19 | assert package is not None 20 | 21 | package.delete() 22 | 23 | # Validate plugin is gone 24 | with pytest.raises(SteamshipError): 25 | _ = Package.get(client, handle=package.handle) 26 | -------------------------------------------------------------------------------- /tests/steamship_tests/data/test_package_version.py: -------------------------------------------------------------------------------- 1 | from steamship_tests import PACKAGES_PATH 2 | from steamship_tests.utils.deployables import zip_deployable 3 | from steamship_tests.utils.fixtures import get_steamship_client 4 | 5 | from steamship import Package, PackageVersion 6 | 7 | 8 | def test_version_create(): 9 | client = get_steamship_client() 10 | demo_package_path = PACKAGES_PATH / "demo_package.py" 11 | 12 | package = Package.create(client) 13 | zip_bytes = zip_deployable(demo_package_path) 14 | 15 | version = PackageVersion.create(client, package_id=package.id, filebytes=zip_bytes) 16 | 17 | assert version is not None 18 | -------------------------------------------------------------------------------- /tests/steamship_tests/data/utterances.csv: -------------------------------------------------------------------------------- 1 | Message,Category 2 | I want a coupon,Coupon 3 | How do I make a product return?,Return 4 | Hi,Greeting 5 | Hello,Greeting 6 | Hey do you have any discounts?,Coupon -------------------------------------------------------------------------------- /tests/steamship_tests/experimental/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steamship-core/python-client/62b3f9659fd43ce4fe62103b6488514259d1956f/tests/steamship_tests/experimental/__init__.py -------------------------------------------------------------------------------- /tests/steamship_tests/integrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steamship-core/python-client/62b3f9659fd43ce4fe62103b6488514259d1956f/tests/steamship_tests/integrations/__init__.py -------------------------------------------------------------------------------- /tests/steamship_tests/integrations/test_dalle.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from steamship import Steamship 4 | 5 | 6 | def use_dalle(prompt: str, client: Steamship) -> str: 7 | """Use DALL-E from Python to generate an image whenever you need it.""" 8 | sd = client.use_plugin( 9 | plugin_handle="dall-e", 10 | config={}, 11 | ) 12 | 13 | task = sd.generate( 14 | text=prompt, 15 | append_output_to_file=True, # Persist the output so that it's stored for later 16 | make_output_public=True, # Permit anyone to consume the output 17 | ) 18 | 19 | task.wait() # Wait for the generation to complete. 20 | 21 | output = task.output.blocks[0] # Get the output block containing the image 22 | 23 | return output.raw_data_url 24 | 25 | 26 | @pytest.mark.usefixtures("client") 27 | def test_use_dalle(client: Steamship): 28 | image_url = use_dalle( 29 | "a cow standing in a field, majestic, 8k, award winning, best quality", client 30 | ) 31 | assert image_url 32 | 33 | # WARNING: This workspace -- and the data within it -- will be deleted after the test runs by the `client` fixture. 34 | # If you are running this test in order to play the audio, set a breakpoint and play it. 35 | print(f"Your image is at: {image_url}") 36 | -------------------------------------------------------------------------------- /tests/steamship_tests/integrations/test_google_image_search.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from steamship import Steamship 4 | 5 | 6 | def use_google_image_search(prompt: str, client: Steamship) -> str: 7 | """Use Google Image Search from Python to generate an image whenever you need it.""" 8 | sd = client.use_plugin( 9 | plugin_handle="google-image-search", 10 | config={}, 11 | ) 12 | 13 | task = sd.generate( 14 | text=prompt, 15 | append_output_to_file=True, # Persist the output so that it's stored for later 16 | make_output_public=True, # Permit anyone to consume the output 17 | ) 18 | 19 | task.wait() # Wait for the generation to complete. 20 | 21 | output = task.output.blocks[0] # Get the output block containing the image 22 | 23 | return output.raw_data_url 24 | 25 | 26 | @pytest.mark.usefixtures("client") 27 | def test_use_google_image_search(client: Steamship): 28 | image_url = use_google_image_search("bill clinton wikipedia", client) 29 | assert image_url 30 | 31 | # WARNING: This workspace -- and the data within it -- will be deleted after the test runs by the `client` fixture. 32 | # If you are running this test in order to play the audio, set a breakpoint and play it. 33 | print(f"Your image is at: {image_url}") 34 | -------------------------------------------------------------------------------- /tests/steamship_tests/integrations/test_google_search.py: -------------------------------------------------------------------------------- 1 | from typing import Optional 2 | 3 | import pytest 4 | 5 | from steamship import Steamship 6 | from steamship.data import TagValueKey 7 | 8 | 9 | def use_google_search(query: str, client: Steamship) -> Optional[str]: 10 | """Use Google Search from Python to generate search snippets about a topic.""" 11 | google_search = client.use_plugin( 12 | plugin_handle="serpapi-wrapper", 13 | config={}, 14 | ) 15 | 16 | task = google_search.tag(doc=query) 17 | task.wait() 18 | 19 | print(task.output) 20 | 21 | for tag in task.output.file.blocks[0].tags: 22 | if tag.kind == "search-result": 23 | return tag.value.get(TagValueKey.STRING_VALUE) 24 | 25 | return None 26 | 27 | 28 | @pytest.mark.usefixtures("client") 29 | def test_use_google_search(client: Steamship): 30 | result = use_google_search("Where was George Washington", client) 31 | assert result 32 | print(f"Who was George Washington: {result}") 33 | -------------------------------------------------------------------------------- /tests/steamship_tests/integrations/test_openai_embedder.py: -------------------------------------------------------------------------------- 1 | from typing import List, Optional 2 | 3 | import pytest 4 | 5 | from steamship import Steamship 6 | from steamship.data import TagKind, TagValueKey 7 | 8 | 9 | def use_openai_embedder(text: str, client: Steamship) -> Optional[List[float]]: 10 | """Use OpenAI's Embedder to turn text into an embedding vector.""" 11 | sd = client.use_plugin( 12 | plugin_handle="openai-embedder", 13 | config={"model": "text-embedding-ada-002", "dimensionality": 1536}, 14 | ) 15 | 16 | task = sd.tag(doc=text) 17 | 18 | task.wait() # Wait for the generation to complete. 19 | 20 | for tag in task.output.file.blocks[0].tags: 21 | if tag.kind == TagKind.EMBEDDING: 22 | return tag.value.get(TagValueKey.VECTOR_VALUE) 23 | 24 | return None 25 | 26 | 27 | @pytest.mark.usefixtures("client") 28 | def test_use_openai_embedder(client: Steamship): 29 | embedding = use_openai_embedder("Pizza", client) 30 | assert embedding 31 | assert len(embedding) 32 | print(f"Your embedding is: {embedding}") 33 | -------------------------------------------------------------------------------- /tests/steamship_tests/integrations/test_pdf_importer.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | import requests 3 | 4 | from steamship import File, Steamship 5 | 6 | 7 | def use_pdf(pdf_url: str, client: Steamship) -> File: 8 | """Use the PDF Blockifier from Python to parse a PDF into a nicely formatted document of Blocks.""" 9 | 10 | pdf_response = requests.get(pdf_url) 11 | pdf_file = File.create(client, content=pdf_response.content) 12 | 13 | pdf_blockifier = client.use_plugin( 14 | plugin_handle="pdf-blockifier", 15 | config={}, 16 | ) 17 | 18 | task = pdf_file.blockify(plugin_instance=pdf_blockifier.handle) 19 | 20 | task.wait() # Wait for the conversion to complete. 21 | 22 | pdf_file = pdf_file.refresh() 23 | 24 | return pdf_file 25 | 26 | 27 | @pytest.mark.usefixtures("client") 28 | def test_use_pdf(client: Steamship): 29 | file = use_pdf("https://www.steamship.com/test/pdf-test.pdf", client) 30 | for block in file.blocks: 31 | # Note: Markdown-style semantic annotations are in the block.tags property. 32 | assert block.text 33 | print(block.text) 34 | -------------------------------------------------------------------------------- /tests/steamship_tests/integrations/test_stable_diffusion_2.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from steamship import Steamship 4 | 5 | 6 | def use_stable_diffusion(prompt: str, client: Steamship) -> str: 7 | """Use Stable Diffusion from Python to generate an image whenever you need it.""" 8 | sd = client.use_plugin( 9 | plugin_handle="stable-diffusion", 10 | config={}, 11 | ) 12 | 13 | task = sd.generate( 14 | text=prompt, 15 | append_output_to_file=True, # Persist the output so that it's stored for later 16 | make_output_public=True, # Permit anyone to consume the output 17 | ) 18 | 19 | task.wait() # Wait for the generation to complete. 20 | 21 | output = task.output.blocks[0] # Get the output block containing the image 22 | 23 | return output.raw_data_url 24 | 25 | 26 | @pytest.mark.usefixtures("client") 27 | def test_use_stable_diffusion(client: Steamship): 28 | image_url = use_stable_diffusion( 29 | "a cow standing in a field, majestic, 8k, award winning, best quality", client 30 | ) 31 | # WARNING: This workspace -- and the data within it -- will be deleted after the test runs by the `client` fixture. 32 | # If you are running this test in order to play the audio, set a breakpoint and play it. 33 | assert image_url 34 | 35 | print(f"Your image is at: {image_url}") 36 | -------------------------------------------------------------------------------- /tests/steamship_tests/integrations/test_wikipedia_importer.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | import requests 3 | 4 | from steamship import File, Steamship 5 | 6 | 7 | def use_wikipedia(url: str, client: Steamship) -> File: 8 | """Use Wikipedia from Python to parse Wikipedia HTML into a nicely formatted document of Blocks.""" 9 | 10 | article_response = requests.get(url) 11 | article_steamship = File.create(client, content=article_response.content) 12 | 13 | wikipedia = client.use_plugin( 14 | plugin_handle="wikipedia-blockifier", 15 | config={}, 16 | ) 17 | 18 | task = article_steamship.blockify(plugin_instance=wikipedia.handle) 19 | 20 | task.wait() # Wait for the conversion to complete. 21 | 22 | article_steamship = article_steamship.refresh() 23 | 24 | return article_steamship 25 | 26 | 27 | @pytest.mark.usefixtures("client") 28 | def test_use_wikipedia(client: Steamship): 29 | file = use_wikipedia("https://en.wikipedia.org/wiki/Parsing", client) 30 | for block in file.blocks: 31 | # Note: Markdown-style semantic annotations are in the block.tags property. 32 | assert block.text 33 | print(block.text) 34 | -------------------------------------------------------------------------------- /tests/steamship_tests/plugin/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steamship-core/python-client/62b3f9659fd43ce4fe62103b6488514259d1956f/tests/steamship_tests/plugin/__init__.py -------------------------------------------------------------------------------- /tests/steamship_tests/plugin/integration/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steamship-core/python-client/62b3f9659fd43ce4fe62103b6488514259d1956f/tests/steamship_tests/plugin/integration/__init__.py -------------------------------------------------------------------------------- /tests/steamship_tests/plugin/integration/test_e2e_async_generator.py: -------------------------------------------------------------------------------- 1 | from assets.plugins.generators.async_generator import OUTPUT_BLOCK_TEXT 2 | from steamship_tests import PLUGINS_PATH 3 | from steamship_tests.utils.deployables import deploy_plugin 4 | from steamship_tests.utils.fixtures import get_steamship_client 5 | 6 | 7 | def test_e2e_generator(): 8 | client = get_steamship_client() 9 | parser_path = PLUGINS_PATH / "generators" / "async_generator.py" 10 | 11 | with deploy_plugin(client, parser_path, "generator") as ( 12 | plugin, 13 | version, 14 | instance, 15 | ): 16 | test_doc = "Yo! Banana boy!" 17 | res = instance.generate(text=test_doc, append_output_to_file=False) 18 | res.wait() 19 | assert res.output is not None 20 | assert len(res.output.blocks) == 1 21 | assert res.output.blocks[0].text == OUTPUT_BLOCK_TEXT 22 | -------------------------------------------------------------------------------- /tests/steamship_tests/plugin/integration/test_e2e_blockifier.py: -------------------------------------------------------------------------------- 1 | from steamship_tests import PLUGINS_PATH 2 | from steamship_tests.utils.deployables import deploy_plugin 3 | from steamship_tests.utils.fixtures import get_steamship_client 4 | 5 | from steamship import File 6 | 7 | 8 | def test_e2e_blockifier_plugin(): 9 | client = get_steamship_client() 10 | blockifier_path = PLUGINS_PATH / "blockifiers" / "blockifier.py" 11 | with deploy_plugin(client, blockifier_path, "blockifier") as ( 12 | plugin, 13 | version, 14 | instance, 15 | ): 16 | file = File.create(client=client, content="This is a test.") 17 | assert len(file.refresh().blocks) == 0 18 | file.blockify(plugin_instance=instance.handle).wait() 19 | assert len(file.refresh().blocks) == 4 20 | file.delete() 21 | -------------------------------------------------------------------------------- /tests/steamship_tests/plugin/integration/test_e2e_blockifier_markdown.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from steamship import File, Steamship, SteamshipError 4 | from steamship.base import TaskState 5 | 6 | 7 | @pytest.mark.usefixtures("client") 8 | def test_e2e_blockifier_markdown(client: Steamship): 9 | # TODO (enias): Stop offering default plugins hosted on the engine 10 | blockifier = client.use_plugin("markdown-blockifier-default") 11 | file = File.create(client=client, content="This is a test.") 12 | assert len(file.refresh().blocks) == 0 13 | task = file.blockify(plugin_instance=blockifier.handle) 14 | task.wait() 15 | 16 | if task.state == TaskState.failed: 17 | raise SteamshipError(message=task.status_message) 18 | assert task.state == TaskState.succeeded 19 | 20 | assert len(file.refresh().blocks) == 1 21 | file.delete() 22 | -------------------------------------------------------------------------------- /tests/steamship_tests/plugin/integration/test_e2e_corpus_importer.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steamship-core/python-client/62b3f9659fd43ce4fe62103b6488514259d1956f/tests/steamship_tests/plugin/integration/test_e2e_corpus_importer.py -------------------------------------------------------------------------------- /tests/steamship_tests/plugin/integration/test_e2e_file_importer_by_url.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | from assets.plugins.blockifiers.blockifier import TEST_DOC 3 | from steamship_tests import PLUGINS_PATH 4 | from steamship_tests.utils.deployables import deploy_plugin 5 | 6 | from steamship import File 7 | from steamship.client import Steamship 8 | 9 | 10 | @pytest.mark.usefixtures("client") 11 | def test_e2e_importer(client: Steamship): 12 | file_importer_path = PLUGINS_PATH / "importers" / "plugin_file_importer_by_url.py" 13 | with deploy_plugin(client, file_importer_path, "fileImporter") as ( 14 | plugin, 15 | version, 16 | instance, 17 | ): 18 | # The test FileImporter should always return a string file with contents TEST_DOC 19 | file = File.create_with_plugin(client=client, plugin_instance=instance.handle) 20 | file.wait() 21 | file = file.output 22 | # Now fetch the data from Steamship and assert that it is the SAME as the data the FileImporter creates 23 | data = file.raw() 24 | assert data.decode("utf-8") == (100000 * TEST_DOC) 25 | 26 | file.delete() 27 | -------------------------------------------------------------------------------- /tests/steamship_tests/plugin/integration/test_e2e_logging_tagger.py: -------------------------------------------------------------------------------- 1 | from steamship_tests import PLUGINS_PATH 2 | from steamship_tests.utils.deployables import deploy_plugin 3 | from steamship_tests.utils.fixtures import get_steamship_client 4 | 5 | 6 | def test_e2e_tagger(): 7 | client = get_steamship_client() 8 | parser_path = PLUGINS_PATH / "taggers" / "plugin_logging_tagger.py" 9 | with deploy_plugin(client, parser_path, "tagger") as (plugin, version, instance): 10 | test_doc = "Hi there" 11 | res = instance.tag(doc=test_doc) 12 | res.wait() 13 | assert res.output is not None 14 | assert len(res.output.file.blocks) == 1 15 | assert res.output.file.blocks[0].text == test_doc 16 | -------------------------------------------------------------------------------- /tests/steamship_tests/plugin/unit/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steamship-core/python-client/62b3f9659fd43ce4fe62103b6488514259d1956f/tests/steamship_tests/plugin/unit/__init__.py -------------------------------------------------------------------------------- /tests/steamship_tests/plugin/unit/test_file_importer.py: -------------------------------------------------------------------------------- 1 | import base64 2 | 3 | from assets.plugins.importers.plugin_file_importer import TEST_DOC, TestFileImporterPlugin 4 | 5 | from steamship.data.file import File 6 | from steamship.invocable import InvocableResponse 7 | from steamship.invocable.plugin_service import PluginRequest 8 | from steamship.plugin.outputs.raw_data_plugin_output import RawDataPluginOutput 9 | 10 | TEST_REQ = File() 11 | TEST_PLUGIN_REQ = PluginRequest(data=TEST_REQ) 12 | TEST_PLUGIN_REQ_DICT = TEST_PLUGIN_REQ.dict() 13 | 14 | 15 | def _test_resp(res): 16 | assert isinstance(res, InvocableResponse) 17 | assert isinstance(res.data, RawDataPluginOutput) 18 | b64 = base64.b64encode(TEST_DOC.encode("utf-8")).decode("utf-8") 19 | assert res.data.data == b64 20 | 21 | 22 | def test_importer(): 23 | importer = TestFileImporterPlugin() 24 | res = importer.run(TEST_PLUGIN_REQ) 25 | _test_resp(res) 26 | 27 | # The endpoints take a kwargs block which is transformed into the appropriate JSON object 28 | res2 = importer.run_endpoint(**TEST_PLUGIN_REQ_DICT) 29 | _test_resp(res2) 30 | -------------------------------------------------------------------------------- /tests/steamship_tests/plugin/unit/trainable/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steamship-core/python-client/62b3f9659fd43ce4fe62103b6488514259d1956f/tests/steamship_tests/plugin/unit/trainable/__init__.py -------------------------------------------------------------------------------- /tests/steamship_tests/plugin/unit/trainable/util.py: -------------------------------------------------------------------------------- 1 | from steamship_tests.base.test_task import NoOpResult 2 | 3 | from steamship.base.tasks import Task, TaskState 4 | 5 | PLUGIN_INSTANCE_ID = "0000-0000-0000-0000" 6 | 7 | 8 | def create_dummy_training_task(client) -> Task[NoOpResult]: 9 | # Create a task that is running in the background 10 | task = client.post("task/noop", expect=NoOpResult, as_background_task=True) 11 | assert task is not None 12 | assert task.state == TaskState.waiting 13 | 14 | # Allow it to complete 15 | task.wait() 16 | assert task.state == TaskState.succeeded 17 | 18 | return task 19 | -------------------------------------------------------------------------------- /tests/steamship_tests/server/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/steamship-core/python-client/62b3f9659fd43ce4fe62103b6488514259d1956f/tests/steamship_tests/server/__init__.py -------------------------------------------------------------------------------- /tests/steamship_tests/server/test_task_timeout.py: -------------------------------------------------------------------------------- 1 | from steamship_tests import PLUGINS_PATH 2 | from steamship_tests.utils.deployables import deploy_plugin 3 | from steamship_tests.utils.fixtures import get_steamship_client 4 | 5 | from steamship.base import SteamshipError 6 | 7 | 8 | def test_task_timeout(): 9 | client = get_steamship_client() 10 | parser_path = PLUGINS_PATH / "taggers" / "plugin_parser.py" 11 | # TODO (enias): Use Enum for plugin type 12 | with deploy_plugin(client, parser_path, "tagger", safe_load_handler=True) as ( 13 | plugin, 14 | version, 15 | instance, 16 | ): 17 | test_doc = "Hi there" 18 | res = instance.tag(doc=test_doc) 19 | try: 20 | res.wait(max_timeout_s=0.01, retry_delay_s=0.01) 21 | raise AssertionError("The call to wait() should throw") 22 | except SteamshipError: 23 | pass 24 | -------------------------------------------------------------------------------- /tests/steamship_tests/utils/__init__.py: -------------------------------------------------------------------------------- 1 | """Collection of utility function used by our steamship_tests.""" 2 | -------------------------------------------------------------------------------- /tests/steamship_tests/utils/context.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from steamship import Steamship 4 | from steamship.agents.schema import AgentContext 5 | 6 | 7 | @pytest.mark.usefixtures("client") 8 | def test_same_context(client: Steamship): 9 | context1 = AgentContext.get_or_create(client=client, context_keys={"one": "one", "two": "two"}) 10 | contextsame = AgentContext.get_or_create( 11 | client=client, context_keys={"one": "one", "two": "two"} 12 | ) 13 | 14 | assert context1.id == contextsame.id 15 | 16 | 17 | @pytest.mark.usefixtures("client") 18 | def test_different_context(client: Steamship): 19 | context1 = AgentContext.get_or_create(client=client, context_keys={"one": "one", "two": "two"}) 20 | contextdiff = AgentContext.get_or_create( 21 | client=client, context_keys={"one": "one", "two": "three"} 22 | ) 23 | assert context1.id != contextdiff.id 24 | -------------------------------------------------------------------------------- /tests/steamship_tests/utils/file.py: -------------------------------------------------------------------------------- 1 | import contextlib 2 | 3 | from steamship_tests import TEST_ASSETS_PATH 4 | 5 | from steamship import File, Steamship 6 | 7 | 8 | @contextlib.contextmanager 9 | def upload_file(client: Steamship, test_asset_filename: str): 10 | full_path = TEST_ASSETS_PATH / test_asset_filename 11 | file = File.create(client, content=full_path.open("rb").read()) 12 | assert file is not None 13 | assert file.id is not None 14 | yield file 15 | file.delete() 16 | -------------------------------------------------------------------------------- /tests/steamship_tests/utils/random.py: -------------------------------------------------------------------------------- 1 | import contextlib 2 | import random 3 | import string 4 | 5 | from steamship import EmbeddingIndex, Steamship, Workspace 6 | 7 | 8 | def random_name() -> str: 9 | """Returns a random name suitable for a handle that has low likelihood of colliding with another. 10 | 11 | Output format matches test_[a-z0-9]+, which should be a valid handle. 12 | """ 13 | letters = string.digits + string.ascii_letters 14 | return f"test_{''.join(random.choice(letters) for _ in range(10))}".lower() # noqa: S311 15 | 16 | 17 | _TEST_EMBEDDER = "test-embedder-v1" 18 | 19 | 20 | @contextlib.contextmanager 21 | def random_index(steamship: Steamship, plugin_instance: str) -> EmbeddingIndex: 22 | index = steamship.use_plugin( 23 | "embedding-index", 24 | random_name(), 25 | config={"embedder": {"plugin_handle": plugin_instance, "fetch_if_exists": True}}, 26 | fetch_if_exists=True, 27 | ) 28 | yield index 29 | index.delete() # or whatever you need to do at exit 30 | 31 | 32 | @contextlib.contextmanager 33 | def temporary_workspace(steamship: Steamship) -> Workspace: 34 | workspace = Workspace.create(client=steamship) 35 | yield workspace 36 | workspace.delete() # or whatever you need to do at exit 37 | -------------------------------------------------------------------------------- /tests/steamship_tests/utils/test_camel_model.py: -------------------------------------------------------------------------------- 1 | from steamship import Block, Tag 2 | from steamship.invocable import InvocableResponse 3 | 4 | 5 | def test_camel_all_levels(): 6 | tag = Tag(kind="kind", name="name", start_idx=0, end_idx=10) 7 | tagd = tag.dict(by_alias=True) 8 | 9 | assert tagd.get("startIdx") == 0 10 | assert tagd.get("endIdx") == 10 11 | 12 | block = Block(tags=[tag]) 13 | blockd = block.dict(by_alias=True) 14 | 15 | tags = blockd.get("tags") 16 | assert tags is not None 17 | assert len(tags) == 1 18 | tagd2 = tags[0] 19 | 20 | assert tagd2.get("startIdx") == 0 21 | assert tagd2.get("endIdx") == 10 22 | 23 | ir = InvocableResponse.from_obj(block) 24 | 25 | tags_ir = ir.data.get("tags") 26 | assert tags_ir is not None 27 | assert len(tags_ir) == 1 28 | tagd3 = tags_ir[0] 29 | 30 | assert tagd3.get("startIdx") == 0 31 | assert tagd3.get("endIdx") == 10 32 | -------------------------------------------------------------------------------- /tests/steamship_tests/utils/test_text_chunker.py: -------------------------------------------------------------------------------- 1 | from steamship.utils.text_chunker import chunk_text 2 | 3 | 4 | def test_text_chunker(): 5 | chunked = list(chunk_text("Hi there")) 6 | assert len(chunked) == 1 7 | 8 | chunked = list(chunk_text("12345", chunk_size=1, chunk_overlap=0)) 9 | assert len(chunked) == 5 10 | assert chunked == ["1", "2", "3", "4", "5"] 11 | 12 | chunked = list(chunk_text("12345", chunk_size=2, chunk_overlap=1)) 13 | assert len(chunked) == 5 14 | assert chunked == ["12", "23", "34", "45", "5"] 15 | 16 | chunked = list(chunk_text("12345", chunk_size=3, chunk_overlap=2)) 17 | assert len(chunked) == 5 18 | assert chunked == ["123", "234", "345", "45", "5"] 19 | --------------------------------------------------------------------------------