From 53329cc38ca66cf73504d6c6f3d4818af467d7ec Mon Sep 17 00:00:00 2001 From: fern-api <115122769+fern-api[bot]@users.noreply.github.com> Date: Tue, 20 May 2025 08:41:30 +0000 Subject: [PATCH] SDK regeneration --- .gitignore | 4 +- .mock/asyncapi.yml | 90 +- .mock/definition/__package__.yml | 201 +- .mock/definition/audioIsolation.yml | 12 +- .mock/definition/audioNative.yml | 2 +- .mock/definition/conversationalAi.yml | 1834 +----- .mock/definition/conversationalAi/agents.yml | 517 ++ .../conversationalAi/agents/link.yml | 39 + .../conversationalAi/agents/widget.yml | 77 + .../conversationalAi/agents/widget/avatar.yml | 44 + .../conversationalAi/batchCalls.yml | 139 + .../conversationalAi/conversations.yml | 165 + .../conversationalAi/conversations/audio.yml | 28 + .../conversations/feedback.yml | 47 + .../conversationalAi/dashboard/settings.yml | 73 + .../conversationalAi/knowledgeBase.yml | 87 + .../knowledgeBase/documents.yml | 346 + .../knowledgeBase/documents/chunk.yml | 42 + .../conversationalAi/phoneNumbers.yml | 206 + .mock/definition/conversationalAi/secrets.yml | 100 + .../definition/conversationalAi/settings.yml | 81 + .../definition/conversationalAi/sipTrunk.yml | 1 + .mock/definition/conversationalAi/twilio.yml | 45 + .mock/definition/dubbing.yml | 443 +- .mock/definition/dubbing/audio.yml | 35 + .mock/definition/dubbing/resource.yml | 271 + .../definition/dubbing/resource/language.yml | 43 + .mock/definition/dubbing/resource/segment.yml | 83 + .../dubbing/{ => resource}/speaker.yml | 4 +- .../{ => resource}/speaker/segment.yml | 2 +- .mock/definition/dubbing/transcript.yml | 48 + .mock/definition/history.yml | 8 +- .mock/definition/models.yml | 2 +- ...nary.yml => pronunciationDictionaries.yml} | 106 +- .../pronunciationDictionaries/rules.yml | 99 + .mock/definition/samples.yml | 27 - .mock/definition/speechToSpeech.yml | 10 +- .mock/definition/studio/projects.yml | 302 +- .../studio/{ => projects}/chapters.yml | 139 +- .../studio/projects/chapters/snapshots.yml | 141 + .mock/definition/studio/projects/content.yml | 94 + .../projects/pronunciationDictionaries.yml | 70 + .../definition/studio/projects/snapshots.yml | 140 + .mock/definition/textToSpeech.yml | 6 +- .mock/definition/textToVoice.yml | 1 + .mock/definition/usage.yml | 4 +- .mock/definition/user.yml | 42 - .mock/definition/user/subscription.yml | 50 + .../v1TextToSpeechVoiceIdMultiStreamInput.yml | 93 +- .../v1TextToSpeechVoiceIdStreamInput.yml | 61 +- .mock/definition/voices.yml | 155 +- .mock/definition/voices/ivc.yml | 57 + .mock/definition/voices/samples/audio.yml | 35 + .mock/definition/voices/settings.yml | 105 + .mock/definition/workspace.yml | 497 -- .mock/definition/workspace/groups.yml | 41 + .mock/definition/workspace/groups/members.yml | 82 + .mock/definition/workspace/invites.yml | 141 + .mock/definition/workspace/members.yml | 83 + .mock/definition/workspace/resources.yml | 184 + .mock/fern.config.json | 2 +- .mock/openapi.json | 1733 +++-- poetry.lock | 109 +- pyproject.toml | 28 +- reference.md | 4766 +++++++------- requirements.txt | 2 +- src/elevenlabs/__init__.py | 136 +- src/elevenlabs/audio_isolation/__init__.py | 6 +- src/elevenlabs/audio_isolation/client.py | 230 +- src/elevenlabs/audio_isolation/raw_client.py | 311 + .../audio_isolation/types/__init__.py | 10 +- ...ion_audio_isolation_request_file_format.py | 5 - ...io_isolation_stream_request_file_format.py | 5 - ...o_isolation_convert_request_file_format.py | 5 + ...io_isolation_stream_request_file_format.py | 5 + src/elevenlabs/audio_native/__init__.py | 2 + src/elevenlabs/audio_native/client.py | 327 +- src/elevenlabs/audio_native/raw_client.py | 514 ++ src/elevenlabs/base_client.py | 73 +- src/elevenlabs/conversational_ai/__init__.py | 96 +- .../conversational_ai/agents/__init__.py | 5 + .../conversational_ai/agents/client.py | 723 ++- .../agents/link}/__init__.py | 2 + .../conversational_ai/agents/link/client.py | 114 + .../agents/link/raw_client.py | 126 + .../conversational_ai/agents/raw_client.py | 959 +++ .../agents/widget/__init__.py | 7 + .../agents/widget/avatar}/__init__.py | 2 + .../agents/widget/avatar/client.py | 124 + .../agents/widget/avatar/raw_client.py | 148 + .../conversational_ai/agents/widget/client.py | 135 + .../agents/widget/raw_client.py | 146 + .../conversational_ai/batch_calls/__init__.py | 4 + .../conversational_ai/batch_calls/client.py | 328 + .../batch_calls/raw_client.py | 407 ++ src/elevenlabs/conversational_ai/client.py | 5729 +---------------- .../conversations/__init__.py | 7 + .../conversations/audio/__init__.py | 4 + .../conversations/audio/client.py | 84 + .../conversations/audio/raw_client.py | 135 + .../conversational_ai/conversations/client.py | 405 ++ .../conversations/feedback/__init__.py | 4 + .../conversations/feedback/client.py | 133 + .../conversations/feedback/raw_client.py | 157 + .../conversations/raw_client.py | 503 ++ .../conversational_ai/dashboard/__init__.py | 19 + .../conversational_ai/dashboard/client.py | 39 + .../conversational_ai/dashboard/raw_client.py | 13 + .../dashboard/settings/__init__.py | 17 + .../dashboard/settings/client.py | 182 + .../dashboard/settings/raw_client.py | 252 + .../dashboard/settings/types/__init__.py | 17 + ..._dashboard_settings_request_charts_item.py | 7 +- .../knowledge_base/__init__.py | 27 +- .../knowledge_base/client.py | 183 +- .../knowledge_base/document/__init__.py | 2 + .../knowledge_base/document/client.py | 115 +- .../knowledge_base/document/raw_client.py | 156 + .../knowledge_base/documents/__init__.py | 27 + .../documents/chunk/__init__.py | 4 + .../knowledge_base/documents/chunk/client.py | 122 + .../documents/chunk/raw_client.py | 132 + .../knowledge_base/documents/client.py | 694 ++ .../knowledge_base/documents/raw_client.py | 955 +++ .../documents/types/__init__.py | 27 + .../types/documents_get_response.py} | 27 +- .../types/documents_update_response.py} | 27 +- .../knowledge_base/raw_client.py | 192 + .../phone_numbers/__init__.py | 33 + .../conversational_ai/phone_numbers/client.py | 433 ++ .../phone_numbers/raw_client.py | 574 ++ .../phone_numbers/types/__init__.py | 39 + .../phone_numbers_create_request_body.py} | 24 +- .../types/phone_numbers_get_response.py} | 22 +- .../phone_numbers_list_response_item.py} | 22 +- .../types/phone_numbers_update_response.py} | 22 +- .../conversational_ai/raw_client.py | 297 + .../conversational_ai/secrets/__init__.py | 4 + .../conversational_ai/secrets/client.py | 250 + .../conversational_ai/secrets/raw_client.py | 328 + .../conversational_ai/settings/__init__.py | 4 + .../conversational_ai/settings/client.py | 211 + .../conversational_ai/settings/raw_client.py | 283 + .../conversational_ai/sip_trunk/__init__.py | 2 + .../conversational_ai/sip_trunk/client.py | 135 +- .../conversational_ai/sip_trunk/raw_client.py | 180 + .../conversational_ai/twilio/__init__.py | 4 + .../conversational_ai/twilio/client.py | 156 + .../conversational_ai/twilio/raw_client.py | 180 + .../conversational_ai/types/__init__.py | 67 - src/elevenlabs/core/__init__.py | 5 + src/elevenlabs/core/api_error.py | 18 +- src/elevenlabs/core/client_wrapper.py | 17 +- src/elevenlabs/core/file.py | 3 +- src/elevenlabs/core/force_multipart.py | 16 + src/elevenlabs/core/http_client.py | 96 +- src/elevenlabs/core/http_response.py | 55 + src/elevenlabs/core/jsonable_encoder.py | 1 - src/elevenlabs/core/pydantic_utilities.py | 183 +- src/elevenlabs/core/serialization.py | 10 +- src/elevenlabs/core/unchecked_base_model.py | 6 +- src/elevenlabs/dubbing/__init__.py | 8 +- src/elevenlabs/dubbing/audio/__init__.py | 4 + src/elevenlabs/dubbing/audio/client.py | 90 + src/elevenlabs/dubbing/audio/raw_client.py | 210 + src/elevenlabs/dubbing/client.py | 2211 +------ src/elevenlabs/dubbing/raw_client.py | 526 ++ src/elevenlabs/dubbing/resource/__init__.py | 7 + src/elevenlabs/dubbing/resource/client.py | 529 ++ .../dubbing/resource/language/__init__.py | 4 + .../dubbing/resource/language/client.py | 131 + .../dubbing/resource/language/raw_client.py | 157 + src/elevenlabs/dubbing/resource/raw_client.py | 682 ++ .../dubbing/resource/segment/__init__.py | 4 + .../dubbing/resource/segment/client.py | 260 + .../dubbing/resource/segment/raw_client.py | 296 + .../{ => resource}/speaker/__init__.py | 2 + .../dubbing/resource/speaker/client.py | 239 + .../speaker/raw_client.py} | 173 +- .../resource/speaker/segment/__init__.py | 4 + .../resource/speaker/segment/client.py | 177 + .../speaker/segment/raw_client.py} | 91 +- src/elevenlabs/dubbing/transcript/__init__.py | 7 + src/elevenlabs/dubbing/transcript/client.py | 142 + .../dubbing/transcript/raw_client.py | 209 + .../dubbing/transcript/types/__init__.py | 7 + ..._transcript_for_dub_request_format_type.py | 5 + src/elevenlabs/dubbing/types/__init__.py | 5 - ..._transcript_for_dub_request_format_type.py | 5 - src/elevenlabs/errors/__init__.py | 2 + src/elevenlabs/errors/bad_request_error.py | 7 +- src/elevenlabs/errors/forbidden_error.py | 7 +- src/elevenlabs/errors/not_found_error.py | 7 +- src/elevenlabs/errors/too_early_error.py | 7 +- .../errors/unprocessable_entity_error.py | 6 +- src/elevenlabs/forced_alignment/__init__.py | 2 + src/elevenlabs/forced_alignment/client.py | 114 +- src/elevenlabs/forced_alignment/raw_client.py | 169 + src/elevenlabs/history/__init__.py | 6 +- src/elevenlabs/history/client.py | 468 +- src/elevenlabs/history/raw_client.py | 664 ++ src/elevenlabs/history/types/__init__.py | 6 +- .../types/history_get_all_request_source.py | 5 - .../types/history_list_request_source.py | 5 + src/elevenlabs/models/__init__.py | 2 + src/elevenlabs/models/client.py | 106 +- src/elevenlabs/models/raw_client.py | 117 + .../__init__.py | 16 +- .../pronunciation_dictionaries/client.py | 556 ++ .../raw_client.py} | 807 +-- .../rules/__init__.py | 7 + .../rules/client.py | 250 + .../rules/raw_client.py | 297 + .../rules/types/__init__.py | 11 + .../types/pronunciation_dictionary_rule.py | 7 +- .../types/__init__.py | 20 +- ...ionaries_add_from_rules_post_rules_item.py | 7 +- ...es_add_from_rules_post_workspace_access.py | 0 ...ate_from_file_request_workspace_access.py} | 2 +- ...ciation_dictionaries_list_request_sort.py} | 2 +- src/elevenlabs/realtime_tts.py | 143 - src/elevenlabs/samples/__init__.py | 2 + src/elevenlabs/samples/client.py | 217 +- src/elevenlabs/samples/raw_client.py | 132 + src/elevenlabs/speech_to_speech/__init__.py | 10 +- src/elevenlabs/speech_to_speech/client.py | 319 +- src/elevenlabs/speech_to_speech/raw_client.py | 506 ++ .../speech_to_speech/types/__init__.py | 10 +- ...h_convert_as_stream_request_file_format.py | 5 - ...ch_to_speech_stream_request_file_format.py | 5 + ...to_speech_stream_request_output_format.py} | 2 +- src/elevenlabs/speech_to_text/__init__.py | 2 + src/elevenlabs/speech_to_text/client.py | 162 +- src/elevenlabs/speech_to_text/raw_client.py | 256 + .../speech_to_text/types/__init__.py | 2 + src/elevenlabs/studio/__init__.py | 21 +- src/elevenlabs/studio/chapters/client.py | 1391 ---- src/elevenlabs/studio/client.py | 182 +- src/elevenlabs/studio/projects/__init__.py | 23 +- .../studio/projects/chapters/__init__.py | 7 + .../studio/projects/chapters/client.py | 580 ++ .../studio/projects/chapters/raw_client.py | 752 +++ .../projects/chapters/snapshots/__init__.py | 4 + .../projects/chapters/snapshots/client.py | 315 + .../projects/chapters/snapshots/raw_client.py | 416 ++ src/elevenlabs/studio/projects/client.py | 1560 +---- .../studio/projects/content/__init__.py | 4 + .../studio/projects/content/client.py | 160 + .../studio/projects/content/raw_client.py | 178 + .../pronunciation_dictionaries/__init__.py | 4 + .../pronunciation_dictionaries/client.py | 160 + .../pronunciation_dictionaries/raw_client.py | 177 + src/elevenlabs/studio/projects/raw_client.py | 1017 +++ .../studio/projects/snapshots/__init__.py | 4 + .../studio/projects/snapshots/client.py | 324 + .../studio/projects/snapshots/raw_client.py | 503 ++ .../studio/projects/types/__init__.py | 18 +- .../types/projects_add_request_fiction.py | 5 - .../types/projects_add_request_source_type.py | 5 - ...reate_request_apply_text_normalization.py} | 2 +- .../types/projects_create_request_fiction.py | 5 + .../projects_create_request_source_type.py | 5 + ...rojects_create_request_target_audience.py} | 2 +- src/elevenlabs/studio/raw_client.py | 249 + src/elevenlabs/studio/types/__init__.py | 2 + ...e_podcast_v_1_studio_podcasts_post_mode.py | 14 +- ...podcast_v_1_studio_podcasts_post_source.py | 9 +- ...st_v_1_studio_podcasts_post_source_item.py | 10 +- .../text_to_sound_effects/__init__.py | 2 + .../text_to_sound_effects/client.py | 139 +- .../text_to_sound_effects/raw_client.py | 192 + .../text_to_sound_effects/types/__init__.py | 2 + src/elevenlabs/text_to_speech/__init__.py | 6 +- src/elevenlabs/text_to_speech/client.py | 740 +-- src/elevenlabs/text_to_speech/raw_client.py | 1379 ++++ .../text_to_speech/types/__init__.py | 6 +- ...to_speech_stream_request_output_format.py} | 2 +- src/elevenlabs/text_to_voice/__init__.py | 2 + src/elevenlabs/text_to_voice/client.py | 238 +- src/elevenlabs/text_to_voice/raw_client.py | 386 ++ .../text_to_voice/types/__init__.py | 2 + src/elevenlabs/types/__init__.py | 26 +- .../types/add_chapter_response_model.py | 7 +- .../add_knowledge_base_response_model.py | 5 +- src/elevenlabs/types/add_project_request.py | 19 +- .../types/add_project_response_model.py | 7 +- ...pronunciation_dictionary_response_model.py | 7 +- .../types/add_voice_ivc_response_model.py | 5 +- .../types/add_voice_response_model.py | 5 +- ...d_workspace_group_member_response_model.py | 5 +- .../add_workspace_invite_response_model.py | 5 +- .../types/additional_format_response_model.py | 7 +- src/elevenlabs/types/additional_formats.py | 1 + src/elevenlabs/types/agent_ban.py | 7 +- src/elevenlabs/types/agent_call_limits.py | 3 +- src/elevenlabs/types/agent_config.py | 15 +- src/elevenlabs/types/agent_config_db_model.py | 15 +- src/elevenlabs/types/agent_config_override.py | 5 +- .../types/agent_config_override_config.py | 5 +- .../types/agent_metadata_response_model.py | 5 +- .../agent_platform_settings_request_model.py | 17 +- .../agent_platform_settings_response_model.py | 17 +- ...gent_simulated_chat_test_response_model.py | 13 +- .../types/agent_summary_response_model.py | 7 +- src/elevenlabs/types/agent_transfer.py | 5 +- .../types/agent_workspace_overrides_input.py | 9 +- .../types/agent_workspace_overrides_output.py | 9 +- src/elevenlabs/types/alignment.py | 7 +- src/elevenlabs/types/allowlist_item.py | 5 +- .../types/array_json_schema_property_input.py | 11 +- .../array_json_schema_property_input_items.py | 9 +- .../array_json_schema_property_output.py | 11 +- ...array_json_schema_property_output_items.py | 9 +- .../types/asr_conversational_config.py | 9 +- src/elevenlabs/types/asr_input_format.py | 11 +- ...io_native_create_project_response_model.py | 5 +- ...udio_native_edit_content_response_model.py | 5 +- ..._native_project_settings_response_model.py | 9 +- src/elevenlabs/types/audio_output.py | 9 +- src/elevenlabs/types/audio_output_multi.py | 9 +- .../types/audio_with_timestamps_response.py | 9 +- src/elevenlabs/types/auth_settings.py | 5 +- .../types/batch_call_detailed_response.py | 9 +- .../types/batch_call_recipient_status.py | 3 +- src/elevenlabs/types/batch_call_response.py | 33 + src/elevenlabs/types/batch_call_status.py | 5 +- ...1_projects_project_id_chapters_add_post.py | 5 +- ...e_v_1_convai_add_to_knowledge_base_post.py | 3 +- ...nts_agent_id_add_to_knowledge_base_post.py | 3 +- ...odcast_v_1_projects_podcast_create_post.py | 19 +- ...t_v_1_projects_podcast_create_post_mode.py | 11 +- ...v_1_projects_podcast_create_post_source.py | 9 +- ...rojects_podcast_create_post_source_item.py | 7 +- ...oject_info_v_1_projects_project_id_post.py | 5 +- ...ts_project_id_chapters_chapter_id_patch.py | 5 +- ...nt_v_1_projects_project_id_content_post.py | 3 +- ...vc_voice_id_samples_sample_id_audio_get.py | 3 +- ...apshots_chapter_snapshot_id_stream_post.py | 3 +- ...apshots_project_snapshot_id_stream_post.py | 3 +- ...nt_block_extendable_node_response_model.py | 5 +- .../chapter_content_block_input_model.py | 9 +- .../chapter_content_block_response_model.py | 9 +- ...content_block_response_model_nodes_item.py | 12 +- ...r_content_block_tts_node_response_model.py | 5 +- .../types/chapter_content_input_model.py | 7 +- ..._content_paragraph_tts_node_input_model.py | 5 +- .../types/chapter_content_response_model.py | 7 +- src/elevenlabs/types/chapter_response.py | 7 +- ...hapter_snapshot_extended_response_model.py | 7 +- .../types/chapter_snapshot_response.py | 5 +- .../types/chapter_snapshots_response.py | 5 +- .../types/chapter_statistics_response.py | 5 +- .../chapter_with_content_response_model.py | 13 +- .../types/character_alignment_model.py | 5 +- .../character_alignment_response_model.py | 5 +- .../types/client_tool_config_input.py | 17 +- .../types/client_tool_config_output.py | 17 +- src/elevenlabs/types/close_connection.py | 3 +- src/elevenlabs/types/close_context.py | 5 +- src/elevenlabs/types/close_socket.py | 3 +- .../types/conv_ai_dynamic_variable.py | 24 + .../types/conv_ai_secret_locator.py | 5 +- .../conv_ai_stored_secret_dependencies.py | 17 +- ...ed_secret_dependencies_agent_tools_item.py | 14 +- ...i_stored_secret_dependencies_tools_item.py | 16 +- src/elevenlabs/types/conv_ai_webhooks.py | 5 +- .../conv_ai_workspace_stored_secret_config.py | 7 +- .../conversation_charging_common_model.py | 7 +- src/elevenlabs/types/conversation_config.py | 10 +- ...ion_config_client_override_config_input.py | 15 +- ...on_config_client_override_config_output.py | 15 +- ...nversation_config_client_override_input.py | 13 +- ...versation_config_client_override_output.py | 13 +- .../types/conversation_config_override.py | 20 + .../conversation_config_override_config.py | 23 + .../types/conversation_deletion_settings.py | 5 +- ...versation_history_analysis_common_model.py | 7 +- .../conversation_history_batch_call_model.py | 5 +- ...conversation_history_error_common_model.py | 5 +- ...evaluation_criteria_result_common_model.py | 7 +- ...versation_history_feedback_common_model.py | 7 +- ...versation_history_metadata_common_model.py | 21 +- ...istory_metadata_common_model_phone_call.py | 15 +- ...ersation_history_rag_usage_common_model.py | 5 +- ...n_history_sip_trunking_phone_call_model.py | 7 +- ...n_history_transcript_common_model_input.py | 27 +- ...script_common_model_input_source_medium.py | 5 + ..._history_transcript_common_model_output.py | 27 +- ...cript_common_model_output_source_medium.py | 5 + ...ory_transcript_tool_call_client_details.py | 5 +- ...story_transcript_tool_call_common_model.py | 7 +- ...ipt_tool_call_common_model_tool_details.py | 7 +- ...ry_transcript_tool_call_webhook_details.py | 5 +- ...ory_transcript_tool_result_common_model.py | 5 +- ...rsation_history_twilio_phone_call_model.py | 9 +- ...ion_initiation_client_data_config_input.py | 7 +- ...on_initiation_client_data_config_output.py | 7 +- ...rsation_initiation_client_data_internal.py | 16 +- ...on_initiation_client_data_request_input.py | 16 +- ...n_initiation_client_data_request_output.py | 16 +- ...ersation_initiation_client_data_webhook.py | 7 +- ...ient_data_webhook_request_headers_value.py | 1 + .../conversation_signed_url_response_model.py | 5 +- .../conversation_simulation_specification.py | 21 +- .../conversation_summary_response_model.py | 11 +- ...versation_summary_response_model_status.py | 2 +- .../types/conversation_token_db_model.py | 7 +- .../types/conversation_turn_metrics.py | 7 +- src/elevenlabs/types/conversational_config.py | 23 +- .../types/convert_chapter_response_model.py | 5 +- .../types/convert_project_response_model.py | 5 +- .../types/create_agent_response_model.py | 5 +- .../create_phone_number_response_model.py | 5 +- ...eate_previously_generated_voice_request.py | 5 +- ...pronunciation_dictionary_response_model.py | 5 +- .../create_sip_trunk_phone_number_request.py | 9 +- .../create_twilio_phone_number_request.py | 5 +- src/elevenlabs/types/custom_llm.py | 7 +- .../dashboard_call_success_chart_model.py | 5 +- .../types/dashboard_criteria_chart_model.py | 5 +- .../dashboard_data_collection_chart_model.py | 5 +- .../data_collection_result_common_model.py | 7 +- .../types/delete_chapter_response_model.py | 5 +- .../types/delete_dubbing_response_model.py | 5 +- .../types/delete_history_item_response.py | 5 +- .../types/delete_project_response_model.py | 5 +- .../types/delete_sample_response.py | 5 +- .../types/delete_voice_response_model.py | 5 +- .../delete_voice_sample_response_model.py | 5 +- ...e_workspace_group_member_response_model.py | 5 +- .../delete_workspace_invite_response_model.py | 5 +- .../delete_workspace_member_response_model.py | 5 +- .../dependent_available_agent_identifier.py | 9 +- ...pendent_available_agent_tool_identifier.py | 9 +- .../dependent_available_tool_identifier.py | 9 +- .../dependent_phone_number_identifier.py | 7 +- .../dependent_unknown_agent_identifier.py | 5 +- ...dependent_unknown_agent_tool_identifier.py | 5 +- .../dependent_unknown_tool_identifier.py | 5 +- src/elevenlabs/types/do_dubbing_response.py | 5 +- src/elevenlabs/types/docx_export_options.py | 5 +- src/elevenlabs/types/dubbed_segment.py | 7 +- .../types/dubbing_media_metadata.py | 5 +- .../types/dubbing_media_reference.py | 5 +- .../types/dubbing_metadata_response.py | 7 +- .../types/dubbing_render_response_model.py | 5 +- src/elevenlabs/types/dubbing_resource.py | 11 +- .../types/dynamic_variables_config.py | 7 +- .../types/edit_chapter_response_model.py | 7 +- .../types/edit_project_response_model.py | 7 +- .../types/edit_voice_response_model.py | 5 +- .../edit_voice_settings_response_model.py | 5 +- src/elevenlabs/types/embedding_model_enum.py | 3 +- src/elevenlabs/types/end_call_tool_config.py | 5 +- src/elevenlabs/types/evaluation_settings.py | 5 +- src/elevenlabs/types/export_options.py | 7 +- ...nded_subscription_response_model_status.py | 11 +- src/elevenlabs/types/feedback_item.py | 5 +- src/elevenlabs/types/final_output.py | 7 +- src/elevenlabs/types/final_output_multi.py | 7 +- src/elevenlabs/types/fine_tuning_response.py | 7 +- .../fine_tuning_response_model_state_value.py | 3 +- src/elevenlabs/types/flush_context.py | 5 +- ...rced_alignment_character_response_model.py | 5 +- .../types/forced_alignment_response_model.py | 9 +- .../forced_alignment_word_response_model.py | 5 +- .../types/generate_voice_request.py | 13 +- src/elevenlabs/types/generation_config.py | 3 +- .../types/get_agent_embed_response_model.py | 7 +- .../types/get_agent_link_response_model.py | 7 +- .../types/get_agent_response_model.py | 34 +- ...agent_response_model_phone_numbers_item.py | 16 +- .../types/get_agents_page_response_model.py | 5 +- ..._native_project_settings_response_model.py | 9 +- src/elevenlabs/types/get_chapters_response.py | 7 +- ...nv_ai_dashboard_settings_response_model.py | 9 +- ...ard_settings_response_model_charts_item.py | 7 +- .../get_conv_ai_settings_response_model.py | 16 +- .../types/get_conversation_response_model.py | 23 +- .../get_conversation_response_model_status.py | 2 +- .../get_conversations_page_response_model.py | 7 +- ...ge_base_dependent_agents_response_model.py | 7 +- ...ndent_agents_response_model_agents_item.py | 11 +- .../get_knowledge_base_file_response_model.py | 11 +- .../get_knowledge_base_list_response_model.py | 9 +- ...base_list_response_model_documents_item.py | 17 +- ...wledge_base_summary_file_response_model.py | 13 +- ...le_response_model_dependent_agents_item.py | 11 +- ...wledge_base_summary_text_response_model.py | 13 +- ...xt_response_model_dependent_agents_item.py | 11 +- ...owledge_base_summary_url_response_model.py | 13 +- ...rl_response_model_dependent_agents_item.py | 11 +- .../get_knowledge_base_text_response_model.py | 11 +- .../get_knowledge_base_url_response_model.py | 11 +- .../types/get_library_voices_response.py | 5 +- ...t_phone_number_sip_trunk_response_model.py | 7 +- .../get_phone_number_twilio_response_model.py | 7 +- src/elevenlabs/types/get_projects_response.py | 5 +- ...on_dictionaries_metadata_response_model.py | 7 +- ...nunciation_dictionary_metadata_response.py | 7 +- .../types/get_speech_history_response.py | 5 +- src/elevenlabs/types/get_voices_response.py | 5 +- .../types/get_voices_v_2_response.py | 7 +- .../get_workspace_secrets_response_model.py | 7 +- .../types/history_alignment_response_model.py | 3 +- .../history_alignments_response_model.py | 7 +- src/elevenlabs/types/history_item_response.py | 5 +- src/elevenlabs/types/html_export_options.py | 5 +- src/elevenlabs/types/http_validation_error.py | 7 +- src/elevenlabs/types/image_avatar.py | 3 +- src/elevenlabs/types/initialise_context.py | 9 +- src/elevenlabs/types/initialize_connection.py | 11 +- .../types/initialize_connection_multi.py | 7 +- src/elevenlabs/types/invoice_response.py | 5 +- src/elevenlabs/types/keep_context_alive.py | 3 +- ...edge_base_document_chunk_response_model.py | 5 +- ...e_base_document_metadata_response_model.py | 5 +- .../types/knowledge_base_locator.py | 9 +- .../types/language_added_response.py | 5 +- .../types/language_detection_tool_config.py | 5 +- src/elevenlabs/types/language_preset_input.py | 11 +- .../types/language_preset_output.py | 11 +- .../types/language_preset_translation.py | 5 +- src/elevenlabs/types/language_response.py | 5 +- .../types/library_voice_response.py | 16 +- .../library_voice_response_model_category.py | 3 +- .../types/literal_json_schema_property.py | 9 +- src/elevenlabs/types/llm_category_usage.py | 7 +- .../types/llm_input_output_tokens_usage.py | 7 +- .../types/llm_tokens_category_usage.py | 5 +- src/elevenlabs/types/llm_usage_input.py | 7 +- src/elevenlabs/types/llm_usage_output.py | 7 +- .../manual_verification_file_response.py | 5 +- .../types/manual_verification_response.py | 7 +- src/elevenlabs/types/mcp_tool_config_input.py | 17 +- .../types/mcp_tool_config_output.py | 17 +- src/elevenlabs/types/metric_record.py | 5 +- src/elevenlabs/types/metric_type.py | 10 +- src/elevenlabs/types/model.py | 7 +- .../types/model_rates_response_model.py | 5 +- .../types/moderation_status_response_model.py | 13 +- src/elevenlabs/types/normalized_alignment.py | 7 +- .../object_json_schema_property_input.py | 11 +- ..._schema_property_input_properties_value.py | 9 +- .../object_json_schema_property_output.py | 11 +- ...schema_property_output_properties_value.py | 9 +- src/elevenlabs/types/orb_avatar.py | 3 +- .../types/outbound_call_recipient.py | 23 + .../outbound_call_recipient_response_model.py | 11 +- src/elevenlabs/types/pdf_export_options.py | 5 +- .../types/phone_number_agent_info.py | 5 +- src/elevenlabs/types/phone_number_transfer.py | 5 +- src/elevenlabs/types/podcast_bulletin_mode.py | 7 +- .../types/podcast_bulletin_mode_data.py | 5 +- .../types/podcast_conversation_mode.py | 7 +- .../types/podcast_conversation_mode_data.py | 5 +- .../types/podcast_project_response_model.py | 7 +- src/elevenlabs/types/podcast_text_source.py | 5 +- src/elevenlabs/types/podcast_url_source.py | 5 +- .../types/post_agent_avatar_response_model.py | 5 +- .../post_workspace_secret_response_model.py | 5 +- src/elevenlabs/types/privacy_config.py | 3 +- .../project_creation_meta_response_model.py | 13 +- .../types/project_extended_response.py | 41 +- src/elevenlabs/types/project_response.py | 13 +- ...roject_snapshot_extended_response_model.py | 7 +- .../types/project_snapshot_response.py | 5 +- .../types/project_snapshots_response.py | 5 +- src/elevenlabs/types/prompt_agent.py | 25 +- src/elevenlabs/types/prompt_agent_db_model.py | 19 +- .../types/prompt_agent_db_model_tools_item.py | 23 +- .../types/prompt_agent_input_tools_item.py | 23 +- .../types/prompt_agent_output_tools_item.py | 23 +- src/elevenlabs/types/prompt_agent_override.py | 3 +- .../types/prompt_agent_override_config.py | 3 +- .../types/prompt_evaluation_criteria.py | 5 +- ...ion_dictionary_alias_rule_request_model.py | 5 +- .../types/pronunciation_dictionary_locator.py | 5 +- ...ation_dictionary_locator_response_model.py | 5 +- ...n_dictionary_phoneme_rule_request_model.py | 5 +- ...ciation_dictionary_rules_response_model.py | 5 +- ...ronunciation_dictionary_version_locator.py | 5 +- ...ation_dictionary_version_response_model.py | 7 +- ...ronunciation_dictionary_version_locator.py | 5 +- .../types/query_params_json_schema.py | 7 +- src/elevenlabs/types/rag_chunk_metadata.py | 5 +- src/elevenlabs/types/rag_config.py | 5 +- .../types/rag_index_response_model.py | 7 +- src/elevenlabs/types/rag_retrieval_info.py | 9 +- .../types/reader_resource_response_model.py | 9 +- .../types/realtime_voice_settings.py | 3 +- src/elevenlabs/types/recording_response.py | 5 +- src/elevenlabs/types/render.py | 9 +- src/elevenlabs/types/render_type.py | 5 +- ..._pvc_manual_verification_response_model.py | 5 +- src/elevenlabs/types/resource_access_info.py | 7 +- .../types/resource_metadata_response_model.py | 9 +- src/elevenlabs/types/review_status.py | 3 +- src/elevenlabs/types/safety_common_model.py | 7 +- src/elevenlabs/types/safety_evaluation.py | 7 +- src/elevenlabs/types/safety_response_model.py | 5 +- .../types/segment_create_response.py | 5 +- .../types/segment_delete_response.py | 5 +- src/elevenlabs/types/segment_dub_response.py | 5 +- .../types/segment_transcription_response.py | 5 +- .../types/segment_translation_response.py | 5 +- .../types/segment_update_response.py | 5 +- .../types/segmented_json_export_options.py | 5 +- src/elevenlabs/types/send_text.py | 9 +- src/elevenlabs/types/send_text_multi.py | 5 +- .../types/share_option_response_model.py | 7 +- src/elevenlabs/types/similar_voice.py | 7 +- .../types/similar_voice_category.py | 3 +- .../similar_voices_for_speaker_response.py | 7 +- .../types/sip_trunk_config_response_model.py | 9 +- src/elevenlabs/types/sip_trunk_credentials.py | 5 +- .../types/sip_trunk_outbound_call_response.py | 6 +- .../types/speaker_audio_response_model.py | 5 +- .../types/speaker_response_model.py | 7 +- src/elevenlabs/types/speaker_segment.py | 7 +- .../speaker_separation_response_model.py | 11 +- src/elevenlabs/types/speaker_track.py | 7 +- .../types/speaker_updated_response.py | 5 +- .../types/speech_history_item_response.py | 15 +- ...eech_history_item_response_model_source.py | 3 +- ...speech_to_text_character_response_model.py | 5 +- .../speech_to_text_chunk_response_model.py | 9 +- .../speech_to_text_word_response_model.py | 9 +- src/elevenlabs/types/srt_export_options.py | 5 +- ...start_pvc_voice_training_response_model.py | 5 +- ...start_speaker_separation_response_model.py | 5 +- .../types/stream_input_query_parameters.py | 73 - ...y_parameters_optimize_streaming_latency.py | 5 - ...ng_audio_chunk_with_timestamps_response.py | 9 +- src/elevenlabs/types/subscription.py | 19 +- .../subscription_extras_response_model.py | 7 +- src/elevenlabs/types/subscription_response.py | 15 +- src/elevenlabs/types/subscription_status.py | 11 +- .../subscription_usage_response_model.py | 5 +- .../types/system_tool_config_input.py | 5 +- .../types/system_tool_config_input_params.py | 9 +- .../types/system_tool_config_output.py | 5 +- .../types/system_tool_config_output_params.py | 9 +- src/elevenlabs/types/tool_mock_config.py | 5 +- .../types/transfer_to_agent_tool_config.py | 7 +- .../types/transfer_to_number_tool_config.py | 7 +- .../types/tts_conversational_config.py | 13 +- .../tts_conversational_config_override.py | 5 +- ...s_conversational_config_override_config.py | 3 +- .../types/tts_conversational_model.py | 3 +- src/elevenlabs/types/tts_output_format.py | 11 +- src/elevenlabs/types/turn_config.py | 5 +- .../types/twilio_outbound_call_response.py | 10 +- src/elevenlabs/types/txt_export_options.py | 5 +- ...date_pronunciation_dictionaries_request.py | 7 +- .../update_workspace_member_response_model.py | 5 +- src/elevenlabs/types/url_avatar.py | 3 +- .../types/usage_characters_response_model.py | 3 +- src/elevenlabs/types/user.py | 9 +- src/elevenlabs/types/user_feedback.py | 7 +- .../types/utterance_response_model.py | 5 +- src/elevenlabs/types/validation_error.py | 7 +- .../types/verification_attempt_response.py | 7 +- .../verified_voice_language_response_model.py | 5 +- ...verify_pvc_voice_captcha_response_model.py | 5 +- src/elevenlabs/types/voice.py | 15 +- .../types/voice_design_preview_response.py | 7 +- ...ce_generation_parameter_option_response.py | 5 +- .../voice_generation_parameter_response.py | 9 +- .../types/voice_preview_response_model.py | 5 +- .../types/voice_response_model_category.py | 3 +- .../voice_response_model_safety_control.py | 9 +- src/elevenlabs/types/voice_sample.py | 5 +- .../voice_sample_preview_response_model.py | 5 +- ...e_sample_visual_waveform_response_model.py | 5 +- src/elevenlabs/types/voice_settings.py | 3 +- ...sharing_moderation_check_response_model.py | 3 +- .../types/voice_sharing_response.py | 20 +- .../voice_sharing_response_model_category.py | 3 +- .../types/voice_verification_response.py | 7 +- .../webhook_tool_api_schema_config_input.py | 23 +- ...hema_config_input_request_headers_value.py | 4 +- .../webhook_tool_api_schema_config_output.py | 23 +- ...ema_config_output_request_headers_value.py | 4 +- .../types/webhook_tool_config_input.py | 17 +- .../types/webhook_tool_config_output.py | 17 +- .../websocket_tts_client_message_multi.py | 9 +- .../websocket_tts_server_message_multi.py | 7 +- src/elevenlabs/types/widget_config.py | 14 +- src/elevenlabs/types/widget_config_avatar.py | 7 +- .../types/widget_config_response_model.py | 14 +- .../widget_config_response_model_avatar.py | 11 +- .../types/workspace_batch_calls_response.py | 30 + .../workspace_group_by_name_response_model.py | 5 +- src/elevenlabs/usage/__init__.py | 2 + src/elevenlabs/usage/client.py | 134 +- src/elevenlabs/usage/raw_client.py | 190 + src/elevenlabs/user/__init__.py | 5 + src/elevenlabs/user/client.py | 192 +- src/elevenlabs/user/raw_client.py | 115 + src/elevenlabs/user/subscription/__init__.py | 4 + src/elevenlabs/user/subscription/client.py | 100 + .../user/subscription/raw_client.py | 115 + .../__init__.py | 6 +- .../types/__init__.py | 6 +- .../types/receive_message_multi.py | 1 + .../types/send_message_multi.py | 9 +- ...text_to_speech_apply_text_normalization.py | 5 - .../types/text_to_speech_output_format.py | 27 - .../__init__.py | 2 + .../types/__init__.py | 2 + .../types/receive_message.py | 1 + .../types/send_message.py | 3 +- src/elevenlabs/voices/__init__.py | 6 +- src/elevenlabs/voices/client.py | 1355 +--- src/elevenlabs/voices/ivc/__init__.py | 4 + src/elevenlabs/voices/ivc/client.py | 170 + src/elevenlabs/voices/ivc/raw_client.py | 189 + src/elevenlabs/voices/pvc/__init__.py | 2 + src/elevenlabs/voices/pvc/client.py | 303 +- src/elevenlabs/voices/pvc/raw_client.py | 470 ++ src/elevenlabs/voices/pvc/samples/__init__.py | 2 + .../voices/pvc/samples/audio/__init__.py | 2 + .../voices/pvc/samples/audio/client.py | 115 +- .../voices/pvc/samples/audio/raw_client.py | 132 + src/elevenlabs/voices/pvc/samples/client.py | 304 +- .../voices/pvc/samples/raw_client.py | 446 ++ .../voices/pvc/samples/speakers/__init__.py | 2 + .../pvc/samples/speakers/audio/__init__.py | 2 + .../pvc/samples/speakers/audio/client.py | 113 +- .../pvc/samples/speakers/audio/raw_client.py | 138 + .../voices/pvc/samples/speakers/client.py | 196 +- .../voices/pvc/samples/speakers/raw_client.py | 241 + .../voices/pvc/samples/waveform/__init__.py | 2 + .../voices/pvc/samples/waveform/client.py | 115 +- .../voices/pvc/samples/waveform/raw_client.py | 132 + .../voices/pvc/verification/__init__.py | 2 + .../pvc/verification/captcha/__init__.py | 2 + .../voices/pvc/verification/captcha/client.py | 177 +- .../pvc/verification/captcha/raw_client.py | 232 + .../voices/pvc/verification/client.py | 124 +- .../voices/pvc/verification/raw_client.py | 168 + src/elevenlabs/voices/raw_client.py | 1293 ++++ src/elevenlabs/voices/samples/__init__.py | 7 + .../voices/samples/audio/__init__.py | 4 + src/elevenlabs/voices/samples/audio/client.py | 90 + .../voices/samples/audio/raw_client.py | 141 + src/elevenlabs/voices/samples/client.py | 39 + src/elevenlabs/voices/samples/raw_client.py | 13 + src/elevenlabs/voices/settings/__init__.py | 4 + src/elevenlabs/voices/settings/client.py | 266 + src/elevenlabs/voices/settings/raw_client.py | 319 + src/elevenlabs/voices/types/__init__.py | 2 + src/elevenlabs/webhooks.py | 70 - src/elevenlabs/workspace/__init__.py | 15 +- src/elevenlabs/workspace/client.py | 1819 +----- src/elevenlabs/workspace/groups/__init__.py | 7 + src/elevenlabs/workspace/groups/client.py | 117 + .../workspace/groups/members/__init__.py | 4 + .../workspace/groups/members/client.py | 208 + .../workspace/groups/members/raw_client.py | 272 + src/elevenlabs/workspace/groups/raw_client.py | 131 + src/elevenlabs/workspace/invites/__init__.py | 7 + src/elevenlabs/workspace/invites/client.py | 311 + .../workspace/invites/raw_client.py | 420 ++ .../workspace/invites/types/__init__.py | 9 + ...e_invites_add_post_workspace_permission.py | 0 src/elevenlabs/workspace/members/__init__.py | 7 + src/elevenlabs/workspace/members/client.py | 221 + .../workspace/members/raw_client.py | 288 + .../workspace/members/types/__init__.py | 9 + ...1_workspace_members_post_workspace_role.py | 0 src/elevenlabs/workspace/raw_client.py | 13 + .../workspace/resources/__init__.py | 7 + src/elevenlabs/workspace/resources/client.py | 407 ++ .../workspace/resources/raw_client.py | 483 ++ .../workspace/resources/types/__init__.py | 9 + ...e_resources_resource_id_share_post_role.py | 0 src/elevenlabs/workspace/types/__init__.py | 17 - 779 files changed, 45800 insertions(+), 27154 deletions(-) create mode 100644 .mock/definition/conversationalAi/agents/link.yml create mode 100644 .mock/definition/conversationalAi/agents/widget.yml create mode 100644 .mock/definition/conversationalAi/agents/widget/avatar.yml create mode 100644 .mock/definition/conversationalAi/batchCalls.yml create mode 100644 .mock/definition/conversationalAi/conversations.yml create mode 100644 .mock/definition/conversationalAi/conversations/audio.yml create mode 100644 .mock/definition/conversationalAi/conversations/feedback.yml create mode 100644 .mock/definition/conversationalAi/dashboard/settings.yml create mode 100644 .mock/definition/conversationalAi/knowledgeBase.yml create mode 100644 .mock/definition/conversationalAi/knowledgeBase/documents.yml create mode 100644 .mock/definition/conversationalAi/knowledgeBase/documents/chunk.yml create mode 100644 .mock/definition/conversationalAi/phoneNumbers.yml create mode 100644 .mock/definition/conversationalAi/secrets.yml create mode 100644 .mock/definition/conversationalAi/settings.yml create mode 100644 .mock/definition/conversationalAi/twilio.yml create mode 100644 .mock/definition/dubbing/audio.yml create mode 100644 .mock/definition/dubbing/resource.yml create mode 100644 .mock/definition/dubbing/resource/language.yml create mode 100644 .mock/definition/dubbing/resource/segment.yml rename .mock/definition/dubbing/{ => resource}/speaker.yml (98%) rename .mock/definition/dubbing/{ => resource}/speaker/segment.yml (97%) create mode 100644 .mock/definition/dubbing/transcript.yml rename .mock/definition/{pronunciationDictionary.yml => pronunciationDictionaries.yml} (71%) create mode 100644 .mock/definition/pronunciationDictionaries/rules.yml rename .mock/definition/studio/{ => projects}/chapters.yml (66%) create mode 100644 .mock/definition/studio/projects/chapters/snapshots.yml create mode 100644 .mock/definition/studio/projects/content.yml create mode 100644 .mock/definition/studio/projects/pronunciationDictionaries.yml create mode 100644 .mock/definition/studio/projects/snapshots.yml create mode 100644 .mock/definition/user/subscription.yml create mode 100644 .mock/definition/voices/ivc.yml create mode 100644 .mock/definition/voices/samples/audio.yml create mode 100644 .mock/definition/voices/settings.yml delete mode 100644 .mock/definition/workspace.yml create mode 100644 .mock/definition/workspace/groups.yml create mode 100644 .mock/definition/workspace/groups/members.yml create mode 100644 .mock/definition/workspace/invites.yml create mode 100644 .mock/definition/workspace/members.yml create mode 100644 .mock/definition/workspace/resources.yml create mode 100644 src/elevenlabs/audio_isolation/raw_client.py delete mode 100644 src/elevenlabs/audio_isolation/types/audio_isolation_audio_isolation_request_file_format.py delete mode 100644 src/elevenlabs/audio_isolation/types/audio_isolation_audio_isolation_stream_request_file_format.py create mode 100644 src/elevenlabs/audio_isolation/types/audio_isolation_convert_request_file_format.py create mode 100644 src/elevenlabs/audio_isolation/types/audio_isolation_stream_request_file_format.py create mode 100644 src/elevenlabs/audio_native/raw_client.py rename src/elevenlabs/{dubbing/speaker/segment => conversational_ai/agents/link}/__init__.py (76%) create mode 100644 src/elevenlabs/conversational_ai/agents/link/client.py create mode 100644 src/elevenlabs/conversational_ai/agents/link/raw_client.py create mode 100644 src/elevenlabs/conversational_ai/agents/raw_client.py create mode 100644 src/elevenlabs/conversational_ai/agents/widget/__init__.py rename src/elevenlabs/{studio/chapters => conversational_ai/agents/widget/avatar}/__init__.py (76%) create mode 100644 src/elevenlabs/conversational_ai/agents/widget/avatar/client.py create mode 100644 src/elevenlabs/conversational_ai/agents/widget/avatar/raw_client.py create mode 100644 src/elevenlabs/conversational_ai/agents/widget/client.py create mode 100644 src/elevenlabs/conversational_ai/agents/widget/raw_client.py create mode 100644 src/elevenlabs/conversational_ai/batch_calls/__init__.py create mode 100644 src/elevenlabs/conversational_ai/batch_calls/client.py create mode 100644 src/elevenlabs/conversational_ai/batch_calls/raw_client.py create mode 100644 src/elevenlabs/conversational_ai/conversations/__init__.py create mode 100644 src/elevenlabs/conversational_ai/conversations/audio/__init__.py create mode 100644 src/elevenlabs/conversational_ai/conversations/audio/client.py create mode 100644 src/elevenlabs/conversational_ai/conversations/audio/raw_client.py create mode 100644 src/elevenlabs/conversational_ai/conversations/client.py create mode 100644 src/elevenlabs/conversational_ai/conversations/feedback/__init__.py create mode 100644 src/elevenlabs/conversational_ai/conversations/feedback/client.py create mode 100644 src/elevenlabs/conversational_ai/conversations/feedback/raw_client.py create mode 100644 src/elevenlabs/conversational_ai/conversations/raw_client.py create mode 100644 src/elevenlabs/conversational_ai/dashboard/__init__.py create mode 100644 src/elevenlabs/conversational_ai/dashboard/client.py create mode 100644 src/elevenlabs/conversational_ai/dashboard/raw_client.py create mode 100644 src/elevenlabs/conversational_ai/dashboard/settings/__init__.py create mode 100644 src/elevenlabs/conversational_ai/dashboard/settings/client.py create mode 100644 src/elevenlabs/conversational_ai/dashboard/settings/raw_client.py create mode 100644 src/elevenlabs/conversational_ai/dashboard/settings/types/__init__.py rename src/elevenlabs/conversational_ai/{ => dashboard/settings}/types/patch_conv_ai_dashboard_settings_request_charts_item.py (91%) create mode 100644 src/elevenlabs/conversational_ai/knowledge_base/document/raw_client.py create mode 100644 src/elevenlabs/conversational_ai/knowledge_base/documents/__init__.py create mode 100644 src/elevenlabs/conversational_ai/knowledge_base/documents/chunk/__init__.py create mode 100644 src/elevenlabs/conversational_ai/knowledge_base/documents/chunk/client.py create mode 100644 src/elevenlabs/conversational_ai/knowledge_base/documents/chunk/raw_client.py create mode 100644 src/elevenlabs/conversational_ai/knowledge_base/documents/client.py create mode 100644 src/elevenlabs/conversational_ai/knowledge_base/documents/raw_client.py create mode 100644 src/elevenlabs/conversational_ai/knowledge_base/documents/types/__init__.py rename src/elevenlabs/conversational_ai/{types/conversational_ai_update_knowledge_base_document_response.py => knowledge_base/documents/types/documents_get_response.py} (65%) rename src/elevenlabs/conversational_ai/{types/conversational_ai_get_knowledge_base_document_by_id_response.py => knowledge_base/documents/types/documents_update_response.py} (65%) create mode 100644 src/elevenlabs/conversational_ai/knowledge_base/raw_client.py create mode 100644 src/elevenlabs/conversational_ai/phone_numbers/__init__.py create mode 100644 src/elevenlabs/conversational_ai/phone_numbers/client.py create mode 100644 src/elevenlabs/conversational_ai/phone_numbers/raw_client.py create mode 100644 src/elevenlabs/conversational_ai/phone_numbers/types/__init__.py rename src/elevenlabs/conversational_ai/{types/conversational_ai_create_phone_number_request_body.py => phone_numbers/types/phone_numbers_create_request_body.py} (65%) rename src/elevenlabs/conversational_ai/{types/conversational_ai_get_phone_number_response.py => phone_numbers/types/phone_numbers_get_response.py} (64%) rename src/elevenlabs/conversational_ai/{types/conversational_ai_update_phone_number_response.py => phone_numbers/types/phone_numbers_list_response_item.py} (64%) rename src/elevenlabs/conversational_ai/{types/conversational_ai_get_phone_numbers_response_item.py => phone_numbers/types/phone_numbers_update_response.py} (63%) create mode 100644 src/elevenlabs/conversational_ai/raw_client.py create mode 100644 src/elevenlabs/conversational_ai/secrets/__init__.py create mode 100644 src/elevenlabs/conversational_ai/secrets/client.py create mode 100644 src/elevenlabs/conversational_ai/secrets/raw_client.py create mode 100644 src/elevenlabs/conversational_ai/settings/__init__.py create mode 100644 src/elevenlabs/conversational_ai/settings/client.py create mode 100644 src/elevenlabs/conversational_ai/settings/raw_client.py create mode 100644 src/elevenlabs/conversational_ai/sip_trunk/raw_client.py create mode 100644 src/elevenlabs/conversational_ai/twilio/__init__.py create mode 100644 src/elevenlabs/conversational_ai/twilio/client.py create mode 100644 src/elevenlabs/conversational_ai/twilio/raw_client.py delete mode 100644 src/elevenlabs/conversational_ai/types/__init__.py create mode 100644 src/elevenlabs/core/force_multipart.py create mode 100644 src/elevenlabs/core/http_response.py create mode 100644 src/elevenlabs/dubbing/audio/__init__.py create mode 100644 src/elevenlabs/dubbing/audio/client.py create mode 100644 src/elevenlabs/dubbing/audio/raw_client.py create mode 100644 src/elevenlabs/dubbing/raw_client.py create mode 100644 src/elevenlabs/dubbing/resource/__init__.py create mode 100644 src/elevenlabs/dubbing/resource/client.py create mode 100644 src/elevenlabs/dubbing/resource/language/__init__.py create mode 100644 src/elevenlabs/dubbing/resource/language/client.py create mode 100644 src/elevenlabs/dubbing/resource/language/raw_client.py create mode 100644 src/elevenlabs/dubbing/resource/raw_client.py create mode 100644 src/elevenlabs/dubbing/resource/segment/__init__.py create mode 100644 src/elevenlabs/dubbing/resource/segment/client.py create mode 100644 src/elevenlabs/dubbing/resource/segment/raw_client.py rename src/elevenlabs/dubbing/{ => resource}/speaker/__init__.py (84%) create mode 100644 src/elevenlabs/dubbing/resource/speaker/client.py rename src/elevenlabs/dubbing/{speaker/client.py => resource/speaker/raw_client.py} (68%) create mode 100644 src/elevenlabs/dubbing/resource/speaker/segment/__init__.py create mode 100644 src/elevenlabs/dubbing/resource/speaker/segment/client.py rename src/elevenlabs/dubbing/{speaker/segment/client.py => resource/speaker/segment/raw_client.py} (72%) create mode 100644 src/elevenlabs/dubbing/transcript/__init__.py create mode 100644 src/elevenlabs/dubbing/transcript/client.py create mode 100644 src/elevenlabs/dubbing/transcript/raw_client.py create mode 100644 src/elevenlabs/dubbing/transcript/types/__init__.py create mode 100644 src/elevenlabs/dubbing/transcript/types/transcript_get_transcript_for_dub_request_format_type.py delete mode 100644 src/elevenlabs/dubbing/types/__init__.py delete mode 100644 src/elevenlabs/dubbing/types/dubbing_get_transcript_for_dub_request_format_type.py create mode 100644 src/elevenlabs/forced_alignment/raw_client.py create mode 100644 src/elevenlabs/history/raw_client.py delete mode 100644 src/elevenlabs/history/types/history_get_all_request_source.py create mode 100644 src/elevenlabs/history/types/history_list_request_source.py create mode 100644 src/elevenlabs/models/raw_client.py rename src/elevenlabs/{pronunciation_dictionary => pronunciation_dictionaries}/__init__.py (70%) create mode 100644 src/elevenlabs/pronunciation_dictionaries/client.py rename src/elevenlabs/{pronunciation_dictionary/client.py => pronunciation_dictionaries/raw_client.py} (50%) create mode 100644 src/elevenlabs/pronunciation_dictionaries/rules/__init__.py create mode 100644 src/elevenlabs/pronunciation_dictionaries/rules/client.py create mode 100644 src/elevenlabs/pronunciation_dictionaries/rules/raw_client.py create mode 100644 src/elevenlabs/pronunciation_dictionaries/rules/types/__init__.py rename src/elevenlabs/{pronunciation_dictionary => pronunciation_dictionaries/rules}/types/pronunciation_dictionary_rule.py (88%) rename src/elevenlabs/{pronunciation_dictionary => pronunciation_dictionaries}/types/__init__.py (63%) rename src/elevenlabs/{pronunciation_dictionary => pronunciation_dictionaries}/types/body_add_a_pronunciation_dictionary_v_1_pronunciation_dictionaries_add_from_rules_post_rules_item.py (93%) rename src/elevenlabs/{pronunciation_dictionary => pronunciation_dictionaries}/types/body_add_a_pronunciation_dictionary_v_1_pronunciation_dictionaries_add_from_rules_post_workspace_access.py (100%) rename src/elevenlabs/{pronunciation_dictionary/types/pronunciation_dictionary_add_from_file_request_workspace_access.py => pronunciation_dictionaries/types/pronunciation_dictionaries_create_from_file_request_workspace_access.py} (64%) rename src/elevenlabs/{pronunciation_dictionary/types/pronunciation_dictionary_get_all_request_sort.py => pronunciation_dictionaries/types/pronunciation_dictionaries_list_request_sort.py} (67%) delete mode 100644 src/elevenlabs/realtime_tts.py create mode 100644 src/elevenlabs/samples/raw_client.py create mode 100644 src/elevenlabs/speech_to_speech/raw_client.py delete mode 100644 src/elevenlabs/speech_to_speech/types/speech_to_speech_convert_as_stream_request_file_format.py create mode 100644 src/elevenlabs/speech_to_speech/types/speech_to_speech_stream_request_file_format.py rename src/elevenlabs/{text_to_speech/types/text_to_speech_convert_as_stream_request_output_format.py => speech_to_speech/types/speech_to_speech_stream_request_output_format.py} (89%) create mode 100644 src/elevenlabs/speech_to_text/raw_client.py delete mode 100644 src/elevenlabs/studio/chapters/client.py create mode 100644 src/elevenlabs/studio/projects/chapters/__init__.py create mode 100644 src/elevenlabs/studio/projects/chapters/client.py create mode 100644 src/elevenlabs/studio/projects/chapters/raw_client.py create mode 100644 src/elevenlabs/studio/projects/chapters/snapshots/__init__.py create mode 100644 src/elevenlabs/studio/projects/chapters/snapshots/client.py create mode 100644 src/elevenlabs/studio/projects/chapters/snapshots/raw_client.py create mode 100644 src/elevenlabs/studio/projects/content/__init__.py create mode 100644 src/elevenlabs/studio/projects/content/client.py create mode 100644 src/elevenlabs/studio/projects/content/raw_client.py create mode 100644 src/elevenlabs/studio/projects/pronunciation_dictionaries/__init__.py create mode 100644 src/elevenlabs/studio/projects/pronunciation_dictionaries/client.py create mode 100644 src/elevenlabs/studio/projects/pronunciation_dictionaries/raw_client.py create mode 100644 src/elevenlabs/studio/projects/raw_client.py create mode 100644 src/elevenlabs/studio/projects/snapshots/__init__.py create mode 100644 src/elevenlabs/studio/projects/snapshots/client.py create mode 100644 src/elevenlabs/studio/projects/snapshots/raw_client.py delete mode 100644 src/elevenlabs/studio/projects/types/projects_add_request_fiction.py delete mode 100644 src/elevenlabs/studio/projects/types/projects_add_request_source_type.py rename src/elevenlabs/studio/projects/types/{projects_add_request_apply_text_normalization.py => projects_create_request_apply_text_normalization.py} (71%) create mode 100644 src/elevenlabs/studio/projects/types/projects_create_request_fiction.py create mode 100644 src/elevenlabs/studio/projects/types/projects_create_request_source_type.py rename src/elevenlabs/studio/projects/types/{projects_add_request_target_audience.py => projects_create_request_target_audience.py} (75%) create mode 100644 src/elevenlabs/studio/raw_client.py create mode 100644 src/elevenlabs/text_to_sound_effects/raw_client.py create mode 100644 src/elevenlabs/text_to_speech/raw_client.py rename src/elevenlabs/{speech_to_speech/types/speech_to_speech_convert_as_stream_request_output_format.py => text_to_speech/types/text_to_speech_stream_request_output_format.py} (89%) create mode 100644 src/elevenlabs/text_to_voice/raw_client.py create mode 100644 src/elevenlabs/types/batch_call_response.py create mode 100644 src/elevenlabs/types/conv_ai_dynamic_variable.py create mode 100644 src/elevenlabs/types/conversation_config_override.py create mode 100644 src/elevenlabs/types/conversation_config_override_config.py create mode 100644 src/elevenlabs/types/conversation_history_transcript_common_model_input_source_medium.py create mode 100644 src/elevenlabs/types/conversation_history_transcript_common_model_output_source_medium.py create mode 100644 src/elevenlabs/types/outbound_call_recipient.py delete mode 100644 src/elevenlabs/types/stream_input_query_parameters.py delete mode 100644 src/elevenlabs/types/stream_input_query_parameters_optimize_streaming_latency.py create mode 100644 src/elevenlabs/types/workspace_batch_calls_response.py create mode 100644 src/elevenlabs/usage/raw_client.py create mode 100644 src/elevenlabs/user/raw_client.py create mode 100644 src/elevenlabs/user/subscription/__init__.py create mode 100644 src/elevenlabs/user/subscription/client.py create mode 100644 src/elevenlabs/user/subscription/raw_client.py delete mode 100644 src/elevenlabs/v_1_text_to_speech_voice_id_multi_stream_input/types/text_to_speech_apply_text_normalization.py delete mode 100644 src/elevenlabs/v_1_text_to_speech_voice_id_multi_stream_input/types/text_to_speech_output_format.py create mode 100644 src/elevenlabs/voices/ivc/__init__.py create mode 100644 src/elevenlabs/voices/ivc/client.py create mode 100644 src/elevenlabs/voices/ivc/raw_client.py create mode 100644 src/elevenlabs/voices/pvc/raw_client.py create mode 100644 src/elevenlabs/voices/pvc/samples/audio/raw_client.py create mode 100644 src/elevenlabs/voices/pvc/samples/raw_client.py create mode 100644 src/elevenlabs/voices/pvc/samples/speakers/audio/raw_client.py create mode 100644 src/elevenlabs/voices/pvc/samples/speakers/raw_client.py create mode 100644 src/elevenlabs/voices/pvc/samples/waveform/raw_client.py create mode 100644 src/elevenlabs/voices/pvc/verification/captcha/raw_client.py create mode 100644 src/elevenlabs/voices/pvc/verification/raw_client.py create mode 100644 src/elevenlabs/voices/raw_client.py create mode 100644 src/elevenlabs/voices/samples/__init__.py create mode 100644 src/elevenlabs/voices/samples/audio/__init__.py create mode 100644 src/elevenlabs/voices/samples/audio/client.py create mode 100644 src/elevenlabs/voices/samples/audio/raw_client.py create mode 100644 src/elevenlabs/voices/samples/client.py create mode 100644 src/elevenlabs/voices/samples/raw_client.py create mode 100644 src/elevenlabs/voices/settings/__init__.py create mode 100644 src/elevenlabs/voices/settings/client.py create mode 100644 src/elevenlabs/voices/settings/raw_client.py delete mode 100644 src/elevenlabs/webhooks.py create mode 100644 src/elevenlabs/workspace/groups/__init__.py create mode 100644 src/elevenlabs/workspace/groups/client.py create mode 100644 src/elevenlabs/workspace/groups/members/__init__.py create mode 100644 src/elevenlabs/workspace/groups/members/client.py create mode 100644 src/elevenlabs/workspace/groups/members/raw_client.py create mode 100644 src/elevenlabs/workspace/groups/raw_client.py create mode 100644 src/elevenlabs/workspace/invites/__init__.py create mode 100644 src/elevenlabs/workspace/invites/client.py create mode 100644 src/elevenlabs/workspace/invites/raw_client.py create mode 100644 src/elevenlabs/workspace/invites/types/__init__.py rename src/elevenlabs/workspace/{ => invites}/types/body_invite_user_v_1_workspace_invites_add_post_workspace_permission.py (100%) create mode 100644 src/elevenlabs/workspace/members/__init__.py create mode 100644 src/elevenlabs/workspace/members/client.py create mode 100644 src/elevenlabs/workspace/members/raw_client.py create mode 100644 src/elevenlabs/workspace/members/types/__init__.py rename src/elevenlabs/workspace/{ => members}/types/body_update_member_v_1_workspace_members_post_workspace_role.py (100%) create mode 100644 src/elevenlabs/workspace/raw_client.py create mode 100644 src/elevenlabs/workspace/resources/__init__.py create mode 100644 src/elevenlabs/workspace/resources/client.py create mode 100644 src/elevenlabs/workspace/resources/raw_client.py create mode 100644 src/elevenlabs/workspace/resources/types/__init__.py rename src/elevenlabs/workspace/{ => resources}/types/body_share_workspace_resource_v_1_workspace_resources_resource_id_share_post_role.py (100%) delete mode 100644 src/elevenlabs/workspace/types/__init__.py diff --git a/.gitignore b/.gitignore index 0da665fe..d2e4ca80 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ -dist/ .mypy_cache/ +.ruff_cache/ __pycache__/ +dist/ poetry.toml -.ruff_cache/ diff --git a/.mock/asyncapi.yml b/.mock/asyncapi.yml index 8d0a49ff..7ea19b93 100644 --- a/.mock/asyncapi.yml +++ b/.mock/asyncapi.yml @@ -39,7 +39,48 @@ channels: bindings: ws: query: - $ref: '#/components/schemas/StreamInputQueryParameters' + type: object + properties: + authorization: + description: Your authorization bearer token. + type: string + model_id: + description: The model ID to use. + type: string + language_code: + description: The ISO 639-1 language code (for specific models). + type: string + enable_logging: + description: Whether to enable logging of the request. + type: boolean + default: true + enable_ssml_parsing: + description: Whether to enable SSML parsing. + type: boolean + default: false + output_format: + $ref: '#/components/schemas/TextToSpeechOutputFormatEnum' + inactivity_timeout: + description: Timeout for inactivity before a context is closed (seconds), can be up to 180 seconds. + type: integer + default: 20 + sync_alignment: + description: Whether to include timing data with every audio chunk. + type: boolean + default: false + auto_mode: + description: Reduces latency by disabling chunk schedule and buffers. Recommended for full sentences/phrases. + type: boolean + default: false + apply_text_normalization: + $ref: '#/components/schemas/TextToSpeechApplyTextNormalizationEnum' + seed: + description: If specified, system will best-effort sample deterministically. Integer between 0 and 4294967295. + type: integer + minimum: 0 + maximum: 4294967295 + example: 12345 + publish: description: Send messages to the WebSocket operationId: sendMessage @@ -813,50 +854,3 @@ components: 'opus_48000_192', ] default: 'mp3_44100' - StreamInputQueryParameters: - type: object - properties: - model_id: - description: The model ID to use - type: string - language_code: - description: The ISO 639-1 language code (for Turbo v2.5 and Flash v2.5 models only) - type: string - enable_logging: - description: Whether to enable logging of the request - type: string - enable_ssml_parsing: - description: Whether to enable SSML parsing - type: boolean - default: false - optimize_streaming_latency: - description: Latency optimization level (deprecated) - type: string - enum: ['0', '1', '2', '3', '4'] - default: '0' - deprecated: true - output_format: - $ref: '#/components/schemas/TextToSpeechOutputFormatEnum' - inactivity_timeout: - description: Timeout for inactivity before connection is closed - type: number - default: 20 - sync_alignment: - description: Whether to include timing data with every audio chunk - type: boolean - default: false - auto_mode: - description: This parameter focuses on reducing the latency by disabling the chunk schedule and all buffers. It is only recommended when sending full sentences or phrases, sending partial phrases will result in highly reduced quality. By default it's set to false. - type: boolean - default: false - apply_text_normalization: - $ref: '#/components/schemas/TextToSpeechApplyTextNormalizationEnum' - seed: - description: >- - If specified, our system will make a best effort to sample deterministically, such that repeated requests - with the same seed and parameters should return the same result. Determinism is not guaranteed. Must be an - integer between 0 and 4294967295. - type: integer - minimum: 0 - maximum: 4294967295 - example: 12345 diff --git a/.mock/definition/__package__.yml b/.mock/definition/__package__.yml index 56345ae7..5fd13805 100644 --- a/.mock/definition/__package__.yml +++ b/.mock/definition/__package__.yml @@ -573,6 +573,8 @@ types: properties: id: string phone_number_id: string + phone_provider: + type: optional name: string agent_id: string created_at_unix: integer @@ -590,12 +592,31 @@ types: BatchCallRecipientStatus: enum: - pending + - initiated - in_progress - completed - failed - cancelled source: openapi: openapi.json + BatchCallResponse: + properties: + id: string + phone_number_id: string + phone_provider: + type: optional + name: string + agent_id: string + created_at_unix: integer + scheduled_time_unix: integer + total_calls_dispatched: integer + total_calls_scheduled: integer + last_updated_at_unix: integer + status: + type: BatchCallStatus + agent_name: string + source: + openapi: openapi.json BatchCallStatus: enum: - pending @@ -1542,6 +1563,12 @@ types: docs: Configuration for dynamic variables source: openapi: openapi.json + ConvAiDynamicVariable: + docs: Used to reference a dynamic variable. + properties: + variable_name: string + source: + openapi: openapi.json ConvAiSecretLocator: docs: Used to reference a secret from the agent's secret store. properties: @@ -1611,6 +1638,12 @@ types: openapi: openapi.json ConversationConfig: properties: + text_only: + type: optional + docs: >- + If enabled audio will not be processed and only text will be used, use + to avoid audio pricing. + default: false max_duration_seconds: type: optional docs: The maximum duration of a conversation in seconds @@ -1628,6 +1661,9 @@ types: tts: type: optional docs: The overrides for the TTS configuration + conversation: + type: optional + docs: The overrides for the conversation configuration source: openapi: openapi.json ConversationConfigClientOverrideOutput: @@ -1638,6 +1674,9 @@ types: tts: type: optional docs: The overrides for the TTS configuration + conversation: + type: optional + docs: The overrides for the conversation configuration source: openapi: openapi.json ConversationConfigClientOverrideConfigInput: @@ -1648,6 +1687,9 @@ types: tts: type: optional docs: Overrides for the TTS configuration + conversation: + type: optional + docs: Overrides for the conversation configuration source: openapi: openapi.json ConversationConfigClientOverrideConfigOutput: @@ -1658,6 +1700,23 @@ types: tts: type: optional docs: Overrides for the TTS configuration + conversation: + type: optional + docs: Overrides for the conversation configuration + source: + openapi: openapi.json + ConversationConfigOverride: + properties: + text_only: + type: optional + source: + openapi: openapi.json + ConversationConfigOverrideConfig: + properties: + text_only: + type: optional + docs: Whether to allow overriding the text only configuration + default: false source: openapi: openapi.json ConversationDeletionSettings: @@ -1795,6 +1854,13 @@ types: inline: true source: openapi: openapi.json + ConversationHistoryTranscriptCommonModelInputSourceMedium: + enum: + - audio + - text + inline: true + source: + openapi: openapi.json ConversationHistoryTranscriptCommonModelInput: properties: role: @@ -1809,6 +1875,8 @@ types: type: optional llm_override: type: optional + source_medium: + type: optional time_in_call_secs: integer conversation_turn_metrics: type: optional @@ -1816,6 +1884,11 @@ types: type: optional llm_usage: type: optional + interrupted: + type: optional + default: false + original_message: + type: optional source: openapi: openapi.json ConversationHistoryTranscriptCommonModelOutputRole: @@ -1825,6 +1898,13 @@ types: inline: true source: openapi: openapi.json + ConversationHistoryTranscriptCommonModelOutputSourceMedium: + enum: + - audio + - text + inline: true + source: + openapi: openapi.json ConversationHistoryTranscriptCommonModelOutput: properties: role: @@ -1839,6 +1919,8 @@ types: type: optional llm_override: type: optional + source_medium: + type: optional time_in_call_secs: integer conversation_turn_metrics: type: optional @@ -1846,6 +1928,11 @@ types: type: optional llm_usage: type: optional + interrupted: + type: optional + default: false + original_message: + type: optional source: openapi: openapi.json ConversationHistoryTranscriptToolCallClientDetails: @@ -2060,6 +2147,7 @@ types: openapi: openapi.json ConversationSummaryResponseModelStatus: enum: + - initiated - value: in-progress name: InProgress - processing @@ -3033,6 +3121,10 @@ types: type: optional webhooks: type: optional + can_use_mcp_servers: + type: optional + docs: Whether the workspace can use MCP servers + default: false rag_retention_period_days: type: optional default: 10 @@ -3042,6 +3134,7 @@ types: openapi: openapi.json GetConversationResponseModelStatus: enum: + - initiated - value: in-progress name: InProgress - processing @@ -3673,7 +3766,10 @@ types: docs: The number of times the voice has been cloned. rate: type: optional - docs: The rate of the voice. + docs: The rate multiplier of the voice. + fiat_rate: + type: optional + docs: The rate of the voice in USD per 1000 credits. null if default free_users_allowed: type: boolean docs: Whether free users are allowed to use the voice. @@ -4027,6 +4123,15 @@ types: default: '#9ce6e6' source: openapi: openapi.json + OutboundCallRecipient: + properties: + id: + type: optional + phone_number: string + conversation_initiation_client_data: + type: optional + source: + openapi: openapi.json OutboundCallRecipientResponseModel: properties: id: string @@ -5056,6 +5161,7 @@ types: properties: success: boolean message: string + conversation_id: optional sip_call_id: optional source: openapi: openapi.json @@ -5926,6 +6032,7 @@ types: properties: success: boolean message: string + conversation_id: optional callSid: optional source: openapi: openapi.json @@ -6403,6 +6510,9 @@ types: rate: type: optional docs: The rate of the voice sharing. + fiat_rate: + type: optional + docs: The rate of the voice sharing in USD per 1000 credits. notice_period: type: optional docs: The notice period of the voice sharing. @@ -6510,6 +6620,7 @@ types: union: - string - type: ConvAiSecretLocator + - type: ConvAiDynamicVariable source: openapi: openapi.json inline: true @@ -6566,6 +6677,7 @@ types: union: - string - type: ConvAiSecretLocator + - type: ConvAiDynamicVariable source: openapi: openapi.json inline: true @@ -6771,6 +6883,9 @@ types: type: optional docs: Whether to disable the banner default: false + override_link: + type: optional + docs: The override link for the widget mic_muting_enabled: type: optional docs: Whether to enable mic muting @@ -6882,6 +6997,9 @@ types: type: optional docs: Whether to disable the banner default: false + override_link: + type: optional + docs: The override link for the widget mic_muting_enabled: type: optional docs: Whether to enable mic muting @@ -6906,6 +7024,19 @@ types: - end source: openapi: openapi.json + WorkspaceBatchCallsResponse: + properties: + batch_calls: + type: list + next_doc: + type: optional + docs: The next document, used to paginate through the batch calls + has_more: + type: optional + docs: Whether there are more batch calls to paginate through + default: false + source: + openapi: openapi.json WorkspaceGroupByNameResponseModel: properties: name: @@ -7625,71 +7756,3 @@ types: docs: The output audio format source: openapi: asyncapi.yml - StreamInputQueryParametersOptimizeStreamingLatency: - enum: - - value: '0' - name: Zero - - value: '1' - name: One - - value: '2' - name: Two - - value: '3' - name: Three - - value: '4' - name: Four - docs: Latency optimization level (deprecated) - default: '0' - inline: true - source: - openapi: asyncapi.yml - StreamInputQueryParameters: - properties: - model_id: - type: optional - docs: The model ID to use - language_code: - type: optional - docs: >- - The ISO 639-1 language code (for Turbo v2.5 and Flash v2.5 models - only) - enable_logging: - type: optional - docs: Whether to enable logging of the request - enable_ssml_parsing: - type: optional - docs: Whether to enable SSML parsing - default: false - optimize_streaming_latency: - type: optional - docs: Latency optimization level (deprecated) - default: '0' - availability: deprecated - output_format: optional - inactivity_timeout: - type: optional - docs: Timeout for inactivity before connection is closed - default: 20 - sync_alignment: - type: optional - docs: Whether to include timing data with every audio chunk - default: false - auto_mode: - type: optional - docs: >- - This parameter focuses on reducing the latency by disabling the chunk - schedule and all buffers. It is only recommended when sending full - sentences or phrases, sending partial phrases will result in highly - reduced quality. By default it's set to false. - default: false - apply_text_normalization: optional - seed: - type: optional - docs: >- - If specified, our system will make a best effort to sample - deterministically, such that repeated requests with the same seed and - parameters should return the same result. Determinism is not - guaranteed. Must be an integer between 0 and 4294967295. - validation: - min: 0 - source: - openapi: asyncapi.yml diff --git a/.mock/definition/audioIsolation.yml b/.mock/definition/audioIsolation.yml index b1620bd9..f3b53f34 100644 --- a/.mock/definition/audioIsolation.yml +++ b/.mock/definition/audioIsolation.yml @@ -1,12 +1,12 @@ types: - AudioIsolationAudioIsolationRequestFileFormat: + AudioIsolationConvertRequestFileFormat: enum: - pcm_s16le_16 - other inline: true source: openapi: openapi.json - AudioIsolationAudioIsolationStreamRequestFileFormat: + AudioIsolationStreamRequestFileFormat: enum: - pcm_s16le_16 - other @@ -19,7 +19,7 @@ service: auth: false base-path: '' endpoints: - audio_isolation: + convert: path: /v1/audio-isolation method: POST auth: false @@ -35,7 +35,7 @@ service: type: file docs: The audio file from which vocals/speech will be isolated from. file_format: - type: optional + type: optional docs: >- The format of input audio. Options are 'pcm_s16le_16' or 'other' For `pcm_s16le_16`, the input audio must be 16-bit PCM at a @@ -49,7 +49,7 @@ service: status-code: 200 errors: - root.UnprocessableEntityError - audio_isolation_stream: + stream: path: /v1/audio-isolation/stream method: POST auth: false @@ -65,7 +65,7 @@ service: type: file docs: The audio file from which vocals/speech will be isolated from. file_format: - type: optional + type: optional docs: >- The format of input audio. Options are 'pcm_s16le_16' or 'other' For `pcm_s16le_16`, the input audio must be 16-bit PCM at a diff --git a/.mock/definition/audioNative.yml b/.mock/definition/audioNative.yml index e9f03368..fcd4826c 100644 --- a/.mock/definition/audioNative.yml +++ b/.mock/definition/audioNative.yml @@ -138,7 +138,7 @@ service: audio_path: audio/my_project.mp3 audio_url: https://example.com/audio/my_project.mp3 status: ready - update_content: + update: path: /v1/audio-native/{project_id}/content method: POST auth: false diff --git a/.mock/definition/conversationalAi.yml b/.mock/definition/conversationalAi.yml index 5b8d3fc7..c49ff19d 100644 --- a/.mock/definition/conversationalAi.yml +++ b/.mock/definition/conversationalAi.yml @@ -4,1701 +4,69 @@ service: auth: false base-path: '' endpoints: - get_signed_url: - path: /v1/convai/conversation/get-signed-url - method: GET - auth: false - docs: >- - Get a signed url to start a conversation with an agent with an agent - that requires authorization - source: - openapi: openapi.json - display-name: Get Signed Url - request: - name: ConversationalAiGetSignedUrlRequest - query-parameters: - agent_id: - type: string - docs: The id of the agent you're taking the action on. - response: - docs: Successful Response - type: root.ConversationSignedUrlResponseModel - status-code: 200 - errors: - - root.UnprocessableEntityError - examples: - - query-parameters: - agent_id: 21m00Tcm4TlvDq8ikWAM - response: - body: - signed_url: signed_url - audiences: - - convai - twilio_outbound_call: - path: /v1/convai/twilio/outbound-call - method: POST - auth: false - docs: Handle an outbound call via Twilio - source: - openapi: openapi.json - display-name: Handle An Outbound Call Via Twilio - request: - name: BodyHandleAnOutboundCallViaTwilioV1ConvaiTwilioOutboundCallPost - body: - properties: - agent_id: string - agent_phone_number_id: string - to_number: string - conversation_initiation_client_data: - type: optional - content-type: application/json - response: - docs: Successful Response - type: root.TwilioOutboundCallResponse - status-code: 200 - errors: - - root.UnprocessableEntityError - examples: - - request: - agent_id: agent_id - agent_phone_number_id: agent_phone_number_id - to_number: to_number - response: - body: - success: true - message: message - callSid: callSid - audiences: - - convai - create_agent: - path: /v1/convai/agents/create - method: POST - auth: false - docs: Create an agent from a config object - source: - openapi: openapi.json - display-name: Create agent - request: - name: BodyCreateAgentV1ConvaiAgentsCreatePost - body: - properties: - conversation_config: - type: root.ConversationalConfig - docs: Conversation configuration for an agent - platform_settings: - type: optional - docs: >- - Platform settings for the agent are all settings that aren't - related to the conversation orchestration and content. - name: - type: optional - docs: A name to make the agent easier to find - tags: - type: optional> - docs: Tags to help classify and filter the agent - content-type: application/json - response: - docs: Successful Response - type: root.CreateAgentResponseModel - status-code: 200 - errors: - - root.UnprocessableEntityError - examples: - - request: - conversation_config: {} - response: - body: - agent_id: J3Pbu5gP6NNKBscdCdwB - audiences: - - convai - get_agent: - path: /v1/convai/agents/{agent_id} - method: GET - auth: false - docs: Retrieve config for an agent - source: - openapi: openapi.json - path-parameters: - agent_id: - type: string - docs: The id of an agent. This is returned on agent creation. - display-name: Get agent - response: - docs: Successful Response - type: root.GetAgentResponseModel - status-code: 200 - errors: - - root.UnprocessableEntityError - examples: - - path-parameters: - agent_id: 21m00Tcm4TlvDq8ikWAM - response: - body: - agent_id: J3Pbu5gP6NNKBscdCdwB - name: My Agent - conversation_config: - asr: - quality: high - provider: elevenlabs - user_input_audio_format: pcm_16000 - keywords: - - hello - - world - turn: - turn_timeout: 7 - silence_end_call_timeout: -1 - mode: turn - tts: - model_id: eleven_turbo_v2 - voice_id: cjVigY5qzO86Huf0OWal - agent_output_audio_format: pcm_16000 - optimize_streaming_latency: 3 - stability: 0.5 - speed: 1 - similarity_boost: 0.8 - pronunciation_dictionary_locators: - - pronunciation_dictionary_id: pronunciation_dictionary_id - conversation: - max_duration_seconds: 600 - client_events: - - audio - - interruption - language_presets: - key: - overrides: {} - agent: - first_message: Hello, how can I help you today? - language: en - dynamic_variables: - dynamic_variable_placeholders: - user_name: John Doe - prompt: - prompt: >- - You are a helpful assistant that can answer questions - about the topic of the conversation. - llm: gemini-2.0-flash-001 - temperature: 0 - max_tokens: -1 - tools: - - name: name - description: description - expects_response: false - dynamic_variables: - dynamic_variable_placeholders: - user_name: John Doe - type: client - tool_ids: - - tool_ids - knowledge_base: - - type: file - name: My Knowledge Base - id: '123' - usage_mode: auto - metadata: - created_at_unix_secs: 1 - platform_settings: - auth: - enable_auth: true - allowlist: - - hostname: https://example.com - shareable_token: '1234567890' - evaluation: - criteria: - - id: '1234567890' - name: name - conversation_goal_prompt: >- - You are a helpful assistant that can answer questions - about the topic of the conversation. - use_knowledge_base: false - widget: - variant: compact - expandable: never - avatar: - color_1: '#2792dc' - color_2: '#9ce6e6' - type: orb - feedback_mode: none - bg_color: bg_color - text_color: text_color - btn_color: btn_color - btn_text_color: btn_text_color - border_color: border_color - focus_color: focus_color - border_radius: 1 - btn_radius: 1 - action_text: action_text - start_call_text: start_call_text - end_call_text: end_call_text - expand_text: expand_text - listening_text: listening_text - speaking_text: speaking_text - shareable_page_text: shareable_page_text - shareable_page_show_terms: true - terms_text: terms_text - terms_html: terms_html - terms_key: terms_key - show_avatar_when_collapsed: true - disable_banner: true - mic_muting_enabled: true - language_selector: false - custom_avatar_path: https://example.com/avatar.png - data_collection: - key: - type: boolean - description: My property - dynamic_variable: Dynamic variable - constant_value: Constant value - overrides: - conversation_config_override: - agent: - prompt: - prompt: false - first_message: false - language: false - tts: - voice_id: false - custom_llm_extra_body: true - enable_conversation_initiation_client_data_from_webhook: true - call_limits: - agent_concurrency_limit: -1 - daily_limit: 100000 - privacy: - record_voice: true - retention_days: -1 - delete_transcript_and_pii: false - delete_audio: false - apply_to_existing_conversations: false - zero_retention_mode: false - workspace_overrides: - conversation_initiation_client_data_webhook: - url: https://example.com/webhook - request_headers: - Content-Type: application/json - safety: - is_blocked_ivc: true - is_blocked_non_ivc: true - ignore_safety_evaluation: true - phone_numbers: - - phone_number: phone_number - label: label - phone_number_id: X3Pbu5gP6NNKBscdCdwB - assigned_agent: - agent_id: F3Pbu5gP6NNKBscdCdwB - agent_name: My Agent - provider_config: - address: address - transport: auto - media_encryption: disabled - has_auth_credentials: true - provider: sip_trunk - access_info: - is_creator: true - creator_name: John Doe - creator_email: john.doe@example.com - role: admin - tags: - - tags - audiences: - - convai - delete_agent: - path: /v1/convai/agents/{agent_id} - method: DELETE - auth: false - docs: Delete an agent - source: - openapi: openapi.json - path-parameters: - agent_id: - type: string - docs: The id of an agent. This is returned on agent creation. - display-name: Delete agent - errors: - - root.UnprocessableEntityError - examples: - - path-parameters: - agent_id: 21m00Tcm4TlvDq8ikWAM - audiences: - - convai - update_agent: - path: /v1/convai/agents/{agent_id} - method: PATCH - auth: false - docs: Patches an Agent settings - source: - openapi: openapi.json - path-parameters: - agent_id: - type: string - docs: The id of an agent. This is returned on agent creation. - display-name: Update agent - request: - name: UpdateAgentRequest - body: - properties: - conversation_config: - type: optional - platform_settings: - type: optional - name: - type: optional - docs: A name to make the agent easier to find - tags: - type: optional> - docs: Tags to help classify and filter the agent - content-type: application/json - response: - docs: Successful Response - type: root.GetAgentResponseModel - status-code: 200 - errors: - - root.UnprocessableEntityError - examples: - - path-parameters: - agent_id: 21m00Tcm4TlvDq8ikWAM - request: {} - response: - body: - agent_id: J3Pbu5gP6NNKBscdCdwB - name: My Agent - conversation_config: - asr: - quality: high - provider: elevenlabs - user_input_audio_format: pcm_16000 - keywords: - - hello - - world - turn: - turn_timeout: 7 - silence_end_call_timeout: -1 - mode: turn - tts: - model_id: eleven_turbo_v2 - voice_id: cjVigY5qzO86Huf0OWal - agent_output_audio_format: pcm_16000 - optimize_streaming_latency: 3 - stability: 0.5 - speed: 1 - similarity_boost: 0.8 - pronunciation_dictionary_locators: - - pronunciation_dictionary_id: pronunciation_dictionary_id - conversation: - max_duration_seconds: 600 - client_events: - - audio - - interruption - language_presets: - key: - overrides: {} - agent: - first_message: Hello, how can I help you today? - language: en - dynamic_variables: - dynamic_variable_placeholders: - user_name: John Doe - prompt: - prompt: >- - You are a helpful assistant that can answer questions - about the topic of the conversation. - llm: gemini-2.0-flash-001 - temperature: 0 - max_tokens: -1 - tools: - - name: name - description: description - expects_response: false - dynamic_variables: - dynamic_variable_placeholders: - user_name: John Doe - type: client - tool_ids: - - tool_ids - knowledge_base: - - type: file - name: My Knowledge Base - id: '123' - usage_mode: auto - metadata: - created_at_unix_secs: 1 - platform_settings: - auth: - enable_auth: true - allowlist: - - hostname: https://example.com - shareable_token: '1234567890' - evaluation: - criteria: - - id: '1234567890' - name: name - conversation_goal_prompt: >- - You are a helpful assistant that can answer questions - about the topic of the conversation. - use_knowledge_base: false - widget: - variant: compact - expandable: never - avatar: - color_1: '#2792dc' - color_2: '#9ce6e6' - type: orb - feedback_mode: none - bg_color: bg_color - text_color: text_color - btn_color: btn_color - btn_text_color: btn_text_color - border_color: border_color - focus_color: focus_color - border_radius: 1 - btn_radius: 1 - action_text: action_text - start_call_text: start_call_text - end_call_text: end_call_text - expand_text: expand_text - listening_text: listening_text - speaking_text: speaking_text - shareable_page_text: shareable_page_text - shareable_page_show_terms: true - terms_text: terms_text - terms_html: terms_html - terms_key: terms_key - show_avatar_when_collapsed: true - disable_banner: true - mic_muting_enabled: true - language_selector: false - custom_avatar_path: https://example.com/avatar.png - data_collection: - key: - type: boolean - description: My property - dynamic_variable: Dynamic variable - constant_value: Constant value - overrides: - conversation_config_override: - agent: - prompt: - prompt: false - first_message: false - language: false - tts: - voice_id: false - custom_llm_extra_body: true - enable_conversation_initiation_client_data_from_webhook: true - call_limits: - agent_concurrency_limit: -1 - daily_limit: 100000 - privacy: - record_voice: true - retention_days: -1 - delete_transcript_and_pii: false - delete_audio: false - apply_to_existing_conversations: false - zero_retention_mode: false - workspace_overrides: - conversation_initiation_client_data_webhook: - url: https://example.com/webhook - request_headers: - Content-Type: application/json - safety: - is_blocked_ivc: true - is_blocked_non_ivc: true - ignore_safety_evaluation: true - phone_numbers: - - phone_number: phone_number - label: label - phone_number_id: X3Pbu5gP6NNKBscdCdwB - assigned_agent: - agent_id: F3Pbu5gP6NNKBscdCdwB - agent_name: My Agent - provider_config: - address: address - transport: auto - media_encryption: disabled - has_auth_credentials: true - provider: sip_trunk - access_info: - is_creator: true - creator_name: John Doe - creator_email: john.doe@example.com - role: admin - tags: - - tags - audiences: - - convai - get_agent_widget: - path: /v1/convai/agents/{agent_id}/widget - method: GET - auth: false - docs: Retrieve the widget configuration for an agent - source: - openapi: openapi.json - path-parameters: - agent_id: - type: string - docs: The id of an agent. This is returned on agent creation. - display-name: Get Agent Widget Config - request: - name: ConversationalAiGetAgentWidgetRequest - query-parameters: - conversation_signature: - type: optional - docs: >- - An expiring token that enables a websocket conversation to start. - These can be generated for an agent using the - /v1/convai/conversation/get-signed-url endpoint - response: - docs: Successful Response - type: root.GetAgentEmbedResponseModel - status-code: 200 - errors: - - root.UnprocessableEntityError - examples: - - path-parameters: - agent_id: 21m00Tcm4TlvDq8ikWAM - response: - body: - agent_id: agent_id - widget_config: - variant: full - expandable: never - avatar: - color_1: '#2792dc' - color_2: '#9ce6e6' - type: orb - feedback_mode: none - bg_color: '#ffffff' - text_color: '#000000' - btn_color: '#000000' - btn_text_color: '#ffffff' - border_color: '#e1e1e1' - focus_color: '#000000' - border_radius: 10 - btn_radius: 10 - action_text: Call - start_call_text: Start Call - end_call_text: End Call - expand_text: Expand - listening_text: Listening... - speaking_text: Speaking... - shareable_page_text: Share - shareable_page_show_terms: true - terms_text: Terms and Conditions - terms_html:

Terms and Conditions

- terms_key: terms - show_avatar_when_collapsed: true - disable_banner: false - mic_muting_enabled: false - language: language - supported_language_overrides: - - supported_language_overrides - audiences: - - convai - get_agent_link: - path: /v1/convai/agents/{agent_id}/link - method: GET - auth: false - docs: Get the current link used to share the agent with others - source: - openapi: openapi.json - path-parameters: - agent_id: - type: string - docs: The id of an agent. This is returned on agent creation. - display-name: Get Shareable Agent Link - response: - docs: Successful Response - type: root.GetAgentLinkResponseModel - status-code: 200 - errors: - - root.UnprocessableEntityError - examples: - - path-parameters: - agent_id: 21m00Tcm4TlvDq8ikWAM - response: - body: - agent_id: J3Pbu5gP6NNKBscdCdwB - token: - agent_id: J3Pbu5gP6NNKBscdCdwB - conversation_token: '1234567890' - expiration_time_unix_secs: 1716153600 - purpose: signed_url - audiences: - - convai - post_agent_avatar: - path: /v1/convai/agents/{agent_id}/avatar - method: POST - auth: false - docs: Sets the avatar for an agent displayed in the widget - source: - openapi: openapi.json - path-parameters: - agent_id: - type: string - docs: The id of an agent. This is returned on agent creation. - display-name: Post Agent Avatar - request: - name: Body_Post_Agent_avatar_v1_convai_agents__agent_id__avatar_post - body: - properties: - avatar_file: - type: file - docs: An image file to be used as the agent's avatar. - content-type: multipart/form-data - response: - docs: Successful Response - type: root.PostAgentAvatarResponseModel - status-code: 200 - errors: - - root.UnprocessableEntityError - examples: - - path-parameters: - agent_id: 21m00Tcm4TlvDq8ikWAM - request: {} - response: - body: - agent_id: agent_id - avatar_url: avatar_url - audiences: - - convai - get_agents: - path: /v1/convai/agents - method: GET - auth: false - docs: Returns a list of your agents and their metadata. - source: - openapi: openapi.json - display-name: List Agents - request: - name: ConversationalAiGetAgentsRequest - query-parameters: - cursor: - type: optional - docs: Used for fetching next page. Cursor is returned in the response. - page_size: - type: optional - default: 30 - docs: >- - How many Agents to return at maximum. Can not exceed 100, defaults - to 30. - validation: - min: 1 - max: 100 - search: - type: optional - docs: Search by agents name. - response: - docs: Successful Response - type: root.GetAgentsPageResponseModel - status-code: 200 - errors: - - root.UnprocessableEntityError - examples: - - response: - body: - agents: - - agent_id: J3Pbu5gP6NNKBscdCdwB - name: My Agent - tags: - - Customer Support - - Technical Help - - Eleven - created_at_unix_secs: 1716153600 - access_info: - is_creator: true - creator_name: John Doe - creator_email: john.doe@example.com - role: admin - next_cursor: '123' - has_more: false - audiences: - - convai - get_conversations: - path: /v1/convai/conversations - method: GET - auth: false - docs: >- - Get all conversations of agents that user owns. With option to restrict - to a specific agent. - source: - openapi: openapi.json - display-name: List conversations - request: - name: ConversationalAiGetConversationsRequest - query-parameters: - cursor: - type: optional - docs: Used for fetching next page. Cursor is returned in the response. - agent_id: - type: optional - docs: The id of the agent you're taking the action on. - call_successful: - type: optional - docs: The result of the success evaluation - call_start_before_unix: - type: optional - docs: >- - Unix timestamp (in seconds) to filter conversations up to this - start date. - call_start_after_unix: - type: optional - docs: >- - Unix timestamp (in seconds) to filter conversations after to this - start date. - page_size: - type: optional - default: 30 - docs: >- - How many conversations to return at maximum. Can not exceed 100, - defaults to 30. - validation: - min: 1 - max: 100 - response: - docs: Successful Response - type: root.GetConversationsPageResponseModel - status-code: 200 - errors: - - root.UnprocessableEntityError - examples: - - response: - body: - conversations: - - agent_id: agent_id - agent_name: agent_name - conversation_id: conversation_id - start_time_unix_secs: 1 - call_duration_secs: 1 - message_count: 1 - status: in-progress - call_successful: success - next_cursor: next_cursor - has_more: true - audiences: - - convai - get_conversation: - path: /v1/convai/conversations/{conversation_id} - method: GET - auth: false - docs: Get the details of a particular conversation - source: - openapi: openapi.json - path-parameters: - conversation_id: - type: string - docs: The id of the conversation you're taking the action on. - display-name: Get Conversation Details - response: - docs: Successful Response - type: root.GetConversationResponseModel - status-code: 200 - errors: - - root.UnprocessableEntityError - examples: - - path-parameters: - conversation_id: '123' - response: - body: - agent_id: '123' - conversation_id: '123' - status: processing - transcript: - - role: user - message: Hello, how are you? - time_in_call_secs: 10 - metadata: - start_time_unix_secs: 1714423232 - call_duration_secs: 10 - has_audio: true - has_user_audio: true - has_response_audio: true - audiences: - - convai - delete_conversation: - path: /v1/convai/conversations/{conversation_id} - method: DELETE - auth: false - docs: Delete a particular conversation - source: - openapi: openapi.json - path-parameters: - conversation_id: - type: string - docs: The id of the conversation you're taking the action on. - display-name: Delete Conversation - response: - docs: Successful Response - type: unknown - status-code: 200 - errors: - - root.UnprocessableEntityError - examples: - - path-parameters: - conversation_id: 21m00Tcm4TlvDq8ikWAM - response: - body: - key: value - audiences: - - convai - get_conversation_audio: - path: /v1/convai/conversations/{conversation_id}/audio - method: GET - auth: false - docs: Get the audio recording of a particular conversation - source: - openapi: openapi.json - path-parameters: - conversation_id: - type: string - docs: The id of the conversation you're taking the action on. - display-name: Get Conversation Audio - response: - docs: Successful Response - type: file - status-code: 200 - errors: - - root.UnprocessableEntityError - audiences: - - convai - post_conversation_feedback: - path: /v1/convai/conversations/{conversation_id}/feedback - method: POST - auth: false - docs: Send the feedback for the given conversation - source: - openapi: openapi.json - path-parameters: - conversation_id: - type: string - docs: The id of the conversation you're taking the action on. - display-name: Send Conversation Feedback - request: - name: >- - BodySendConversationFeedbackV1ConvaiConversationsConversationIdFeedbackPost - body: - properties: - feedback: - type: root.UserFeedbackScore - docs: >- - Either 'like' or 'dislike' to indicate the feedback for the - conversation. - content-type: application/json - response: - docs: Successful Response - type: unknown - status-code: 200 - errors: - - root.UnprocessableEntityError - examples: - - path-parameters: - conversation_id: 21m00Tcm4TlvDq8ikWAM - request: - feedback: like - response: - body: - key: value - audiences: - - convai - create_phone_number: - path: /v1/convai/phone-numbers/create - method: POST - auth: false - docs: Import Phone Number from provider configuration (Twilio or SIP trunk) - source: - openapi: openapi.json - display-name: Import Phone Number - request: - body: - display-name: Phone Request - type: ConversationalAiCreatePhoneNumberRequestBody - docs: Create Phone Request Information - content-type: application/json - response: - docs: Successful Response - type: root.CreatePhoneNumberResponseModel - status-code: 200 - errors: - - root.UnprocessableEntityError - examples: - - request: - phone_number: phone_number - label: label - sid: sid - token: token - provider: twilio - response: - body: - phone_number_id: phone_number_id - audiences: - - convai - get_phone_number: - path: /v1/convai/phone-numbers/{phone_number_id} - method: GET - auth: false - docs: Retrieve Phone Number details by ID - source: - openapi: openapi.json - path-parameters: - phone_number_id: - type: string - docs: The id of an agent. This is returned on agent creation. - display-name: Get Phone Number - response: - docs: Successful Response - type: ConversationalAiGetPhoneNumberResponse - status-code: 200 - errors: - - root.UnprocessableEntityError - examples: - - path-parameters: - phone_number_id: TeaqRRdTcIfIu2i7BYfT - response: - body: - phone_number: phone_number - label: label - phone_number_id: X3Pbu5gP6NNKBscdCdwB - assigned_agent: - agent_id: F3Pbu5gP6NNKBscdCdwB - agent_name: My Agent - provider: twilio - audiences: - - convai - delete_phone_number: - path: /v1/convai/phone-numbers/{phone_number_id} - method: DELETE - auth: false - docs: Delete Phone Number by ID - source: - openapi: openapi.json - path-parameters: - phone_number_id: - type: string - docs: The id of an agent. This is returned on agent creation. - display-name: Delete Phone Number - response: - docs: Successful Response - type: unknown - status-code: 200 - errors: - - root.UnprocessableEntityError - examples: - - path-parameters: - phone_number_id: TeaqRRdTcIfIu2i7BYfT - response: - body: - key: value - audiences: - - convai - update_phone_number: - path: /v1/convai/phone-numbers/{phone_number_id} - method: PATCH - auth: false - docs: Update Phone Number details by ID - source: - openapi: openapi.json - path-parameters: - phone_number_id: - type: string - docs: The id of an agent. This is returned on agent creation. - display-name: Update Phone Number - request: - name: UpdatePhoneNumberRequest - body: - properties: - agent_id: - type: optional - content-type: application/json - response: - docs: Successful Response - type: ConversationalAiUpdatePhoneNumberResponse - status-code: 200 - errors: - - root.UnprocessableEntityError - examples: - - path-parameters: - phone_number_id: TeaqRRdTcIfIu2i7BYfT - request: {} - response: - body: - phone_number: phone_number - label: label - phone_number_id: X3Pbu5gP6NNKBscdCdwB - assigned_agent: - agent_id: F3Pbu5gP6NNKBscdCdwB - agent_name: My Agent - provider: twilio - audiences: - - convai - get_phone_numbers: - path: /v1/convai/phone-numbers/ - method: GET - auth: false - docs: Retrieve all Phone Numbers - source: - openapi: openapi.json - display-name: List Phone Numbers - response: - docs: Successful Response - type: list - status-code: 200 - errors: - - root.UnprocessableEntityError - examples: - - response: - body: - - phone_number: phone_number - label: label - phone_number_id: X3Pbu5gP6NNKBscdCdwB - assigned_agent: - agent_id: F3Pbu5gP6NNKBscdCdwB - agent_name: My Agent - provider: twilio - audiences: - - convai - get_knowledge_base_list: - path: /v1/convai/knowledge-base - method: GET - auth: false - docs: Get a list of available knowledge base documents - source: - openapi: openapi.json - display-name: Get Knowledge Base List - request: - name: ConversationalAiGetKnowledgeBaseListRequest - query-parameters: - cursor: - type: optional - docs: Used for fetching next page. Cursor is returned in the response. - page_size: - type: optional - default: 30 - docs: >- - How many documents to return at maximum. Can not exceed 100, - defaults to 30. - validation: - min: 1 - max: 100 - search: - type: optional - docs: >- - If specified, the endpoint returns only such knowledge base - documents whose names start with this string. - show_only_owned_documents: - type: optional - default: false - docs: >- - If set to true, the endpoint will return only documents owned by - you (and not shared from somebody else). - types: - type: optional - allow-multiple: true - docs: >- - If present, the endpoint will return only documents of the given - types. - use_typesense: - type: optional - default: false - docs: >- - If set to true, the endpoint will use typesense DB to search for - the documents). - response: - docs: Successful Response - type: root.GetKnowledgeBaseListResponseModel - status-code: 200 - errors: - - root.UnprocessableEntityError - examples: - - response: - body: - documents: - - id: id - name: name - metadata: - created_at_unix_secs: 1 - last_updated_at_unix_secs: 1 - size_bytes: 1 - prompt_injectable: true - access_info: - is_creator: true - creator_name: John Doe - creator_email: john.doe@example.com - role: admin - dependent_agents: - - id: id - name: name - created_at_unix_secs: 1 - access_level: admin - type: available - type: file - next_cursor: next_cursor - has_more: true - audiences: - - convai - add_to_knowledge_base: - path: /v1/convai/knowledge-base - method: POST - auth: false - docs: >- - Upload a file or webpage URL to create a knowledge base document.
- After creating the document, update the agent's knowledge base by - calling [Update - agent](/docs/conversational-ai/api-reference/agents/update-agent). - - source: - openapi: openapi.json - display-name: Add To Knowledge Base - request: - name: Body_Add_to_knowledge_base_v1_convai_knowledge_base_post - body: - properties: - name: - type: optional - docs: A custom, human-readable name for the document. - validation: - minLength: 1 - url: - type: optional - docs: >- - URL to a page of documentation that the agent will have access - to in order to interact with users. - file: - type: optional - docs: >- - Documentation that the agent will have access to in order to - interact with users. - content-type: multipart/form-data - response: - docs: Successful Response - type: root.AddKnowledgeBaseResponseModel - status-code: 200 - availability: deprecated - errors: - - root.UnprocessableEntityError - examples: - - request: {} - response: - body: - id: id - name: name - prompt_injectable: true - create_knowledge_base_url_document: - path: /v1/convai/knowledge-base/url - method: POST - auth: false - docs: >- - Create a knowledge base document generated by scraping the given - webpage. - source: - openapi: openapi.json - display-name: Create Url Document - request: - name: BodyCreateUrlDocumentV1ConvaiKnowledgeBaseUrlPost - body: - properties: - url: - type: string - docs: >- - URL to a page of documentation that the agent will have access - to in order to interact with users. - name: - type: optional - docs: A custom, human-readable name for the document. - validation: - minLength: 1 - content-type: application/json - response: - docs: Successful Response - type: root.AddKnowledgeBaseResponseModel - status-code: 200 - errors: - - root.UnprocessableEntityError - examples: - - request: - url: url - response: - body: - id: id - name: name - prompt_injectable: true - audiences: - - convai - create_knowledge_base_file_document: - path: /v1/convai/knowledge-base/file - method: POST - auth: false - docs: Create a knowledge base document generated form the uploaded file. - source: - openapi: openapi.json - display-name: Create File Document - request: - name: Body_Create_file_document_v1_convai_knowledge_base_file_post - body: - properties: - file: - type: file - docs: >- - Documentation that the agent will have access to in order to - interact with users. - name: - type: optional - docs: A custom, human-readable name for the document. - validation: - minLength: 1 - content-type: multipart/form-data - response: - docs: Successful Response - type: root.AddKnowledgeBaseResponseModel - status-code: 200 - errors: - - root.UnprocessableEntityError - examples: - - request: {} - response: - body: - id: id - name: name - prompt_injectable: true - audiences: - - convai - create_knowledge_base_text_document: - path: /v1/convai/knowledge-base/text + add_to_knowledge_base: + path: /v1/convai/knowledge-base method: POST auth: false - docs: Create a knowledge base document containing the provided text. + docs: >- + Upload a file or webpage URL to create a knowledge base document.
+ After creating the document, update the agent's knowledge base by + calling [Update + agent](/docs/conversational-ai/api-reference/agents/update-agent). + source: openapi: openapi.json - display-name: Create Text Document + display-name: Add To Knowledge Base request: - name: BodyCreateTextDocumentV1ConvaiKnowledgeBaseTextPost + name: Body_Add_to_knowledge_base_v1_convai_knowledge_base_post body: properties: - text: - type: string - docs: Text content to be added to the knowledge base. name: type: optional docs: A custom, human-readable name for the document. validation: minLength: 1 - content-type: application/json + url: + type: optional + docs: >- + URL to a page of documentation that the agent will have access + to in order to interact with users. + file: + type: optional + docs: >- + Documentation that the agent will have access to in order to + interact with users. + content-type: multipart/form-data response: docs: Successful Response type: root.AddKnowledgeBaseResponseModel status-code: 200 + availability: deprecated errors: - root.UnprocessableEntityError examples: - - request: - text: text - response: - body: - id: id - name: name - prompt_injectable: true - audiences: - - convai - get_knowledge_base_document_by_id: - path: /v1/convai/knowledge-base/{documentation_id} - method: GET - auth: false - docs: >- - Get details about a specific documentation making up the agent's - knowledge base - source: - openapi: openapi.json - path-parameters: - documentation_id: - type: string - docs: >- - The id of a document from the knowledge base. This is returned on - document addition. - display-name: Get Documentation From Knowledge Base - response: - docs: Successful Response - type: ConversationalAiGetKnowledgeBaseDocumentByIdResponse - status-code: 200 - errors: - - root.UnprocessableEntityError - examples: - - path-parameters: - documentation_id: 21m00Tcm4TlvDq8ikWAM + - request: {} response: body: id: id name: name - metadata: - created_at_unix_secs: 1 - last_updated_at_unix_secs: 1 - size_bytes: 1 prompt_injectable: true - access_info: - is_creator: true - creator_name: John Doe - creator_email: john.doe@example.com - role: admin - extracted_inner_html: extracted_inner_html - url: url - type: url - audiences: - - convai - delete_knowledge_base_document: - path: /v1/convai/knowledge-base/{documentation_id} - method: DELETE - auth: false - docs: Delete a document from the knowledge base - source: - openapi: openapi.json - path-parameters: - documentation_id: - type: string - docs: >- - The id of a document from the knowledge base. This is returned on - document addition. - display-name: Delete Knowledge Base Document - response: - docs: Successful Response - type: unknown - status-code: 200 - errors: - - root.UnprocessableEntityError - examples: - - path-parameters: - documentation_id: 21m00Tcm4TlvDq8ikWAM - response: - body: - key: value - audiences: - - convai - update_knowledge_base_document: - path: /v1/convai/knowledge-base/{documentation_id} + update_secret: + path: /v1/convai/secrets/{secret_id} method: PATCH auth: false - docs: Update the name of a document - source: - openapi: openapi.json - path-parameters: - documentation_id: - type: string - docs: >- - The id of a document from the knowledge base. This is returned on - document addition. - display-name: Update Document - request: - name: BodyUpdateDocumentV1ConvaiKnowledgeBaseDocumentationIdPatch - body: - properties: - name: - type: string - docs: A custom, human-readable name for the document. - validation: - minLength: 1 - content-type: application/json - response: - docs: Successful Response - type: ConversationalAiUpdateKnowledgeBaseDocumentResponse - status-code: 200 - errors: - - root.UnprocessableEntityError - examples: - - path-parameters: - documentation_id: 21m00Tcm4TlvDq8ikWAM - request: - name: name - response: - body: - id: id - name: name - metadata: - created_at_unix_secs: 1 - last_updated_at_unix_secs: 1 - size_bytes: 1 - prompt_injectable: true - access_info: - is_creator: true - creator_name: John Doe - creator_email: john.doe@example.com - role: admin - extracted_inner_html: extracted_inner_html - url: url - type: url - audiences: - - convai - get_dependent_agents: - path: /v1/convai/knowledge-base/{documentation_id}/dependent-agents - method: GET - auth: false - docs: Get a list of agents depending on this knowledge base document - source: - openapi: openapi.json - path-parameters: - documentation_id: - type: string - docs: >- - The id of a document from the knowledge base. This is returned on - document addition. - display-name: Get Dependent Agents List - request: - name: ConversationalAiGetDependentAgentsRequest - query-parameters: - cursor: - type: optional - docs: Used for fetching next page. Cursor is returned in the response. - page_size: - type: optional - default: 30 - docs: >- - How many documents to return at maximum. Can not exceed 100, - defaults to 30. - validation: - min: 1 - max: 100 - response: - docs: Successful Response - type: root.GetKnowledgeBaseDependentAgentsResponseModel - status-code: 200 - errors: - - root.UnprocessableEntityError - examples: - - path-parameters: - documentation_id: 21m00Tcm4TlvDq8ikWAM - response: - body: - agents: - - id: id - name: name - created_at_unix_secs: 1 - access_level: admin - type: available - next_cursor: next_cursor - has_more: true - audiences: - - convai - get_knowledge_base_document_content: - path: /v1/convai/knowledge-base/{documentation_id}/content - method: GET - auth: false - docs: Get the entire content of a document from the knowledge base - source: - openapi: openapi.json - path-parameters: - documentation_id: - type: string - docs: >- - The id of a document from the knowledge base. This is returned on - document addition. - display-name: Get Document Content - errors: - - root.UnprocessableEntityError - examples: - - path-parameters: - documentation_id: 21m00Tcm4TlvDq8ikWAM - audiences: - - convai - get_knowledge_base_document_part_by_id: - path: /v1/convai/knowledge-base/{documentation_id}/chunk/{chunk_id} - method: GET - auth: false - docs: Get details about a specific documentation part used by RAG. + docs: Update an existing secret for the workspace source: openapi: openapi.json path-parameters: - documentation_id: - type: string - docs: >- - The id of a document from the knowledge base. This is returned on - document addition. - chunk_id: - type: string - docs: The id of a document RAG chunk from the knowledge base. - display-name: Get Documentation Chunk From Knowledge Base - response: - docs: Successful Response - type: root.KnowledgeBaseDocumentChunkResponseModel - status-code: 200 - errors: - - root.UnprocessableEntityError - examples: - - path-parameters: - documentation_id: 21m00Tcm4TlvDq8ikWAM - chunk_id: chunk_id - response: - body: - id: id - name: name - content: content - audiences: - - convai - get_settings: - path: /v1/convai/settings - method: GET - auth: false - docs: Retrieve Convai settings for the workspace - source: - openapi: openapi.json - display-name: Get Convai Settings - response: - docs: Successful Response - type: root.GetConvAiSettingsResponseModel - status-code: 200 - errors: - - root.UnprocessableEntityError - examples: - - response: - body: - conversation_initiation_client_data_webhook: - url: https://example.com/webhook - request_headers: - Content-Type: application/json - webhooks: - post_call_webhook_id: post_call_webhook_id - rag_retention_period_days: 1 - audiences: - - convai - update_settings: - path: /v1/convai/settings - method: PATCH - auth: false - docs: Update Convai settings for the workspace - source: - openapi: openapi.json - display-name: Update Convai Settings - request: - name: PatchConvAiSettingsRequest - body: - properties: - conversation_initiation_client_data_webhook: - type: optional - webhooks: - type: optional - rag_retention_period_days: - type: optional - default: 10 - validation: - max: 30 - content-type: application/json - response: - docs: Successful Response - type: root.GetConvAiSettingsResponseModel - status-code: 200 - errors: - - root.UnprocessableEntityError - examples: - - request: {} - response: - body: - conversation_initiation_client_data_webhook: - url: https://example.com/webhook - request_headers: - Content-Type: application/json - webhooks: - post_call_webhook_id: post_call_webhook_id - rag_retention_period_days: 1 - audiences: - - convai - get_dashboard_settings: - path: /v1/convai/settings/dashboard - method: GET - auth: false - docs: Retrieve Convai dashboard settings for the workspace - source: - openapi: openapi.json - display-name: Get Convai Dashboard Settings - response: - docs: Successful Response - type: root.GetConvAiDashboardSettingsResponseModel - status-code: 200 - errors: - - root.UnprocessableEntityError - examples: - - response: - body: - charts: - - name: name - type: call_success - audiences: - - convai - update_dashboard_settings: - path: /v1/convai/settings/dashboard - method: PATCH - auth: false - docs: Update Convai dashboard settings for the workspace - source: - openapi: openapi.json - display-name: Update Convai Dashboard Settings - request: - name: PatchConvAiDashboardSettingsRequest - body: - properties: - charts: - type: optional> - content-type: application/json - response: - docs: Successful Response - type: root.GetConvAiDashboardSettingsResponseModel - status-code: 200 - errors: - - root.UnprocessableEntityError - examples: - - request: {} - response: - body: - charts: - - name: name - type: call_success - audiences: - - convai - get_secrets: - path: /v1/convai/secrets - method: GET - auth: false - docs: Get all workspace secrets for the user - source: - openapi: openapi.json - display-name: Get Convai Workspace Secrets - response: - docs: Successful Response - type: root.GetWorkspaceSecretsResponseModel - status-code: 200 - errors: - - root.UnprocessableEntityError - examples: - - response: - body: - secrets: - - type: stored - secret_id: secret_id - name: name - used_by: - tools: - - id: id - name: name - created_at_unix_secs: 1 - access_level: admin - type: available - agent_tools: - - agent_id: agent_id - agent_name: agent_name - used_by: - - used_by - created_at_unix_secs: 1 - access_level: admin - type: available - others: - - conversation_initiation_webhook - audiences: - - convai - create_secret: - path: /v1/convai/secrets - method: POST - auth: false - docs: Create a new secret for the workspace - source: - openapi: openapi.json - display-name: Create Convai Workspace Secret + secret_id: string + display-name: Update Convai Workspace Secret request: - name: PostWorkspaceSecretRequest + name: PatchWorkspaceSecretRequest body: properties: type: - type: literal<"new"> + type: literal<"update"> name: string value: string content-type: application/json @@ -1709,8 +77,10 @@ service: errors: - root.UnprocessableEntityError examples: - - request: - type: new + - path-parameters: + secret_id: secret_id + request: + type: update name: name value: value response: @@ -1720,141 +90,5 @@ service: name: name audiences: - convai - delete_secret: - path: /v1/convai/secrets/{secret_id} - method: DELETE - auth: false - docs: Delete a workspace secret if it's not in use - source: - openapi: openapi.json - path-parameters: - secret_id: string - display-name: Delete Convai Workspace Secret - errors: - - root.UnprocessableEntityError - examples: - - path-parameters: - secret_id: secret_id - audiences: - - convai - get_batch_call: - path: /v1/convai/batch-calling/{batch_id} - method: GET - auth: false - docs: Get detailed information about a batch call including all recipients. - source: - openapi: openapi.json - path-parameters: - batch_id: string - display-name: Get A Batch Call By Id. - response: - docs: Successful Response - type: root.BatchCallDetailedResponse - status-code: 200 - errors: - - root.UnprocessableEntityError - examples: - - path-parameters: - batch_id: batch_id - response: - body: - id: id - phone_number_id: phone_number_id - name: name - agent_id: agent_id - created_at_unix: 1 - scheduled_time_unix: 1 - total_calls_dispatched: 1 - total_calls_scheduled: 1 - last_updated_at_unix: 1 - status: pending - agent_name: agent_name - recipients: - - id: id - phone_number: phone_number - status: pending - created_at_unix: 1 - updated_at_unix: 1 - conversation_id: conversation_id - audiences: - - convai source: openapi: openapi.json -types: - ConversationalAiCreatePhoneNumberRequestBody: - discriminant: provider - base-properties: {} - docs: Create Phone Request Information - union: - twilio: - type: root.CreateTwilioPhoneNumberRequest - sip_trunk: - type: root.CreateSipTrunkPhoneNumberRequest - source: - openapi: openapi.json - ConversationalAiGetPhoneNumberResponse: - discriminant: provider - base-properties: {} - union: - twilio: - type: root.GetPhoneNumberTwilioResponseModel - sip_trunk: - type: root.GetPhoneNumberSipTrunkResponseModel - source: - openapi: openapi.json - ConversationalAiUpdatePhoneNumberResponse: - discriminant: provider - base-properties: {} - union: - twilio: - type: root.GetPhoneNumberTwilioResponseModel - sip_trunk: - type: root.GetPhoneNumberSipTrunkResponseModel - source: - openapi: openapi.json - ConversationalAiGetPhoneNumbersResponseItem: - discriminant: provider - base-properties: {} - union: - twilio: - type: root.GetPhoneNumberTwilioResponseModel - sip_trunk: - type: root.GetPhoneNumberSipTrunkResponseModel - source: - openapi: openapi.json - ConversationalAiGetKnowledgeBaseDocumentByIdResponse: - discriminant: type - base-properties: {} - union: - url: - type: root.GetKnowledgeBaseUrlResponseModel - file: - type: root.GetKnowledgeBaseFileResponseModel - text: - type: root.GetKnowledgeBaseTextResponseModel - source: - openapi: openapi.json - ConversationalAiUpdateKnowledgeBaseDocumentResponse: - discriminant: type - base-properties: {} - union: - url: - type: root.GetKnowledgeBaseUrlResponseModel - file: - type: root.GetKnowledgeBaseFileResponseModel - text: - type: root.GetKnowledgeBaseTextResponseModel - source: - openapi: openapi.json - PatchConvAiDashboardSettingsRequestChartsItem: - discriminant: type - base-properties: {} - union: - call_success: - type: root.DashboardCallSuccessChartModel - criteria: - type: root.DashboardCriteriaChartModel - data_collection: - type: root.DashboardDataCollectionChartModel - source: - openapi: openapi.json diff --git a/.mock/definition/conversationalAi/agents.yml b/.mock/definition/conversationalAi/agents.yml index cb311e11..00fcf696 100644 --- a/.mock/definition/conversationalAi/agents.yml +++ b/.mock/definition/conversationalAi/agents.yml @@ -4,6 +4,520 @@ service: auth: false base-path: '' endpoints: + create: + path: /v1/convai/agents/create + method: POST + auth: false + docs: Create an agent from a config object + source: + openapi: openapi.json + display-name: Create agent + request: + name: BodyCreateAgentV1ConvaiAgentsCreatePost + body: + properties: + conversation_config: + type: root.ConversationalConfig + docs: Conversation configuration for an agent + platform_settings: + type: optional + docs: >- + Platform settings for the agent are all settings that aren't + related to the conversation orchestration and content. + name: + type: optional + docs: A name to make the agent easier to find + tags: + type: optional> + docs: Tags to help classify and filter the agent + content-type: application/json + response: + docs: Successful Response + type: root.CreateAgentResponseModel + status-code: 200 + errors: + - root.UnprocessableEntityError + examples: + - request: + conversation_config: {} + response: + body: + agent_id: J3Pbu5gP6NNKBscdCdwB + audiences: + - convai + get: + path: /v1/convai/agents/{agent_id} + method: GET + auth: false + docs: Retrieve config for an agent + source: + openapi: openapi.json + path-parameters: + agent_id: + type: string + docs: The id of an agent. This is returned on agent creation. + display-name: Get agent + response: + docs: Successful Response + type: root.GetAgentResponseModel + status-code: 200 + errors: + - root.UnprocessableEntityError + examples: + - path-parameters: + agent_id: 21m00Tcm4TlvDq8ikWAM + response: + body: + agent_id: J3Pbu5gP6NNKBscdCdwB + name: My Agent + conversation_config: + asr: + quality: high + provider: elevenlabs + user_input_audio_format: pcm_16000 + keywords: + - hello + - world + turn: + turn_timeout: 7 + silence_end_call_timeout: -1 + mode: turn + tts: + model_id: eleven_turbo_v2 + voice_id: cjVigY5qzO86Huf0OWal + agent_output_audio_format: pcm_16000 + optimize_streaming_latency: 3 + stability: 0.5 + speed: 1 + similarity_boost: 0.8 + pronunciation_dictionary_locators: + - pronunciation_dictionary_id: pronunciation_dictionary_id + conversation: + text_only: true + max_duration_seconds: 600 + client_events: + - audio + - interruption + language_presets: + key: + overrides: {} + agent: + first_message: Hello, how can I help you today? + language: en + dynamic_variables: + dynamic_variable_placeholders: + user_name: John Doe + prompt: + prompt: >- + You are a helpful assistant that can answer questions + about the topic of the conversation. + llm: gemini-2.0-flash-001 + temperature: 0 + max_tokens: -1 + tools: + - name: name + description: description + expects_response: false + dynamic_variables: + dynamic_variable_placeholders: + user_name: John Doe + type: client + tool_ids: + - tool_ids + knowledge_base: + - type: file + name: My Knowledge Base + id: '123' + usage_mode: auto + metadata: + created_at_unix_secs: 1 + platform_settings: + auth: + enable_auth: true + allowlist: + - hostname: https://example.com + shareable_token: '1234567890' + evaluation: + criteria: + - id: '1234567890' + name: name + conversation_goal_prompt: >- + You are a helpful assistant that can answer questions + about the topic of the conversation. + use_knowledge_base: false + widget: + variant: compact + expandable: never + avatar: + color_1: '#2792dc' + color_2: '#9ce6e6' + type: orb + feedback_mode: none + bg_color: bg_color + text_color: text_color + btn_color: btn_color + btn_text_color: btn_text_color + border_color: border_color + focus_color: focus_color + border_radius: 1 + btn_radius: 1 + action_text: action_text + start_call_text: start_call_text + end_call_text: end_call_text + expand_text: expand_text + listening_text: listening_text + speaking_text: speaking_text + shareable_page_text: shareable_page_text + shareable_page_show_terms: true + terms_text: terms_text + terms_html: terms_html + terms_key: terms_key + show_avatar_when_collapsed: true + disable_banner: true + override_link: override_link + mic_muting_enabled: true + language_selector: false + custom_avatar_path: https://example.com/avatar.png + data_collection: + key: + type: boolean + description: My property + dynamic_variable: Dynamic variable + constant_value: Constant value + overrides: + conversation_config_override: + agent: + prompt: + prompt: false + first_message: false + language: false + tts: + voice_id: false + conversation: + text_only: false + custom_llm_extra_body: true + enable_conversation_initiation_client_data_from_webhook: true + call_limits: + agent_concurrency_limit: -1 + daily_limit: 100000 + privacy: + record_voice: true + retention_days: -1 + delete_transcript_and_pii: false + delete_audio: false + apply_to_existing_conversations: false + zero_retention_mode: false + workspace_overrides: + conversation_initiation_client_data_webhook: + url: https://example.com/webhook + request_headers: + Content-Type: application/json + safety: + is_blocked_ivc: true + is_blocked_non_ivc: true + ignore_safety_evaluation: true + phone_numbers: + - phone_number: phone_number + label: label + phone_number_id: X3Pbu5gP6NNKBscdCdwB + assigned_agent: + agent_id: F3Pbu5gP6NNKBscdCdwB + agent_name: My Agent + provider_config: + address: address + transport: auto + media_encryption: disabled + has_auth_credentials: true + provider: sip_trunk + access_info: + is_creator: true + creator_name: John Doe + creator_email: john.doe@example.com + role: admin + tags: + - tags + audiences: + - convai + delete: + path: /v1/convai/agents/{agent_id} + method: DELETE + auth: false + docs: Delete an agent + source: + openapi: openapi.json + path-parameters: + agent_id: + type: string + docs: The id of an agent. This is returned on agent creation. + display-name: Delete agent + errors: + - root.UnprocessableEntityError + examples: + - path-parameters: + agent_id: 21m00Tcm4TlvDq8ikWAM + audiences: + - convai + update: + path: /v1/convai/agents/{agent_id} + method: PATCH + auth: false + docs: Patches an Agent settings + source: + openapi: openapi.json + path-parameters: + agent_id: + type: string + docs: The id of an agent. This is returned on agent creation. + display-name: Update agent + request: + name: UpdateAgentRequest + body: + properties: + conversation_config: + type: optional + platform_settings: + type: optional + name: + type: optional + docs: A name to make the agent easier to find + tags: + type: optional> + docs: Tags to help classify and filter the agent + content-type: application/json + response: + docs: Successful Response + type: root.GetAgentResponseModel + status-code: 200 + errors: + - root.UnprocessableEntityError + examples: + - path-parameters: + agent_id: 21m00Tcm4TlvDq8ikWAM + request: {} + response: + body: + agent_id: J3Pbu5gP6NNKBscdCdwB + name: My Agent + conversation_config: + asr: + quality: high + provider: elevenlabs + user_input_audio_format: pcm_16000 + keywords: + - hello + - world + turn: + turn_timeout: 7 + silence_end_call_timeout: -1 + mode: turn + tts: + model_id: eleven_turbo_v2 + voice_id: cjVigY5qzO86Huf0OWal + agent_output_audio_format: pcm_16000 + optimize_streaming_latency: 3 + stability: 0.5 + speed: 1 + similarity_boost: 0.8 + pronunciation_dictionary_locators: + - pronunciation_dictionary_id: pronunciation_dictionary_id + conversation: + text_only: true + max_duration_seconds: 600 + client_events: + - audio + - interruption + language_presets: + key: + overrides: {} + agent: + first_message: Hello, how can I help you today? + language: en + dynamic_variables: + dynamic_variable_placeholders: + user_name: John Doe + prompt: + prompt: >- + You are a helpful assistant that can answer questions + about the topic of the conversation. + llm: gemini-2.0-flash-001 + temperature: 0 + max_tokens: -1 + tools: + - name: name + description: description + expects_response: false + dynamic_variables: + dynamic_variable_placeholders: + user_name: John Doe + type: client + tool_ids: + - tool_ids + knowledge_base: + - type: file + name: My Knowledge Base + id: '123' + usage_mode: auto + metadata: + created_at_unix_secs: 1 + platform_settings: + auth: + enable_auth: true + allowlist: + - hostname: https://example.com + shareable_token: '1234567890' + evaluation: + criteria: + - id: '1234567890' + name: name + conversation_goal_prompt: >- + You are a helpful assistant that can answer questions + about the topic of the conversation. + use_knowledge_base: false + widget: + variant: compact + expandable: never + avatar: + color_1: '#2792dc' + color_2: '#9ce6e6' + type: orb + feedback_mode: none + bg_color: bg_color + text_color: text_color + btn_color: btn_color + btn_text_color: btn_text_color + border_color: border_color + focus_color: focus_color + border_radius: 1 + btn_radius: 1 + action_text: action_text + start_call_text: start_call_text + end_call_text: end_call_text + expand_text: expand_text + listening_text: listening_text + speaking_text: speaking_text + shareable_page_text: shareable_page_text + shareable_page_show_terms: true + terms_text: terms_text + terms_html: terms_html + terms_key: terms_key + show_avatar_when_collapsed: true + disable_banner: true + override_link: override_link + mic_muting_enabled: true + language_selector: false + custom_avatar_path: https://example.com/avatar.png + data_collection: + key: + type: boolean + description: My property + dynamic_variable: Dynamic variable + constant_value: Constant value + overrides: + conversation_config_override: + agent: + prompt: + prompt: false + first_message: false + language: false + tts: + voice_id: false + conversation: + text_only: false + custom_llm_extra_body: true + enable_conversation_initiation_client_data_from_webhook: true + call_limits: + agent_concurrency_limit: -1 + daily_limit: 100000 + privacy: + record_voice: true + retention_days: -1 + delete_transcript_and_pii: false + delete_audio: false + apply_to_existing_conversations: false + zero_retention_mode: false + workspace_overrides: + conversation_initiation_client_data_webhook: + url: https://example.com/webhook + request_headers: + Content-Type: application/json + safety: + is_blocked_ivc: true + is_blocked_non_ivc: true + ignore_safety_evaluation: true + phone_numbers: + - phone_number: phone_number + label: label + phone_number_id: X3Pbu5gP6NNKBscdCdwB + assigned_agent: + agent_id: F3Pbu5gP6NNKBscdCdwB + agent_name: My Agent + provider_config: + address: address + transport: auto + media_encryption: disabled + has_auth_credentials: true + provider: sip_trunk + access_info: + is_creator: true + creator_name: John Doe + creator_email: john.doe@example.com + role: admin + tags: + - tags + audiences: + - convai + list: + path: /v1/convai/agents + method: GET + auth: false + docs: Returns a list of your agents and their metadata. + source: + openapi: openapi.json + display-name: List Agents + request: + name: AgentsListRequest + query-parameters: + cursor: + type: optional + docs: Used for fetching next page. Cursor is returned in the response. + page_size: + type: optional + default: 30 + docs: >- + How many Agents to return at maximum. Can not exceed 100, defaults + to 30. + validation: + min: 1 + max: 100 + search: + type: optional + docs: Search by agents name. + response: + docs: Successful Response + type: root.GetAgentsPageResponseModel + status-code: 200 + errors: + - root.UnprocessableEntityError + examples: + - response: + body: + agents: + - agent_id: J3Pbu5gP6NNKBscdCdwB + name: My Agent + tags: + - Customer Support + - Technical Help + - Eleven + created_at_unix_secs: 1716153600 + access_info: + is_creator: true + creator_name: John Doe + creator_email: john.doe@example.com + role: admin + next_cursor: '123' + has_more: false + audiences: + - convai simulate_conversation: path: /v1/convai/agents/{agent_id}/simulate-conversation method: POST @@ -64,6 +578,7 @@ service: score: like time_in_call_secs: 1 llm_override: llm_override + source_medium: audio time_in_call_secs: 1 rag_retrieval_info: chunks: @@ -73,6 +588,8 @@ service: embedding_model: e5_mistral_7b_instruct retrieval_query: retrieval_query rag_latency_secs: 1.1 + interrupted: true + original_message: original_message analysis: evaluation_criteria_results: key: diff --git a/.mock/definition/conversationalAi/agents/link.yml b/.mock/definition/conversationalAi/agents/link.yml new file mode 100644 index 00000000..57187529 --- /dev/null +++ b/.mock/definition/conversationalAi/agents/link.yml @@ -0,0 +1,39 @@ +imports: + root: ../../__package__.yml +service: + auth: false + base-path: '' + endpoints: + get: + path: /v1/convai/agents/{agent_id}/link + method: GET + auth: false + docs: Get the current link used to share the agent with others + source: + openapi: openapi.json + path-parameters: + agent_id: + type: string + docs: The id of an agent. This is returned on agent creation. + display-name: Get Shareable Agent Link + response: + docs: Successful Response + type: root.GetAgentLinkResponseModel + status-code: 200 + errors: + - root.UnprocessableEntityError + examples: + - path-parameters: + agent_id: 21m00Tcm4TlvDq8ikWAM + response: + body: + agent_id: J3Pbu5gP6NNKBscdCdwB + token: + agent_id: J3Pbu5gP6NNKBscdCdwB + conversation_token: '1234567890' + expiration_time_unix_secs: 1716153600 + purpose: signed_url + audiences: + - convai + source: + openapi: openapi.json diff --git a/.mock/definition/conversationalAi/agents/widget.yml b/.mock/definition/conversationalAi/agents/widget.yml new file mode 100644 index 00000000..59a0dea6 --- /dev/null +++ b/.mock/definition/conversationalAi/agents/widget.yml @@ -0,0 +1,77 @@ +imports: + root: ../../__package__.yml +service: + auth: false + base-path: '' + endpoints: + get: + path: /v1/convai/agents/{agent_id}/widget + method: GET + auth: false + docs: Retrieve the widget configuration for an agent + source: + openapi: openapi.json + path-parameters: + agent_id: + type: string + docs: The id of an agent. This is returned on agent creation. + display-name: Get Agent Widget Config + request: + name: WidgetGetRequest + query-parameters: + conversation_signature: + type: optional + docs: >- + An expiring token that enables a websocket conversation to start. + These can be generated for an agent using the + /v1/convai/conversation/get-signed-url endpoint + response: + docs: Successful Response + type: root.GetAgentEmbedResponseModel + status-code: 200 + errors: + - root.UnprocessableEntityError + examples: + - path-parameters: + agent_id: 21m00Tcm4TlvDq8ikWAM + response: + body: + agent_id: agent_id + widget_config: + variant: full + expandable: never + avatar: + color_1: '#2792dc' + color_2: '#9ce6e6' + type: orb + feedback_mode: none + bg_color: '#ffffff' + text_color: '#000000' + btn_color: '#000000' + btn_text_color: '#ffffff' + border_color: '#e1e1e1' + focus_color: '#000000' + border_radius: 10 + btn_radius: 10 + action_text: Call + start_call_text: Start Call + end_call_text: End Call + expand_text: Expand + listening_text: Listening... + speaking_text: Speaking... + shareable_page_text: Share + shareable_page_show_terms: true + terms_text: Terms and Conditions + terms_html:

Terms and Conditions

+ terms_key: terms + show_avatar_when_collapsed: true + disable_banner: false + override_link: override_link + mic_muting_enabled: false + language: language + supported_language_overrides: + - supported_language_overrides + audiences: + - convai + source: + openapi: openapi.json diff --git a/.mock/definition/conversationalAi/agents/widget/avatar.yml b/.mock/definition/conversationalAi/agents/widget/avatar.yml new file mode 100644 index 00000000..86ab51b8 --- /dev/null +++ b/.mock/definition/conversationalAi/agents/widget/avatar.yml @@ -0,0 +1,44 @@ +imports: + root: ../../../__package__.yml +service: + auth: false + base-path: '' + endpoints: + create: + path: /v1/convai/agents/{agent_id}/avatar + method: POST + auth: false + docs: Sets the avatar for an agent displayed in the widget + source: + openapi: openapi.json + path-parameters: + agent_id: + type: string + docs: The id of an agent. This is returned on agent creation. + display-name: Post Agent Avatar + request: + name: Body_Post_Agent_avatar_v1_convai_agents__agent_id__avatar_post + body: + properties: + avatar_file: + type: file + docs: An image file to be used as the agent's avatar. + content-type: multipart/form-data + response: + docs: Successful Response + type: root.PostAgentAvatarResponseModel + status-code: 200 + errors: + - root.UnprocessableEntityError + examples: + - path-parameters: + agent_id: 21m00Tcm4TlvDq8ikWAM + request: {} + response: + body: + agent_id: agent_id + avatar_url: avatar_url + audiences: + - convai + source: + openapi: openapi.json diff --git a/.mock/definition/conversationalAi/batchCalls.yml b/.mock/definition/conversationalAi/batchCalls.yml new file mode 100644 index 00000000..8eb3f7dd --- /dev/null +++ b/.mock/definition/conversationalAi/batchCalls.yml @@ -0,0 +1,139 @@ +imports: + root: ../__package__.yml +service: + auth: false + base-path: '' + endpoints: + create: + path: /v1/convai/batch-calling/submit + method: POST + auth: false + docs: Submit a batch call request to schedule calls for multiple recipients. + source: + openapi: openapi.json + display-name: Submit A Batch Call Request. + request: + name: BodySubmitABatchCallRequestV1ConvaiBatchCallingSubmitPost + body: + properties: + call_name: string + agent_id: string + agent_phone_number_id: string + scheduled_time_unix: optional + recipients: + type: list + content-type: application/json + response: + docs: Successful Response + type: root.BatchCallResponse + status-code: 200 + errors: + - root.UnprocessableEntityError + examples: + - request: + call_name: call_name + agent_id: agent_id + agent_phone_number_id: agent_phone_number_id + recipients: + - phone_number: phone_number + response: + body: + id: id + phone_number_id: phone_number_id + phone_provider: twilio + name: name + agent_id: agent_id + created_at_unix: 1 + scheduled_time_unix: 1 + total_calls_dispatched: 1 + total_calls_scheduled: 1 + last_updated_at_unix: 1 + status: pending + agent_name: agent_name + audiences: + - convai + list: + path: /v1/convai/batch-calling/workspace + method: GET + auth: false + docs: Get all batch calls for the current workspace. + source: + openapi: openapi.json + display-name: Get All Batch Calls For A Workspace. + request: + name: BatchCallsListRequest + query-parameters: + limit: + type: optional + default: 100 + last_doc: optional + response: + docs: Successful Response + type: root.WorkspaceBatchCallsResponse + status-code: 200 + errors: + - root.UnprocessableEntityError + examples: + - response: + body: + batch_calls: + - id: id + phone_number_id: phone_number_id + phone_provider: twilio + name: name + agent_id: agent_id + created_at_unix: 1 + scheduled_time_unix: 1 + total_calls_dispatched: 1 + total_calls_scheduled: 1 + last_updated_at_unix: 1 + status: pending + agent_name: agent_name + next_doc: next_doc + has_more: true + audiences: + - convai + get: + path: /v1/convai/batch-calling/{batch_id} + method: GET + auth: false + docs: Get detailed information about a batch call including all recipients. + source: + openapi: openapi.json + path-parameters: + batch_id: string + display-name: Get A Batch Call By Id. + response: + docs: Successful Response + type: root.BatchCallDetailedResponse + status-code: 200 + errors: + - root.UnprocessableEntityError + examples: + - path-parameters: + batch_id: batch_id + response: + body: + id: id + phone_number_id: phone_number_id + phone_provider: twilio + name: name + agent_id: agent_id + created_at_unix: 1 + scheduled_time_unix: 1 + total_calls_dispatched: 1 + total_calls_scheduled: 1 + last_updated_at_unix: 1 + status: pending + agent_name: agent_name + recipients: + - id: id + phone_number: phone_number + status: pending + created_at_unix: 1 + updated_at_unix: 1 + conversation_id: conversation_id + audiences: + - convai + source: + openapi: openapi.json diff --git a/.mock/definition/conversationalAi/conversations.yml b/.mock/definition/conversationalAi/conversations.yml new file mode 100644 index 00000000..2f97fc3f --- /dev/null +++ b/.mock/definition/conversationalAi/conversations.yml @@ -0,0 +1,165 @@ +imports: + root: ../__package__.yml +service: + auth: false + base-path: '' + endpoints: + get_signed_url: + path: /v1/convai/conversation/get-signed-url + method: GET + auth: false + docs: >- + Get a signed url to start a conversation with an agent with an agent + that requires authorization + source: + openapi: openapi.json + display-name: Get Signed Url + request: + name: ConversationsGetSignedUrlRequest + query-parameters: + agent_id: + type: string + docs: The id of the agent you're taking the action on. + response: + docs: Successful Response + type: root.ConversationSignedUrlResponseModel + status-code: 200 + errors: + - root.UnprocessableEntityError + examples: + - query-parameters: + agent_id: 21m00Tcm4TlvDq8ikWAM + response: + body: + signed_url: signed_url + audiences: + - convai + list: + path: /v1/convai/conversations + method: GET + auth: false + docs: >- + Get all conversations of agents that user owns. With option to restrict + to a specific agent. + source: + openapi: openapi.json + display-name: List conversations + request: + name: ConversationsListRequest + query-parameters: + cursor: + type: optional + docs: Used for fetching next page. Cursor is returned in the response. + agent_id: + type: optional + docs: The id of the agent you're taking the action on. + call_successful: + type: optional + docs: The result of the success evaluation + call_start_before_unix: + type: optional + docs: >- + Unix timestamp (in seconds) to filter conversations up to this + start date. + call_start_after_unix: + type: optional + docs: >- + Unix timestamp (in seconds) to filter conversations after to this + start date. + page_size: + type: optional + default: 30 + docs: >- + How many conversations to return at maximum. Can not exceed 100, + defaults to 30. + validation: + min: 1 + max: 100 + response: + docs: Successful Response + type: root.GetConversationsPageResponseModel + status-code: 200 + errors: + - root.UnprocessableEntityError + examples: + - response: + body: + conversations: + - agent_id: agent_id + agent_name: agent_name + conversation_id: conversation_id + start_time_unix_secs: 1 + call_duration_secs: 1 + message_count: 1 + status: initiated + call_successful: success + next_cursor: next_cursor + has_more: true + audiences: + - convai + get: + path: /v1/convai/conversations/{conversation_id} + method: GET + auth: false + docs: Get the details of a particular conversation + source: + openapi: openapi.json + path-parameters: + conversation_id: + type: string + docs: The id of the conversation you're taking the action on. + display-name: Get Conversation Details + response: + docs: Successful Response + type: root.GetConversationResponseModel + status-code: 200 + errors: + - root.UnprocessableEntityError + examples: + - path-parameters: + conversation_id: '123' + response: + body: + agent_id: '123' + conversation_id: '123' + status: processing + transcript: + - role: user + message: Hello, how are you? + time_in_call_secs: 10 + metadata: + start_time_unix_secs: 1714423232 + call_duration_secs: 10 + has_audio: true + has_user_audio: true + has_response_audio: true + audiences: + - convai + delete: + path: /v1/convai/conversations/{conversation_id} + method: DELETE + auth: false + docs: Delete a particular conversation + source: + openapi: openapi.json + path-parameters: + conversation_id: + type: string + docs: The id of the conversation you're taking the action on. + display-name: Delete Conversation + response: + docs: Successful Response + type: unknown + status-code: 200 + errors: + - root.UnprocessableEntityError + examples: + - path-parameters: + conversation_id: 21m00Tcm4TlvDq8ikWAM + response: + body: + key: value + audiences: + - convai + source: + openapi: openapi.json diff --git a/.mock/definition/conversationalAi/conversations/audio.yml b/.mock/definition/conversationalAi/conversations/audio.yml new file mode 100644 index 00000000..7153c0bc --- /dev/null +++ b/.mock/definition/conversationalAi/conversations/audio.yml @@ -0,0 +1,28 @@ +imports: + root: ../../__package__.yml +service: + auth: false + base-path: '' + endpoints: + get: + path: /v1/convai/conversations/{conversation_id}/audio + method: GET + auth: false + docs: Get the audio recording of a particular conversation + source: + openapi: openapi.json + path-parameters: + conversation_id: + type: string + docs: The id of the conversation you're taking the action on. + display-name: Get Conversation Audio + response: + docs: Successful Response + type: file + status-code: 200 + errors: + - root.UnprocessableEntityError + audiences: + - convai + source: + openapi: openapi.json diff --git a/.mock/definition/conversationalAi/conversations/feedback.yml b/.mock/definition/conversationalAi/conversations/feedback.yml new file mode 100644 index 00000000..c02ac819 --- /dev/null +++ b/.mock/definition/conversationalAi/conversations/feedback.yml @@ -0,0 +1,47 @@ +imports: + root: ../../__package__.yml +service: + auth: false + base-path: '' + endpoints: + create: + path: /v1/convai/conversations/{conversation_id}/feedback + method: POST + auth: false + docs: Send the feedback for the given conversation + source: + openapi: openapi.json + path-parameters: + conversation_id: + type: string + docs: The id of the conversation you're taking the action on. + display-name: Send Conversation Feedback + request: + name: >- + BodySendConversationFeedbackV1ConvaiConversationsConversationIdFeedbackPost + body: + properties: + feedback: + type: root.UserFeedbackScore + docs: >- + Either 'like' or 'dislike' to indicate the feedback for the + conversation. + content-type: application/json + response: + docs: Successful Response + type: unknown + status-code: 200 + errors: + - root.UnprocessableEntityError + examples: + - path-parameters: + conversation_id: 21m00Tcm4TlvDq8ikWAM + request: + feedback: like + response: + body: + key: value + audiences: + - convai + source: + openapi: openapi.json diff --git a/.mock/definition/conversationalAi/dashboard/settings.yml b/.mock/definition/conversationalAi/dashboard/settings.yml new file mode 100644 index 00000000..dbde5f58 --- /dev/null +++ b/.mock/definition/conversationalAi/dashboard/settings.yml @@ -0,0 +1,73 @@ +imports: + root: ../../__package__.yml +service: + auth: false + base-path: '' + endpoints: + get: + path: /v1/convai/settings/dashboard + method: GET + auth: false + docs: Retrieve Convai dashboard settings for the workspace + source: + openapi: openapi.json + display-name: Get Convai Dashboard Settings + response: + docs: Successful Response + type: root.GetConvAiDashboardSettingsResponseModel + status-code: 200 + errors: + - root.UnprocessableEntityError + examples: + - response: + body: + charts: + - name: name + type: call_success + audiences: + - convai + update: + path: /v1/convai/settings/dashboard + method: PATCH + auth: false + docs: Update Convai dashboard settings for the workspace + source: + openapi: openapi.json + display-name: Update Convai Dashboard Settings + request: + name: PatchConvAiDashboardSettingsRequest + body: + properties: + charts: + type: optional> + content-type: application/json + response: + docs: Successful Response + type: root.GetConvAiDashboardSettingsResponseModel + status-code: 200 + errors: + - root.UnprocessableEntityError + examples: + - request: {} + response: + body: + charts: + - name: name + type: call_success + audiences: + - convai + source: + openapi: openapi.json +types: + PatchConvAiDashboardSettingsRequestChartsItem: + discriminant: type + base-properties: {} + union: + call_success: + type: root.DashboardCallSuccessChartModel + criteria: + type: root.DashboardCriteriaChartModel + data_collection: + type: root.DashboardDataCollectionChartModel + source: + openapi: openapi.json diff --git a/.mock/definition/conversationalAi/knowledgeBase.yml b/.mock/definition/conversationalAi/knowledgeBase.yml new file mode 100644 index 00000000..314c4e46 --- /dev/null +++ b/.mock/definition/conversationalAi/knowledgeBase.yml @@ -0,0 +1,87 @@ +imports: + root: ../__package__.yml +service: + auth: false + base-path: '' + endpoints: + list: + path: /v1/convai/knowledge-base + method: GET + auth: false + docs: Get a list of available knowledge base documents + source: + openapi: openapi.json + display-name: Get Knowledge Base List + request: + name: KnowledgeBaseListRequest + query-parameters: + cursor: + type: optional + docs: Used for fetching next page. Cursor is returned in the response. + page_size: + type: optional + default: 30 + docs: >- + How many documents to return at maximum. Can not exceed 100, + defaults to 30. + validation: + min: 1 + max: 100 + search: + type: optional + docs: >- + If specified, the endpoint returns only such knowledge base + documents whose names start with this string. + show_only_owned_documents: + type: optional + default: false + docs: >- + If set to true, the endpoint will return only documents owned by + you (and not shared from somebody else). + types: + type: optional + allow-multiple: true + docs: >- + If present, the endpoint will return only documents of the given + types. + use_typesense: + type: optional + default: false + docs: >- + If set to true, the endpoint will use typesense DB to search for + the documents). + response: + docs: Successful Response + type: root.GetKnowledgeBaseListResponseModel + status-code: 200 + errors: + - root.UnprocessableEntityError + examples: + - response: + body: + documents: + - id: id + name: name + metadata: + created_at_unix_secs: 1 + last_updated_at_unix_secs: 1 + size_bytes: 1 + prompt_injectable: true + access_info: + is_creator: true + creator_name: John Doe + creator_email: john.doe@example.com + role: admin + dependent_agents: + - id: id + name: name + created_at_unix_secs: 1 + access_level: admin + type: available + type: file + next_cursor: next_cursor + has_more: true + audiences: + - convai + source: + openapi: openapi.json diff --git a/.mock/definition/conversationalAi/knowledgeBase/documents.yml b/.mock/definition/conversationalAi/knowledgeBase/documents.yml new file mode 100644 index 00000000..607604a6 --- /dev/null +++ b/.mock/definition/conversationalAi/knowledgeBase/documents.yml @@ -0,0 +1,346 @@ +imports: + root: ../../__package__.yml +service: + auth: false + base-path: '' + endpoints: + create_from_url: + path: /v1/convai/knowledge-base/url + method: POST + auth: false + docs: >- + Create a knowledge base document generated by scraping the given + webpage. + source: + openapi: openapi.json + display-name: Create Url Document + request: + name: BodyCreateUrlDocumentV1ConvaiKnowledgeBaseUrlPost + body: + properties: + url: + type: string + docs: >- + URL to a page of documentation that the agent will have access + to in order to interact with users. + name: + type: optional + docs: A custom, human-readable name for the document. + validation: + minLength: 1 + content-type: application/json + response: + docs: Successful Response + type: root.AddKnowledgeBaseResponseModel + status-code: 200 + errors: + - root.UnprocessableEntityError + examples: + - request: + url: url + response: + body: + id: id + name: name + prompt_injectable: true + audiences: + - convai + create_from_file: + path: /v1/convai/knowledge-base/file + method: POST + auth: false + docs: Create a knowledge base document generated form the uploaded file. + source: + openapi: openapi.json + display-name: Create File Document + request: + name: Body_Create_file_document_v1_convai_knowledge_base_file_post + body: + properties: + file: + type: file + docs: >- + Documentation that the agent will have access to in order to + interact with users. + name: + type: optional + docs: A custom, human-readable name for the document. + validation: + minLength: 1 + content-type: multipart/form-data + response: + docs: Successful Response + type: root.AddKnowledgeBaseResponseModel + status-code: 200 + errors: + - root.UnprocessableEntityError + examples: + - request: {} + response: + body: + id: id + name: name + prompt_injectable: true + audiences: + - convai + create_from_text: + path: /v1/convai/knowledge-base/text + method: POST + auth: false + docs: Create a knowledge base document containing the provided text. + source: + openapi: openapi.json + display-name: Create Text Document + request: + name: BodyCreateTextDocumentV1ConvaiKnowledgeBaseTextPost + body: + properties: + text: + type: string + docs: Text content to be added to the knowledge base. + name: + type: optional + docs: A custom, human-readable name for the document. + validation: + minLength: 1 + content-type: application/json + response: + docs: Successful Response + type: root.AddKnowledgeBaseResponseModel + status-code: 200 + errors: + - root.UnprocessableEntityError + examples: + - request: + text: text + response: + body: + id: id + name: name + prompt_injectable: true + audiences: + - convai + get: + path: /v1/convai/knowledge-base/{documentation_id} + method: GET + auth: false + docs: >- + Get details about a specific documentation making up the agent's + knowledge base + source: + openapi: openapi.json + path-parameters: + documentation_id: + type: string + docs: >- + The id of a document from the knowledge base. This is returned on + document addition. + display-name: Get Documentation From Knowledge Base + response: + docs: Successful Response + type: DocumentsGetResponse + status-code: 200 + errors: + - root.UnprocessableEntityError + examples: + - path-parameters: + documentation_id: 21m00Tcm4TlvDq8ikWAM + response: + body: + id: id + name: name + metadata: + created_at_unix_secs: 1 + last_updated_at_unix_secs: 1 + size_bytes: 1 + prompt_injectable: true + access_info: + is_creator: true + creator_name: John Doe + creator_email: john.doe@example.com + role: admin + extracted_inner_html: extracted_inner_html + url: url + type: url + audiences: + - convai + delete: + path: /v1/convai/knowledge-base/{documentation_id} + method: DELETE + auth: false + docs: Delete a document from the knowledge base + source: + openapi: openapi.json + path-parameters: + documentation_id: + type: string + docs: >- + The id of a document from the knowledge base. This is returned on + document addition. + display-name: Delete Knowledge Base Document + response: + docs: Successful Response + type: unknown + status-code: 200 + errors: + - root.UnprocessableEntityError + examples: + - path-parameters: + documentation_id: 21m00Tcm4TlvDq8ikWAM + response: + body: + key: value + audiences: + - convai + update: + path: /v1/convai/knowledge-base/{documentation_id} + method: PATCH + auth: false + docs: Update the name of a document + source: + openapi: openapi.json + path-parameters: + documentation_id: + type: string + docs: >- + The id of a document from the knowledge base. This is returned on + document addition. + display-name: Update Document + request: + name: BodyUpdateDocumentV1ConvaiKnowledgeBaseDocumentationIdPatch + body: + properties: + name: + type: string + docs: A custom, human-readable name for the document. + validation: + minLength: 1 + content-type: application/json + response: + docs: Successful Response + type: DocumentsUpdateResponse + status-code: 200 + errors: + - root.UnprocessableEntityError + examples: + - path-parameters: + documentation_id: 21m00Tcm4TlvDq8ikWAM + request: + name: name + response: + body: + id: id + name: name + metadata: + created_at_unix_secs: 1 + last_updated_at_unix_secs: 1 + size_bytes: 1 + prompt_injectable: true + access_info: + is_creator: true + creator_name: John Doe + creator_email: john.doe@example.com + role: admin + extracted_inner_html: extracted_inner_html + url: url + type: url + audiences: + - convai + get_agents: + path: /v1/convai/knowledge-base/{documentation_id}/dependent-agents + method: GET + auth: false + docs: Get a list of agents depending on this knowledge base document + source: + openapi: openapi.json + path-parameters: + documentation_id: + type: string + docs: >- + The id of a document from the knowledge base. This is returned on + document addition. + display-name: Get Dependent Agents List + request: + name: DocumentsGetAgentsRequest + query-parameters: + cursor: + type: optional + docs: Used for fetching next page. Cursor is returned in the response. + page_size: + type: optional + default: 30 + docs: >- + How many documents to return at maximum. Can not exceed 100, + defaults to 30. + validation: + min: 1 + max: 100 + response: + docs: Successful Response + type: root.GetKnowledgeBaseDependentAgentsResponseModel + status-code: 200 + errors: + - root.UnprocessableEntityError + examples: + - path-parameters: + documentation_id: 21m00Tcm4TlvDq8ikWAM + response: + body: + agents: + - id: id + name: name + created_at_unix_secs: 1 + access_level: admin + type: available + next_cursor: next_cursor + has_more: true + audiences: + - convai + get_content: + path: /v1/convai/knowledge-base/{documentation_id}/content + method: GET + auth: false + docs: Get the entire content of a document from the knowledge base + source: + openapi: openapi.json + path-parameters: + documentation_id: + type: string + docs: >- + The id of a document from the knowledge base. This is returned on + document addition. + display-name: Get Document Content + errors: + - root.UnprocessableEntityError + examples: + - path-parameters: + documentation_id: 21m00Tcm4TlvDq8ikWAM + audiences: + - convai + source: + openapi: openapi.json +types: + DocumentsGetResponse: + discriminant: type + base-properties: {} + union: + url: + type: root.GetKnowledgeBaseUrlResponseModel + file: + type: root.GetKnowledgeBaseFileResponseModel + text: + type: root.GetKnowledgeBaseTextResponseModel + source: + openapi: openapi.json + DocumentsUpdateResponse: + discriminant: type + base-properties: {} + union: + url: + type: root.GetKnowledgeBaseUrlResponseModel + file: + type: root.GetKnowledgeBaseFileResponseModel + text: + type: root.GetKnowledgeBaseTextResponseModel + source: + openapi: openapi.json diff --git a/.mock/definition/conversationalAi/knowledgeBase/documents/chunk.yml b/.mock/definition/conversationalAi/knowledgeBase/documents/chunk.yml new file mode 100644 index 00000000..0a3aff39 --- /dev/null +++ b/.mock/definition/conversationalAi/knowledgeBase/documents/chunk.yml @@ -0,0 +1,42 @@ +imports: + root: ../../../__package__.yml +service: + auth: false + base-path: '' + endpoints: + get: + path: /v1/convai/knowledge-base/{documentation_id}/chunk/{chunk_id} + method: GET + auth: false + docs: Get details about a specific documentation part used by RAG. + source: + openapi: openapi.json + path-parameters: + documentation_id: + type: string + docs: >- + The id of a document from the knowledge base. This is returned on + document addition. + chunk_id: + type: string + docs: The id of a document RAG chunk from the knowledge base. + display-name: Get Documentation Chunk From Knowledge Base + response: + docs: Successful Response + type: root.KnowledgeBaseDocumentChunkResponseModel + status-code: 200 + errors: + - root.UnprocessableEntityError + examples: + - path-parameters: + documentation_id: 21m00Tcm4TlvDq8ikWAM + chunk_id: chunk_id + response: + body: + id: id + name: name + content: content + audiences: + - convai + source: + openapi: openapi.json diff --git a/.mock/definition/conversationalAi/phoneNumbers.yml b/.mock/definition/conversationalAi/phoneNumbers.yml new file mode 100644 index 00000000..1fa4e3ea --- /dev/null +++ b/.mock/definition/conversationalAi/phoneNumbers.yml @@ -0,0 +1,206 @@ +imports: + root: ../__package__.yml +types: + PhoneNumbersCreateRequestBody: + discriminant: provider + base-properties: {} + docs: Create Phone Request Information + union: + twilio: + type: root.CreateTwilioPhoneNumberRequest + sip_trunk: + type: root.CreateSipTrunkPhoneNumberRequest + source: + openapi: openapi.json + PhoneNumbersGetResponse: + discriminant: provider + base-properties: {} + union: + twilio: + type: root.GetPhoneNumberTwilioResponseModel + sip_trunk: + type: root.GetPhoneNumberSipTrunkResponseModel + source: + openapi: openapi.json + PhoneNumbersUpdateResponse: + discriminant: provider + base-properties: {} + union: + twilio: + type: root.GetPhoneNumberTwilioResponseModel + sip_trunk: + type: root.GetPhoneNumberSipTrunkResponseModel + source: + openapi: openapi.json + PhoneNumbersListResponseItem: + discriminant: provider + base-properties: {} + union: + twilio: + type: root.GetPhoneNumberTwilioResponseModel + sip_trunk: + type: root.GetPhoneNumberSipTrunkResponseModel + source: + openapi: openapi.json +service: + auth: false + base-path: '' + endpoints: + create: + path: /v1/convai/phone-numbers/create + method: POST + auth: false + docs: Import Phone Number from provider configuration (Twilio or SIP trunk) + source: + openapi: openapi.json + display-name: Import Phone Number + request: + body: + display-name: Phone Request + type: PhoneNumbersCreateRequestBody + docs: Create Phone Request Information + content-type: application/json + response: + docs: Successful Response + type: root.CreatePhoneNumberResponseModel + status-code: 200 + errors: + - root.UnprocessableEntityError + examples: + - request: + phone_number: phone_number + label: label + sid: sid + token: token + provider: twilio + response: + body: + phone_number_id: phone_number_id + audiences: + - convai + get: + path: /v1/convai/phone-numbers/{phone_number_id} + method: GET + auth: false + docs: Retrieve Phone Number details by ID + source: + openapi: openapi.json + path-parameters: + phone_number_id: + type: string + docs: The id of an agent. This is returned on agent creation. + display-name: Get Phone Number + response: + docs: Successful Response + type: PhoneNumbersGetResponse + status-code: 200 + errors: + - root.UnprocessableEntityError + examples: + - path-parameters: + phone_number_id: TeaqRRdTcIfIu2i7BYfT + response: + body: + phone_number: phone_number + label: label + phone_number_id: X3Pbu5gP6NNKBscdCdwB + assigned_agent: + agent_id: F3Pbu5gP6NNKBscdCdwB + agent_name: My Agent + provider: twilio + audiences: + - convai + delete: + path: /v1/convai/phone-numbers/{phone_number_id} + method: DELETE + auth: false + docs: Delete Phone Number by ID + source: + openapi: openapi.json + path-parameters: + phone_number_id: + type: string + docs: The id of an agent. This is returned on agent creation. + display-name: Delete Phone Number + response: + docs: Successful Response + type: unknown + status-code: 200 + errors: + - root.UnprocessableEntityError + examples: + - path-parameters: + phone_number_id: TeaqRRdTcIfIu2i7BYfT + response: + body: + key: value + audiences: + - convai + update: + path: /v1/convai/phone-numbers/{phone_number_id} + method: PATCH + auth: false + docs: Update Phone Number details by ID + source: + openapi: openapi.json + path-parameters: + phone_number_id: + type: string + docs: The id of an agent. This is returned on agent creation. + display-name: Update Phone Number + request: + name: UpdatePhoneNumberRequest + body: + properties: + agent_id: + type: optional + content-type: application/json + response: + docs: Successful Response + type: PhoneNumbersUpdateResponse + status-code: 200 + errors: + - root.UnprocessableEntityError + examples: + - path-parameters: + phone_number_id: TeaqRRdTcIfIu2i7BYfT + request: {} + response: + body: + phone_number: phone_number + label: label + phone_number_id: X3Pbu5gP6NNKBscdCdwB + assigned_agent: + agent_id: F3Pbu5gP6NNKBscdCdwB + agent_name: My Agent + provider: twilio + audiences: + - convai + list: + path: /v1/convai/phone-numbers/ + method: GET + auth: false + docs: Retrieve all Phone Numbers + source: + openapi: openapi.json + display-name: List Phone Numbers + response: + docs: Successful Response + type: list + status-code: 200 + errors: + - root.UnprocessableEntityError + examples: + - response: + body: + - phone_number: phone_number + label: label + phone_number_id: X3Pbu5gP6NNKBscdCdwB + assigned_agent: + agent_id: F3Pbu5gP6NNKBscdCdwB + agent_name: My Agent + provider: twilio + audiences: + - convai + source: + openapi: openapi.json diff --git a/.mock/definition/conversationalAi/secrets.yml b/.mock/definition/conversationalAi/secrets.yml new file mode 100644 index 00000000..443302dd --- /dev/null +++ b/.mock/definition/conversationalAi/secrets.yml @@ -0,0 +1,100 @@ +imports: + root: ../__package__.yml +service: + auth: false + base-path: '' + endpoints: + list: + path: /v1/convai/secrets + method: GET + auth: false + docs: Get all workspace secrets for the user + source: + openapi: openapi.json + display-name: Get Convai Workspace Secrets + response: + docs: Successful Response + type: root.GetWorkspaceSecretsResponseModel + status-code: 200 + errors: + - root.UnprocessableEntityError + examples: + - response: + body: + secrets: + - type: stored + secret_id: secret_id + name: name + used_by: + tools: + - id: id + name: name + created_at_unix_secs: 1 + access_level: admin + type: available + agent_tools: + - agent_id: agent_id + agent_name: agent_name + used_by: + - used_by + created_at_unix_secs: 1 + access_level: admin + type: available + others: + - conversation_initiation_webhook + audiences: + - convai + create: + path: /v1/convai/secrets + method: POST + auth: false + docs: Create a new secret for the workspace + source: + openapi: openapi.json + display-name: Create Convai Workspace Secret + request: + name: PostWorkspaceSecretRequest + body: + properties: + type: + type: literal<"new"> + name: string + value: string + content-type: application/json + response: + docs: Successful Response + type: root.PostWorkspaceSecretResponseModel + status-code: 200 + errors: + - root.UnprocessableEntityError + examples: + - request: + type: new + name: name + value: value + response: + body: + type: stored + secret_id: secret_id + name: name + audiences: + - convai + delete: + path: /v1/convai/secrets/{secret_id} + method: DELETE + auth: false + docs: Delete a workspace secret if it's not in use + source: + openapi: openapi.json + path-parameters: + secret_id: string + display-name: Delete Convai Workspace Secret + errors: + - root.UnprocessableEntityError + examples: + - path-parameters: + secret_id: secret_id + audiences: + - convai + source: + openapi: openapi.json diff --git a/.mock/definition/conversationalAi/settings.yml b/.mock/definition/conversationalAi/settings.yml new file mode 100644 index 00000000..0e1c01a8 --- /dev/null +++ b/.mock/definition/conversationalAi/settings.yml @@ -0,0 +1,81 @@ +imports: + root: ../__package__.yml +service: + auth: false + base-path: '' + endpoints: + get: + path: /v1/convai/settings + method: GET + auth: false + docs: Retrieve Convai settings for the workspace + source: + openapi: openapi.json + display-name: Get Convai Settings + response: + docs: Successful Response + type: root.GetConvAiSettingsResponseModel + status-code: 200 + errors: + - root.UnprocessableEntityError + examples: + - response: + body: + conversation_initiation_client_data_webhook: + url: https://example.com/webhook + request_headers: + Content-Type: application/json + webhooks: + post_call_webhook_id: post_call_webhook_id + can_use_mcp_servers: true + rag_retention_period_days: 1 + audiences: + - convai + update: + path: /v1/convai/settings + method: PATCH + auth: false + docs: Update Convai settings for the workspace + source: + openapi: openapi.json + display-name: Update Convai Settings + request: + name: PatchConvAiSettingsRequest + body: + properties: + conversation_initiation_client_data_webhook: + type: optional + webhooks: + type: optional + can_use_mcp_servers: + type: optional + docs: Whether the workspace can use MCP servers + default: false + rag_retention_period_days: + type: optional + default: 10 + validation: + max: 30 + content-type: application/json + response: + docs: Successful Response + type: root.GetConvAiSettingsResponseModel + status-code: 200 + errors: + - root.UnprocessableEntityError + examples: + - request: {} + response: + body: + conversation_initiation_client_data_webhook: + url: https://example.com/webhook + request_headers: + Content-Type: application/json + webhooks: + post_call_webhook_id: post_call_webhook_id + can_use_mcp_servers: true + rag_retention_period_days: 1 + audiences: + - convai + source: + openapi: openapi.json diff --git a/.mock/definition/conversationalAi/sipTrunk.yml b/.mock/definition/conversationalAi/sipTrunk.yml index a9249e03..2cd25793 100644 --- a/.mock/definition/conversationalAi/sipTrunk.yml +++ b/.mock/definition/conversationalAi/sipTrunk.yml @@ -37,6 +37,7 @@ service: body: success: true message: message + conversation_id: conversation_id sip_call_id: sip_call_id audiences: - convai diff --git a/.mock/definition/conversationalAi/twilio.yml b/.mock/definition/conversationalAi/twilio.yml new file mode 100644 index 00000000..d76f4294 --- /dev/null +++ b/.mock/definition/conversationalAi/twilio.yml @@ -0,0 +1,45 @@ +imports: + root: ../__package__.yml +service: + auth: false + base-path: '' + endpoints: + outbound_call: + path: /v1/convai/twilio/outbound-call + method: POST + auth: false + docs: Handle an outbound call via Twilio + source: + openapi: openapi.json + display-name: Handle An Outbound Call Via Twilio + request: + name: BodyHandleAnOutboundCallViaTwilioV1ConvaiTwilioOutboundCallPost + body: + properties: + agent_id: string + agent_phone_number_id: string + to_number: string + conversation_initiation_client_data: + type: optional + content-type: application/json + response: + docs: Successful Response + type: root.TwilioOutboundCallResponse + status-code: 200 + errors: + - root.UnprocessableEntityError + examples: + - request: + agent_id: agent_id + agent_phone_number_id: agent_phone_number_id + to_number: to_number + response: + body: + success: true + message: message + conversation_id: conversation_id + callSid: callSid + audiences: + - convai + source: + openapi: openapi.json diff --git a/.mock/definition/dubbing.yml b/.mock/definition/dubbing.yml index 9cf1fbc2..770c0880 100644 --- a/.mock/definition/dubbing.yml +++ b/.mock/definition/dubbing.yml @@ -4,378 +4,7 @@ service: auth: false base-path: '' endpoints: - get_dubbing_resource: - path: /v1/dubbing/resource/{dubbing_id} - method: GET - auth: false - docs: >- - Given a dubbing ID generated from the '/v1/dubbing' endpoint with studio - enabled, returns the dubbing resource. - source: - openapi: openapi.json - path-parameters: - dubbing_id: - type: string - docs: ID of the dubbing project. - display-name: Get dubbing resource - response: - docs: Successful Response - type: root.DubbingResource - status-code: 200 - errors: - - root.UnprocessableEntityError - examples: - - path-parameters: - dubbing_id: dubbing_id - response: - body: - id: id - version: 1 - source_language: source_language - target_languages: - - target_languages - input: - src: src - content_type: content_type - bucket_name: bucket_name - random_path_slug: random_path_slug - duration_secs: 1.1 - is_audio: true - url: url - background: - src: src - content_type: content_type - bucket_name: bucket_name - random_path_slug: random_path_slug - duration_secs: 1.1 - is_audio: true - url: url - foreground: - src: src - content_type: content_type - bucket_name: bucket_name - random_path_slug: random_path_slug - duration_secs: 1.1 - is_audio: true - url: url - speaker_tracks: - key: - id: id - media_ref: - src: src - content_type: content_type - bucket_name: bucket_name - random_path_slug: random_path_slug - duration_secs: 1.1 - is_audio: true - url: url - speaker_name: speaker_name - voices: - key: value - segments: - - segments - speaker_segments: - key: - id: id - start_time: 1.1 - end_time: 1.1 - text: text - dubs: - key: - start_time: 1.1 - end_time: 1.1 - audio_stale: true - renders: - key: - id: id - version: 1 - language: language - type: mp4 - media_ref: - src: src - content_type: content_type - bucket_name: bucket_name - random_path_slug: random_path_slug - duration_secs: 1.1 - is_audio: true - url: url - status: complete - add_language_to_resource: - path: /v1/dubbing/resource/{dubbing_id}/language - method: POST - auth: false - docs: >- - Adds the given ElevenLab Turbo V2/V2.5 language code to the resource. - Does not automatically generate transcripts/translations/audio. - source: - openapi: openapi.json - path-parameters: - dubbing_id: - type: string - docs: ID of the dubbing project. - display-name: Add language to dubbing resource - request: - name: BodyAddALanguageToTheResourceV1DubbingResourceDubbingIdLanguagePost - body: - properties: - language: - type: optional - docs: The Target language. - content-type: application/json - response: - docs: Successful Response - type: root.LanguageAddedResponse - status-code: 201 - errors: - - root.UnprocessableEntityError - examples: - - path-parameters: - dubbing_id: dubbing_id - request: {} - response: - body: - version: 1 - update_segment_language: - path: /v1/dubbing/resource/{dubbing_id}/segment/{segment_id}/{language} - method: PATCH - auth: false - docs: >- - Modifies a single segment with new text and/or start/end times. Will - update the values for only a specific language of a segment. Does not - automatically regenerate the dub. - source: - openapi: openapi.json - path-parameters: - dubbing_id: - type: string - docs: ID of the dubbing project. - segment_id: - type: string - docs: ID of the segment - language: - type: string - docs: ID of the language. - display-name: Modify a segment - request: - name: SegmentUpdatePayload - body: - properties: - start_time: - type: optional - end_time: - type: optional - text: - type: optional - content-type: application/json - response: - docs: Successful Response - type: root.SegmentUpdateResponse - status-code: 200 - errors: - - root.UnprocessableEntityError - examples: - - path-parameters: - dubbing_id: dubbing_id - segment_id: segment_id - language: language - request: {} - response: - body: - version: 1 - delete_segment: - path: /v1/dubbing/resource/{dubbing_id}/segment/{segment_id} - method: DELETE - auth: false - docs: Deletes a single segment from the dubbing. - source: - openapi: openapi.json - path-parameters: - dubbing_id: - type: string - docs: ID of the dubbing project. - segment_id: - type: string - docs: ID of the segment - display-name: Delete a segment - response: - docs: Successful Response - type: root.SegmentDeleteResponse - status-code: 200 - errors: - - root.UnprocessableEntityError - examples: - - path-parameters: - dubbing_id: dubbing_id - segment_id: segment_id - response: - body: - version: 1 - transcribe_segments: - path: /v1/dubbing/resource/{dubbing_id}/transcribe - method: POST - auth: false - docs: >- - Regenerate the transcriptions for the specified segments. Does not - automatically regenerate translations or dubs. - source: - openapi: openapi.json - path-parameters: - dubbing_id: - type: string - docs: ID of the dubbing project. - display-name: Transcribe segments - request: - name: BodyTranscribesSegmentsV1DubbingResourceDubbingIdTranscribePost - body: - properties: - segments: - docs: Transcribe this specific list of segments. - type: list - content-type: application/json - response: - docs: Successful Response - type: root.SegmentTranscriptionResponse - status-code: 200 - errors: - - root.UnprocessableEntityError - examples: - - path-parameters: - dubbing_id: dubbing_id - request: - segments: - - segments - response: - body: - version: 1 - translate_segments: - path: /v1/dubbing/resource/{dubbing_id}/translate - method: POST - auth: false - docs: >- - Regenerate the translations for either the entire resource or the - specified segments/languages. Will automatically transcribe missing - transcriptions. Will not automatically regenerate the dubs. - source: - openapi: openapi.json - path-parameters: - dubbing_id: - type: string - docs: ID of the dubbing project. - display-name: Translate segments - request: - name: >- - BodyTranslatesAllOrSomeSegmentsAndLanguagesV1DubbingResourceDubbingIdTranslatePost - body: - properties: - segments: - docs: Translate only this list of segments. - type: list - languages: - type: optional> - docs: Translate only these languages for each segment. - content-type: application/json - response: - docs: Successful Response - type: root.SegmentTranslationResponse - status-code: 200 - errors: - - root.UnprocessableEntityError - examples: - - path-parameters: - dubbing_id: dubbing_id - request: - segments: - - segments - response: - body: - version: 1 - dub_segments: - path: /v1/dubbing/resource/{dubbing_id}/dub - method: POST - auth: false - docs: >- - Regenerate the dubs for either the entire resource or the specified - segments/languages. Will automatically transcribe and translate any - missing transcriptions and translations. - source: - openapi: openapi.json - path-parameters: - dubbing_id: - type: string - docs: ID of the dubbing project. - display-name: Dub segments - request: - name: BodyDubsAllOrSomeSegmentsAndLanguagesV1DubbingResourceDubbingIdDubPost - body: - properties: - segments: - docs: Dub only this list of segments. - type: list - languages: - type: optional> - docs: Dub only these languages for each segment. - content-type: application/json - response: - docs: Successful Response - type: root.SegmentDubResponse - status-code: 200 - errors: - - root.UnprocessableEntityError - examples: - - path-parameters: - dubbing_id: dubbing_id - request: - segments: - - segments - response: - body: - version: 1 - render_dub: - path: /v1/dubbing/resource/{dubbing_id}/render/{language} - method: POST - auth: false - docs: >- - Regenerate the dubs for either the entire resource or the specified - segments/languages. Will automatically transcribe and translate any - missing transcriptions and translations. - source: - openapi: openapi.json - path-parameters: - dubbing_id: - type: string - docs: ID of the dubbing project. - language: - type: string - docs: Render this language - display-name: Render Audio Or Video For The Given Language - request: - name: >- - BodyRenderAudioOrVideoForTheGivenLanguageV1DubbingResourceDubbingIdRenderLanguagePost - body: - properties: - render_type: - type: root.RenderType - docs: >- - The type of the render. One of ['mp4', 'aac', 'mp3', 'wav', - 'aaf', 'tracks_zip', 'clips_zip'] - content-type: application/json - response: - docs: Successful Response - type: root.DubbingRenderResponseModel - status-code: 200 - errors: - - root.UnprocessableEntityError - examples: - - path-parameters: - dubbing_id: dubbing_id - language: language - request: - render_type: mp4 - response: - body: - version: 1 - render_id: render_id - dub_a_video_or_an_audio_file: + create: path: /v1/dubbing method: POST auth: false @@ -477,7 +106,7 @@ service: body: dubbing_id: 21m00Tcm4TlvDq8ikWAM expected_duration_sec: 127.5 - get_dubbing_project_metadata: + get: path: /v1/dubbing/{dubbing_id} method: GET auth: false @@ -513,7 +142,7 @@ service: content_type: video/mp4 duration: 127.5 error: error - delete_dubbing_project: + delete: path: /v1/dubbing/{dubbing_id} method: DELETE auth: false @@ -537,71 +166,5 @@ service: response: body: status: ok - get_dubbed_file: - path: /v1/dubbing/{dubbing_id}/audio/{language_code} - method: GET - auth: false - docs: >- - Returns dubbed file as a streamed file. Videos will be returned in MP4 - format and audio only dubs will be returned in MP3. - source: - openapi: openapi.json - path-parameters: - dubbing_id: - type: string - docs: ID of the dubbing project. - language_code: - type: string - docs: ID of the language. - display-name: Get dubbed audio - response: - docs: The dubbed audio or video file - type: file - status-code: 200 - errors: - - root.ForbiddenError - - root.NotFoundError - - root.UnprocessableEntityError - - root.TooEarlyError - get_transcript_for_dub: - path: /v1/dubbing/{dubbing_id}/transcript/{language_code} - method: GET - auth: false - docs: Returns transcript for the dub as an SRT or WEBVTT file. - source: - openapi: openapi.json - path-parameters: - dubbing_id: - type: string - docs: ID of the dubbing project. - language_code: - type: string - docs: ID of the language. - display-name: Get dubbed transcript - request: - name: DubbingGetTranscriptForDubRequest - query-parameters: - format_type: - type: optional - default: srt - docs: Format to use for the subtitle file, either 'srt' or 'webvtt' - response: - docs: Successful Response - type: text - status-code: 200 - errors: - - root.ForbiddenError - - root.NotFoundError - - root.UnprocessableEntityError - - root.TooEarlyError source: openapi: openapi.json -types: - DubbingGetTranscriptForDubRequestFormatType: - enum: - - srt - - webvtt - docs: Format to use for the subtitle file, either 'srt' or 'webvtt' - default: srt - source: - openapi: openapi.json diff --git a/.mock/definition/dubbing/audio.yml b/.mock/definition/dubbing/audio.yml new file mode 100644 index 00000000..ff874880 --- /dev/null +++ b/.mock/definition/dubbing/audio.yml @@ -0,0 +1,35 @@ +imports: + root: ../__package__.yml +service: + auth: false + base-path: '' + endpoints: + get: + path: /v1/dubbing/{dubbing_id}/audio/{language_code} + method: GET + auth: false + docs: >- + Returns dub as a streamed MP3 or MP4 file. If this dub has been edited + using Dubbing Studio you need to use the resource render endpoint as + this endpoint only returns the original automatic dub result. + source: + openapi: openapi.json + path-parameters: + dubbing_id: + type: string + docs: ID of the dubbing project. + language_code: + type: string + docs: ID of the language. + display-name: Get dubbed audio + response: + docs: The dubbed audio or video file + type: file + status-code: 200 + errors: + - root.ForbiddenError + - root.NotFoundError + - root.UnprocessableEntityError + - root.TooEarlyError + source: + openapi: openapi.json diff --git a/.mock/definition/dubbing/resource.yml b/.mock/definition/dubbing/resource.yml new file mode 100644 index 00000000..6ab40289 --- /dev/null +++ b/.mock/definition/dubbing/resource.yml @@ -0,0 +1,271 @@ +imports: + root: ../__package__.yml +service: + auth: false + base-path: '' + endpoints: + get: + path: /v1/dubbing/resource/{dubbing_id} + method: GET + auth: false + docs: >- + Given a dubbing ID generated from the '/v1/dubbing' endpoint with studio + enabled, returns the dubbing resource. + source: + openapi: openapi.json + path-parameters: + dubbing_id: + type: string + docs: ID of the dubbing project. + display-name: Get dubbing resource + response: + docs: Successful Response + type: root.DubbingResource + status-code: 200 + errors: + - root.UnprocessableEntityError + examples: + - path-parameters: + dubbing_id: dubbing_id + response: + body: + id: id + version: 1 + source_language: source_language + target_languages: + - target_languages + input: + src: src + content_type: content_type + bucket_name: bucket_name + random_path_slug: random_path_slug + duration_secs: 1.1 + is_audio: true + url: url + background: + src: src + content_type: content_type + bucket_name: bucket_name + random_path_slug: random_path_slug + duration_secs: 1.1 + is_audio: true + url: url + foreground: + src: src + content_type: content_type + bucket_name: bucket_name + random_path_slug: random_path_slug + duration_secs: 1.1 + is_audio: true + url: url + speaker_tracks: + key: + id: id + media_ref: + src: src + content_type: content_type + bucket_name: bucket_name + random_path_slug: random_path_slug + duration_secs: 1.1 + is_audio: true + url: url + speaker_name: speaker_name + voices: + key: value + segments: + - segments + speaker_segments: + key: + id: id + start_time: 1.1 + end_time: 1.1 + text: text + dubs: + key: + start_time: 1.1 + end_time: 1.1 + audio_stale: true + renders: + key: + id: id + version: 1 + language: language + type: mp4 + media_ref: + src: src + content_type: content_type + bucket_name: bucket_name + random_path_slug: random_path_slug + duration_secs: 1.1 + is_audio: true + url: url + status: complete + transcribe: + path: /v1/dubbing/resource/{dubbing_id}/transcribe + method: POST + auth: false + docs: >- + Regenerate the transcriptions for the specified segments. Does not + automatically regenerate translations or dubs. + source: + openapi: openapi.json + path-parameters: + dubbing_id: + type: string + docs: ID of the dubbing project. + display-name: Transcribe segments + request: + name: BodyTranscribesSegmentsV1DubbingResourceDubbingIdTranscribePost + body: + properties: + segments: + docs: Transcribe this specific list of segments. + type: list + content-type: application/json + response: + docs: Successful Response + type: root.SegmentTranscriptionResponse + status-code: 200 + errors: + - root.UnprocessableEntityError + examples: + - path-parameters: + dubbing_id: dubbing_id + request: + segments: + - segments + response: + body: + version: 1 + translate: + path: /v1/dubbing/resource/{dubbing_id}/translate + method: POST + auth: false + docs: >- + Regenerate the translations for either the entire resource or the + specified segments/languages. Will automatically transcribe missing + transcriptions. Will not automatically regenerate the dubs. + source: + openapi: openapi.json + path-parameters: + dubbing_id: + type: string + docs: ID of the dubbing project. + display-name: Translate segments + request: + name: >- + BodyTranslatesAllOrSomeSegmentsAndLanguagesV1DubbingResourceDubbingIdTranslatePost + body: + properties: + segments: + docs: Translate only this list of segments. + type: list + languages: + type: optional> + docs: Translate only these languages for each segment. + content-type: application/json + response: + docs: Successful Response + type: root.SegmentTranslationResponse + status-code: 200 + errors: + - root.UnprocessableEntityError + examples: + - path-parameters: + dubbing_id: dubbing_id + request: + segments: + - segments + response: + body: + version: 1 + dub: + path: /v1/dubbing/resource/{dubbing_id}/dub + method: POST + auth: false + docs: >- + Regenerate the dubs for either the entire resource or the specified + segments/languages. Will automatically transcribe and translate any + missing transcriptions and translations. + source: + openapi: openapi.json + path-parameters: + dubbing_id: + type: string + docs: ID of the dubbing project. + display-name: Dub segments + request: + name: BodyDubsAllOrSomeSegmentsAndLanguagesV1DubbingResourceDubbingIdDubPost + body: + properties: + segments: + docs: Dub only this list of segments. + type: list + languages: + type: optional> + docs: Dub only these languages for each segment. + content-type: application/json + response: + docs: Successful Response + type: root.SegmentDubResponse + status-code: 200 + errors: + - root.UnprocessableEntityError + examples: + - path-parameters: + dubbing_id: dubbing_id + request: + segments: + - segments + response: + body: + version: 1 + render: + path: /v1/dubbing/resource/{dubbing_id}/render/{language} + method: POST + auth: false + docs: >- + Regenerate the output media for a language using the latest Studio + state. Please ensure all segments have been dubbed before rendering, + otherwise they will be omitted. Renders are generated asynchronously, + and to check the status of all renders please use the 'Get Dubbing + Resource' endpoint. + source: + openapi: openapi.json + path-parameters: + dubbing_id: + type: string + docs: ID of the dubbing project. + language: + type: string + docs: Render this language + display-name: Render Audio Or Video For The Given Language + request: + name: >- + BodyRenderAudioOrVideoForTheGivenLanguageV1DubbingResourceDubbingIdRenderLanguagePost + body: + properties: + render_type: + type: root.RenderType + docs: >- + The type of the render. One of ['mp4', 'aac', 'mp3', 'wav', + 'aaf', 'tracks_zip', 'clips_zip'] + content-type: application/json + response: + docs: Successful Response + type: root.DubbingRenderResponseModel + status-code: 200 + errors: + - root.UnprocessableEntityError + examples: + - path-parameters: + dubbing_id: dubbing_id + language: language + request: + render_type: mp4 + response: + body: + version: 1 + render_id: render_id + source: + openapi: openapi.json diff --git a/.mock/definition/dubbing/resource/language.yml b/.mock/definition/dubbing/resource/language.yml new file mode 100644 index 00000000..9373c0c2 --- /dev/null +++ b/.mock/definition/dubbing/resource/language.yml @@ -0,0 +1,43 @@ +imports: + root: ../../__package__.yml +service: + auth: false + base-path: '' + endpoints: + add: + path: /v1/dubbing/resource/{dubbing_id}/language + method: POST + auth: false + docs: >- + Adds the given ElevenLab Turbo V2/V2.5 language code to the resource. + Does not automatically generate transcripts/translations/audio. + source: + openapi: openapi.json + path-parameters: + dubbing_id: + type: string + docs: ID of the dubbing project. + display-name: Add language to dubbing resource + request: + name: BodyAddALanguageToTheResourceV1DubbingResourceDubbingIdLanguagePost + body: + properties: + language: + type: optional + docs: The Target language. + content-type: application/json + response: + docs: Successful Response + type: root.LanguageAddedResponse + status-code: 201 + errors: + - root.UnprocessableEntityError + examples: + - path-parameters: + dubbing_id: dubbing_id + request: {} + response: + body: + version: 1 + source: + openapi: openapi.json diff --git a/.mock/definition/dubbing/resource/segment.yml b/.mock/definition/dubbing/resource/segment.yml new file mode 100644 index 00000000..a5983f68 --- /dev/null +++ b/.mock/definition/dubbing/resource/segment.yml @@ -0,0 +1,83 @@ +imports: + root: ../../__package__.yml +service: + auth: false + base-path: '' + endpoints: + update: + path: /v1/dubbing/resource/{dubbing_id}/segment/{segment_id}/{language} + method: PATCH + auth: false + docs: >- + Modifies a single segment with new text and/or start/end times. Will + update the values for only a specific language of a segment. Does not + automatically regenerate the dub. + source: + openapi: openapi.json + path-parameters: + dubbing_id: + type: string + docs: ID of the dubbing project. + segment_id: + type: string + docs: ID of the segment + language: + type: string + docs: ID of the language. + display-name: Modify a segment + request: + name: SegmentUpdatePayload + body: + properties: + start_time: + type: optional + end_time: + type: optional + text: + type: optional + content-type: application/json + response: + docs: Successful Response + type: root.SegmentUpdateResponse + status-code: 200 + errors: + - root.UnprocessableEntityError + examples: + - path-parameters: + dubbing_id: dubbing_id + segment_id: segment_id + language: language + request: {} + response: + body: + version: 1 + delete: + path: /v1/dubbing/resource/{dubbing_id}/segment/{segment_id} + method: DELETE + auth: false + docs: Deletes a single segment from the dubbing. + source: + openapi: openapi.json + path-parameters: + dubbing_id: + type: string + docs: ID of the dubbing project. + segment_id: + type: string + docs: ID of the segment + display-name: Delete a segment + response: + docs: Successful Response + type: root.SegmentDeleteResponse + status-code: 200 + errors: + - root.UnprocessableEntityError + examples: + - path-parameters: + dubbing_id: dubbing_id + segment_id: segment_id + response: + body: + version: 1 + source: + openapi: openapi.json diff --git a/.mock/definition/dubbing/speaker.yml b/.mock/definition/dubbing/resource/speaker.yml similarity index 98% rename from .mock/definition/dubbing/speaker.yml rename to .mock/definition/dubbing/resource/speaker.yml index 45d5acfb..9237492b 100644 --- a/.mock/definition/dubbing/speaker.yml +++ b/.mock/definition/dubbing/resource/speaker.yml @@ -1,5 +1,5 @@ imports: - root: ../__package__.yml + root: ../../__package__.yml service: auth: false base-path: '' @@ -52,7 +52,7 @@ service: response: body: version: 1 - similar_voices: + find_similar_voices: path: /v1/dubbing/resource/{dubbing_id}/speaker/{speaker_id}/similar-voices method: GET auth: false diff --git a/.mock/definition/dubbing/speaker/segment.yml b/.mock/definition/dubbing/resource/speaker/segment.yml similarity index 97% rename from .mock/definition/dubbing/speaker/segment.yml rename to .mock/definition/dubbing/resource/speaker/segment.yml index c39a779b..069dcb73 100644 --- a/.mock/definition/dubbing/speaker/segment.yml +++ b/.mock/definition/dubbing/resource/speaker/segment.yml @@ -1,5 +1,5 @@ imports: - root: ../../__package__.yml + root: ../../../__package__.yml service: auth: false base-path: '' diff --git a/.mock/definition/dubbing/transcript.yml b/.mock/definition/dubbing/transcript.yml new file mode 100644 index 00000000..45fc982d --- /dev/null +++ b/.mock/definition/dubbing/transcript.yml @@ -0,0 +1,48 @@ +types: + TranscriptGetTranscriptForDubRequestFormatType: + enum: + - srt + - webvtt + docs: Format to use for the subtitle file, either 'srt' or 'webvtt' + default: srt + source: + openapi: openapi.json +imports: + root: ../__package__.yml +service: + auth: false + base-path: '' + endpoints: + get_transcript_for_dub: + path: /v1/dubbing/{dubbing_id}/transcript/{language_code} + method: GET + auth: false + docs: Returns transcript for the dub as an SRT or WEBVTT file. + source: + openapi: openapi.json + path-parameters: + dubbing_id: + type: string + docs: ID of the dubbing project. + language_code: + type: string + docs: ID of the language. + display-name: Get dubbed transcript + request: + name: TranscriptGetTranscriptForDubRequest + query-parameters: + format_type: + type: optional + default: srt + docs: Format to use for the subtitle file, either 'srt' or 'webvtt' + response: + docs: Successful Response + type: text + status-code: 200 + errors: + - root.ForbiddenError + - root.NotFoundError + - root.UnprocessableEntityError + - root.TooEarlyError + source: + openapi: openapi.json diff --git a/.mock/definition/history.yml b/.mock/definition/history.yml index 132db78e..4ff54799 100644 --- a/.mock/definition/history.yml +++ b/.mock/definition/history.yml @@ -1,5 +1,5 @@ types: - HistoryGetAllRequestSource: + HistoryListRequestSource: enum: - TTS - STS @@ -11,7 +11,7 @@ service: auth: false base-path: '' endpoints: - get_all: + list: path: /v1/history method: GET auth: false @@ -20,7 +20,7 @@ service: openapi: openapi.json display-name: Get generated items request: - name: HistoryGetAllRequest + name: HistoryListRequest query-parameters: page_size: type: optional @@ -48,7 +48,7 @@ service: Search term used for filtering history items. If provided, source becomes required. source: - type: optional + type: optional docs: Source of the generated history item response: docs: Successful Response diff --git a/.mock/definition/models.yml b/.mock/definition/models.yml index ab0c6d6f..40c572dd 100644 --- a/.mock/definition/models.yml +++ b/.mock/definition/models.yml @@ -4,7 +4,7 @@ service: auth: false base-path: '' endpoints: - get_all: + list: path: /v1/models method: GET auth: false diff --git a/.mock/definition/pronunciationDictionary.yml b/.mock/definition/pronunciationDictionaries.yml similarity index 71% rename from .mock/definition/pronunciationDictionary.yml rename to .mock/definition/pronunciationDictionaries.yml index 4cf9b906..b842ac47 100644 --- a/.mock/definition/pronunciationDictionary.yml +++ b/.mock/definition/pronunciationDictionaries.yml @@ -1,5 +1,5 @@ types: - PronunciationDictionaryAddFromFileRequestWorkspaceAccess: + PronunciationDictionariesCreateFromFileRequestWorkspaceAccess: enum: - admin - editor @@ -25,17 +25,7 @@ types: inline: true source: openapi: openapi.json - PronunciationDictionaryRule: - discriminant: type - base-properties: {} - union: - alias: - type: root.PronunciationDictionaryAliasRuleRequestModel - phoneme: - type: root.PronunciationDictionaryPhonemeRuleRequestModel - source: - openapi: openapi.json - PronunciationDictionaryGetAllRequestSort: + PronunciationDictionariesListRequestSort: enum: - creation_time_unix - name @@ -47,7 +37,7 @@ service: auth: false base-path: '' endpoints: - add_from_file: + create_from_file: path: /v1/pronunciation-dictionaries/add-from-file method: POST auth: false @@ -77,7 +67,7 @@ service: identification only. workspace_access: type: >- - optional + optional docs: >- Should be one of 'admin', 'editor' or 'viewer'. If not provided, defaults to no access. @@ -101,7 +91,7 @@ service: version_rules_num: 1 description: This is a test dictionary permission_on_resource: admin - add_from_rules: + create_from_rules: path: /v1/pronunciation-dictionaries/add-from-rules method: POST auth: false @@ -161,86 +151,6 @@ service: version_rules_num: 1 description: This is a test dictionary permission_on_resource: admin - add_rules: - path: /v1/pronunciation-dictionaries/{pronunciation_dictionary_id}/add-rules - method: POST - auth: false - docs: Add rules to the pronunciation dictionary - source: - openapi: openapi.json - path-parameters: - pronunciation_dictionary_id: - type: string - docs: The id of the pronunciation dictionary - display-name: Add pronunciation dictionary rules - request: - name: PronunciationDictionary - body: - properties: - rules: - docs: |- - List of pronunciation rules. Rule can be either: - an alias rule: {'string_to_replace': 'a', 'type': 'alias', 'alias': 'b', } - or a phoneme rule: {'string_to_replace': 'a', 'type': 'phoneme', 'phoneme': 'b', 'alphabet': 'ipa' } - type: list - content-type: application/json - response: - docs: Successful Response - type: root.PronunciationDictionaryRulesResponseModel - status-code: 200 - errors: - - root.UnprocessableEntityError - examples: - - path-parameters: - pronunciation_dictionary_id: 21m00Tcm4TlvDq8ikWAM - request: - rules: - - string_to_replace: Thailand - alias: tie-land - type: alias - response: - body: - id: 5xM3yVvZQKV0EfqQpLrJ - version_id: 5xM3yVvZQKV0EfqQpLr2 - version_rules_num: 1 - remove_rules: - path: >- - /v1/pronunciation-dictionaries/{pronunciation_dictionary_id}/remove-rules - method: POST - auth: false - docs: Remove rules from the pronunciation dictionary - source: - openapi: openapi.json - path-parameters: - pronunciation_dictionary_id: - type: string - docs: The id of the pronunciation dictionary - display-name: Remove pronunciation dictionary rules - request: - name: RemovePronunciationDictionaryRulesRequest - body: - properties: - rule_strings: - docs: List of strings to remove from the pronunciation dictionary. - type: list - content-type: application/json - response: - docs: Successful Response - type: root.PronunciationDictionaryRulesResponseModel - status-code: 200 - errors: - - root.UnprocessableEntityError - examples: - - path-parameters: - pronunciation_dictionary_id: 21m00Tcm4TlvDq8ikWAM - request: - rule_strings: - - rule_strings - response: - body: - id: 5xM3yVvZQKV0EfqQpLrJ - version_id: 5xM3yVvZQKV0EfqQpLr2 - version_rules_num: 1 download: path: /v1/pronunciation-dictionaries/{dictionary_id}/{version_id}/download method: GET @@ -294,7 +204,7 @@ service: creation_time_unix: 1714156800 archived_time_unix: 1 description: This is a test dictionary - get_all: + list: path: /v1/pronunciation-dictionaries/ method: GET auth: false @@ -305,7 +215,7 @@ service: openapi: openapi.json display-name: List pronunciation dictionaries request: - name: PronunciationDictionaryGetAllRequest + name: PronunciationDictionariesListRequest query-parameters: cursor: type: optional @@ -320,7 +230,7 @@ service: min: 1 max: 100 sort: - type: optional + type: optional docs: Which field to sort by, one of 'created_at_unix' or 'name'. sort_direction: type: optional diff --git a/.mock/definition/pronunciationDictionaries/rules.yml b/.mock/definition/pronunciationDictionaries/rules.yml new file mode 100644 index 00000000..0609a87e --- /dev/null +++ b/.mock/definition/pronunciationDictionaries/rules.yml @@ -0,0 +1,99 @@ +imports: + root: ../__package__.yml +types: + PronunciationDictionaryRule: + discriminant: type + base-properties: {} + union: + alias: + type: root.PronunciationDictionaryAliasRuleRequestModel + phoneme: + type: root.PronunciationDictionaryPhonemeRuleRequestModel + source: + openapi: openapi.json +service: + auth: false + base-path: '' + endpoints: + add: + path: /v1/pronunciation-dictionaries/{pronunciation_dictionary_id}/add-rules + method: POST + auth: false + docs: Add rules to the pronunciation dictionary + source: + openapi: openapi.json + path-parameters: + pronunciation_dictionary_id: + type: string + docs: The id of the pronunciation dictionary + display-name: Add pronunciation dictionary rules + request: + name: PronunciationDictionary + body: + properties: + rules: + docs: |- + List of pronunciation rules. Rule can be either: + an alias rule: {'string_to_replace': 'a', 'type': 'alias', 'alias': 'b', } + or a phoneme rule: {'string_to_replace': 'a', 'type': 'phoneme', 'phoneme': 'b', 'alphabet': 'ipa' } + type: list + content-type: application/json + response: + docs: Successful Response + type: root.PronunciationDictionaryRulesResponseModel + status-code: 200 + errors: + - root.UnprocessableEntityError + examples: + - path-parameters: + pronunciation_dictionary_id: 21m00Tcm4TlvDq8ikWAM + request: + rules: + - string_to_replace: Thailand + alias: tie-land + type: alias + response: + body: + id: 5xM3yVvZQKV0EfqQpLrJ + version_id: 5xM3yVvZQKV0EfqQpLr2 + version_rules_num: 1 + remove: + path: >- + /v1/pronunciation-dictionaries/{pronunciation_dictionary_id}/remove-rules + method: POST + auth: false + docs: Remove rules from the pronunciation dictionary + source: + openapi: openapi.json + path-parameters: + pronunciation_dictionary_id: + type: string + docs: The id of the pronunciation dictionary + display-name: Remove pronunciation dictionary rules + request: + name: RemovePronunciationDictionaryRulesRequest + body: + properties: + rule_strings: + docs: List of strings to remove from the pronunciation dictionary. + type: list + content-type: application/json + response: + docs: Successful Response + type: root.PronunciationDictionaryRulesResponseModel + status-code: 200 + errors: + - root.UnprocessableEntityError + examples: + - path-parameters: + pronunciation_dictionary_id: 21m00Tcm4TlvDq8ikWAM + request: + rule_strings: + - rule_strings + response: + body: + id: 5xM3yVvZQKV0EfqQpLrJ + version_id: 5xM3yVvZQKV0EfqQpLr2 + version_rules_num: 1 + source: + openapi: openapi.json diff --git a/.mock/definition/samples.yml b/.mock/definition/samples.yml index 0e14cc21..627f9602 100644 --- a/.mock/definition/samples.yml +++ b/.mock/definition/samples.yml @@ -38,33 +38,6 @@ service: response: body: status: ok - get_audio: - path: /v1/voices/{voice_id}/samples/{sample_id}/audio - method: GET - auth: false - docs: Returns the audio corresponding to a sample attached to a voice. - source: - openapi: openapi.json - path-parameters: - voice_id: - type: string - docs: >- - ID of the voice to be used. You can use the [Get - voices](/docs/api-reference/voices/search) endpoint list all the - available voices. - sample_id: - type: string - docs: >- - ID of the sample to be used. You can use the [Get - voices](/docs/api-reference/voices/get) endpoint list all the - available samples for a voice. - display-name: Get audio from sample - response: - docs: Successful Response - type: file - status-code: 200 - errors: - - root.UnprocessableEntityError source: openapi: openapi.json display-name: Samples diff --git a/.mock/definition/speechToSpeech.yml b/.mock/definition/speechToSpeech.yml index 7f1cc4b8..3dcb9069 100644 --- a/.mock/definition/speechToSpeech.yml +++ b/.mock/definition/speechToSpeech.yml @@ -38,7 +38,7 @@ types: inline: true source: openapi: openapi.json - SpeechToSpeechConvertAsStreamRequestOutputFormat: + SpeechToSpeechStreamRequestOutputFormat: enum: - mp3_22050_32 - mp3_44100_32 @@ -70,7 +70,7 @@ types: default: mp3_44100_128 source: openapi: openapi.json - SpeechToSpeechConvertAsStreamRequestFileFormat: + SpeechToSpeechStreamRequestFileFormat: enum: - pcm_s16le_16 - other @@ -201,7 +201,7 @@ service: output_format: mp3_44100_128 request: model_id: eleven_multilingual_sts_v2 - convert_as_stream: + stream: path: /v1/speech-to-speech/{voice_id}/stream method: POST auth: false @@ -254,7 +254,7 @@ service: Defaults to None. availability: deprecated output_format: - type: optional + type: optional default: mp3_44100_128 docs: >- Output format of the generated audio. Formatted as @@ -299,7 +299,7 @@ service: using our audio isolation model. Only applies to Voice Changer. default: false file_format: - type: optional + type: optional docs: >- The format of input audio. Options are 'pcm_s16le_16' or 'other' For `pcm_s16le_16`, the input audio must be 16-bit PCM at a diff --git a/.mock/definition/studio/projects.yml b/.mock/definition/studio/projects.yml index 81602ce7..16391a3b 100644 --- a/.mock/definition/studio/projects.yml +++ b/.mock/definition/studio/projects.yml @@ -4,7 +4,7 @@ service: auth: false base-path: '' endpoints: - get_all: + list: path: /v1/studio/projects method: GET auth: false @@ -55,7 +55,7 @@ service: type: blank source_type: blank chapters_enabled: true - add: + create: path: /v1/studio/projects method: POST auth: false @@ -142,7 +142,7 @@ service: type: optional> docs: An optional list of genres associated with the Studio project. target_audience: - type: optional + type: optional docs: An optional target audience of the Studio project. language: type: optional @@ -209,12 +209,12 @@ service: is converted. Request will contain a json blob containing the status of the conversion fiction: - type: optional + type: optional docs: >- An optional specification of whether the content of this Studio project is fiction. apply_text_normalization: - type: optional + type: optional docs: |2- This parameter controls text normalization with four modes: 'auto', 'on', 'apply_english' and 'off'. @@ -232,7 +232,7 @@ service: [Alpha Feature] Whether automatically assign voices to phrases in the create Project. source_type: - type: optional + type: optional docs: The type of Studio project to create. content-type: multipart/form-data response: @@ -374,7 +374,7 @@ service: apply_text_normalization: auto experimental: key: value - update_metadata: + update: path: /v1/studio/projects/{project_id} method: POST auth: false @@ -510,92 +510,6 @@ service: response: body: status: ok - update_content: - path: /v1/studio/projects/{project_id}/content - method: POST - auth: false - docs: Updates Studio project content. - source: - openapi: openapi.json - path-parameters: - project_id: - type: string - docs: >- - The ID of the project to be used. You can use the [List - projects](/docs/api-reference/studio/get-projects) endpoint to list - all the available projects. - display-name: Update Studio Project Content - request: - name: >- - Body_Update_Studio_project_content_v1_studio_projects__project_id__content_post - body: - properties: - from_url: - type: optional - docs: >- - An optional URL from which we will extract content to initialize - the Studio project. If this is set, 'from_url' must be null. If - neither 'from_url' or 'from_document' are provided we will - initialize the Studio project as blank. - from_document: - type: optional - docs: >- - An optional .epub, .pdf, .txt or similar file can be provided. - If provided, we will initialize the Studio project with its - content. If this is set, 'from_url' must be null. If neither - 'from_url' or 'from_document' are provided we will initialize - the Studio project as blank. - auto_convert: - type: optional - docs: Whether to auto convert the Studio project to audio or not. - default: false - content-type: multipart/form-data - response: - docs: Successful Response - type: root.EditProjectResponseModel - status-code: 200 - errors: - - root.UnprocessableEntityError - examples: - - path-parameters: - project_id: 21m00Tcm4TlvDq8ikWAM - request: {} - response: - body: - project: - project_id: aw1NgEzBg83R7vgmiJt6 - name: My Project - create_date_unix: 1714204800 - default_title_voice_id: JBFqnCBsd6RMkjVDRZzb - default_paragraph_voice_id: JBFqnCBsd6RMkjVDRZzb - default_model_id: eleven_multilingual_v2 - last_conversion_date_unix: 1714204800 - can_be_downloaded: true - title: My Project - author: John Doe - description: This is a description of my project. - genres: - - Novel - - Short Story - cover_image_url: https://example.com/cover.jpg - target_audience: children - language: en - content_type: Novel - original_publication_date: '2025-01-01' - mature_content: false - isbn_number: 978-90-274-3964-2 - volume_normalization: true - state: default - access_level: viewer - fiction: fiction - quality_check_on: false - quality_check_on_when_bulk_convert: false - creation_meta: - creation_progress: 0.5 - status: pending - type: blank - source_type: blank - chapters_enabled: true convert: path: /v1/studio/projects/{project_id}/convert method: POST @@ -623,204 +537,10 @@ service: response: body: status: ok - get_snapshots: - path: /v1/studio/projects/{project_id}/snapshots - method: GET - auth: false - docs: Retrieves a list of snapshots for a Studio project. - source: - openapi: openapi.json - path-parameters: - project_id: - type: string - docs: The ID of the Studio project. - display-name: List Studio Project Snapshots - response: - docs: Successful Response - type: root.ProjectSnapshotsResponse - status-code: 200 - errors: - - root.UnprocessableEntityError - examples: - - path-parameters: - project_id: 21m00Tcm4TlvDq8ikWAM - response: - body: - snapshots: - - project_snapshot_id: aw1NgEzBg83R7vgmiJt6 - project_id: aw1NgEzBg83R7vgmiJt6 - created_at_unix: 1714204800 - name: My Project Snapshot - audio_upload: - key: value - zip_upload: - key: value - get_project_snapshot: - path: /v1/studio/projects/{project_id}/snapshots/{project_snapshot_id} - method: GET - auth: false - docs: Returns the project snapshot. - source: - openapi: openapi.json - path-parameters: - project_id: - type: string - docs: The ID of the Studio project. - project_snapshot_id: - type: string - docs: The ID of the Studio project snapshot. - display-name: Get Project Snapshot - response: - docs: Successful Response - type: root.ProjectSnapshotExtendedResponseModel - status-code: 200 - errors: - - root.UnprocessableEntityError - examples: - - path-parameters: - project_id: 21m00Tcm4TlvDq8ikWAM - project_snapshot_id: 21m00Tcm4TlvDq8ikWAM - response: - body: - project_snapshot_id: aw1NgEzBg83R7vgmiJt6 - project_id: aw1NgEzBg83R7vgmiJt6 - created_at_unix: 1714204800 - name: My Project Snapshot - audio_upload: - key: value - zip_upload: - key: value - character_alignments: - - characters: - - characters - character_start_times_seconds: - - 1.1 - character_end_times_seconds: - - 1.1 - stream_audio: - path: /v1/studio/projects/{project_id}/snapshots/{project_snapshot_id}/stream - method: POST - auth: false - docs: Stream the audio from a Studio project snapshot. - source: - openapi: openapi.json - path-parameters: - project_id: - type: string - docs: >- - The ID of the project to be used. You can use the [List - projects](/docs/api-reference/studio/get-projects) endpoint to list - all the available projects. - project_snapshot_id: - type: string - docs: The ID of the Studio project snapshot. - display-name: Stream Studio Project Audio - request: - name: >- - BodyStreamStudioProjectAudioV1StudioProjectsProjectIdSnapshotsProjectSnapshotIdStreamPost - body: - properties: - convert_to_mpeg: - type: optional - docs: Whether to convert the audio to mpeg format. - default: false - content-type: application/json - response: - docs: Successful Response - type: file - status-code: 200 - errors: - - root.UnprocessableEntityError - stream_archive: - path: /v1/studio/projects/{project_id}/snapshots/{project_snapshot_id}/archive - method: POST - auth: false - docs: Returns a compressed archive of the Studio project's audio. - source: - openapi: openapi.json - path-parameters: - project_id: - type: string - docs: >- - The ID of the project to be used. You can use the [List - projects](/docs/api-reference/studio/get-projects) endpoint to list - all the available projects. - project_snapshot_id: - type: string - docs: The ID of the Studio project snapshot. - display-name: Stream Archive With Studio Project Audio - response: - docs: Streaming archive data - type: file - status-code: 200 - errors: - - root.UnprocessableEntityError - update_pronunciation_dictionaries: - path: /v1/studio/projects/{project_id}/pronunciation-dictionaries - method: POST - auth: false - docs: >- - Create a set of pronunciation dictionaries acting on a project. This - will automatically mark text within this project as requiring - reconverting where the new dictionary would apply or the old one no - longer does. - source: - openapi: openapi.json - path-parameters: - project_id: - type: string - docs: >- - The ID of the project to be used. You can use the [List - projects](/docs/api-reference/studio/get-projects) endpoint to list - all the available projects. - display-name: Create Pronunciation Dictionaries - request: - name: >- - BodyCreatePronunciationDictionariesV1StudioProjectsProjectIdPronunciationDictionariesPost - body: - properties: - pronunciation_dictionary_locators: - docs: >- - A list of pronunciation dictionary locators - (pronunciation_dictionary_id, version_id) encoded as a list of - JSON strings for pronunciation dictionaries to be applied to the - text. A list of json encoded strings is required as adding - projects may occur through formData as opposed to jsonBody. To - specify multiple dictionaries use multiple --form lines in your - curl, such as --form - 'pronunciation_dictionary_locators="{\"pronunciation_dictionary_id\":\"Vmd4Zor6fplcA7WrINey\",\"version_id\":\"hRPaxjlTdR7wFMhV4w0b\"}"' - --form - 'pronunciation_dictionary_locators="{\"pronunciation_dictionary_id\":\"JzWtcGQMJ6bnlWwyMo7e\",\"version_id\":\"lbmwxiLu4q6txYxgdZqn\"}"'. - Note that multiple dictionaries are not currently supported by - our UI which will only show the first. - type: list - invalidate_affected_text: - type: optional - docs: >- - This will automatically mark text in this project for - reconversion when the new dictionary applies or the old one no - longer does. - default: true - content-type: application/json - response: - docs: Successful Response - type: root.CreatePronunciationDictionaryResponseModel - status-code: 200 - errors: - - root.UnprocessableEntityError - examples: - - path-parameters: - project_id: 21m00Tcm4TlvDq8ikWAM - request: - pronunciation_dictionary_locators: - - pronunciation_dictionary_id: pronunciation_dictionary_id - response: - body: - status: ok source: openapi: openapi.json types: - ProjectsAddRequestTargetAudience: + ProjectsCreateRequestTargetAudience: enum: - children - value: young adult @@ -831,7 +551,7 @@ types: inline: true source: openapi: openapi.json - ProjectsAddRequestFiction: + ProjectsCreateRequestFiction: enum: - fiction - value: non-fiction @@ -839,7 +559,7 @@ types: inline: true source: openapi: openapi.json - ProjectsAddRequestApplyTextNormalization: + ProjectsCreateRequestApplyTextNormalization: enum: - auto - 'on' @@ -848,7 +568,7 @@ types: inline: true source: openapi: openapi.json - ProjectsAddRequestSourceType: + ProjectsCreateRequestSourceType: enum: - blank - book diff --git a/.mock/definition/studio/chapters.yml b/.mock/definition/studio/projects/chapters.yml similarity index 66% rename from .mock/definition/studio/chapters.yml rename to .mock/definition/studio/projects/chapters.yml index 8f9bf642..1bead27a 100644 --- a/.mock/definition/studio/chapters.yml +++ b/.mock/definition/studio/projects/chapters.yml @@ -1,10 +1,10 @@ imports: - root: ../__package__.yml + root: ../../__package__.yml service: auth: false base-path: '' endpoints: - get_all: + list: path: /v1/studio/projects/{project_id}/chapters method: GET auth: false @@ -152,7 +152,7 @@ service: - voice_id: voice_id text: text type: tts_node - edit: + update: path: /v1/studio/projects/{project_id}/chapters/{chapter_id} method: POST auth: false @@ -285,138 +285,5 @@ service: response: body: status: ok - get_all_snapshots: - path: /v1/studio/projects/{project_id}/chapters/{chapter_id}/snapshots - method: GET - auth: false - docs: >- - Gets information about all the snapshots of a chapter. Each snapshot can - be downloaded as audio. Whenever a chapter is converted a snapshot will - automatically be created. - source: - openapi: openapi.json - path-parameters: - project_id: - type: string - docs: >- - The ID of the project to be used. You can use the [List - projects](/docs/api-reference/studio/get-projects) endpoint to list - all the available projects. - chapter_id: - type: string - docs: >- - The ID of the chapter to be used. You can use the [List project - chapters](/docs/api-reference/studio/get-chapters) endpoint to list - all the available chapters. - display-name: List Chapter Snapshots - response: - docs: Successful Response - type: root.ChapterSnapshotsResponse - status-code: 200 - errors: - - root.UnprocessableEntityError - examples: - - path-parameters: - project_id: 21m00Tcm4TlvDq8ikWAM - chapter_id: 21m00Tcm4TlvDq8ikWAM - response: - body: - snapshots: - - chapter_snapshot_id: aw1NgEzBg83R7vgmiJt1 - project_id: aw1NgEzBg83R7vgmiJt2 - chapter_id: aw1NgEzBg83R7vgmiJt3 - created_at_unix: 1714204800 - name: My Chapter Snapshot - get_chapter_snapshot: - path: >- - /v1/studio/projects/{project_id}/chapters/{chapter_id}/snapshots/{chapter_snapshot_id} - method: GET - auth: false - docs: Returns the chapter snapshot. - source: - openapi: openapi.json - path-parameters: - project_id: - type: string - docs: The ID of the Studio project. - chapter_id: - type: string - docs: The ID of the chapter. - chapter_snapshot_id: - type: string - docs: The ID of the chapter snapshot. - display-name: Get Chapter Snapshot - response: - docs: Successful Response - type: root.ChapterSnapshotExtendedResponseModel - status-code: 200 - errors: - - root.UnprocessableEntityError - examples: - - path-parameters: - project_id: 21m00Tcm4TlvDq8ikWAM - chapter_id: 21m00Tcm4TlvDq8ikWAM - chapter_snapshot_id: 21m00Tcm4TlvDq8ikWAM - response: - body: - chapter_snapshot_id: aw1NgEzBg83R7vgmiJt1 - project_id: aw1NgEzBg83R7vgmiJt2 - chapter_id: aw1NgEzBg83R7vgmiJt3 - created_at_unix: 1714204800 - name: My Chapter Snapshot - character_alignments: - - characters: - - characters - character_start_times_seconds: - - 1.1 - character_end_times_seconds: - - 1.1 - stream_snapshot: - path: >- - /v1/studio/projects/{project_id}/chapters/{chapter_id}/snapshots/{chapter_snapshot_id}/stream - method: POST - auth: false - docs: >- - Stream the audio from a chapter snapshot. Use `GET - /v1/studio/projects/{project_id}/chapters/{chapter_id}/snapshots` to - return the snapshots of a chapter. - source: - openapi: openapi.json - path-parameters: - project_id: - type: string - docs: >- - The ID of the project to be used. You can use the [List - projects](/docs/api-reference/studio/get-projects) endpoint to list - all the available projects. - chapter_id: - type: string - docs: >- - The ID of the chapter to be used. You can use the [List project - chapters](/docs/api-reference/studio/get-chapters) endpoint to list - all the available chapters. - chapter_snapshot_id: - type: string - docs: >- - The ID of the chapter snapshot to be used. You can use the [List - project chapter snapshots](/docs/api-reference/studio/get-snapshots) - endpoint to list all the available snapshots. - display-name: Stream Chapter Audio - request: - name: >- - BodyStreamChapterAudioV1StudioProjectsProjectIdChaptersChapterIdSnapshotsChapterSnapshotIdStreamPost - body: - properties: - convert_to_mpeg: - type: optional - docs: Whether to convert the audio to mpeg format. - default: false - content-type: application/json - response: - docs: Streaming audio data - type: file - status-code: 200 - errors: - - root.UnprocessableEntityError source: openapi: openapi.json diff --git a/.mock/definition/studio/projects/chapters/snapshots.yml b/.mock/definition/studio/projects/chapters/snapshots.yml new file mode 100644 index 00000000..251ad533 --- /dev/null +++ b/.mock/definition/studio/projects/chapters/snapshots.yml @@ -0,0 +1,141 @@ +imports: + root: ../../../__package__.yml +service: + auth: false + base-path: '' + endpoints: + list: + path: /v1/studio/projects/{project_id}/chapters/{chapter_id}/snapshots + method: GET + auth: false + docs: >- + Gets information about all the snapshots of a chapter. Each snapshot can + be downloaded as audio. Whenever a chapter is converted a snapshot will + automatically be created. + source: + openapi: openapi.json + path-parameters: + project_id: + type: string + docs: >- + The ID of the project to be used. You can use the [List + projects](/docs/api-reference/studio/get-projects) endpoint to list + all the available projects. + chapter_id: + type: string + docs: >- + The ID of the chapter to be used. You can use the [List project + chapters](/docs/api-reference/studio/get-chapters) endpoint to list + all the available chapters. + display-name: List Chapter Snapshots + response: + docs: Successful Response + type: root.ChapterSnapshotsResponse + status-code: 200 + errors: + - root.UnprocessableEntityError + examples: + - path-parameters: + project_id: 21m00Tcm4TlvDq8ikWAM + chapter_id: 21m00Tcm4TlvDq8ikWAM + response: + body: + snapshots: + - chapter_snapshot_id: aw1NgEzBg83R7vgmiJt1 + project_id: aw1NgEzBg83R7vgmiJt2 + chapter_id: aw1NgEzBg83R7vgmiJt3 + created_at_unix: 1714204800 + name: My Chapter Snapshot + get: + path: >- + /v1/studio/projects/{project_id}/chapters/{chapter_id}/snapshots/{chapter_snapshot_id} + method: GET + auth: false + docs: Returns the chapter snapshot. + source: + openapi: openapi.json + path-parameters: + project_id: + type: string + docs: The ID of the Studio project. + chapter_id: + type: string + docs: The ID of the chapter. + chapter_snapshot_id: + type: string + docs: The ID of the chapter snapshot. + display-name: Get Chapter Snapshot + response: + docs: Successful Response + type: root.ChapterSnapshotExtendedResponseModel + status-code: 200 + errors: + - root.UnprocessableEntityError + examples: + - path-parameters: + project_id: 21m00Tcm4TlvDq8ikWAM + chapter_id: 21m00Tcm4TlvDq8ikWAM + chapter_snapshot_id: 21m00Tcm4TlvDq8ikWAM + response: + body: + chapter_snapshot_id: aw1NgEzBg83R7vgmiJt1 + project_id: aw1NgEzBg83R7vgmiJt2 + chapter_id: aw1NgEzBg83R7vgmiJt3 + created_at_unix: 1714204800 + name: My Chapter Snapshot + character_alignments: + - characters: + - characters + character_start_times_seconds: + - 1.1 + character_end_times_seconds: + - 1.1 + stream: + path: >- + /v1/studio/projects/{project_id}/chapters/{chapter_id}/snapshots/{chapter_snapshot_id}/stream + method: POST + auth: false + docs: >- + Stream the audio from a chapter snapshot. Use `GET + /v1/studio/projects/{project_id}/chapters/{chapter_id}/snapshots` to + return the snapshots of a chapter. + source: + openapi: openapi.json + path-parameters: + project_id: + type: string + docs: >- + The ID of the project to be used. You can use the [List + projects](/docs/api-reference/studio/get-projects) endpoint to list + all the available projects. + chapter_id: + type: string + docs: >- + The ID of the chapter to be used. You can use the [List project + chapters](/docs/api-reference/studio/get-chapters) endpoint to list + all the available chapters. + chapter_snapshot_id: + type: string + docs: >- + The ID of the chapter snapshot to be used. You can use the [List + project chapter snapshots](/docs/api-reference/studio/get-snapshots) + endpoint to list all the available snapshots. + display-name: Stream Chapter Audio + request: + name: >- + BodyStreamChapterAudioV1StudioProjectsProjectIdChaptersChapterIdSnapshotsChapterSnapshotIdStreamPost + body: + properties: + convert_to_mpeg: + type: optional + docs: Whether to convert the audio to mpeg format. + default: false + content-type: application/json + response: + docs: Streaming audio data + type: file + status-code: 200 + errors: + - root.UnprocessableEntityError + source: + openapi: openapi.json diff --git a/.mock/definition/studio/projects/content.yml b/.mock/definition/studio/projects/content.yml new file mode 100644 index 00000000..982dce1d --- /dev/null +++ b/.mock/definition/studio/projects/content.yml @@ -0,0 +1,94 @@ +imports: + root: ../../__package__.yml +service: + auth: false + base-path: '' + endpoints: + update: + path: /v1/studio/projects/{project_id}/content + method: POST + auth: false + docs: Updates Studio project content. + source: + openapi: openapi.json + path-parameters: + project_id: + type: string + docs: >- + The ID of the project to be used. You can use the [List + projects](/docs/api-reference/studio/get-projects) endpoint to list + all the available projects. + display-name: Update Studio Project Content + request: + name: >- + Body_Update_Studio_project_content_v1_studio_projects__project_id__content_post + body: + properties: + from_url: + type: optional + docs: >- + An optional URL from which we will extract content to initialize + the Studio project. If this is set, 'from_url' must be null. If + neither 'from_url' or 'from_document' are provided we will + initialize the Studio project as blank. + from_document: + type: optional + docs: >- + An optional .epub, .pdf, .txt or similar file can be provided. + If provided, we will initialize the Studio project with its + content. If this is set, 'from_url' must be null. If neither + 'from_url' or 'from_document' are provided we will initialize + the Studio project as blank. + auto_convert: + type: optional + docs: Whether to auto convert the Studio project to audio or not. + default: false + content-type: multipart/form-data + response: + docs: Successful Response + type: root.EditProjectResponseModel + status-code: 200 + errors: + - root.UnprocessableEntityError + examples: + - path-parameters: + project_id: 21m00Tcm4TlvDq8ikWAM + request: {} + response: + body: + project: + project_id: aw1NgEzBg83R7vgmiJt6 + name: My Project + create_date_unix: 1714204800 + default_title_voice_id: JBFqnCBsd6RMkjVDRZzb + default_paragraph_voice_id: JBFqnCBsd6RMkjVDRZzb + default_model_id: eleven_multilingual_v2 + last_conversion_date_unix: 1714204800 + can_be_downloaded: true + title: My Project + author: John Doe + description: This is a description of my project. + genres: + - Novel + - Short Story + cover_image_url: https://example.com/cover.jpg + target_audience: children + language: en + content_type: Novel + original_publication_date: '2025-01-01' + mature_content: false + isbn_number: 978-90-274-3964-2 + volume_normalization: true + state: default + access_level: viewer + fiction: fiction + quality_check_on: false + quality_check_on_when_bulk_convert: false + creation_meta: + creation_progress: 0.5 + status: pending + type: blank + source_type: blank + chapters_enabled: true + source: + openapi: openapi.json diff --git a/.mock/definition/studio/projects/pronunciationDictionaries.yml b/.mock/definition/studio/projects/pronunciationDictionaries.yml new file mode 100644 index 00000000..187ceb61 --- /dev/null +++ b/.mock/definition/studio/projects/pronunciationDictionaries.yml @@ -0,0 +1,70 @@ +imports: + root: ../../__package__.yml +service: + auth: false + base-path: '' + endpoints: + create: + path: /v1/studio/projects/{project_id}/pronunciation-dictionaries + method: POST + auth: false + docs: >- + Create a set of pronunciation dictionaries acting on a project. This + will automatically mark text within this project as requiring + reconverting where the new dictionary would apply or the old one no + longer does. + source: + openapi: openapi.json + path-parameters: + project_id: + type: string + docs: >- + The ID of the project to be used. You can use the [List + projects](/docs/api-reference/studio/get-projects) endpoint to list + all the available projects. + display-name: Create Pronunciation Dictionaries + request: + name: >- + BodyCreatePronunciationDictionariesV1StudioProjectsProjectIdPronunciationDictionariesPost + body: + properties: + pronunciation_dictionary_locators: + docs: >- + A list of pronunciation dictionary locators + (pronunciation_dictionary_id, version_id) encoded as a list of + JSON strings for pronunciation dictionaries to be applied to the + text. A list of json encoded strings is required as adding + projects may occur through formData as opposed to jsonBody. To + specify multiple dictionaries use multiple --form lines in your + curl, such as --form + 'pronunciation_dictionary_locators="{\"pronunciation_dictionary_id\":\"Vmd4Zor6fplcA7WrINey\",\"version_id\":\"hRPaxjlTdR7wFMhV4w0b\"}"' + --form + 'pronunciation_dictionary_locators="{\"pronunciation_dictionary_id\":\"JzWtcGQMJ6bnlWwyMo7e\",\"version_id\":\"lbmwxiLu4q6txYxgdZqn\"}"'. + Note that multiple dictionaries are not currently supported by + our UI which will only show the first. + type: list + invalidate_affected_text: + type: optional + docs: >- + This will automatically mark text in this project for + reconversion when the new dictionary applies or the old one no + longer does. + default: true + content-type: application/json + response: + docs: Successful Response + type: root.CreatePronunciationDictionaryResponseModel + status-code: 200 + errors: + - root.UnprocessableEntityError + examples: + - path-parameters: + project_id: 21m00Tcm4TlvDq8ikWAM + request: + pronunciation_dictionary_locators: + - pronunciation_dictionary_id: pronunciation_dictionary_id + response: + body: + status: ok + source: + openapi: openapi.json diff --git a/.mock/definition/studio/projects/snapshots.yml b/.mock/definition/studio/projects/snapshots.yml new file mode 100644 index 00000000..7a2dfa31 --- /dev/null +++ b/.mock/definition/studio/projects/snapshots.yml @@ -0,0 +1,140 @@ +imports: + root: ../../__package__.yml +service: + auth: false + base-path: '' + endpoints: + list: + path: /v1/studio/projects/{project_id}/snapshots + method: GET + auth: false + docs: Retrieves a list of snapshots for a Studio project. + source: + openapi: openapi.json + path-parameters: + project_id: + type: string + docs: The ID of the Studio project. + display-name: List Studio Project Snapshots + response: + docs: Successful Response + type: root.ProjectSnapshotsResponse + status-code: 200 + errors: + - root.UnprocessableEntityError + examples: + - path-parameters: + project_id: 21m00Tcm4TlvDq8ikWAM + response: + body: + snapshots: + - project_snapshot_id: aw1NgEzBg83R7vgmiJt6 + project_id: aw1NgEzBg83R7vgmiJt6 + created_at_unix: 1714204800 + name: My Project Snapshot + audio_upload: + key: value + zip_upload: + key: value + get: + path: /v1/studio/projects/{project_id}/snapshots/{project_snapshot_id} + method: GET + auth: false + docs: Returns the project snapshot. + source: + openapi: openapi.json + path-parameters: + project_id: + type: string + docs: The ID of the Studio project. + project_snapshot_id: + type: string + docs: The ID of the Studio project snapshot. + display-name: Get Project Snapshot + response: + docs: Successful Response + type: root.ProjectSnapshotExtendedResponseModel + status-code: 200 + errors: + - root.UnprocessableEntityError + examples: + - path-parameters: + project_id: 21m00Tcm4TlvDq8ikWAM + project_snapshot_id: 21m00Tcm4TlvDq8ikWAM + response: + body: + project_snapshot_id: aw1NgEzBg83R7vgmiJt6 + project_id: aw1NgEzBg83R7vgmiJt6 + created_at_unix: 1714204800 + name: My Project Snapshot + audio_upload: + key: value + zip_upload: + key: value + character_alignments: + - characters: + - characters + character_start_times_seconds: + - 1.1 + character_end_times_seconds: + - 1.1 + stream: + path: /v1/studio/projects/{project_id}/snapshots/{project_snapshot_id}/stream + method: POST + auth: false + docs: Stream the audio from a Studio project snapshot. + source: + openapi: openapi.json + path-parameters: + project_id: + type: string + docs: >- + The ID of the project to be used. You can use the [List + projects](/docs/api-reference/studio/get-projects) endpoint to list + all the available projects. + project_snapshot_id: + type: string + docs: The ID of the Studio project snapshot. + display-name: Stream Studio Project Audio + request: + name: >- + BodyStreamStudioProjectAudioV1StudioProjectsProjectIdSnapshotsProjectSnapshotIdStreamPost + body: + properties: + convert_to_mpeg: + type: optional + docs: Whether to convert the audio to mpeg format. + default: false + content-type: application/json + response: + docs: Successful Response + type: file + status-code: 200 + errors: + - root.UnprocessableEntityError + stream_archive: + path: /v1/studio/projects/{project_id}/snapshots/{project_snapshot_id}/archive + method: POST + auth: false + docs: Returns a compressed archive of the Studio project's audio. + source: + openapi: openapi.json + path-parameters: + project_id: + type: string + docs: >- + The ID of the project to be used. You can use the [List + projects](/docs/api-reference/studio/get-projects) endpoint to list + all the available projects. + project_snapshot_id: + type: string + docs: The ID of the Studio project snapshot. + display-name: Stream Archive With Studio Project Audio + response: + docs: Streaming archive data + type: file + status-code: 200 + errors: + - root.UnprocessableEntityError + source: + openapi: openapi.json diff --git a/.mock/definition/textToSpeech.yml b/.mock/definition/textToSpeech.yml index 62aa26bf..ce87fb28 100644 --- a/.mock/definition/textToSpeech.yml +++ b/.mock/definition/textToSpeech.yml @@ -95,7 +95,7 @@ types: inline: true source: openapi: openapi.json - TextToSpeechConvertAsStreamRequestOutputFormat: + TextToSpeechStreamRequestOutputFormat: enum: - mp3_22050_32 - mp3_44100_32 @@ -594,7 +594,7 @@ service: - 0.3 - 0.4 - 0.5 - convert_as_stream: + stream: path: /v1/text-to-speech/{voice_id}/stream method: POST auth: false @@ -646,7 +646,7 @@ service: Defaults to None. availability: deprecated output_format: - type: optional + type: optional default: mp3_44100_128 docs: >- Output format of the generated audio. Formatted as diff --git a/.mock/definition/textToVoice.yml b/.mock/definition/textToVoice.yml index 6107e151..e222f578 100644 --- a/.mock/definition/textToVoice.yml +++ b/.mock/definition/textToVoice.yml @@ -268,6 +268,7 @@ service: free_users_allowed: true live_moderation_enabled: true rate: 0.05 + fiat_rate: 1.1 notice_period: 30 disable_at_unix: 1714204800 voice_mixing_allowed: false diff --git a/.mock/definition/usage.yml b/.mock/definition/usage.yml index c70f1ae0..1ec7b59f 100644 --- a/.mock/definition/usage.yml +++ b/.mock/definition/usage.yml @@ -4,7 +4,7 @@ service: auth: false base-path: '' endpoints: - get_characters_usage_metrics: + get: path: /v1/usage/character-stats method: GET auth: false @@ -19,7 +19,7 @@ service: openapi: openapi.json display-name: Get character usage metrics request: - name: UsageGetCharactersUsageMetricsRequest + name: UsageGetRequest query-parameters: start_unix: type: integer diff --git a/.mock/definition/user.yml b/.mock/definition/user.yml index a07e4360..efe52a87 100644 --- a/.mock/definition/user.yml +++ b/.mock/definition/user.yml @@ -4,48 +4,6 @@ service: auth: false base-path: '' endpoints: - get_subscription: - path: /v1/user/subscription - method: GET - auth: false - docs: Gets extended information about the users subscription - source: - openapi: openapi.json - display-name: Get user subscription - response: - docs: Successful Response - type: root.Subscription - status-code: 200 - errors: - - root.UnprocessableEntityError - examples: - - response: - body: - tier: tier - character_count: 1 - character_limit: 1 - max_character_limit_extension: 1 - can_extend_character_limit: true - allowed_to_extend_character_limit: true - next_character_count_reset_unix: 1 - voice_slots_used: 1 - professional_voice_slots_used: 1 - voice_limit: 1 - max_voice_add_edits: 1 - voice_add_edit_counter: 1 - professional_voice_limit: 1 - can_extend_voice_limit: true - can_use_instant_voice_cloning: true - can_use_professional_voice_cloning: true - currency: usd - status: trialing - billing_period: monthly_period - character_refresh_period: monthly_period - next_invoice: - amount_due_cents: 1000 - discount_percent_off: 1.1 - next_payment_attempt_unix: 1738356858 - has_open_invoices: false get: path: /v1/user method: GET diff --git a/.mock/definition/user/subscription.yml b/.mock/definition/user/subscription.yml new file mode 100644 index 00000000..84f394e7 --- /dev/null +++ b/.mock/definition/user/subscription.yml @@ -0,0 +1,50 @@ +imports: + root: ../__package__.yml +service: + auth: false + base-path: '' + endpoints: + get: + path: /v1/user/subscription + method: GET + auth: false + docs: Gets extended information about the users subscription + source: + openapi: openapi.json + display-name: Get user subscription + response: + docs: Successful Response + type: root.Subscription + status-code: 200 + errors: + - root.UnprocessableEntityError + examples: + - response: + body: + tier: tier + character_count: 1 + character_limit: 1 + max_character_limit_extension: 1 + can_extend_character_limit: true + allowed_to_extend_character_limit: true + next_character_count_reset_unix: 1 + voice_slots_used: 1 + professional_voice_slots_used: 1 + voice_limit: 1 + max_voice_add_edits: 1 + voice_add_edit_counter: 1 + professional_voice_limit: 1 + can_extend_voice_limit: true + can_use_instant_voice_cloning: true + can_use_professional_voice_cloning: true + currency: usd + status: trialing + billing_period: monthly_period + character_refresh_period: monthly_period + next_invoice: + amount_due_cents: 1000 + discount_percent_off: 1.1 + next_payment_attempt_unix: 1738356858 + has_open_invoices: false + source: + openapi: openapi.json diff --git a/.mock/definition/v1TextToSpeechVoiceIdMultiStreamInput.yml b/.mock/definition/v1TextToSpeechVoiceIdMultiStreamInput.yml index 8a5b0958..5d1e079e 100644 --- a/.mock/definition/v1TextToSpeechVoiceIdMultiStreamInput.yml +++ b/.mock/definition/v1TextToSpeechVoiceIdMultiStreamInput.yml @@ -1,63 +1,5 @@ -types: - TextToSpeechOutputFormat: - enum: - - mp3_22050_32 - - mp3_44100_32 - - mp3_44100_64 - - mp3_44100_96 - - mp3_44100_128 - - mp3_44100_192 - - pcm_8000 - - pcm_16000 - - pcm_22050 - - pcm_24000 - - pcm_44100 - - ulaw_8000 - - alaw_8000 - - opus_48000_32 - - opus_48000_64 - - opus_48000_96 - - opus_48000_128 - - opus_48000_192 - docs: The output audio format - source: - openapi: asyncapi.yml - TextToSpeechApplyTextNormalization: - enum: - - auto - - 'on' - - 'off' - docs: >- - This parameter controls text normalization with three modes - 'auto', - 'on', and 'off'. When set to 'auto', the system will automatically decide - whether to apply text normalization (e.g., spelling out numbers). With - 'on', text normalization will always be applied, while with 'off', it will - be skipped. Cannot be turned on for 'eleven_turbo_v2_5' or - 'eleven_flash_v2_5' models. Defaults to 'auto'. - default: auto - source: - openapi: asyncapi.yml - sendMessageMulti: - discriminated: false - docs: Send messages to the multi-context WebSocket. - union: - - root.InitializeConnectionMulti - - root.InitialiseContext - - root.SendTextMulti - - root.FlushContext - - root.CloseContext - - root.CloseSocket - - root.KeepContextAlive - source: - openapi: asyncapi.yml - receiveMessageMulti: - discriminated: false - docs: Receive messages from the multi-context WebSocket. - union: - - root.AudioOutputMulti - - root.FinalOutputMulti - source: - openapi: asyncapi.yml +imports: + root: __package__.yml channel: path: /v1/text-to-speech/{voice_id}/multi-stream-input url: WSS @@ -110,7 +52,7 @@ channel: default: false docs: Whether to enable SSML parsing. output_format: - type: optional + type: root.TextToSpeechOutputFormatEnum docs: The output audio format inactivity_timeout: type: optional @@ -129,8 +71,7 @@ channel: Reduces latency by disabling chunk schedule and buffers. Recommended for full sentences/phrases. apply_text_normalization: - type: optional - default: auto + type: root.TextToSpeechApplyTextNormalizationEnum docs: >- This parameter controls text normalization with three modes - 'auto', 'on', and 'off'. When set to 'auto', the system will automatically @@ -282,6 +223,28 @@ channel: close_socket: true docs: Demonstrates initializing two contexts, sending text, and managing them. query-parameters: + output_format: mp3_22050_32 + apply_text_normalization: auto seed: 12345 -imports: - root: __package__.yml +types: + sendMessageMulti: + discriminated: false + docs: Send messages to the multi-context WebSocket. + union: + - root.InitializeConnectionMulti + - root.InitialiseContext + - root.SendTextMulti + - root.FlushContext + - root.CloseContext + - root.CloseSocket + - root.KeepContextAlive + source: + openapi: asyncapi.yml + receiveMessageMulti: + discriminated: false + docs: Receive messages from the multi-context WebSocket. + union: + - root.AudioOutputMulti + - root.FinalOutputMulti + source: + openapi: asyncapi.yml diff --git a/.mock/definition/v1TextToSpeechVoiceIdStreamInput.yml b/.mock/definition/v1TextToSpeechVoiceIdStreamInput.yml index 1ca43b2d..18276fa8 100644 --- a/.mock/definition/v1TextToSpeechVoiceIdStreamInput.yml +++ b/.mock/definition/v1TextToSpeechVoiceIdStreamInput.yml @@ -1,3 +1,5 @@ +imports: + root: __package__.yml channel: path: /v1/text-to-speech/{voice_id}/stream-input url: WSS @@ -24,6 +26,59 @@ channel: voice_id: type: string docs: The unique identifier for the voice to use in the TTS process. + query-parameters: + authorization: + type: optional + docs: Your authorization bearer token. + model_id: + type: optional + docs: The model ID to use. + language_code: + type: optional + docs: The ISO 639-1 language code (for specific models). + enable_logging: + type: optional + default: true + docs: Whether to enable logging of the request. + enable_ssml_parsing: + type: optional + default: false + docs: Whether to enable SSML parsing. + output_format: + type: root.TextToSpeechOutputFormatEnum + docs: The output audio format + inactivity_timeout: + type: optional + default: 20 + docs: >- + Timeout for inactivity before a context is closed (seconds), can be up + to 180 seconds. + sync_alignment: + type: optional + default: false + docs: Whether to include timing data with every audio chunk. + auto_mode: + type: optional + default: false + docs: >- + Reduces latency by disabling chunk schedule and buffers. Recommended for + full sentences/phrases. + apply_text_normalization: + type: root.TextToSpeechApplyTextNormalizationEnum + docs: >- + This parameter controls text normalization with three modes - 'auto', + 'on', and 'off'. When set to 'auto', the system will automatically + decide whether to apply text normalization (e.g., spelling out numbers). + With 'on', text normalization will always be applied, while with 'off', + it will be skipped. Cannot be turned on for 'eleven_turbo_v2_5' or + 'eleven_flash_v2_5' models. Defaults to 'auto'. + seed: + type: optional + docs: >- + If specified, system will best-effort sample deterministically. Integer + between 0 and 4294967295. + validation: + min: 0 messages: publish: origin: client @@ -128,8 +183,10 @@ channel: - r - l - d -imports: - root: __package__.yml + query-parameters: + output_format: mp3_22050_32 + apply_text_normalization: auto + seed: 12345 types: sendMessage: discriminated: false diff --git a/.mock/definition/voices.yml b/.mock/definition/voices.yml index 410e7844..3a479529 100644 --- a/.mock/definition/voices.yml +++ b/.mock/definition/voices.yml @@ -351,62 +351,6 @@ service: has_more: true total_count: 1 next_page_token: next_page_token - get_default_settings: - path: /v1/voices/settings/default - method: GET - auth: false - docs: >- - Gets the default settings for voices. "similarity_boost" corresponds - to"Clarity + Similarity Enhancement" in the web app and "stability" - corresponds to "Stability" slider in the web app. - source: - openapi: openapi.json - display-name: Get default voice settings - response: - docs: Successful Response - type: root.VoiceSettings - status-code: 200 - examples: - - response: - body: - stability: 1 - similarity_boost: 1 - style: 0 - use_speaker_boost: true - speed: 1 - get_settings: - path: /v1/voices/{voice_id}/settings - method: GET - auth: false - docs: >- - Returns the settings for a specific voice. "similarity_boost" - corresponds to"Clarity + Similarity Enhancement" in the web app and - "stability" corresponds to "Stability" slider in the web app. - source: - openapi: openapi.json - path-parameters: - voice_id: - type: string - docs: >- - Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices - to list all the available voices. - display-name: Get voice settings - response: - docs: Successful Response - type: root.VoiceSettings - status-code: 200 - errors: - - root.UnprocessableEntityError - examples: - - path-parameters: - voice_id: 21m00Tcm4TlvDq8ikWAM - response: - body: - stability: 1 - similarity_boost: 1 - style: 0 - use_speaker_boost: true - speed: 1 get: path: /v1/voices/{voice_id} method: GET @@ -533,6 +477,7 @@ service: free_users_allowed: true live_moderation_enabled: true rate: 0.05 + fiat_rate: 1.1 notice_period: 30 disable_at_unix: 1714204800 voice_mixing_allowed: false @@ -642,97 +587,7 @@ service: response: body: status: ok - edit_settings: - path: /v1/voices/{voice_id}/settings/edit - method: POST - auth: false - docs: >- - Edit your settings for a specific voice. "similarity_boost" corresponds - to "Clarity + Similarity Enhancement" in the web app and "stability" - corresponds to "Stability" slider in the web app. - source: - openapi: openapi.json - path-parameters: - voice_id: - type: string - docs: >- - ID of the voice to be used. You can use the [Get - voices](/docs/api-reference/voices/search) endpoint list all the - available voices. - display-name: Edit voice settings - request: - body: - type: root.VoiceSettings - docs: The settings for a specific voice. - content-type: application/json - response: - docs: Successful Response - type: root.EditVoiceSettingsResponseModel - status-code: 200 - errors: - - root.UnprocessableEntityError - examples: - - path-parameters: - voice_id: 21m00Tcm4TlvDq8ikWAM - request: - stability: 1 - similarity_boost: 1 - style: 0 - use_speaker_boost: true - speed: 1 - response: - body: - status: ok - add: - path: /v1/voices/add - method: POST - auth: false - docs: Create a voice clone and add it to your Voices - source: - openapi: openapi.json - display-name: Create voice clone - request: - name: Body_Add_voice_v1_voices_add_post - body: - properties: - name: - type: string - docs: >- - The name that identifies this voice. This will be displayed in - the dropdown of the website. - files: - type: list - docs: >- - A list of file paths to audio recordings intended for voice - cloning. - remove_background_noise: - type: optional - docs: >- - If set will remove background noise for voice samples using our - audio isolation model. If the samples do not include background - noise, it can make the quality worse. - default: false - description: - type: optional - docs: A description of the voice. - labels: - type: optional - docs: Serialized labels dictionary for the voice. - content-type: multipart/form-data - response: - docs: Successful Response - type: root.AddVoiceIvcResponseModel - status-code: 200 - errors: - - root.UnprocessableEntityError - examples: - - request: - name: name - response: - body: - voice_id: c38kUX8pkfYO2kHyqfFy - requires_verification: false - edit: + update: path: /v1/voices/{voice_id}/edit method: POST auth: false @@ -787,7 +642,7 @@ service: response: body: status: ok - add_sharing_voice: + share: path: /v1/voices/add/{public_user_id}/{voice_id} method: POST auth: false @@ -937,6 +792,7 @@ service: play_api_usage_character_count_1y: 12852 cloned_by_count: 11 rate: 1 + fiat_rate: 1.1 free_users_allowed: true live_moderation_enabled: false featured: false @@ -953,7 +809,7 @@ service: is_added_by_user: true has_more: false last_sort_id: last_sort_id - get_similar_library_voices: + find_similar_voices: path: /v1/similar-voices method: POST auth: false @@ -1016,6 +872,7 @@ service: play_api_usage_character_count_1y: 12852 cloned_by_count: 11 rate: 1 + fiat_rate: 1.1 free_users_allowed: true live_moderation_enabled: false featured: false diff --git a/.mock/definition/voices/ivc.yml b/.mock/definition/voices/ivc.yml new file mode 100644 index 00000000..49c422ca --- /dev/null +++ b/.mock/definition/voices/ivc.yml @@ -0,0 +1,57 @@ +imports: + root: ../__package__.yml +service: + auth: false + base-path: '' + endpoints: + create: + path: /v1/voices/add + method: POST + auth: false + docs: Create a voice clone and add it to your Voices + source: + openapi: openapi.json + display-name: Create voice clone + request: + name: Body_Add_voice_v1_voices_add_post + body: + properties: + name: + type: string + docs: >- + The name that identifies this voice. This will be displayed in + the dropdown of the website. + files: + type: list + docs: >- + A list of file paths to audio recordings intended for voice + cloning. + remove_background_noise: + type: optional + docs: >- + If set will remove background noise for voice samples using our + audio isolation model. If the samples do not include background + noise, it can make the quality worse. + default: false + description: + type: optional + docs: A description of the voice. + labels: + type: optional + docs: Serialized labels dictionary for the voice. + content-type: multipart/form-data + response: + docs: Successful Response + type: root.AddVoiceIvcResponseModel + status-code: 200 + errors: + - root.UnprocessableEntityError + examples: + - request: + name: name + response: + body: + voice_id: c38kUX8pkfYO2kHyqfFy + requires_verification: false + source: + openapi: openapi.json diff --git a/.mock/definition/voices/samples/audio.yml b/.mock/definition/voices/samples/audio.yml new file mode 100644 index 00000000..dda0df2e --- /dev/null +++ b/.mock/definition/voices/samples/audio.yml @@ -0,0 +1,35 @@ +imports: + root: ../../__package__.yml +service: + auth: false + base-path: '' + endpoints: + get: + path: /v1/voices/{voice_id}/samples/{sample_id}/audio + method: GET + auth: false + docs: Returns the audio corresponding to a sample attached to a voice. + source: + openapi: openapi.json + path-parameters: + voice_id: + type: string + docs: >- + ID of the voice to be used. You can use the [Get + voices](/docs/api-reference/voices/search) endpoint list all the + available voices. + sample_id: + type: string + docs: >- + ID of the sample to be used. You can use the [Get + voices](/docs/api-reference/voices/get) endpoint list all the + available samples for a voice. + display-name: Get audio from sample + response: + docs: Successful Response + type: file + status-code: 200 + errors: + - root.UnprocessableEntityError + source: + openapi: openapi.json diff --git a/.mock/definition/voices/settings.yml b/.mock/definition/voices/settings.yml new file mode 100644 index 00000000..846c3a8d --- /dev/null +++ b/.mock/definition/voices/settings.yml @@ -0,0 +1,105 @@ +imports: + root: ../__package__.yml +service: + auth: false + base-path: '' + endpoints: + get_default: + path: /v1/voices/settings/default + method: GET + auth: false + docs: >- + Gets the default settings for voices. "similarity_boost" corresponds + to"Clarity + Similarity Enhancement" in the web app and "stability" + corresponds to "Stability" slider in the web app. + source: + openapi: openapi.json + display-name: Get default voice settings + response: + docs: Successful Response + type: root.VoiceSettings + status-code: 200 + examples: + - response: + body: + stability: 1 + similarity_boost: 1 + style: 0 + use_speaker_boost: true + speed: 1 + get: + path: /v1/voices/{voice_id}/settings + method: GET + auth: false + docs: >- + Returns the settings for a specific voice. "similarity_boost" + corresponds to"Clarity + Similarity Enhancement" in the web app and + "stability" corresponds to "Stability" slider in the web app. + source: + openapi: openapi.json + path-parameters: + voice_id: + type: string + docs: >- + Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices + to list all the available voices. + display-name: Get voice settings + response: + docs: Successful Response + type: root.VoiceSettings + status-code: 200 + errors: + - root.UnprocessableEntityError + examples: + - path-parameters: + voice_id: 21m00Tcm4TlvDq8ikWAM + response: + body: + stability: 1 + similarity_boost: 1 + style: 0 + use_speaker_boost: true + speed: 1 + update: + path: /v1/voices/{voice_id}/settings/edit + method: POST + auth: false + docs: >- + Edit your settings for a specific voice. "similarity_boost" corresponds + to "Clarity + Similarity Enhancement" in the web app and "stability" + corresponds to "Stability" slider in the web app. + source: + openapi: openapi.json + path-parameters: + voice_id: + type: string + docs: >- + ID of the voice to be used. You can use the [Get + voices](/docs/api-reference/voices/search) endpoint list all the + available voices. + display-name: Edit voice settings + request: + body: + type: root.VoiceSettings + docs: The settings for a specific voice. + content-type: application/json + response: + docs: Successful Response + type: root.EditVoiceSettingsResponseModel + status-code: 200 + errors: + - root.UnprocessableEntityError + examples: + - path-parameters: + voice_id: 21m00Tcm4TlvDq8ikWAM + request: + stability: 1 + similarity_boost: 1 + style: 0 + use_speaker_boost: true + speed: 1 + response: + body: + status: ok + source: + openapi: openapi.json diff --git a/.mock/definition/workspace.yml b/.mock/definition/workspace.yml deleted file mode 100644 index 10850bc6..00000000 --- a/.mock/definition/workspace.yml +++ /dev/null @@ -1,497 +0,0 @@ -imports: - root: __package__.yml -service: - auth: false - base-path: '' - endpoints: - searchUserGroups: - path: /v1/workspace/groups/search - method: GET - auth: false - docs: >- - Searches for user groups in the workspace. Multiple or no groups may be - returned. - source: - openapi: openapi.json - display-name: Search user group - request: - name: SearchUserGroupsV1WorkspaceGroupsSearchGetRequest - query-parameters: - name: - type: string - docs: Name of the target group. - response: - docs: Successful Response - type: list - status-code: 200 - errors: - - root.UnprocessableEntityError - examples: - - query-parameters: - name: name - headers: {} - response: - body: - - name: My Workspace Group - id: '1234567890' - members_emails: - - john.doe@example.com - - jane.smith@example.com - deleteMemberFromUserGroup: - path: /v1/workspace/groups/{group_id}/members/remove - method: POST - auth: false - docs: >- - Removes a member from the specified group. This endpoint may only be - called by workspace administrators. - source: - openapi: openapi.json - path-parameters: - group_id: - type: string - docs: The ID of the target group. - display-name: Remove member from user group - request: - name: BodyDeleteMemberFromUserGroupV1WorkspaceGroupsGroupIdMembersRemovePost - body: - properties: - email: - type: string - docs: The email of the target workspace member. - content-type: application/json - response: - docs: Successful Response - type: root.DeleteWorkspaceGroupMemberResponseModel - status-code: 200 - errors: - - root.UnprocessableEntityError - examples: - - path-parameters: - group_id: group_id - headers: {} - request: - email: email - response: - body: - status: ok - addMemberToUserGroup: - path: /v1/workspace/groups/{group_id}/members - method: POST - auth: false - docs: >- - Adds a member of your workspace to the specified group. This endpoint - may only be called by workspace administrators. - source: - openapi: openapi.json - path-parameters: - group_id: - type: string - docs: The ID of the target group. - display-name: Add member to user group - request: - name: AddMemberToGroupRequest - body: - properties: - email: - type: string - docs: The email of the target workspace member. - content-type: application/json - response: - docs: Successful Response - type: root.AddWorkspaceGroupMemberResponseModel - status-code: 200 - errors: - - root.UnprocessableEntityError - examples: - - path-parameters: - group_id: group_id - headers: {} - request: - email: email - response: - body: - status: ok - inviteUser: - path: /v1/workspace/invites/add - method: POST - auth: false - docs: >- - Sends an email invitation to join your workspace to the provided email. - If the user doesn't have an account they will be prompted to create one. - If the user accepts this invite they will be added as a user to your - workspace and your subscription using one of your seats. This endpoint - may only be called by workspace administrators. If the user is already - in the workspace a 400 error will be returned. - source: - openapi: openapi.json - display-name: Invite user - request: - name: InviteUserRequest - body: - properties: - email: - type: string - docs: The email of the customer - group_ids: - type: optional> - docs: The group ids of the user - workspace_permission: - type: >- - optional - docs: The workspace permission of the user - content-type: application/json - response: - docs: Successful Response - type: root.AddWorkspaceInviteResponseModel - status-code: 200 - errors: - - root.UnprocessableEntityError - examples: - - request: - email: john.doe@testmail.com - response: - body: - status: ok - inviteMultipleUsers: - path: /v1/workspace/invites/add-bulk - method: POST - auth: false - docs: >- - Sends email invitations to join your workspace to the provided emails. - Requires all email addresses to be part of a verified domain. If the - users don't have an account they will be prompted to create one. If the - users accept these invites they will be added as users to your workspace - and your subscription using one of your seats. This endpoint may only be - called by workspace administrators. - source: - openapi: openapi.json - display-name: Invite Multiple Users - request: - name: BodyInviteMultipleUsersV1WorkspaceInvitesAddBulkPost - body: - properties: - emails: - docs: The email of the customer - type: list - group_ids: - type: optional> - docs: The group ids of the user - content-type: application/json - response: - docs: Successful Response - type: root.AddWorkspaceInviteResponseModel - status-code: 200 - errors: - - root.UnprocessableEntityError - examples: - - request: - emails: - - emails - response: - body: - status: ok - deleteExistingInvitation: - path: /v1/workspace/invites - method: DELETE - auth: false - docs: >- - Invalidates an existing email invitation. The invitation will still show - up in the inbox it has been delivered to, but activating it to join the - workspace won't work. This endpoint may only be called by workspace - administrators. - source: - openapi: openapi.json - display-name: Delete invite - request: - name: BodyDeleteExistingInvitationV1WorkspaceInvitesDelete - body: - properties: - email: - type: string - docs: The email of the customer - content-type: application/json - response: - docs: Successful Response - type: root.DeleteWorkspaceInviteResponseModel - status-code: 200 - errors: - - root.UnprocessableEntityError - examples: - - request: - email: john.doe@testmail.com - response: - body: - status: ok - updateMember: - path: /v1/workspace/members - method: POST - auth: false - docs: >- - Updates attributes of a workspace member. Apart from the email - identifier, all parameters will remain unchanged unless specified. This - endpoint may only be called by workspace administrators. - source: - openapi: openapi.json - display-name: Update member - request: - name: UpdateMemberRequest - body: - properties: - email: - type: string - docs: Email of the target user. - is_locked: - type: optional - docs: Whether to lock or unlock the user account. - workspace_role: - type: optional - docs: Role dictating permissions in the workspace. - content-type: application/json - response: - docs: Successful Response - type: root.UpdateWorkspaceMemberResponseModel - status-code: 200 - errors: - - root.UnprocessableEntityError - examples: - - request: - email: email - response: - body: - status: ok - deleteMember: - path: /v1/workspace/members - method: DELETE - auth: false - docs: >- - Deletes a workspace member. This endpoint may only be called by - workspace administrators. - source: - openapi: openapi.json - display-name: Delete Member - request: - name: BodyDeleteMemberV1WorkspaceMembersDelete - body: - properties: - email: - type: string - docs: Email of the target user. - content-type: application/json - response: - docs: Successful Response - type: root.DeleteWorkspaceMemberResponseModel - status-code: 200 - errors: - - root.UnprocessableEntityError - examples: - - request: - email: email - response: - body: - status: ok - getResource: - path: /v1/workspace/resources/{resource_id} - method: GET - auth: false - docs: Gets the metadata of a resource by ID. - source: - openapi: openapi.json - path-parameters: - resource_id: - type: string - docs: The ID of the target resource. - display-name: Get Resource - request: - name: GetResourceV1WorkspaceResourcesResourceIdGetRequest - query-parameters: - resource_type: - type: root.WorkspaceResourceType - docs: Resource type of the target resource. - response: - docs: Successful Response - type: root.ResourceMetadataResponseModel - status-code: 200 - errors: - - root.UnprocessableEntityError - examples: - - path-parameters: - resource_id: resource_id - query-parameters: - resource_type: voice - response: - body: - resource_id: 4ZUqyldxf71HqUbcP2Lc - resource_type: voice - creator_user_id: 5zavrE1kZXv2lFw9BKgEkf0B5Wqo - role_to_group_ids: - admin: - - 5zavrE1kZXv2lFw9BKgEkf0B5Wqo - editor: - - 8ruQDGM2R4w1mFbHI5aROCUjIpJZ - viewer: - - role_to_group_ids - share_options: - - name: user@example.com - id: i2YYI6huwBmcgYydAXARmQJc3pmX - type: user - - name: mygroup - id: x1AfvYKAmiqxCnbvZeNXHqqthJaC - type: group - shareWorkspaceResource: - path: /v1/workspace/resources/{resource_id}/share - method: POST - auth: false - docs: >- - Grants a role on a workspace resource to a user or a group. It overrides - any existing role this user/service account/group/workspace api key has - on the resource. To target a user or service account, pass only the user - email. The user must be in your workspace. To target a group, pass only - the group id. To target a workspace api key, pass the api key id. The - resource will be shared with the service account associated with the api - key. You must have admin access to the resource to share it. - source: - openapi: openapi.json - path-parameters: - resource_id: - type: string - docs: The ID of the target resource. - display-name: Share Workspace Resource - request: - name: BodyShareWorkspaceResourceV1WorkspaceResourcesResourceIdSharePost - body: - properties: - role: - type: >- - BodyShareWorkspaceResourceV1WorkspaceResourcesResourceIdSharePostRole - docs: Role to update the target principal with. - resource_type: - type: root.WorkspaceResourceType - docs: Resource type of the target resource. - user_email: - type: optional - docs: The email of the user or service account. - group_id: - type: optional - docs: >- - The ID of the target group. To target the permissions principals - have by default on this resource, use the value 'default'. - workspace_api_key_id: - type: optional - docs: >- - The ID of the target workspace API key. This isn't the same as - the key itself that would you pass in the header for - authentication. Workspace admins can find this in the workspace - settings UI. - content-type: application/json - response: - docs: Successful Response - type: unknown - status-code: 200 - errors: - - root.UnprocessableEntityError - examples: - - path-parameters: - resource_id: resource_id - request: - role: admin - resource_type: voice - response: - body: - key: value - unshareWorkspaceResource: - path: /v1/workspace/resources/{resource_id}/unshare - method: POST - auth: false - docs: >- - Removes any existing role on a workspace resource from a user, service - account, group or workspace api key. To target a user or service - account, pass only the user email. The user must be in your workspace. - To target a group, pass only the group id. To target a workspace api - key, pass the api key id. The resource will be unshared from the service - account associated with the api key. You must have admin access to the - resource to unshare it. You cannot remove permissions from the user who - created the resource. - source: - openapi: openapi.json - path-parameters: - resource_id: - type: string - docs: The ID of the target resource. - display-name: Unshare Workspace Resource - request: - name: BodyUnshareWorkspaceResourceV1WorkspaceResourcesResourceIdUnsharePost - body: - properties: - resource_type: - type: root.WorkspaceResourceType - docs: Resource type of the target resource. - user_email: - type: optional - docs: The email of the user or service account. - group_id: - type: optional - docs: >- - The ID of the target group. To target the permissions principals - have by default on this resource, use the value 'default'. - workspace_api_key_id: - type: optional - docs: >- - The ID of the target workspace API key. This isn't the same as - the key itself that would you pass in the header for - authentication. Workspace admins can find this in the workspace - settings UI. - content-type: application/json - response: - docs: Successful Response - type: unknown - status-code: 200 - errors: - - root.UnprocessableEntityError - examples: - - path-parameters: - resource_id: resource_id - request: - resource_type: voice - response: - body: - key: value - source: - openapi: openapi.json -types: - BodyInviteUserV1WorkspaceInvitesAddPostWorkspacePermission: - enum: - - external - - admin - - workspace_admin - - workspace_member - - support_l1 - - support_l2 - - moderator - - sales - - voice_mixer - - voice_admin - - convai_admin - - enterprise_viewer - - quality_check_admin - - workspace_migration_admin - - human_reviewer - - productions_admin - inline: true - source: - openapi: openapi.json - BodyUpdateMemberV1WorkspaceMembersPostWorkspaceRole: - enum: - - workspace_admin - - workspace_member - inline: true - source: - openapi: openapi.json - BodyShareWorkspaceResourceV1WorkspaceResourcesResourceIdSharePostRole: - enum: - - admin - - editor - - viewer - docs: Role to update the target principal with. - inline: true - source: - openapi: openapi.json diff --git a/.mock/definition/workspace/groups.yml b/.mock/definition/workspace/groups.yml new file mode 100644 index 00000000..bd0eba74 --- /dev/null +++ b/.mock/definition/workspace/groups.yml @@ -0,0 +1,41 @@ +imports: + root: ../__package__.yml +service: + auth: false + base-path: '' + endpoints: + search: + path: /v1/workspace/groups/search + method: GET + auth: false + docs: >- + Searches for user groups in the workspace. Multiple or no groups may be + returned. + source: + openapi: openapi.json + display-name: Search user group + request: + name: GroupsSearchRequest + query-parameters: + name: + type: string + docs: Name of the target group. + response: + docs: Successful Response + type: list + status-code: 200 + errors: + - root.UnprocessableEntityError + examples: + - query-parameters: + name: name + headers: {} + response: + body: + - name: My Workspace Group + id: '1234567890' + members_emails: + - john.doe@example.com + - jane.smith@example.com + source: + openapi: openapi.json diff --git a/.mock/definition/workspace/groups/members.yml b/.mock/definition/workspace/groups/members.yml new file mode 100644 index 00000000..4c982130 --- /dev/null +++ b/.mock/definition/workspace/groups/members.yml @@ -0,0 +1,82 @@ +imports: + root: ../../__package__.yml +service: + auth: false + base-path: '' + endpoints: + remove: + path: /v1/workspace/groups/{group_id}/members/remove + method: POST + auth: false + docs: >- + Removes a member from the specified group. This endpoint may only be + called by workspace administrators. + source: + openapi: openapi.json + path-parameters: + group_id: + type: string + docs: The ID of the target group. + display-name: Remove member from user group + request: + name: BodyDeleteMemberFromUserGroupV1WorkspaceGroupsGroupIdMembersRemovePost + body: + properties: + email: + type: string + docs: The email of the target workspace member. + content-type: application/json + response: + docs: Successful Response + type: root.DeleteWorkspaceGroupMemberResponseModel + status-code: 200 + errors: + - root.UnprocessableEntityError + examples: + - path-parameters: + group_id: group_id + headers: {} + request: + email: email + response: + body: + status: ok + add: + path: /v1/workspace/groups/{group_id}/members + method: POST + auth: false + docs: >- + Adds a member of your workspace to the specified group. This endpoint + may only be called by workspace administrators. + source: + openapi: openapi.json + path-parameters: + group_id: + type: string + docs: The ID of the target group. + display-name: Add member to user group + request: + name: AddMemberToGroupRequest + body: + properties: + email: + type: string + docs: The email of the target workspace member. + content-type: application/json + response: + docs: Successful Response + type: root.AddWorkspaceGroupMemberResponseModel + status-code: 200 + errors: + - root.UnprocessableEntityError + examples: + - path-parameters: + group_id: group_id + headers: {} + request: + email: email + response: + body: + status: ok + source: + openapi: openapi.json diff --git a/.mock/definition/workspace/invites.yml b/.mock/definition/workspace/invites.yml new file mode 100644 index 00000000..315de921 --- /dev/null +++ b/.mock/definition/workspace/invites.yml @@ -0,0 +1,141 @@ +types: + BodyInviteUserV1WorkspaceInvitesAddPostWorkspacePermission: + enum: + - external + - admin + - workspace_admin + - workspace_member + - support_l1 + - support_l2 + - moderator + - sales + - voice_mixer + - voice_admin + - convai_admin + - enterprise_viewer + - quality_check_admin + - workspace_migration_admin + - human_reviewer + - productions_admin + inline: true + source: + openapi: openapi.json +imports: + root: ../__package__.yml +service: + auth: false + base-path: '' + endpoints: + create: + path: /v1/workspace/invites/add + method: POST + auth: false + docs: >- + Sends an email invitation to join your workspace to the provided email. + If the user doesn't have an account they will be prompted to create one. + If the user accepts this invite they will be added as a user to your + workspace and your subscription using one of your seats. This endpoint + may only be called by workspace administrators. If the user is already + in the workspace a 400 error will be returned. + source: + openapi: openapi.json + display-name: Invite user + request: + name: InviteUserRequest + body: + properties: + email: + type: string + docs: The email of the customer + group_ids: + type: optional> + docs: The group ids of the user + workspace_permission: + type: >- + optional + docs: The workspace permission of the user + content-type: application/json + response: + docs: Successful Response + type: root.AddWorkspaceInviteResponseModel + status-code: 200 + errors: + - root.UnprocessableEntityError + examples: + - request: + email: john.doe@testmail.com + response: + body: + status: ok + create_batch: + path: /v1/workspace/invites/add-bulk + method: POST + auth: false + docs: >- + Sends email invitations to join your workspace to the provided emails. + Requires all email addresses to be part of a verified domain. If the + users don't have an account they will be prompted to create one. If the + users accept these invites they will be added as users to your workspace + and your subscription using one of your seats. This endpoint may only be + called by workspace administrators. + source: + openapi: openapi.json + display-name: Invite Multiple Users + request: + name: BodyInviteMultipleUsersV1WorkspaceInvitesAddBulkPost + body: + properties: + emails: + docs: The email of the customer + type: list + group_ids: + type: optional> + docs: The group ids of the user + content-type: application/json + response: + docs: Successful Response + type: root.AddWorkspaceInviteResponseModel + status-code: 200 + errors: + - root.UnprocessableEntityError + examples: + - request: + emails: + - emails + response: + body: + status: ok + delete: + path: /v1/workspace/invites + method: DELETE + auth: false + docs: >- + Invalidates an existing email invitation. The invitation will still show + up in the inbox it has been delivered to, but activating it to join the + workspace won't work. This endpoint may only be called by workspace + administrators. + source: + openapi: openapi.json + display-name: Delete invite + request: + name: BodyDeleteExistingInvitationV1WorkspaceInvitesDelete + body: + properties: + email: + type: string + docs: The email of the customer + content-type: application/json + response: + docs: Successful Response + type: root.DeleteWorkspaceInviteResponseModel + status-code: 200 + errors: + - root.UnprocessableEntityError + examples: + - request: + email: john.doe@testmail.com + response: + body: + status: ok + source: + openapi: openapi.json diff --git a/.mock/definition/workspace/members.yml b/.mock/definition/workspace/members.yml new file mode 100644 index 00000000..7b1f6710 --- /dev/null +++ b/.mock/definition/workspace/members.yml @@ -0,0 +1,83 @@ +types: + BodyUpdateMemberV1WorkspaceMembersPostWorkspaceRole: + enum: + - workspace_admin + - workspace_member + inline: true + source: + openapi: openapi.json +imports: + root: ../__package__.yml +service: + auth: false + base-path: '' + endpoints: + update: + path: /v1/workspace/members + method: POST + auth: false + docs: >- + Updates attributes of a workspace member. Apart from the email + identifier, all parameters will remain unchanged unless specified. This + endpoint may only be called by workspace administrators. + source: + openapi: openapi.json + display-name: Update member + request: + name: UpdateMemberRequest + body: + properties: + email: + type: string + docs: Email of the target user. + is_locked: + type: optional + docs: Whether to lock or unlock the user account. + workspace_role: + type: optional + docs: Role dictating permissions in the workspace. + content-type: application/json + response: + docs: Successful Response + type: root.UpdateWorkspaceMemberResponseModel + status-code: 200 + errors: + - root.UnprocessableEntityError + examples: + - request: + email: email + response: + body: + status: ok + delete: + path: /v1/workspace/members + method: DELETE + auth: false + docs: >- + Deletes a workspace member. This endpoint may only be called by + workspace administrators. + source: + openapi: openapi.json + display-name: Delete Member + request: + name: BodyDeleteMemberV1WorkspaceMembersDelete + body: + properties: + email: + type: string + docs: Email of the target user. + content-type: application/json + response: + docs: Successful Response + type: root.DeleteWorkspaceMemberResponseModel + status-code: 200 + errors: + - root.UnprocessableEntityError + examples: + - request: + email: email + response: + body: + status: ok + source: + openapi: openapi.json diff --git a/.mock/definition/workspace/resources.yml b/.mock/definition/workspace/resources.yml new file mode 100644 index 00000000..55025218 --- /dev/null +++ b/.mock/definition/workspace/resources.yml @@ -0,0 +1,184 @@ +imports: + root: ../__package__.yml +service: + auth: false + base-path: '' + endpoints: + get: + path: /v1/workspace/resources/{resource_id} + method: GET + auth: false + docs: Gets the metadata of a resource by ID. + source: + openapi: openapi.json + path-parameters: + resource_id: + type: string + docs: The ID of the target resource. + display-name: Get Resource + request: + name: ResourcesGetRequest + query-parameters: + resource_type: + type: root.WorkspaceResourceType + docs: Resource type of the target resource. + response: + docs: Successful Response + type: root.ResourceMetadataResponseModel + status-code: 200 + errors: + - root.UnprocessableEntityError + examples: + - path-parameters: + resource_id: resource_id + query-parameters: + resource_type: voice + response: + body: + resource_id: 4ZUqyldxf71HqUbcP2Lc + resource_type: voice + creator_user_id: 5zavrE1kZXv2lFw9BKgEkf0B5Wqo + role_to_group_ids: + admin: + - 5zavrE1kZXv2lFw9BKgEkf0B5Wqo + editor: + - 8ruQDGM2R4w1mFbHI5aROCUjIpJZ + viewer: + - role_to_group_ids + share_options: + - name: user@example.com + id: i2YYI6huwBmcgYydAXARmQJc3pmX + type: user + - name: mygroup + id: x1AfvYKAmiqxCnbvZeNXHqqthJaC + type: group + share: + path: /v1/workspace/resources/{resource_id}/share + method: POST + auth: false + docs: >- + Grants a role on a workspace resource to a user or a group. It overrides + any existing role this user/service account/group/workspace api key has + on the resource. To target a user or service account, pass only the user + email. The user must be in your workspace. To target a group, pass only + the group id. To target a workspace api key, pass the api key id. The + resource will be shared with the service account associated with the api + key. You must have admin access to the resource to share it. + source: + openapi: openapi.json + path-parameters: + resource_id: + type: string + docs: The ID of the target resource. + display-name: Share Workspace Resource + request: + name: BodyShareWorkspaceResourceV1WorkspaceResourcesResourceIdSharePost + body: + properties: + role: + type: >- + BodyShareWorkspaceResourceV1WorkspaceResourcesResourceIdSharePostRole + docs: Role to update the target principal with. + resource_type: + type: root.WorkspaceResourceType + docs: Resource type of the target resource. + user_email: + type: optional + docs: The email of the user or service account. + group_id: + type: optional + docs: >- + The ID of the target group. To target the permissions principals + have by default on this resource, use the value 'default'. + workspace_api_key_id: + type: optional + docs: >- + The ID of the target workspace API key. This isn't the same as + the key itself that would you pass in the header for + authentication. Workspace admins can find this in the workspace + settings UI. + content-type: application/json + response: + docs: Successful Response + type: unknown + status-code: 200 + errors: + - root.UnprocessableEntityError + examples: + - path-parameters: + resource_id: resource_id + request: + role: admin + resource_type: voice + response: + body: + key: value + unshare: + path: /v1/workspace/resources/{resource_id}/unshare + method: POST + auth: false + docs: >- + Removes any existing role on a workspace resource from a user, service + account, group or workspace api key. To target a user or service + account, pass only the user email. The user must be in your workspace. + To target a group, pass only the group id. To target a workspace api + key, pass the api key id. The resource will be unshared from the service + account associated with the api key. You must have admin access to the + resource to unshare it. You cannot remove permissions from the user who + created the resource. + source: + openapi: openapi.json + path-parameters: + resource_id: + type: string + docs: The ID of the target resource. + display-name: Unshare Workspace Resource + request: + name: BodyUnshareWorkspaceResourceV1WorkspaceResourcesResourceIdUnsharePost + body: + properties: + resource_type: + type: root.WorkspaceResourceType + docs: Resource type of the target resource. + user_email: + type: optional + docs: The email of the user or service account. + group_id: + type: optional + docs: >- + The ID of the target group. To target the permissions principals + have by default on this resource, use the value 'default'. + workspace_api_key_id: + type: optional + docs: >- + The ID of the target workspace API key. This isn't the same as + the key itself that would you pass in the header for + authentication. Workspace admins can find this in the workspace + settings UI. + content-type: application/json + response: + docs: Successful Response + type: unknown + status-code: 200 + errors: + - root.UnprocessableEntityError + examples: + - path-parameters: + resource_id: resource_id + request: + resource_type: voice + response: + body: + key: value + source: + openapi: openapi.json +types: + BodyShareWorkspaceResourceV1WorkspaceResourcesResourceIdSharePostRole: + enum: + - admin + - editor + - viewer + docs: Role to update the target principal with. + inline: true + source: + openapi: openapi.json diff --git a/.mock/fern.config.json b/.mock/fern.config.json index 1fdb3034..e34521f2 100644 --- a/.mock/fern.config.json +++ b/.mock/fern.config.json @@ -1,4 +1,4 @@ { "organization" : "elevenlabs", - "version" : "0.60.28" + "version" : "0.61.21" } \ No newline at end of file diff --git a/.mock/openapi.json b/.mock/openapi.json index f33c42a9..3fd61901 100644 --- a/.mock/openapi.json +++ b/.mock/openapi.json @@ -151,7 +151,7 @@ "speech-history" ], "x-fern-sdk-group-name": "history", - "x-fern-sdk-method-name": "get_all" + "x-fern-sdk-method-name": "list" } }, "/v1/history/{history_item_id}": { @@ -597,7 +597,7 @@ "audio-isolation" ], "x-fern-sdk-group-name": "audio_isolation", - "x-fern-sdk-method-name": "audio_isolation" + "x-fern-sdk-method-name": "convert" } }, "/v1/audio-isolation/stream": { @@ -657,7 +657,7 @@ "audio-isolation" ], "x-fern-sdk-group-name": "audio_isolation", - "x-fern-sdk-method-name": "audio_isolation_stream", + "x-fern-sdk-method-name": "stream", "x-fern-streaming": true } }, @@ -817,8 +817,12 @@ "tags": [ "samples" ], - "x-fern-sdk-group-name": "samples", - "x-fern-sdk-method-name": "get_audio" + "x-fern-sdk-group-name": [ + "voices", + "samples", + "audio" + ], + "x-fern-sdk-method-name": "get" } }, "/v1/text-to-speech/{voice_id}": { @@ -1249,7 +1253,7 @@ "text-to-speech" ], "x-fern-sdk-group-name": "text_to_speech", - "x-fern-sdk-method-name": "convert_as_stream", + "x-fern-sdk-method-name": "stream", "x-fern-streaming": true } }, @@ -1682,7 +1686,7 @@ "speech-to-speech" ], "x-fern-sdk-group-name": "speech_to_speech", - "x-fern-sdk-method-name": "convert_as_stream", + "x-fern-sdk-method-name": "stream", "x-fern-streaming": true } }, @@ -2045,8 +2049,11 @@ "tags": [ "user" ], - "x-fern-sdk-group-name": "user", - "x-fern-sdk-method-name": "get_subscription" + "x-fern-sdk-group-name": [ + "user", + "subscription" + ], + "x-fern-sdk-method-name": "get" } }, "/v1/user": { @@ -2433,8 +2440,11 @@ "tags": [ "voices" ], - "x-fern-sdk-group-name": "voices", - "x-fern-sdk-method-name": "get_default_settings" + "x-fern-sdk-group-name": [ + "voices", + "settings" + ], + "x-fern-sdk-method-name": "get_default" } }, "/v1/voices/{voice_id}/settings": { @@ -2501,8 +2511,11 @@ "tags": [ "voices" ], - "x-fern-sdk-group-name": "voices", - "x-fern-sdk-method-name": "get_settings" + "x-fern-sdk-group-name": [ + "voices", + "settings" + ], + "x-fern-sdk-method-name": "get" } }, "/v1/voices/{voice_id}": { @@ -2728,8 +2741,11 @@ "tags": [ "voices" ], - "x-fern-sdk-group-name": "voices", - "x-fern-sdk-method-name": "edit_settings" + "x-fern-sdk-group-name": [ + "voices", + "settings" + ], + "x-fern-sdk-method-name": "update" } }, "/v1/voices/add": { @@ -2792,8 +2808,11 @@ "tags": [ "voices" ], - "x-fern-sdk-group-name": "voices", - "x-fern-sdk-method-name": "add" + "x-fern-sdk-group-name": [ + "voices", + "ivc" + ], + "x-fern-sdk-method-name": "create" } }, "/v1/voices/{voice_id}/edit": { @@ -2871,7 +2890,7 @@ "voices" ], "x-fern-sdk-group-name": "voices", - "x-fern-sdk-method-name": "edit" + "x-fern-sdk-method-name": "update" } }, "/v1/voices/add/{public_user_id}/{voice_id}": { @@ -2963,7 +2982,7 @@ "voices" ], "x-fern-sdk-group-name": "voices", - "x-fern-sdk-method-name": "add_sharing_voice" + "x-fern-sdk-method-name": "share" } }, "/v1/studio/podcasts": { @@ -3133,7 +3152,7 @@ "studio", "projects" ], - "x-fern-sdk-method-name": "get_all" + "x-fern-sdk-method-name": "list" }, "post": { "operationId": "Create_Studio_project_v1_studio_projects_post", @@ -3198,7 +3217,7 @@ "studio", "projects" ], - "x-fern-sdk-method-name": "add" + "x-fern-sdk-method-name": "create" } }, "/v1/projects": { @@ -3395,7 +3414,7 @@ "studio", "projects" ], - "x-fern-sdk-method-name": "update_metadata" + "x-fern-sdk-method-name": "update" }, "get": { "operationId": "Get_Studio_project_v1_studio_projects__project_id__get", @@ -3816,9 +3835,10 @@ ], "x-fern-sdk-group-name": [ "studio", - "projects" + "projects", + "content" ], - "x-fern-sdk-method-name": "update_content" + "x-fern-sdk-method-name": "update" } }, "/v1/projects/{project_id}/content": { @@ -4099,9 +4119,10 @@ ], "x-fern-sdk-group-name": [ "studio", - "projects" + "projects", + "snapshots" ], - "x-fern-sdk-method-name": "get_snapshots" + "x-fern-sdk-method-name": "list" } }, "/v1/projects/{project_id}/snapshots": { @@ -4251,9 +4272,10 @@ ], "x-fern-sdk-group-name": [ "studio", - "projects" + "projects", + "snapshots" ], - "x-fern-sdk-method-name": "get_project_snapshot" + "x-fern-sdk-method-name": "get" } }, "/v1/studio/projects/{project_id}/snapshots/{project_snapshot_id}/stream": { @@ -4338,9 +4360,10 @@ ], "x-fern-sdk-group-name": [ "studio", - "projects" + "projects", + "snapshots" ], - "x-fern-sdk-method-name": "stream_audio", + "x-fern-sdk-method-name": "stream", "x-fern-streaming": true } }, @@ -4508,7 +4531,8 @@ ], "x-fern-sdk-group-name": [ "studio", - "projects" + "projects", + "snapshots" ], "x-fern-sdk-method-name": "stream_archive" } @@ -4653,9 +4677,10 @@ ], "x-fern-sdk-group-name": [ "studio", + "projects", "chapters" ], - "x-fern-sdk-method-name": "get_all" + "x-fern-sdk-method-name": "list" }, "post": { "operationId": "Create_chapter_v1_studio_projects__project_id__chapters_post", @@ -4732,6 +4757,7 @@ ], "x-fern-sdk-group-name": [ "studio", + "projects", "chapters" ], "x-fern-sdk-method-name": "create" @@ -4884,6 +4910,7 @@ ], "x-fern-sdk-group-name": [ "studio", + "projects", "chapters" ], "x-fern-sdk-method-name": "get" @@ -4976,9 +5003,10 @@ ], "x-fern-sdk-group-name": [ "studio", + "projects", "chapters" ], - "x-fern-sdk-method-name": "edit" + "x-fern-sdk-method-name": "update" }, "delete": { "operationId": "Delete_chapter_v1_studio_projects__project_id__chapters__chapter_id__delete", @@ -5059,6 +5087,7 @@ ], "x-fern-sdk-group-name": [ "studio", + "projects", "chapters" ], "x-fern-sdk-method-name": "delete" @@ -5467,6 +5496,7 @@ ], "x-fern-sdk-group-name": [ "studio", + "projects", "chapters" ], "x-fern-sdk-method-name": "convert" @@ -5631,9 +5661,11 @@ ], "x-fern-sdk-group-name": [ "studio", - "chapters" + "projects", + "chapters", + "snapshots" ], - "x-fern-sdk-method-name": "get_all_snapshots" + "x-fern-sdk-method-name": "list" } }, "/v1/projects/{project_id}/chapters/{chapter_id}/snapshots": { @@ -5811,9 +5843,11 @@ ], "x-fern-sdk-group-name": [ "studio", - "chapters" + "projects", + "chapters", + "snapshots" ], - "x-fern-sdk-method-name": "get_chapter_snapshot" + "x-fern-sdk-method-name": "get" } }, "/v1/studio/projects/{project_id}/chapters/{chapter_id}/snapshots/{chapter_snapshot_id}/stream": { @@ -5920,9 +5954,11 @@ ], "x-fern-sdk-group-name": [ "studio", - "chapters" + "projects", + "chapters", + "snapshots" ], - "x-fern-sdk-method-name": "stream_snapshot", + "x-fern-sdk-method-name": "stream", "x-fern-streaming": true } }, @@ -6099,9 +6135,10 @@ ], "x-fern-sdk-group-name": [ "studio", - "projects" + "projects", + "pronunciation_dictionaries" ], - "x-fern-sdk-method-name": "update_pronunciation_dictionaries" + "x-fern-sdk-method-name": "create" } }, "/v1/projects/{project_id}/update-pronunciation-dictionaries": { @@ -6244,8 +6281,11 @@ "segment", "enterprise" ], - "x-fern-sdk-group-name": "dubbing", - "x-fern-sdk-method-name": "get_dubbing_resource" + "x-fern-sdk-group-name": [ + "dubbing", + "resource" + ], + "x-fern-sdk-method-name": "get" } }, "/v1/dubbing/resource/{dubbing_id}/language": { @@ -6323,8 +6363,12 @@ "segment", "enterprise" ], - "x-fern-sdk-group-name": "dubbing", - "x-fern-sdk-method-name": "add_language_to_resource" + "x-fern-sdk-group-name": [ + "dubbing", + "resource", + "language" + ], + "x-fern-sdk-method-name": "add" } }, "/v1/dubbing/resource/{dubbing_id}/speaker/{speaker_id}/segment": { @@ -6416,6 +6460,7 @@ ], "x-fern-sdk-group-name": [ "dubbing", + "resource", "speaker", "segment" ], @@ -6520,8 +6565,12 @@ "segment", "enterprise" ], - "x-fern-sdk-group-name": "dubbing", - "x-fern-sdk-method-name": "update_segment_language" + "x-fern-sdk-group-name": [ + "dubbing", + "resource", + "segment" + ], + "x-fern-sdk-method-name": "update" } }, "/v1/dubbing/resource/{dubbing_id}/segment/{segment_id}": { @@ -6600,8 +6649,12 @@ "segment", "enterprise" ], - "x-fern-sdk-group-name": "dubbing", - "x-fern-sdk-method-name": "delete_segment" + "x-fern-sdk-group-name": [ + "dubbing", + "resource", + "segment" + ], + "x-fern-sdk-method-name": "delete" } }, "/v1/dubbing/resource/{dubbing_id}/transcribe": { @@ -6679,8 +6732,11 @@ "segment", "enterprise" ], - "x-fern-sdk-group-name": "dubbing", - "x-fern-sdk-method-name": "transcribe_segments" + "x-fern-sdk-group-name": [ + "dubbing", + "resource" + ], + "x-fern-sdk-method-name": "transcribe" } }, "/v1/dubbing/resource/{dubbing_id}/translate": { @@ -6758,8 +6814,11 @@ "segment", "enterprise" ], - "x-fern-sdk-group-name": "dubbing", - "x-fern-sdk-method-name": "translate_segments" + "x-fern-sdk-group-name": [ + "dubbing", + "resource" + ], + "x-fern-sdk-method-name": "translate" } }, "/v1/dubbing/resource/{dubbing_id}/dub": { @@ -6837,8 +6896,11 @@ "segment", "enterprise" ], - "x-fern-sdk-group-name": "dubbing", - "x-fern-sdk-method-name": "dub_segments" + "x-fern-sdk-group-name": [ + "dubbing", + "resource" + ], + "x-fern-sdk-method-name": "dub" } }, "/v1/dubbing/resource/{dubbing_id}/speaker/{speaker_id}": { @@ -6928,6 +6990,7 @@ ], "x-fern-sdk-group-name": [ "dubbing", + "resource", "speaker" ], "x-fern-sdk-method-name": "update" @@ -7011,16 +7074,17 @@ ], "x-fern-sdk-group-name": [ "dubbing", + "resource", "speaker" ], - "x-fern-sdk-method-name": "similar_voices" + "x-fern-sdk-method-name": "find_similar_voices" } }, "/v1/dubbing/resource/{dubbing_id}/render/{language}": { "post": { "operationId": "Render_audio_or_video_for_the_given_language_v1_dubbing_resource__dubbing_id__render__language__post", "summary": "Render Audio Or Video For The Given Language", - "description": "Regenerate the dubs for either the entire resource or the specified segments/languages. Will automatically transcribe and translate any missing transcriptions and translations.", + "description": "Regenerate the output media for a language using the latest Studio state. Please ensure all segments have been dubbed before rendering, otherwise they will be omitted. Renders are generated asynchronously, and to check the status of all renders please use the 'Get Dubbing Resource' endpoint.", "parameters": [ { "name": "dubbing_id", @@ -7102,8 +7166,11 @@ "segment", "enterprise" ], - "x-fern-sdk-group-name": "dubbing", - "x-fern-sdk-method-name": "render_dub" + "x-fern-sdk-group-name": [ + "dubbing", + "resource" + ], + "x-fern-sdk-method-name": "render" } }, "/v1/dubbing": { @@ -7168,7 +7235,7 @@ "dubbing" ], "x-fern-sdk-group-name": "dubbing", - "x-fern-sdk-method-name": "dub_a_video_or_an_audio_file" + "x-fern-sdk-method-name": "create" } }, "/v1/dubbing/{dubbing_id}": { @@ -7235,7 +7302,7 @@ "dubbing" ], "x-fern-sdk-group-name": "dubbing", - "x-fern-sdk-method-name": "get_dubbing_project_metadata" + "x-fern-sdk-method-name": "get" }, "delete": { "operationId": "Delete_dubbing_v1_dubbing__dubbing_id__delete", @@ -7300,14 +7367,14 @@ "dubbing" ], "x-fern-sdk-group-name": "dubbing", - "x-fern-sdk-method-name": "delete_dubbing_project" + "x-fern-sdk-method-name": "delete" } }, "/v1/dubbing/{dubbing_id}/audio/{language_code}": { "get": { "operationId": "Get_dubbed_file_v1_dubbing__dubbing_id__audio__language_code__get", "summary": "Get Dubbed File", - "description": "Returns dubbed file as a streamed file. Videos will be returned in MP4 format and audio only dubs will be returned in MP3.", + "description": "Returns dub as a streamed MP3 or MP4 file. If this dub has been edited using Dubbing Studio you need to use the resource render endpoint as this endpoint only returns the original automatic dub result.", "parameters": [ { "name": "dubbing_id", @@ -7417,8 +7484,11 @@ "dubbing", "dubbing" ], - "x-fern-sdk-group-name": "dubbing", - "x-fern-sdk-method-name": "get_dubbed_file" + "x-fern-sdk-group-name": [ + "dubbing", + "audio" + ], + "x-fern-sdk-method-name": "get" } }, "/v1/dubbing/{dubbing_id}/transcript/{language_code}": { @@ -7546,8 +7616,11 @@ "dubbing", "dubbing" ], - "x-fern-sdk-group-name": "dubbing", - "x-fern-sdk-method-name": "get_transcript_for_dub" + "x-fern-sdk-group-name": [ + "dubbing", + "transcript" + ], + "x-fern-sdk-method-name": "get" } }, "/v1/models": { @@ -7605,7 +7678,7 @@ "models" ], "x-fern-sdk-group-name": "models", - "x-fern-sdk-method-name": "get_all" + "x-fern-sdk-method-name": "list" } }, "/v1/audio-native": { @@ -7814,7 +7887,7 @@ "audio-native" ], "x-fern-sdk-group-name": "audio_native", - "x-fern-sdk-method-name": "update_content" + "x-fern-sdk-method-name": "update" } }, "/v1/shared-voices": { @@ -8267,7 +8340,7 @@ "voices" ], "x-fern-sdk-group-name": "voices", - "x-fern-sdk-method-name": "get_similar_library_voices" + "x-fern-sdk-method-name": "find_similar_voices" } }, "/v1/usage/character-stats": { @@ -8394,7 +8467,7 @@ "usage" ], "x-fern-sdk-group-name": "usage", - "x-fern-sdk-method-name": "get_characters_usage_metrics" + "x-fern-sdk-method-name": "get" } }, "/v1/pronunciation-dictionaries/add-from-file": { @@ -8457,8 +8530,8 @@ "tags": [ "Pronunciation Dictionary" ], - "x-fern-sdk-group-name": "pronunciation_dictionary", - "x-fern-sdk-method-name": "add_from_file" + "x-fern-sdk-group-name": "pronunciation_dictionaries", + "x-fern-sdk-method-name": "create_from_file" } }, "/v1/pronunciation-dictionaries/add-from-rules": { @@ -8521,8 +8594,8 @@ "tags": [ "Pronunciation Dictionary" ], - "x-fern-sdk-group-name": "pronunciation_dictionary", - "x-fern-sdk-method-name": "add_from_rules" + "x-fern-sdk-group-name": "pronunciation_dictionaries", + "x-fern-sdk-method-name": "create_from_rules" } }, "/v1/pronunciation-dictionaries/{pronunciation_dictionary_id}/add-rules": { @@ -8599,8 +8672,11 @@ "tags": [ "Pronunciation Dictionary" ], - "x-fern-sdk-group-name": "pronunciation_dictionary", - "x-fern-sdk-method-name": "add_rules" + "x-fern-sdk-group-name": [ + "pronunciation_dictionaries", + "rules" + ], + "x-fern-sdk-method-name": "add" } }, "/v1/pronunciation-dictionaries/{pronunciation_dictionary_id}/remove-rules": { @@ -8677,8 +8753,11 @@ "tags": [ "Pronunciation Dictionary" ], - "x-fern-sdk-group-name": "pronunciation_dictionary", - "x-fern-sdk-method-name": "remove_rules" + "x-fern-sdk-group-name": [ + "pronunciation_dictionaries", + "rules" + ], + "x-fern-sdk-method-name": "remove" } }, "/v1/pronunciation-dictionaries/{dictionary_id}/{version_id}/download": { @@ -8768,7 +8847,7 @@ "tags": [ "Pronunciation Dictionary" ], - "x-fern-sdk-group-name": "pronunciation_dictionary", + "x-fern-sdk-group-name": "pronunciation_dictionaries", "x-fern-sdk-method-name": "download" } }, @@ -8836,7 +8915,7 @@ "tags": [ "Pronunciation Dictionary" ], - "x-fern-sdk-group-name": "pronunciation_dictionary", + "x-fern-sdk-group-name": "pronunciation_dictionaries", "x-fern-sdk-method-name": "get" } }, @@ -8970,8 +9049,8 @@ "tags": [ "Pronunciation Dictionary" ], - "x-fern-sdk-group-name": "pronunciation_dictionary", - "x-fern-sdk-method-name": "get_all" + "x-fern-sdk-group-name": "pronunciation_dictionaries", + "x-fern-sdk-method-name": "list" } }, "/v1/workspace/groups/search": { @@ -9031,7 +9110,12 @@ }, "tags": [ "workspace" - ] + ], + "x-fern-sdk-group-name": [ + "workspace", + "groups" + ], + "x-fern-sdk-method-name": "search" } }, "/v1/workspace/groups/{group_id}/members/remove": { @@ -9097,7 +9181,13 @@ }, "tags": [ "workspace" - ] + ], + "x-fern-sdk-group-name": [ + "workspace", + "groups", + "members" + ], + "x-fern-sdk-method-name": "remove" } }, "/v1/workspace/groups/{group_id}/members": { @@ -9163,7 +9253,13 @@ }, "tags": [ "workspace" - ] + ], + "x-fern-sdk-group-name": [ + "workspace", + "groups", + "members" + ], + "x-fern-sdk-method-name": "add" } }, "/v1/workspace/invites/add": { @@ -9225,7 +9321,12 @@ }, "tags": [ "workspace" - ] + ], + "x-fern-sdk-group-name": [ + "workspace", + "invites" + ], + "x-fern-sdk-method-name": "create" } }, "/v1/workspace/invites/add-bulk": { @@ -9287,7 +9388,12 @@ }, "tags": [ "workspace" - ] + ], + "x-fern-sdk-group-name": [ + "workspace", + "invites" + ], + "x-fern-sdk-method-name": "create_batch" } }, "/v1/workspace/invites": { @@ -9349,7 +9455,12 @@ }, "tags": [ "workspace" - ] + ], + "x-fern-sdk-group-name": [ + "workspace", + "invites" + ], + "x-fern-sdk-method-name": "delete" } }, "/v1/workspace/members": { @@ -9411,7 +9522,12 @@ }, "tags": [ "workspace" - ] + ], + "x-fern-sdk-group-name": [ + "workspace", + "members" + ], + "x-fern-sdk-method-name": "update" }, "delete": { "operationId": "Delete_member_v1_workspace_members_delete", @@ -9451,7 +9567,12 @@ }, "tags": [ "workspace" - ] + ], + "x-fern-sdk-group-name": [ + "workspace", + "members" + ], + "x-fern-sdk-method-name": "delete" } }, "/v1/workspace/resources/{resource_id}": { @@ -9524,7 +9645,12 @@ }, "tags": [ "workspace" - ] + ], + "x-fern-sdk-group-name": [ + "workspace", + "resources" + ], + "x-fern-sdk-method-name": "get" } }, "/v1/workspace/resources/{resource_id}/share": { @@ -9595,7 +9721,12 @@ }, "tags": [ "workspace" - ] + ], + "x-fern-sdk-group-name": [ + "workspace", + "resources" + ], + "x-fern-sdk-method-name": "share" } }, "/v1/workspace/resources/{resource_id}/unshare": { @@ -9666,7 +9797,12 @@ }, "tags": [ "workspace" - ] + ], + "x-fern-sdk-group-name": [ + "workspace", + "resources" + ], + "x-fern-sdk-method-name": "unshare" } }, "/v1/speech-to-text": { @@ -9873,7 +10009,10 @@ "tags": [ "Conversational AI" ], - "x-fern-sdk-group-name": "conversational_ai", + "x-fern-sdk-group-name": [ + "conversational_ai", + "conversations" + ], "x-fern-sdk-method-name": "get_signed_url" } }, @@ -10005,8 +10144,11 @@ "tags": [ "Conversational AI" ], - "x-fern-sdk-group-name": "conversational_ai", - "x-fern-sdk-method-name": "twilio_outbound_call" + "x-fern-sdk-group-name": [ + "conversational_ai", + "twilio" + ], + "x-fern-sdk-method-name": "outbound_call" } }, "/v1/convai/agents/create": { @@ -10069,8 +10211,11 @@ "tags": [ "Conversational AI" ], - "x-fern-sdk-group-name": "conversational_ai", - "x-fern-sdk-method-name": "create_agent" + "x-fern-sdk-group-name": [ + "conversational_ai", + "agents" + ], + "x-fern-sdk-method-name": "create" } }, "/v1/convai/agents/{agent_id}": { @@ -10138,8 +10283,11 @@ "tags": [ "Conversational AI" ], - "x-fern-sdk-group-name": "conversational_ai", - "x-fern-sdk-method-name": "get_agent" + "x-fern-sdk-group-name": [ + "conversational_ai", + "agents" + ], + "x-fern-sdk-method-name": "get" }, "patch": { "operationId": "Patches_an_Agent_settings_v1_convai_agents__agent_id__patch", @@ -10214,8 +10362,11 @@ "tags": [ "Conversational AI" ], - "x-fern-sdk-group-name": "conversational_ai", - "x-fern-sdk-method-name": "update_agent" + "x-fern-sdk-group-name": [ + "conversational_ai", + "agents" + ], + "x-fern-sdk-method-name": "update" }, "delete": { "operationId": "Delete_Agent_v1_convai_agents__agent_id__delete", @@ -10277,8 +10428,11 @@ "tags": [ "Conversational AI" ], - "x-fern-sdk-group-name": "conversational_ai", - "x-fern-sdk-method-name": "delete_agent" + "x-fern-sdk-group-name": [ + "conversational_ai", + "agents" + ], + "x-fern-sdk-method-name": "delete" } }, "/v1/convai/agents/{agent_id}/widget": { @@ -10364,8 +10518,12 @@ "tags": [ "Conversational AI" ], - "x-fern-sdk-group-name": "conversational_ai", - "x-fern-sdk-method-name": "get_agent_widget" + "x-fern-sdk-group-name": [ + "conversational_ai", + "agents", + "widget" + ], + "x-fern-sdk-method-name": "get" } }, "/v1/convai/agents/{agent_id}/link": { @@ -10433,8 +10591,12 @@ "tags": [ "Conversational AI" ], - "x-fern-sdk-group-name": "conversational_ai", - "x-fern-sdk-method-name": "get_agent_link" + "x-fern-sdk-group-name": [ + "conversational_ai", + "agents", + "link" + ], + "x-fern-sdk-method-name": "get" } }, "/v1/convai/agents/{agent_id}/avatar": { @@ -10512,8 +10674,13 @@ "tags": [ "Conversational AI" ], - "x-fern-sdk-group-name": "conversational_ai", - "x-fern-sdk-method-name": "post_agent_avatar" + "x-fern-sdk-group-name": [ + "conversational_ai", + "agents", + "widget", + "avatar" + ], + "x-fern-sdk-method-name": "create" } }, "/v1/convai/agents": { @@ -10616,8 +10783,11 @@ "tags": [ "Conversational AI" ], - "x-fern-sdk-group-name": "conversational_ai", - "x-fern-sdk-method-name": "get_agents" + "x-fern-sdk-group-name": [ + "conversational_ai", + "agents" + ], + "x-fern-sdk-method-name": "list" } }, "/v1/convai/agents/{agent_id}/simulate-conversation": { @@ -10937,8 +11107,11 @@ "tags": [ "Conversational AI" ], - "x-fern-sdk-group-name": "conversational_ai", - "x-fern-sdk-method-name": "get_conversations" + "x-fern-sdk-group-name": [ + "conversational_ai", + "conversations" + ], + "x-fern-sdk-method-name": "list" } }, "/v1/convai/conversations/{conversation_id}": { @@ -11006,8 +11179,11 @@ "tags": [ "Conversational AI" ], - "x-fern-sdk-group-name": "conversational_ai", - "x-fern-sdk-method-name": "get_conversation" + "x-fern-sdk-group-name": [ + "conversational_ai", + "conversations" + ], + "x-fern-sdk-method-name": "get" }, "delete": { "operationId": "Delete_Conversation_v1_convai_conversations__conversation_id__delete", @@ -11071,8 +11247,11 @@ "tags": [ "Conversational AI" ], - "x-fern-sdk-group-name": "conversational_ai", - "x-fern-sdk-method-name": "delete_conversation" + "x-fern-sdk-group-name": [ + "conversational_ai", + "conversations" + ], + "x-fern-sdk-method-name": "delete" } }, "/v1/convai/conversations/{conversation_id}/audio": { @@ -11136,8 +11315,12 @@ "tags": [ "Conversational AI" ], - "x-fern-sdk-group-name": "conversational_ai", - "x-fern-sdk-method-name": "get_conversation_audio", + "x-fern-sdk-group-name": [ + "conversational_ai", + "conversations", + "audio" + ], + "x-fern-sdk-method-name": "get", "x-fern-streaming": true } }, @@ -11196,8 +11379,12 @@ "tags": [ "Conversational AI" ], - "x-fern-sdk-group-name": "conversational_ai", - "x-fern-sdk-method-name": "post_conversation_feedback" + "x-fern-sdk-group-name": [ + "conversational_ai", + "conversations", + "feedback" + ], + "x-fern-sdk-method-name": "create" } }, "/v1/convai/phone-numbers/create": { @@ -11269,8 +11456,11 @@ "tags": [ "Conversational AI" ], - "x-fern-sdk-group-name": "conversational_ai", - "x-fern-sdk-method-name": "create_phone_number" + "x-fern-sdk-group-name": [ + "conversational_ai", + "phone_numbers" + ], + "x-fern-sdk-method-name": "create" } }, "/v1/convai/phone-numbers/{phone_number_id}": { @@ -11353,8 +11543,11 @@ "tags": [ "Conversational AI" ], - "x-fern-sdk-group-name": "conversational_ai", - "x-fern-sdk-method-name": "get_phone_number" + "x-fern-sdk-group-name": [ + "conversational_ai", + "phone_numbers" + ], + "x-fern-sdk-method-name": "get" }, "delete": { "operationId": "Delete_phone_number_v1_convai_phone_numbers__phone_number_id__delete", @@ -11418,8 +11611,11 @@ "tags": [ "Conversational AI" ], - "x-fern-sdk-group-name": "conversational_ai", - "x-fern-sdk-method-name": "delete_phone_number" + "x-fern-sdk-group-name": [ + "conversational_ai", + "phone_numbers" + ], + "x-fern-sdk-method-name": "delete" }, "patch": { "operationId": "Update_phone_number_v1_convai_phone_numbers__phone_number_id__patch", @@ -11511,8 +11707,11 @@ "tags": [ "Conversational AI" ], - "x-fern-sdk-group-name": "conversational_ai", - "x-fern-sdk-method-name": "update_phone_number" + "x-fern-sdk-group-name": [ + "conversational_ai", + "phone_numbers" + ], + "x-fern-sdk-method-name": "update" } }, "/v1/convai/phone-numbers/": { @@ -11583,8 +11782,11 @@ "tags": [ "Conversational AI" ], - "x-fern-sdk-group-name": "conversational_ai", - "x-fern-sdk-method-name": "get_phone_numbers" + "x-fern-sdk-group-name": [ + "conversational_ai", + "phone_numbers" + ], + "x-fern-sdk-method-name": "list" } }, "/v1/convai/knowledge-base": { @@ -11794,8 +11996,11 @@ "tags": [ "Conversational AI" ], - "x-fern-sdk-group-name": "conversational_ai", - "x-fern-sdk-method-name": "get_knowledge_base_list" + "x-fern-sdk-group-name": [ + "conversational_ai", + "knowledge_base" + ], + "x-fern-sdk-method-name": "list" } }, "/v1/convai/add-to-knowledge-base": { @@ -11984,8 +12189,12 @@ "tags": [ "Conversational AI" ], - "x-fern-sdk-group-name": "conversational_ai", - "x-fern-sdk-method-name": "create_knowledge_base_url_document" + "x-fern-sdk-group-name": [ + "conversational_ai", + "knowledge_base", + "documents" + ], + "x-fern-sdk-method-name": "create_from_url" } }, "/v1/convai/knowledge-base/file": { @@ -12048,8 +12257,12 @@ "tags": [ "Conversational AI" ], - "x-fern-sdk-group-name": "conversational_ai", - "x-fern-sdk-method-name": "create_knowledge_base_file_document" + "x-fern-sdk-group-name": [ + "conversational_ai", + "knowledge_base", + "documents" + ], + "x-fern-sdk-method-name": "create_from_file" } }, "/v1/convai/knowledge-base/text": { @@ -12112,8 +12325,12 @@ "tags": [ "Conversational AI" ], - "x-fern-sdk-group-name": "conversational_ai", - "x-fern-sdk-method-name": "create_knowledge_base_text_document" + "x-fern-sdk-group-name": [ + "conversational_ai", + "knowledge_base", + "documents" + ], + "x-fern-sdk-method-name": "create_from_text" } }, "/v1/convai/knowledge-base/{documentation_id}": { @@ -12210,8 +12427,12 @@ "tags": [ "Conversational AI" ], - "x-fern-sdk-group-name": "conversational_ai", - "x-fern-sdk-method-name": "update_knowledge_base_document" + "x-fern-sdk-group-name": [ + "conversational_ai", + "knowledge_base", + "documents" + ], + "x-fern-sdk-method-name": "update" }, "get": { "operationId": "Get_documentation_from_knowledge_base_v1_convai_knowledge_base__documentation_id__get", @@ -12296,8 +12517,12 @@ "tags": [ "Conversational AI" ], - "x-fern-sdk-group-name": "conversational_ai", - "x-fern-sdk-method-name": "get_knowledge_base_document_by_id" + "x-fern-sdk-group-name": [ + "conversational_ai", + "knowledge_base", + "documents" + ], + "x-fern-sdk-method-name": "get" }, "delete": { "operationId": "Delete_knowledge_base_document_v1_convai_knowledge_base__documentation_id__delete", @@ -12361,8 +12586,12 @@ "tags": [ "Conversational AI" ], - "x-fern-sdk-group-name": "conversational_ai", - "x-fern-sdk-method-name": "delete_knowledge_base_document" + "x-fern-sdk-group-name": [ + "conversational_ai", + "knowledge_base", + "documents" + ], + "x-fern-sdk-method-name": "delete" } }, "/v1/convai/knowledge-base/{documentation_id}/rag-index": { @@ -12634,8 +12863,12 @@ "tags": [ "Conversational AI" ], - "x-fern-sdk-group-name": "conversational_ai", - "x-fern-sdk-method-name": "get_dependent_agents" + "x-fern-sdk-group-name": [ + "conversational_ai", + "knowledge_base", + "documents" + ], + "x-fern-sdk-method-name": "get_agents" } }, "/v1/convai/knowledge-base/{documentation_id}/content": { @@ -12699,8 +12932,12 @@ "tags": [ "Conversational AI" ], - "x-fern-sdk-group-name": "conversational_ai", - "x-fern-sdk-method-name": "get_knowledge_base_document_content", + "x-fern-sdk-group-name": [ + "conversational_ai", + "knowledge_base", + "documents" + ], + "x-fern-sdk-method-name": "get_content", "x-fern-sdk-streaming": true } }, @@ -12784,8 +13021,13 @@ "tags": [ "Conversational AI" ], - "x-fern-sdk-group-name": "conversational_ai", - "x-fern-sdk-method-name": "get_knowledge_base_document_part_by_id" + "x-fern-sdk-group-name": [ + "conversational_ai", + "knowledge_base", + "documents", + "chunk" + ], + "x-fern-sdk-method-name": "get" } }, "/v1/convai/settings": { @@ -12838,8 +13080,11 @@ "tags": [ "Conversational AI" ], - "x-fern-sdk-group-name": "conversational_ai", - "x-fern-sdk-method-name": "get_settings" + "x-fern-sdk-group-name": [ + "conversational_ai", + "settings" + ], + "x-fern-sdk-method-name": "get" }, "patch": { "operationId": "Update_Convai_settings_v1_convai_settings_patch", @@ -12901,8 +13146,11 @@ "tags": [ "Conversational AI" ], - "x-fern-sdk-group-name": "conversational_ai", - "x-fern-sdk-method-name": "update_settings" + "x-fern-sdk-group-name": [ + "conversational_ai", + "settings" + ], + "x-fern-sdk-method-name": "update" } }, "/v1/convai/settings/dashboard": { @@ -12955,8 +13203,12 @@ "tags": [ "Conversational AI" ], - "x-fern-sdk-group-name": "conversational_ai", - "x-fern-sdk-method-name": "get_dashboard_settings" + "x-fern-sdk-group-name": [ + "conversational_ai", + "dashboard", + "settings" + ], + "x-fern-sdk-method-name": "get" }, "patch": { "operationId": "Update_Convai_dashboard_settings_v1_convai_settings_dashboard_patch", @@ -13018,8 +13270,12 @@ "tags": [ "Conversational AI" ], - "x-fern-sdk-group-name": "conversational_ai", - "x-fern-sdk-method-name": "update_dashboard_settings" + "x-fern-sdk-group-name": [ + "conversational_ai", + "dashboard", + "settings" + ], + "x-fern-sdk-method-name": "update" } }, "/v1/convai/secrets": { @@ -13083,8 +13339,11 @@ "tags": [ "Conversational AI" ], - "x-fern-sdk-group-name": "conversational_ai", - "x-fern-sdk-method-name": "create_secret" + "x-fern-sdk-group-name": [ + "conversational_ai", + "secrets" + ], + "x-fern-sdk-method-name": "create" }, "get": { "operationId": "Get_ConvAI_workspace_secrets_v1_convai_secrets_get", @@ -13132,8 +13391,11 @@ } } }, - "x-fern-sdk-group-name": "conversational_ai", - "x-fern-sdk-method-name": "get_secrets" + "x-fern-sdk-group-name": [ + "conversational_ai", + "secrets" + ], + "x-fern-sdk-method-name": "list" } }, "/v1/convai/secrets/{secret_id}": { @@ -13188,23 +13450,24 @@ "tags": [ "Conversational AI" ], - "x-fern-sdk-group-name": "conversational_ai", - "x-fern-sdk-method-name": "delete_secret" - } - }, - "/v1/convai/batch-calling/{batch_id}": { - "get": { - "operationId": "Get_a_batch_call_by_ID__v1_convai_batch_calling__batch_id__get", - "summary": "Get A Batch Call By Id.", - "description": "Get detailed information about a batch call including all recipients.", + "x-fern-sdk-group-name": [ + "conversational_ai", + "secrets" + ], + "x-fern-sdk-method-name": "delete" + }, + "patch": { + "operationId": "Update_ConvAI_workspace_secret_v1_convai_secrets__secret_id__patch", + "summary": "Update Convai Workspace Secret", + "description": "Update an existing secret for the workspace", "parameters": [ { - "name": "batch_id", + "name": "secret_id", "in": "path", "required": true, "schema": { "type": "string", - "title": "Batch Id" + "title": "Secret Id" } }, { @@ -13226,13 +13489,24 @@ } } ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "description": "Secret data to update", + "$ref": "#/components/schemas/PatchWorkspaceSecretRequest" + } + } + } + }, "responses": { "200": { "description": "Successful Response", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/BatchCallDetailedResponse" + "$ref": "#/components/schemas/PostWorkspaceSecretResponseModel" } } } @@ -13252,14 +13526,14 @@ "Conversational AI" ], "x-fern-sdk-group-name": "conversational_ai", - "x-fern-sdk-method-name": "get_batch_call" + "x-fern-sdk-method-name": "update_secret" } }, - "/v1/convai/sip-trunk/outbound-call": { + "/v1/convai/batch-calling/submit": { "post": { - "operationId": "Handle_an_outbound_call_via_SIP_trunk_v1_convai_sip_trunk_outbound_call_post", - "summary": "Handle An Outbound Call Via Sip Trunk", - "description": "Handle an outbound call via SIP trunk", + "operationId": "Submit_a_batch_call_request__v1_convai_batch_calling_submit_post", + "summary": "Submit A Batch Call Request.", + "description": "Submit a batch call request to schedule calls for multiple recipients.", "parameters": [ { "name": "xi-api-key", @@ -13285,7 +13559,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/Body_Handle_an_outbound_call_via_SIP_trunk_v1_convai_sip_trunk_outbound_call_post" + "$ref": "#/components/schemas/Body_Submit_a_batch_call_request__v1_convai_batch_calling_submit_post" } } } @@ -13296,7 +13570,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/SIPTrunkOutboundCallResponse" + "$ref": "#/components/schemas/BatchCallResponse" } } } @@ -13317,17 +13591,43 @@ ], "x-fern-sdk-group-name": [ "conversational_ai", - "sip_trunk" + "batch_calls" ], - "x-fern-sdk-method-name": "outbound_call" + "x-fern-sdk-method-name": "create" } }, - "/v1/voices/pvc": { - "post": { - "operationId": "Create_PVC_voice_v1_voices_pvc_post", - "summary": "Create Pvc Voice", - "description": "Creates a new PVC voice with metadata but no samples", + "/v1/convai/batch-calling/workspace": { + "get": { + "operationId": "Get_all_batch_calls_for_a_workspace__v1_convai_batch_calling_workspace_get", + "summary": "Get All Batch Calls For A Workspace.", + "description": "Get all batch calls for the current workspace.", "parameters": [ + { + "name": "limit", + "in": "query", + "required": false, + "schema": { + "type": "integer", + "default": 100, + "title": "Limit" + } + }, + { + "name": "last_doc", + "in": "query", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Last Doc" + } + }, { "name": "xi-api-key", "in": "header", @@ -13347,23 +13647,13 @@ } } ], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Body_Create_PVC_voice_v1_voices_pvc_post" - } - } - } - }, "responses": { "200": { "description": "Successful Response", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/AddVoiceResponseModel" + "$ref": "#/components/schemas/WorkspaceBatchCallsResponse" } } } @@ -13380,33 +13670,28 @@ } }, "tags": [ - "pvc-voices" + "Conversational AI" ], "x-fern-sdk-group-name": [ - "voices", - "pvc" + "conversational_ai", + "batch_calls" ], - "x-fern-sdk-method-name": "create" + "x-fern-sdk-method-name": "list" } }, - "/v1/voices/pvc/{voice_id}": { - "post": { - "operationId": "Edit_PVC_voice_v1_voices_pvc__voice_id__post", - "summary": "Edit Pvc Voice", - "description": "Edit PVC voice metadata", + "/v1/convai/batch-calling/{batch_id}": { + "get": { + "operationId": "Get_a_batch_call_by_ID__v1_convai_batch_calling__batch_id__get", + "summary": "Get A Batch Call By Id.", + "description": "Get detailed information about a batch call including all recipients.", "parameters": [ { - "name": "voice_id", + "name": "batch_id", "in": "path", - "description": "Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices.", "required": true, "schema": { - "description": "Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices.", "type": "string", - "examples": [ - "21m00Tcm4TlvDq8ikWAM" - ], - "title": "Voice Id" + "title": "Batch Id" } }, { @@ -13428,22 +13713,13 @@ } } ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Body_Edit_PVC_voice_v1_voices_pvc__voice_id__post" - } - } - } - }, "responses": { "200": { "description": "Successful Response", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/AddVoiceResponseModel" + "$ref": "#/components/schemas/BatchCallDetailedResponse" } } } @@ -13460,35 +13736,21 @@ } }, "tags": [ - "pvc-voices" + "Conversational AI" ], "x-fern-sdk-group-name": [ - "voices", - "pvc" + "conversational_ai", + "batch_calls" ], - "x-fern-sdk-method-name": "update" + "x-fern-sdk-method-name": "get" } }, - "/v1/voices/pvc/{voice_id}/samples": { + "/v1/convai/sip-trunk/outbound-call": { "post": { - "operationId": "Add_samples_to_PVC_voice_v1_voices_pvc__voice_id__samples_post", - "summary": "Add Samples To Pvc Voice", - "description": "Add audio samples to a PVC voice", + "operationId": "Handle_an_outbound_call_via_SIP_trunk_v1_convai_sip_trunk_outbound_call_post", + "summary": "Handle An Outbound Call Via Sip Trunk", + "description": "Handle an outbound call via SIP trunk", "parameters": [ - { - "name": "voice_id", - "in": "path", - "description": "Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices.", - "required": true, - "schema": { - "description": "Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices.", - "type": "string", - "examples": [ - "21m00Tcm4TlvDq8ikWAM" - ], - "title": "Voice Id" - } - }, { "name": "xi-api-key", "in": "header", @@ -13511,9 +13773,9 @@ "requestBody": { "required": true, "content": { - "multipart/form-data": { + "application/json": { "schema": { - "$ref": "#/components/schemas/Body_Add_samples_to_PVC_voice_v1_voices_pvc__voice_id__samples_post" + "$ref": "#/components/schemas/Body_Handle_an_outbound_call_via_SIP_trunk_v1_convai_sip_trunk_outbound_call_post" } } } @@ -13524,11 +13786,7 @@ "content": { "application/json": { "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/SampleResponseModel" - }, - "title": "Response Add Samples To Pvc Voice V1 Voices Pvc Voice Id Samples Post" + "$ref": "#/components/schemas/SIPTrunkOutboundCallResponse" } } } @@ -13545,50 +13803,21 @@ } }, "tags": [ - "pvc-voices" + "Conversational AI" ], "x-fern-sdk-group-name": [ - "voices", - "pvc", - "samples" + "conversational_ai", + "sip_trunk" ], - "x-fern-sdk-method-name": "create" + "x-fern-sdk-method-name": "outbound_call" } }, - "/v1/voices/pvc/{voice_id}/samples/{sample_id}": { + "/v1/voices/pvc": { "post": { - "operationId": "Update_PVC_voice_sample_v1_voices_pvc__voice_id__samples__sample_id__post", - "summary": "Update Pvc Voice Sample", - "description": "Update a PVC voice sample - apply noise removal, or select speaker.", + "operationId": "Create_PVC_voice_v1_voices_pvc_post", + "summary": "Create Pvc Voice", + "description": "Creates a new PVC voice with metadata but no samples", "parameters": [ - { - "name": "voice_id", - "in": "path", - "description": "Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices.", - "required": true, - "schema": { - "description": "Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices.", - "type": "string", - "examples": [ - "21m00Tcm4TlvDq8ikWAM" - ], - "title": "Voice Id" - } - }, - { - "name": "sample_id", - "in": "path", - "description": "Sample ID to be used", - "required": true, - "schema": { - "description": "Sample ID to be used", - "type": "string", - "examples": [ - "VW7YKqPnjY4h39yTbx2L" - ], - "title": "Sample Id" - } - }, { "name": "xi-api-key", "in": "header", @@ -13609,10 +13838,11 @@ } ], "requestBody": { + "required": true, "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/Body_Update_PVC_voice_sample_v1_voices_pvc__voice_id__samples__sample_id__post" + "$ref": "#/components/schemas/Body_Create_PVC_voice_v1_voices_pvc_post" } } } @@ -13644,15 +13874,16 @@ ], "x-fern-sdk-group-name": [ "voices", - "pvc", - "samples" + "pvc" ], - "x-fern-sdk-method-name": "update" - }, - "delete": { - "operationId": "Delete_PVC_voice_sample_v1_voices_pvc__voice_id__samples__sample_id__delete", - "summary": "Delete Pvc Voice Sample", - "description": "Delete a sample from a PVC voice.", + "x-fern-sdk-method-name": "create" + } + }, + "/v1/voices/pvc/{voice_id}": { + "post": { + "operationId": "Edit_PVC_voice_v1_voices_pvc__voice_id__post", + "summary": "Edit Pvc Voice", + "description": "Edit PVC voice metadata", "parameters": [ { "name": "voice_id", @@ -13668,20 +13899,6 @@ "title": "Voice Id" } }, - { - "name": "sample_id", - "in": "path", - "description": "Sample ID to be used", - "required": true, - "schema": { - "description": "Sample ID to be used", - "type": "string", - "examples": [ - "VW7YKqPnjY4h39yTbx2L" - ], - "title": "Sample Id" - } - }, { "name": "xi-api-key", "in": "header", @@ -13701,13 +13918,22 @@ } } ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Body_Edit_PVC_voice_v1_voices_pvc__voice_id__post" + } + } + } + }, "responses": { "200": { "description": "Successful Response", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/DeleteVoiceSampleResponseModel" + "$ref": "#/components/schemas/AddVoiceResponseModel" } } } @@ -13728,17 +13954,16 @@ ], "x-fern-sdk-group-name": [ "voices", - "pvc", - "samples" + "pvc" ], - "x-fern-sdk-method-name": "delete" + "x-fern-sdk-method-name": "update" } }, - "/v1/voices/pvc/{voice_id}/samples/{sample_id}/audio": { - "get": { - "operationId": "Retrieve_voice_sample_audio_v1_voices_pvc__voice_id__samples__sample_id__audio_get", - "summary": "Retrieve Voice Sample Audio", - "description": "Retrieve the first 30 seconds of voice sample audio with or without noise removal.", + "/v1/voices/pvc/{voice_id}/samples": { + "post": { + "operationId": "Add_samples_to_PVC_voice_v1_voices_pvc__voice_id__samples_post", + "summary": "Add Samples To Pvc Voice", + "description": "Add audio samples to a PVC voice", "parameters": [ { "name": "voice_id", @@ -13754,20 +13979,6 @@ "title": "Voice Id" } }, - { - "name": "sample_id", - "in": "path", - "description": "Sample ID to be used", - "required": true, - "schema": { - "description": "Sample ID to be used", - "type": "string", - "examples": [ - "VW7YKqPnjY4h39yTbx2L" - ], - "title": "Sample Id" - } - }, { "name": "xi-api-key", "in": "header", @@ -13788,10 +13999,11 @@ } ], "requestBody": { + "required": true, "content": { - "application/json": { + "multipart/form-data": { "schema": { - "$ref": "#/components/schemas/Body_Retrieve_voice_sample_audio_v1_voices_pvc__voice_id__samples__sample_id__audio_get" + "$ref": "#/components/schemas/Body_Add_samples_to_PVC_voice_v1_voices_pvc__voice_id__samples_post" } } } @@ -13802,7 +14014,11 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/VoiceSamplePreviewResponseModel" + "type": "array", + "items": { + "$ref": "#/components/schemas/SampleResponseModel" + }, + "title": "Response Add Samples To Pvc Voice V1 Voices Pvc Voice Id Samples Post" } } } @@ -13824,17 +14040,16 @@ "x-fern-sdk-group-name": [ "voices", "pvc", - "samples", - "audio" + "samples" ], - "x-fern-sdk-method-name": "get" + "x-fern-sdk-method-name": "create" } }, - "/v1/voices/pvc/{voice_id}/samples/{sample_id}/waveform": { - "get": { - "operationId": "Retrieve_voice_sample_visual_waveform_v1_voices_pvc__voice_id__samples__sample_id__waveform_get", - "summary": "Retrieve Voice Sample Visual Waveform", - "description": "Retrieve the visual waveform of a voice sample.", + "/v1/voices/pvc/{voice_id}/samples/{sample_id}": { + "post": { + "operationId": "Update_PVC_voice_sample_v1_voices_pvc__voice_id__samples__sample_id__post", + "summary": "Update Pvc Voice Sample", + "description": "Update a PVC voice sample - apply noise removal, or select speaker.", "parameters": [ { "name": "voice_id", @@ -13883,13 +14098,22 @@ } } ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Body_Update_PVC_voice_sample_v1_voices_pvc__voice_id__samples__sample_id__post" + } + } + } + }, "responses": { "200": { "description": "Successful Response", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/VoiceSampleVisualWaveformResponseModel" + "$ref": "#/components/schemas/AddVoiceResponseModel" } } } @@ -13911,17 +14135,14 @@ "x-fern-sdk-group-name": [ "voices", "pvc", - "samples", - "waveform" + "samples" ], - "x-fern-sdk-method-name": "get" - } - }, - "/v1/voices/pvc/{voice_id}/samples/{sample_id}/speakers": { - "get": { - "operationId": "Retrieve_speaker_separation_status_v1_voices_pvc__voice_id__samples__sample_id__speakers_get", - "summary": "Retrieve Speaker Separation Status", - "description": "Retrieve the status of the speaker separation process and the list of detected speakers if complete.", + "x-fern-sdk-method-name": "update" + }, + "delete": { + "operationId": "Delete_PVC_voice_sample_v1_voices_pvc__voice_id__samples__sample_id__delete", + "summary": "Delete Pvc Voice Sample", + "description": "Delete a sample from a PVC voice.", "parameters": [ { "name": "voice_id", @@ -13976,7 +14197,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/SpeakerSeparationResponseModel" + "$ref": "#/components/schemas/DeleteVoiceSampleResponseModel" } } } @@ -13998,17 +14219,16 @@ "x-fern-sdk-group-name": [ "voices", "pvc", - "samples", - "speakers" + "samples" ], - "x-fern-sdk-method-name": "get" + "x-fern-sdk-method-name": "delete" } }, - "/v1/voices/pvc/{voice_id}/samples/{sample_id}/separate-speakers": { - "post": { - "operationId": "Start_speaker_separation_v1_voices_pvc__voice_id__samples__sample_id__separate_speakers_post", - "summary": "Start Speaker Separation", - "description": "Start speaker separation process for a sample", + "/v1/voices/pvc/{voice_id}/samples/{sample_id}/audio": { + "get": { + "operationId": "Retrieve_voice_sample_audio_v1_voices_pvc__voice_id__samples__sample_id__audio_get", + "summary": "Retrieve Voice Sample Audio", + "description": "Retrieve the first 30 seconds of voice sample audio with or without noise removal.", "parameters": [ { "name": "voice_id", @@ -14057,13 +14277,22 @@ } } ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Body_Retrieve_voice_sample_audio_v1_voices_pvc__voice_id__samples__sample_id__audio_get" + } + } + } + }, "responses": { "200": { "description": "Successful Response", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/StartSpeakerSeparationResponseModel" + "$ref": "#/components/schemas/VoiceSamplePreviewResponseModel" } } } @@ -14086,16 +14315,16 @@ "voices", "pvc", "samples", - "speakers" + "audio" ], - "x-fern-sdk-method-name": "separate" + "x-fern-sdk-method-name": "get" } }, - "/v1/voices/pvc/{voice_id}/samples/{sample_id}/speakers/{speaker_id}/audio": { + "/v1/voices/pvc/{voice_id}/samples/{sample_id}/waveform": { "get": { - "operationId": "Retrieve_separated_speaker_audio_v1_voices_pvc__voice_id__samples__sample_id__speakers__speaker_id__audio_get", - "summary": "Retrieve Separated Speaker Audio", - "description": "Retrieve the separated audio for a specific speaker.", + "operationId": "Retrieve_voice_sample_visual_waveform_v1_voices_pvc__voice_id__samples__sample_id__waveform_get", + "summary": "Retrieve Voice Sample Visual Waveform", + "description": "Retrieve the visual waveform of a voice sample.", "parameters": [ { "name": "voice_id", @@ -14125,20 +14354,6 @@ "title": "Sample Id" } }, - { - "name": "speaker_id", - "in": "path", - "description": "Speaker ID to be used, you can use GET https://api.elevenlabs.io/v1/voices/{voice_id}/samples/{sample_id}/speakers to list all the available speakers for a sample.", - "required": true, - "schema": { - "description": "Speaker ID to be used, you can use GET https://api.elevenlabs.io/v1/voices/{voice_id}/samples/{sample_id}/speakers to list all the available speakers for a sample.", - "type": "string", - "examples": [ - "VW7YKqPnjY4h39yTbx2L" - ], - "title": "Speaker Id" - } - }, { "name": "xi-api-key", "in": "header", @@ -14164,7 +14379,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/SpeakerAudioResponseModel" + "$ref": "#/components/schemas/VoiceSampleVisualWaveformResponseModel" } } } @@ -14187,17 +14402,292 @@ "voices", "pvc", "samples", - "speakers", - "audio" + "waveform" ], "x-fern-sdk-method-name": "get" } }, - "/v1/voices/pvc/{voice_id}/captcha": { + "/v1/voices/pvc/{voice_id}/samples/{sample_id}/speakers": { "get": { - "operationId": "Get_PVC_voice_captcha_v1_voices_pvc__voice_id__captcha_get", - "summary": "Get Pvc Voice Captcha", - "description": "Get captcha for PVC voice verification.", + "operationId": "Retrieve_speaker_separation_status_v1_voices_pvc__voice_id__samples__sample_id__speakers_get", + "summary": "Retrieve Speaker Separation Status", + "description": "Retrieve the status of the speaker separation process and the list of detected speakers if complete.", + "parameters": [ + { + "name": "voice_id", + "in": "path", + "description": "Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices.", + "required": true, + "schema": { + "description": "Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices.", + "type": "string", + "examples": [ + "21m00Tcm4TlvDq8ikWAM" + ], + "title": "Voice Id" + } + }, + { + "name": "sample_id", + "in": "path", + "description": "Sample ID to be used", + "required": true, + "schema": { + "description": "Sample ID to be used", + "type": "string", + "examples": [ + "VW7YKqPnjY4h39yTbx2L" + ], + "title": "Sample Id" + } + }, + { + "name": "xi-api-key", + "in": "header", + "description": "Your API key. This is required by most endpoints to access our API programatically. You can view your xi-api-key using the 'Profile' tab on the website.", + "required": false, + "schema": { + "description": "Your API key. This is required by most endpoints to access our API programatically. You can view your xi-api-key using the 'Profile' tab on the website.", + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Xi-Api-Key" + } + } + ], + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SpeakerSeparationResponseModel" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + }, + "tags": [ + "pvc-voices" + ], + "x-fern-sdk-group-name": [ + "voices", + "pvc", + "samples", + "speakers" + ], + "x-fern-sdk-method-name": "get" + } + }, + "/v1/voices/pvc/{voice_id}/samples/{sample_id}/separate-speakers": { + "post": { + "operationId": "Start_speaker_separation_v1_voices_pvc__voice_id__samples__sample_id__separate_speakers_post", + "summary": "Start Speaker Separation", + "description": "Start speaker separation process for a sample", + "parameters": [ + { + "name": "voice_id", + "in": "path", + "description": "Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices.", + "required": true, + "schema": { + "description": "Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices.", + "type": "string", + "examples": [ + "21m00Tcm4TlvDq8ikWAM" + ], + "title": "Voice Id" + } + }, + { + "name": "sample_id", + "in": "path", + "description": "Sample ID to be used", + "required": true, + "schema": { + "description": "Sample ID to be used", + "type": "string", + "examples": [ + "VW7YKqPnjY4h39yTbx2L" + ], + "title": "Sample Id" + } + }, + { + "name": "xi-api-key", + "in": "header", + "description": "Your API key. This is required by most endpoints to access our API programatically. You can view your xi-api-key using the 'Profile' tab on the website.", + "required": false, + "schema": { + "description": "Your API key. This is required by most endpoints to access our API programatically. You can view your xi-api-key using the 'Profile' tab on the website.", + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Xi-Api-Key" + } + } + ], + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/StartSpeakerSeparationResponseModel" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + }, + "tags": [ + "pvc-voices" + ], + "x-fern-sdk-group-name": [ + "voices", + "pvc", + "samples", + "speakers" + ], + "x-fern-sdk-method-name": "separate" + } + }, + "/v1/voices/pvc/{voice_id}/samples/{sample_id}/speakers/{speaker_id}/audio": { + "get": { + "operationId": "Retrieve_separated_speaker_audio_v1_voices_pvc__voice_id__samples__sample_id__speakers__speaker_id__audio_get", + "summary": "Retrieve Separated Speaker Audio", + "description": "Retrieve the separated audio for a specific speaker.", + "parameters": [ + { + "name": "voice_id", + "in": "path", + "description": "Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices.", + "required": true, + "schema": { + "description": "Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices.", + "type": "string", + "examples": [ + "21m00Tcm4TlvDq8ikWAM" + ], + "title": "Voice Id" + } + }, + { + "name": "sample_id", + "in": "path", + "description": "Sample ID to be used", + "required": true, + "schema": { + "description": "Sample ID to be used", + "type": "string", + "examples": [ + "VW7YKqPnjY4h39yTbx2L" + ], + "title": "Sample Id" + } + }, + { + "name": "speaker_id", + "in": "path", + "description": "Speaker ID to be used, you can use GET https://api.elevenlabs.io/v1/voices/{voice_id}/samples/{sample_id}/speakers to list all the available speakers for a sample.", + "required": true, + "schema": { + "description": "Speaker ID to be used, you can use GET https://api.elevenlabs.io/v1/voices/{voice_id}/samples/{sample_id}/speakers to list all the available speakers for a sample.", + "type": "string", + "examples": [ + "VW7YKqPnjY4h39yTbx2L" + ], + "title": "Speaker Id" + } + }, + { + "name": "xi-api-key", + "in": "header", + "description": "Your API key. This is required by most endpoints to access our API programatically. You can view your xi-api-key using the 'Profile' tab on the website.", + "required": false, + "schema": { + "description": "Your API key. This is required by most endpoints to access our API programatically. You can view your xi-api-key using the 'Profile' tab on the website.", + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Xi-Api-Key" + } + } + ], + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SpeakerAudioResponseModel" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + }, + "tags": [ + "pvc-voices" + ], + "x-fern-sdk-group-name": [ + "voices", + "pvc", + "samples", + "speakers", + "audio" + ], + "x-fern-sdk-method-name": "get" + } + }, + "/v1/voices/pvc/{voice_id}/captcha": { + "get": { + "operationId": "Get_PVC_voice_captcha_v1_voices_pvc__voice_id__captcha_get", + "summary": "Get Pvc Voice Captcha", + "description": "Get captcha for PVC voice verification.", "parameters": [ { "name": "voice_id", @@ -15686,6 +16176,10 @@ "type": "string", "title": "Phone Number Id" }, + "phone_provider": { + "default": "twilio", + "$ref": "#/components/schemas/TelephonyProvider" + }, "name": { "type": "string", "title": "Name" @@ -15749,6 +16243,7 @@ "type": "string", "enum": [ "pending", + "initiated", "in_progress", "completed", "failed", @@ -15756,6 +16251,72 @@ ], "title": "BatchCallRecipientStatus" }, + "BatchCallResponse": { + "type": "object", + "properties": { + "id": { + "type": "string", + "title": "Id" + }, + "phone_number_id": { + "type": "string", + "title": "Phone Number Id" + }, + "phone_provider": { + "default": "twilio", + "$ref": "#/components/schemas/TelephonyProvider" + }, + "name": { + "type": "string", + "title": "Name" + }, + "agent_id": { + "type": "string", + "title": "Agent Id" + }, + "created_at_unix": { + "type": "integer", + "title": "Created At Unix" + }, + "scheduled_time_unix": { + "type": "integer", + "title": "Scheduled Time Unix" + }, + "total_calls_dispatched": { + "type": "integer", + "title": "Total Calls Dispatched" + }, + "total_calls_scheduled": { + "type": "integer", + "title": "Total Calls Scheduled" + }, + "last_updated_at_unix": { + "type": "integer", + "title": "Last Updated At Unix" + }, + "status": { + "$ref": "#/components/schemas/BatchCallStatus" + }, + "agent_name": { + "type": "string", + "title": "Agent Name" + } + }, + "required": [ + "id", + "phone_number_id", + "name", + "agent_id", + "created_at_unix", + "scheduled_time_unix", + "total_calls_dispatched", + "total_calls_scheduled", + "last_updated_at_unix", + "status", + "agent_name" + ], + "title": "BatchCallResponse" + }, "BatchCallStatus": { "type": "string", "enum": [ @@ -19406,6 +19967,50 @@ }, "title": "Body_Stream_project_audio_v1_projects__project_id__snapshots__project_snapshot_id__stream_post" }, + "Body_Submit_a_batch_call_request__v1_convai_batch_calling_submit_post": { + "type": "object", + "properties": { + "call_name": { + "type": "string", + "title": "Call Name" + }, + "agent_id": { + "type": "string", + "title": "Agent Id" + }, + "agent_phone_number_id": { + "type": "string", + "title": "Agent Phone Number Id" + }, + "scheduled_time_unix": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "title": "Scheduled Time Unix" + }, + "recipients": { + "type": "array", + "items": { + "$ref": "#/components/schemas/OutboundCallRecipient" + }, + "maxItems": 10000, + "title": "Recipients" + } + }, + "required": [ + "call_name", + "agent_id", + "agent_phone_number_id", + "scheduled_time_unix", + "recipients" + ], + "title": "Body_Submit_a_batch_call_request__v1_convai_batch_calling_submit_post" + }, "Body_Text_to_speech_streaming_v1_text_to_speech__voice_id__stream_post": { "type": "object", "properties": { @@ -21380,6 +21985,20 @@ ], "title": "ClientToolConfig" }, + "ConvAIDynamicVariable": { + "description": "Used to reference a dynamic variable.", + "type": "object", + "properties": { + "variable_name": { + "type": "string", + "title": "Variable Name" + } + }, + "required": [ + "variable_name" + ], + "title": "ConvAIDynamicVariable" + }, "ConvAISecretLocator": { "description": "Used to reference a secret from the agent's secret store.", "type": "object", @@ -21545,6 +22164,12 @@ "ConversationConfig": { "type": "object", "properties": { + "text_only": { + "description": "If enabled audio will not be processed and only text will be used, use to avoid audio pricing.", + "type": "boolean", + "default": false, + "title": "Text Only" + }, "max_duration_seconds": { "description": "The maximum duration of a conversation in seconds", "type": "integer", @@ -21593,6 +22218,17 @@ "type": "null" } ] + }, + "conversation": { + "description": "The overrides for the conversation configuration", + "anyOf": [ + { + "$ref": "#/components/schemas/ConversationConfigOverride" + }, + { + "type": "null" + } + ] } }, "title": "ConversationConfigClientOverride" @@ -21621,6 +22257,17 @@ "type": "null" } ] + }, + "conversation": { + "description": "The overrides for the conversation configuration", + "anyOf": [ + { + "$ref": "#/components/schemas/ConversationConfigOverride" + }, + { + "type": "null" + } + ] } }, "title": "ConversationConfigClientOverride" @@ -21635,6 +22282,10 @@ "tts": { "description": "Overrides for the TTS configuration", "$ref": "#/components/schemas/TTSConversationalConfigOverrideConfig" + }, + "conversation": { + "description": "Overrides for the conversation configuration", + "$ref": "#/components/schemas/ConversationConfigOverrideConfig" } }, "title": "ConversationConfigClientOverrideConfig" @@ -21649,10 +22300,46 @@ "tts": { "description": "Overrides for the TTS configuration", "$ref": "#/components/schemas/TTSConversationalConfigOverrideConfig" + }, + "conversation": { + "description": "Overrides for the conversation configuration", + "$ref": "#/components/schemas/ConversationConfigOverrideConfig" } }, "title": "ConversationConfigClientOverrideConfig" }, + "ConversationConfigOverride": { + "type": "object", + "properties": { + "text_only": { + "anyOf": [ + { + "type": "boolean" + }, + { + "type": "null" + } + ], + "title": "Text Only" + } + }, + "title": "ConversationConfigOverride" + }, + "ConversationConfigOverrideConfig": { + "type": "object", + "properties": { + "text_only": { + "description": "Whether to allow overriding the text only configuration", + "type": "boolean", + "default": false, + "title": "Text Only" + } + }, + "example": { + "text_only": false + }, + "title": "ConversationConfigOverrideConfig" + }, "ConversationDeletionSettings": { "type": "object", "properties": { @@ -22076,6 +22763,21 @@ ], "title": "Llm Override" }, + "source_medium": { + "anyOf": [ + { + "type": "string", + "enum": [ + "audio", + "text" + ] + }, + { + "type": "null" + } + ], + "title": "Source Medium" + }, "time_in_call_secs": { "type": "integer", "title": "Time In Call Secs" @@ -22109,6 +22811,22 @@ "type": "null" } ] + }, + "interrupted": { + "type": "boolean", + "default": false, + "title": "Interrupted" + }, + "original_message": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Original Message" } }, "required": [ @@ -22174,6 +22892,21 @@ ], "title": "Llm Override" }, + "source_medium": { + "anyOf": [ + { + "type": "string", + "enum": [ + "audio", + "text" + ] + }, + { + "type": "null" + } + ], + "title": "Source Medium" + }, "time_in_call_secs": { "type": "integer", "title": "Time In Call Secs" @@ -22207,6 +22940,22 @@ "type": "null" } ] + }, + "interrupted": { + "type": "boolean", + "default": false, + "title": "Interrupted" + }, + "original_message": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Original Message" } }, "required": [ @@ -22725,6 +23474,7 @@ "status": { "type": "string", "enum": [ + "initiated", "in-progress", "processing", "done", @@ -24929,6 +25679,12 @@ "webhooks": { "$ref": "#/components/schemas/ConvAIWebhooks" }, + "can_use_mcp_servers": { + "description": "Whether the workspace can use MCP servers", + "type": "boolean", + "default": false, + "title": "Can Use Mcp Servers" + }, "rag_retention_period_days": { "type": "integer", "default": 10, @@ -24953,6 +25709,7 @@ "status": { "type": "string", "enum": [ + "initiated", "in-progress", "processing", "done", @@ -26689,7 +27446,7 @@ "title": "Cloned By Count" }, "rate": { - "description": "The rate of the voice.", + "description": "The rate multiplier of the voice.", "anyOf": [ { "type": "number" @@ -26700,6 +27457,18 @@ ], "title": "Rate" }, + "fiat_rate": { + "description": "The rate of the voice in USD per 1000 credits. null if default", + "anyOf": [ + { + "type": "number" + }, + { + "type": "null" + } + ], + "title": "Fiat Rate" + }, "free_users_allowed": { "description": "Whether free users are allowed to use the voice.", "type": "boolean", @@ -27517,6 +28286,40 @@ }, "title": "OrbAvatar" }, + "OutboundCallRecipient": { + "type": "object", + "properties": { + "id": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Id" + }, + "phone_number": { + "type": "string", + "title": "Phone Number" + }, + "conversation_initiation_client_data": { + "anyOf": [ + { + "$ref": "#/components/schemas/ConversationInitiationClientDataRequest-Input" + }, + { + "type": "null" + } + ] + } + }, + "required": [ + "phone_number" + ], + "title": "OutboundCallRecipient" + }, "OutboundCallRecipientResponseModel": { "type": "object", "properties": { @@ -27619,6 +28422,12 @@ "webhooks": { "$ref": "#/components/schemas/ConvAIWebhooks" }, + "can_use_mcp_servers": { + "description": "Whether the workspace can use MCP servers", + "type": "boolean", + "default": false, + "title": "Can Use Mcp Servers" + }, "rag_retention_period_days": { "type": "integer", "default": 10, @@ -27629,6 +28438,30 @@ }, "title": "PatchConvAISettingsRequest" }, + "PatchWorkspaceSecretRequest": { + "type": "object", + "properties": { + "type": { + "type": "string", + "const": "update", + "title": "Type" + }, + "name": { + "type": "string", + "title": "Name" + }, + "value": { + "type": "string", + "title": "Value" + } + }, + "required": [ + "type", + "name", + "value" + ], + "title": "PatchWorkspaceSecretRequest" + }, "PdfExportOptions": { "type": "object", "properties": { @@ -30210,6 +31043,17 @@ "type": "string", "title": "Message" }, + "conversation_id": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Conversation Id" + }, "sip_call_id": { "anyOf": [ { @@ -30225,6 +31069,7 @@ "required": [ "success", "message", + "conversation_id", "sip_call_id" ], "title": "SIPTrunkOutboundCallResponse" @@ -32405,6 +33250,17 @@ "type": "string", "title": "Message" }, + "conversation_id": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Conversation Id" + }, "callSid": { "anyOf": [ { @@ -32420,6 +33276,7 @@ "required": [ "success", "message", + "conversation_id", "callSid" ], "title": "TwilioOutboundCallResponse" @@ -33956,6 +34813,18 @@ ], "title": "Rate" }, + "fiat_rate": { + "description": "The rate of the voice sharing in USD per 1000 credits.", + "anyOf": [ + { + "type": "number" + }, + { + "type": "null" + } + ], + "title": "Fiat Rate" + }, "notice_period": { "description": "The notice period of the voice sharing.", "type": "integer", @@ -34399,6 +35268,9 @@ }, { "$ref": "#/components/schemas/ConvAISecretLocator" + }, + { + "$ref": "#/components/schemas/ConvAIDynamicVariable" } ] }, @@ -34494,6 +35366,9 @@ }, { "$ref": "#/components/schemas/ConvAISecretLocator" + }, + { + "$ref": "#/components/schemas/ConvAIDynamicVariable" } ] }, @@ -34875,6 +35750,18 @@ "default": false, "title": "Disable Banner" }, + "override_link": { + "description": "The override link for the widget", + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Override Link" + }, "mic_muting_enabled": { "description": "Whether to enable mic muting", "type": "boolean", @@ -35144,6 +36031,18 @@ "default": false, "title": "Disable Banner" }, + "override_link": { + "description": "The override link for the widget", + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Override Link" + }, "mic_muting_enabled": { "description": "Whether to enable mic muting", "type": "boolean", @@ -35219,6 +36118,40 @@ ], "title": "WidgetFeedbackMode" }, + "WorkspaceBatchCallsResponse": { + "type": "object", + "properties": { + "batch_calls": { + "type": "array", + "items": { + "$ref": "#/components/schemas/BatchCallResponse" + }, + "title": "Batch Calls" + }, + "next_doc": { + "description": "The next document, used to paginate through the batch calls", + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Next Doc" + }, + "has_more": { + "description": "Whether there are more batch calls to paginate through", + "type": "boolean", + "default": false, + "title": "Has More" + } + }, + "required": [ + "batch_calls" + ], + "title": "WorkspaceBatchCallsResponse" + }, "WorkspaceGroupByNameResponseModel": { "type": "object", "properties": { diff --git a/poetry.lock b/poetry.lock index e31b1950..f9668e89 100644 --- a/poetry.lock +++ b/poetry.lock @@ -259,48 +259,55 @@ files = [ [[package]] name = "mypy" -version = "1.0.1" +version = "1.13.0" description = "Optional static typing for Python" optional = false -python-versions = ">=3.7" +python-versions = ">=3.8" files = [ - {file = "mypy-1.0.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:71a808334d3f41ef011faa5a5cd8153606df5fc0b56de5b2e89566c8093a0c9a"}, - {file = "mypy-1.0.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:920169f0184215eef19294fa86ea49ffd4635dedfdea2b57e45cb4ee85d5ccaf"}, - {file = "mypy-1.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:27a0f74a298769d9fdc8498fcb4f2beb86f0564bcdb1a37b58cbbe78e55cf8c0"}, - {file = "mypy-1.0.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:65b122a993d9c81ea0bfde7689b3365318a88bde952e4dfa1b3a8b4ac05d168b"}, - {file = "mypy-1.0.1-cp310-cp310-win_amd64.whl", hash = "sha256:5deb252fd42a77add936b463033a59b8e48eb2eaec2976d76b6878d031933fe4"}, - {file = "mypy-1.0.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:2013226d17f20468f34feddd6aae4635a55f79626549099354ce641bc7d40262"}, - {file = "mypy-1.0.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:48525aec92b47baed9b3380371ab8ab6e63a5aab317347dfe9e55e02aaad22e8"}, - {file = "mypy-1.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c96b8a0c019fe29040d520d9257d8c8f122a7343a8307bf8d6d4a43f5c5bfcc8"}, - {file = "mypy-1.0.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:448de661536d270ce04f2d7dddaa49b2fdba6e3bd8a83212164d4174ff43aa65"}, - {file = "mypy-1.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:d42a98e76070a365a1d1c220fcac8aa4ada12ae0db679cb4d910fabefc88b994"}, - {file = "mypy-1.0.1-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:e64f48c6176e243ad015e995de05af7f22bbe370dbb5b32bd6988438ec873919"}, - {file = "mypy-1.0.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5fdd63e4f50e3538617887e9aee91855368d9fc1dea30da743837b0df7373bc4"}, - {file = "mypy-1.0.1-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:dbeb24514c4acbc78d205f85dd0e800f34062efcc1f4a4857c57e4b4b8712bff"}, - {file = "mypy-1.0.1-cp37-cp37m-win_amd64.whl", hash = "sha256:a2948c40a7dd46c1c33765718936669dc1f628f134013b02ff5ac6c7ef6942bf"}, - {file = "mypy-1.0.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:5bc8d6bd3b274dd3846597855d96d38d947aedba18776aa998a8d46fabdaed76"}, - {file = "mypy-1.0.1-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:17455cda53eeee0a4adb6371a21dd3dbf465897de82843751cf822605d152c8c"}, - {file = "mypy-1.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e831662208055b006eef68392a768ff83596035ffd6d846786578ba1714ba8f6"}, - {file = "mypy-1.0.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:e60d0b09f62ae97a94605c3f73fd952395286cf3e3b9e7b97f60b01ddfbbda88"}, - {file = "mypy-1.0.1-cp38-cp38-win_amd64.whl", hash = "sha256:0af4f0e20706aadf4e6f8f8dc5ab739089146b83fd53cb4a7e0e850ef3de0bb6"}, - {file = "mypy-1.0.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:24189f23dc66f83b839bd1cce2dfc356020dfc9a8bae03978477b15be61b062e"}, - {file = "mypy-1.0.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:93a85495fb13dc484251b4c1fd7a5ac370cd0d812bbfc3b39c1bafefe95275d5"}, - {file = "mypy-1.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5f546ac34093c6ce33f6278f7c88f0f147a4849386d3bf3ae193702f4fe31407"}, - {file = "mypy-1.0.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:c6c2ccb7af7154673c591189c3687b013122c5a891bb5651eca3db8e6c6c55bd"}, - {file = "mypy-1.0.1-cp39-cp39-win_amd64.whl", hash = "sha256:15b5a824b58c7c822c51bc66308e759243c32631896743f030daf449fe3677f3"}, - {file = "mypy-1.0.1-py3-none-any.whl", hash = "sha256:eda5c8b9949ed411ff752b9a01adda31afe7eae1e53e946dbdf9db23865e66c4"}, - {file = "mypy-1.0.1.tar.gz", hash = "sha256:28cea5a6392bb43d266782983b5a4216c25544cd7d80be681a155ddcdafd152d"}, + {file = "mypy-1.13.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:6607e0f1dd1fb7f0aca14d936d13fd19eba5e17e1cd2a14f808fa5f8f6d8f60a"}, + {file = "mypy-1.13.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:8a21be69bd26fa81b1f80a61ee7ab05b076c674d9b18fb56239d72e21d9f4c80"}, + {file = "mypy-1.13.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:7b2353a44d2179846a096e25691d54d59904559f4232519d420d64da6828a3a7"}, + {file = "mypy-1.13.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:0730d1c6a2739d4511dc4253f8274cdd140c55c32dfb0a4cf8b7a43f40abfa6f"}, + {file = "mypy-1.13.0-cp310-cp310-win_amd64.whl", hash = "sha256:c5fc54dbb712ff5e5a0fca797e6e0aa25726c7e72c6a5850cfd2adbc1eb0a372"}, + {file = "mypy-1.13.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:581665e6f3a8a9078f28d5502f4c334c0c8d802ef55ea0e7276a6e409bc0d82d"}, + {file = "mypy-1.13.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:3ddb5b9bf82e05cc9a627e84707b528e5c7caaa1c55c69e175abb15a761cec2d"}, + {file = "mypy-1.13.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:20c7ee0bc0d5a9595c46f38beb04201f2620065a93755704e141fcac9f59db2b"}, + {file = "mypy-1.13.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:3790ded76f0b34bc9c8ba4def8f919dd6a46db0f5a6610fb994fe8efdd447f73"}, + {file = "mypy-1.13.0-cp311-cp311-win_amd64.whl", hash = "sha256:51f869f4b6b538229c1d1bcc1dd7d119817206e2bc54e8e374b3dfa202defcca"}, + {file = "mypy-1.13.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:5c7051a3461ae84dfb5dd15eff5094640c61c5f22257c8b766794e6dd85e72d5"}, + {file = "mypy-1.13.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:39bb21c69a5d6342f4ce526e4584bc5c197fd20a60d14a8624d8743fffb9472e"}, + {file = "mypy-1.13.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:164f28cb9d6367439031f4c81e84d3ccaa1e19232d9d05d37cb0bd880d3f93c2"}, + {file = "mypy-1.13.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:a4c1bfcdbce96ff5d96fc9b08e3831acb30dc44ab02671eca5953eadad07d6d0"}, + {file = "mypy-1.13.0-cp312-cp312-win_amd64.whl", hash = "sha256:a0affb3a79a256b4183ba09811e3577c5163ed06685e4d4b46429a271ba174d2"}, + {file = "mypy-1.13.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:a7b44178c9760ce1a43f544e595d35ed61ac2c3de306599fa59b38a6048e1aa7"}, + {file = "mypy-1.13.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:5d5092efb8516d08440e36626f0153b5006d4088c1d663d88bf79625af3d1d62"}, + {file = "mypy-1.13.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:de2904956dac40ced10931ac967ae63c5089bd498542194b436eb097a9f77bc8"}, + {file = "mypy-1.13.0-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:7bfd8836970d33c2105562650656b6846149374dc8ed77d98424b40b09340ba7"}, + {file = "mypy-1.13.0-cp313-cp313-win_amd64.whl", hash = "sha256:9f73dba9ec77acb86457a8fc04b5239822df0c14a082564737833d2963677dbc"}, + {file = "mypy-1.13.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:100fac22ce82925f676a734af0db922ecfea991e1d7ec0ceb1e115ebe501301a"}, + {file = "mypy-1.13.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:7bcb0bb7f42a978bb323a7c88f1081d1b5dee77ca86f4100735a6f541299d8fb"}, + {file = "mypy-1.13.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:bde31fc887c213e223bbfc34328070996061b0833b0a4cfec53745ed61f3519b"}, + {file = "mypy-1.13.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:07de989f89786f62b937851295ed62e51774722e5444a27cecca993fc3f9cd74"}, + {file = "mypy-1.13.0-cp38-cp38-win_amd64.whl", hash = "sha256:4bde84334fbe19bad704b3f5b78c4abd35ff1026f8ba72b29de70dda0916beb6"}, + {file = "mypy-1.13.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:0246bcb1b5de7f08f2826451abd947bf656945209b140d16ed317f65a17dc7dc"}, + {file = "mypy-1.13.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:7f5b7deae912cf8b77e990b9280f170381fdfbddf61b4ef80927edd813163732"}, + {file = "mypy-1.13.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:7029881ec6ffb8bc233a4fa364736789582c738217b133f1b55967115288a2bc"}, + {file = "mypy-1.13.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:3e38b980e5681f28f033f3be86b099a247b13c491f14bb8b1e1e134d23bb599d"}, + {file = "mypy-1.13.0-cp39-cp39-win_amd64.whl", hash = "sha256:a6789be98a2017c912ae6ccb77ea553bbaf13d27605d2ca20a76dfbced631b24"}, + {file = "mypy-1.13.0-py3-none-any.whl", hash = "sha256:9c250883f9fd81d212e0952c92dbfcc96fc237f4b7c92f56ac81fd48460b3e5a"}, + {file = "mypy-1.13.0.tar.gz", hash = "sha256:0291a61b6fbf3e6673e3405cfcc0e7650bebc7939659fdca2702958038bd835e"}, ] [package.dependencies] -mypy-extensions = ">=0.4.3" +mypy-extensions = ">=1.0.0" tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""} -typing-extensions = ">=3.10" +typing-extensions = ">=4.6.0" [package.extras] dmypy = ["psutil (>=4.0)"] +faster-cache = ["orjson"] install-types = ["pip"] -python2 = ["typed-ast (>=1.4.0,<2)"] +mypyc = ["setuptools (>=50)"] reports = ["lxml"] [[package]] @@ -574,29 +581,29 @@ use-chardet-on-py3 = ["chardet (>=3.0.2,<6)"] [[package]] name = "ruff" -version = "0.5.7" +version = "0.11.5" description = "An extremely fast Python linter and code formatter, written in Rust." optional = false python-versions = ">=3.7" files = [ - {file = "ruff-0.5.7-py3-none-linux_armv6l.whl", hash = "sha256:548992d342fc404ee2e15a242cdbea4f8e39a52f2e7752d0e4cbe88d2d2f416a"}, - {file = "ruff-0.5.7-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:00cc8872331055ee017c4f1071a8a31ca0809ccc0657da1d154a1d2abac5c0be"}, - {file = "ruff-0.5.7-py3-none-macosx_11_0_arm64.whl", hash = "sha256:eaf3d86a1fdac1aec8a3417a63587d93f906c678bb9ed0b796da7b59c1114a1e"}, - {file = "ruff-0.5.7-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a01c34400097b06cf8a6e61b35d6d456d5bd1ae6961542de18ec81eaf33b4cb8"}, - {file = "ruff-0.5.7-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:fcc8054f1a717e2213500edaddcf1dbb0abad40d98e1bd9d0ad364f75c763eea"}, - {file = "ruff-0.5.7-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:7f70284e73f36558ef51602254451e50dd6cc479f8b6f8413a95fcb5db4a55fc"}, - {file = "ruff-0.5.7-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:a78ad870ae3c460394fc95437d43deb5c04b5c29297815a2a1de028903f19692"}, - {file = "ruff-0.5.7-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:9ccd078c66a8e419475174bfe60a69adb36ce04f8d4e91b006f1329d5cd44bcf"}, - {file = "ruff-0.5.7-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:7e31c9bad4ebf8fdb77b59cae75814440731060a09a0e0077d559a556453acbb"}, - {file = "ruff-0.5.7-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8d796327eed8e168164346b769dd9a27a70e0298d667b4ecee6877ce8095ec8e"}, - {file = "ruff-0.5.7-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:4a09ea2c3f7778cc635e7f6edf57d566a8ee8f485f3c4454db7771efb692c499"}, - {file = "ruff-0.5.7-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:a36d8dcf55b3a3bc353270d544fb170d75d2dff41eba5df57b4e0b67a95bb64e"}, - {file = "ruff-0.5.7-py3-none-musllinux_1_2_i686.whl", hash = "sha256:9369c218f789eefbd1b8d82a8cf25017b523ac47d96b2f531eba73770971c9e5"}, - {file = "ruff-0.5.7-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:b88ca3db7eb377eb24fb7c82840546fb7acef75af4a74bd36e9ceb37a890257e"}, - {file = "ruff-0.5.7-py3-none-win32.whl", hash = "sha256:33d61fc0e902198a3e55719f4be6b375b28f860b09c281e4bdbf783c0566576a"}, - {file = "ruff-0.5.7-py3-none-win_amd64.whl", hash = "sha256:083bbcbe6fadb93cd86709037acc510f86eed5a314203079df174c40bbbca6b3"}, - {file = "ruff-0.5.7-py3-none-win_arm64.whl", hash = "sha256:2dca26154ff9571995107221d0aeaad0e75a77b5a682d6236cf89a58c70b76f4"}, - {file = "ruff-0.5.7.tar.gz", hash = "sha256:8dfc0a458797f5d9fb622dd0efc52d796f23f0a1493a9527f4e49a550ae9a7e5"}, + {file = "ruff-0.11.5-py3-none-linux_armv6l.whl", hash = "sha256:2561294e108eb648e50f210671cc56aee590fb6167b594144401532138c66c7b"}, + {file = "ruff-0.11.5-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:ac12884b9e005c12d0bd121f56ccf8033e1614f736f766c118ad60780882a077"}, + {file = "ruff-0.11.5-py3-none-macosx_11_0_arm64.whl", hash = "sha256:4bfd80a6ec559a5eeb96c33f832418bf0fb96752de0539905cf7b0cc1d31d779"}, + {file = "ruff-0.11.5-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0947c0a1afa75dcb5db4b34b070ec2bccee869d40e6cc8ab25aca11a7d527794"}, + {file = "ruff-0.11.5-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:ad871ff74b5ec9caa66cb725b85d4ef89b53f8170f47c3406e32ef040400b038"}, + {file = "ruff-0.11.5-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:e6cf918390cfe46d240732d4d72fa6e18e528ca1f60e318a10835cf2fa3dc19f"}, + {file = "ruff-0.11.5-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:56145ee1478582f61c08f21076dc59153310d606ad663acc00ea3ab5b2125f82"}, + {file = "ruff-0.11.5-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:e5f66f8f1e8c9fc594cbd66fbc5f246a8d91f916cb9667e80208663ec3728304"}, + {file = "ruff-0.11.5-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:80b4df4d335a80315ab9afc81ed1cff62be112bd165e162b5eed8ac55bfc8470"}, + {file = "ruff-0.11.5-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3068befab73620b8a0cc2431bd46b3cd619bc17d6f7695a3e1bb166b652c382a"}, + {file = "ruff-0.11.5-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:f5da2e710a9641828e09aa98b92c9ebbc60518fdf3921241326ca3e8f8e55b8b"}, + {file = "ruff-0.11.5-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:ef39f19cb8ec98cbc762344921e216f3857a06c47412030374fffd413fb8fd3a"}, + {file = "ruff-0.11.5-py3-none-musllinux_1_2_i686.whl", hash = "sha256:b2a7cedf47244f431fd11aa5a7e2806dda2e0c365873bda7834e8f7d785ae159"}, + {file = "ruff-0.11.5-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:81be52e7519f3d1a0beadcf8e974715b2dfc808ae8ec729ecfc79bddf8dbb783"}, + {file = "ruff-0.11.5-py3-none-win32.whl", hash = "sha256:e268da7b40f56e3eca571508a7e567e794f9bfcc0f412c4b607931d3af9c4afe"}, + {file = "ruff-0.11.5-py3-none-win_amd64.whl", hash = "sha256:6c6dc38af3cfe2863213ea25b6dc616d679205732dc0fb673356c2d69608f800"}, + {file = "ruff-0.11.5-py3-none-win_arm64.whl", hash = "sha256:67e241b4314f4eacf14a601d586026a962f4002a475aa702c69980a38087aa4e"}, + {file = "ruff-0.11.5.tar.gz", hash = "sha256:cae2e2439cb88853e421901ec040a758960b576126dab520fa08e9de431d1bef"}, ] [[package]] @@ -813,4 +820,4 @@ pyaudio = ["pyaudio"] [metadata] lock-version = "2.0" python-versions = "^3.8" -content-hash = "af57dd0aacaa752d61d29db9f958f2d8d0950d51ab868c925a2a973689de5ff7" +content-hash = "b820898bc8f521807e3f8b6d5dc0323fc0b5ff4110a82646f60865bd9738d84a" diff --git a/pyproject.toml b/pyproject.toml index 690d2ea3..b3bfab7e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ name = "elevenlabs" [tool.poetry] name = "elevenlabs" -version = "v1.59.0" +version = "v2.0.0" description = "" readme = "README.md" authors = [] @@ -44,13 +44,13 @@ requests = ">=2.20" typing_extensions = ">= 4.0.0" websockets = ">=11.0" -[tool.poetry.dev-dependencies] -mypy = "1.0.1" +[tool.poetry.group.dev.dependencies] +mypy = "==1.13.0" pytest = "^7.4.0" pytest-asyncio = "^0.23.5" python-dateutil = "^2.9.0" types-python-dateutil = "^2.9.0.20240316" -ruff = "^0.5.6" +ruff = "==0.11.5" types-pyaudio = "^0.2.16.20240516" [tool.pytest.ini_options] @@ -63,6 +63,26 @@ plugins = ["pydantic.mypy"] [tool.ruff] line-length = 120 +[tool.ruff.lint] +select = [ + "E", # pycodestyle errors + "F", # pyflakes + "I", # isort +] +ignore = [ + "E402", # Module level import not at top of file + "E501", # Line too long + "E711", # Comparison to `None` should be `cond is not None` + "E712", # Avoid equality comparisons to `True`; use `if ...:` checks + "E721", # Use `is` and `is not` for type comparisons, or `isinstance()` for insinstance checks + "E722", # Do not use bare `except` + "E731", # Do not assign a `lambda` expression, use a `def` + "F821", # Undefined name + "F841" # Local variable ... is assigned to but never used +] + +[tool.ruff.lint.isort] +section-order = ["future", "standard-library", "third-party", "first-party"] [build-system] requires = ["poetry-core"] diff --git a/reference.md b/reference.md index 719d439d..ebbea200 100644 --- a/reference.md +++ b/reference.md @@ -1,6 +1,6 @@ # Reference ## History -
client.history.get_all(...) +
client.history.list(...)
@@ -32,7 +32,7 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.history.get_all() +client.history.list() ```
@@ -80,7 +80,7 @@ client.history.get_all()
-**source:** `typing.Optional[HistoryGetAllRequestSource]` — Source of the generated history item +**source:** `typing.Optional[HistoryListRequestSource]` — Source of the generated history item
@@ -837,7 +837,7 @@ Defaults to None.
-
client.text_to_speech.convert_as_stream(...) +
client.text_to_speech.stream(...)
@@ -869,7 +869,7 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.text_to_speech.convert_as_stream( +client.text_to_speech.stream( voice_id="JBFqnCBsd6RMkjVDRZzb", output_format="mp3_44100_128", text="The first move is what sets everything in motion.", @@ -931,7 +931,7 @@ Defaults to None.
-**output_format:** `typing.Optional[TextToSpeechConvertAsStreamRequestOutputFormat]` — Output format of the generated audio. Formatted as codec_sample_rate_bitrate. So an mp3 with 22.05kHz sample rate at 32kbs is represented as mp3_22050_32. MP3 with 192kbps bitrate requires you to be subscribed to Creator tier or above. PCM with 44.1kHz sample rate requires you to be subscribed to Pro tier or above. Note that the μ-law format (sometimes written mu-law, often approximated as u-law) is commonly used for Twilio audio inputs. +**output_format:** `typing.Optional[TextToSpeechStreamRequestOutputFormat]` — Output format of the generated audio. Formatted as codec_sample_rate_bitrate. So an mp3 with 22.05kHz sample rate at 32kbs is represented as mp3_22050_32. MP3 with 192kbps bitrate requires you to be subscribed to Creator tier or above. PCM with 44.1kHz sample rate requires you to be subscribed to Pro tier or above. Note that the μ-law format (sometimes written mu-law, often approximated as u-law) is commonly used for Twilio audio inputs.
@@ -1087,7 +1087,7 @@ response = client.text_to_speech.stream_with_timestamps( text="The first move is what sets everything in motion.", model_id="eleven_multilingual_v2", ) -for chunk in response: +for chunk in response.data: yield chunk ``` @@ -1419,7 +1419,7 @@ Defaults to None.
-
client.speech_to_speech.convert_as_stream(...) +
client.speech_to_speech.stream(...)
@@ -1451,7 +1451,7 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.speech_to_speech.convert_as_stream( +client.speech_to_speech.stream( voice_id="JBFqnCBsd6RMkjVDRZzb", output_format="mp3_44100_128", model_id="eleven_multilingual_sts_v2", @@ -1514,7 +1514,7 @@ Defaults to None.
-**output_format:** `typing.Optional[SpeechToSpeechConvertAsStreamRequestOutputFormat]` — Output format of the generated audio. Formatted as codec_sample_rate_bitrate. So an mp3 with 22.05kHz sample rate at 32kbs is represented as mp3_22050_32. MP3 with 192kbps bitrate requires you to be subscribed to Creator tier or above. PCM with 44.1kHz sample rate requires you to be subscribed to Pro tier or above. Note that the μ-law format (sometimes written mu-law, often approximated as u-law) is commonly used for Twilio audio inputs. +**output_format:** `typing.Optional[SpeechToSpeechStreamRequestOutputFormat]` — Output format of the generated audio. Formatted as codec_sample_rate_bitrate. So an mp3 with 22.05kHz sample rate at 32kbs is represented as mp3_22050_32. MP3 with 192kbps bitrate requires you to be subscribed to Creator tier or above. PCM with 44.1kHz sample rate requires you to be subscribed to Pro tier or above. Note that the μ-law format (sometimes written mu-law, often approximated as u-law) is commonly used for Twilio audio inputs.
@@ -1554,7 +1554,7 @@ Defaults to None.
-**file_format:** `typing.Optional[SpeechToSpeechConvertAsStreamRequestFileFormat]` — The format of input audio. Options are 'pcm_s16le_16' or 'other' For `pcm_s16le_16`, the input audio must be 16-bit PCM at a 16kHz sample rate, single channel (mono), and little-endian byte order. Latency will be lower than with passing an encoded waveform. +**file_format:** `typing.Optional[SpeechToSpeechStreamRequestFileFormat]` — The format of input audio. Options are 'pcm_s16le_16' or 'other' For `pcm_s16le_16`, the input audio must be 16-bit PCM at a 16kHz sample rate, single channel (mono), and little-endian byte order. Latency will be lower than with passing an encoded waveform.
@@ -1806,66 +1806,6 @@ client.text_to_voice.create_voice_from_preview(
## User -
client.user.get_subscription() -
-
- -#### 📝 Description - -
-
- -
-
- -Gets extended information about the users subscription -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```python -from elevenlabs import ElevenLabs - -client = ElevenLabs( - api_key="YOUR_API_KEY", -) -client.user.get_subscription() - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. - -
-
-
-
- - -
-
-
-
client.user.get()
@@ -2137,7 +2077,7 @@ client.voices.search(
-
client.voices.get_default_settings() +
client.voices.get(...)
@@ -2149,7 +2089,7 @@ client.voices.search(
-Gets the default settings for voices. "similarity_boost" corresponds to"Clarity + Similarity Enhancement" in the web app and "stability" corresponds to "Stability" slider in the web app. +Returns metadata about a specific voice.
@@ -2169,7 +2109,9 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.voices.get_default_settings() +client.voices.get( + voice_id="21m00Tcm4TlvDq8ikWAM", +) ``` @@ -2185,6 +2127,22 @@ client.voices.get_default_settings()
+**voice_id:** `str` — ID of the voice to be used. You can use the [Get voices](/docs/api-reference/voices/search) endpoint list all the available voices. + +
+
+ +
+
+ +**with_settings:** `typing.Optional[bool]` — This parameter is now deprecated. It is ignored and will be removed in a future version. + +
+
+ +
+
+ **request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration.
@@ -2197,7 +2155,7 @@ client.voices.get_default_settings()
-
client.voices.get_settings(...) +
client.voices.delete(...)
@@ -2209,7 +2167,7 @@ client.voices.get_default_settings()
-Returns the settings for a specific voice. "similarity_boost" corresponds to"Clarity + Similarity Enhancement" in the web app and "stability" corresponds to "Stability" slider in the web app. +Deletes a voice by its ID.
@@ -2229,7 +2187,7 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.voices.get_settings( +client.voices.delete( voice_id="21m00Tcm4TlvDq8ikWAM", ) @@ -2247,7 +2205,7 @@ client.voices.get_settings(
-**voice_id:** `str` — Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices. +**voice_id:** `str` — ID of the voice to be used. You can use the [Get voices](/docs/api-reference/voices/search) endpoint list all the available voices.
@@ -2267,7 +2225,7 @@ client.voices.get_settings(
-
client.voices.get(...) +
client.voices.update(...)
@@ -2279,7 +2237,7 @@ client.voices.get_settings(
-Returns metadata about a specific voice. +Edit a voice created by you.
@@ -2299,8 +2257,9 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.voices.get( +client.voices.update( voice_id="21m00Tcm4TlvDq8ikWAM", + name="name", ) ``` @@ -2325,7 +2284,7 @@ client.voices.get(
-**with_settings:** `typing.Optional[bool]` — This parameter is now deprecated. It is ignored and will be removed in a future version. +**name:** `str` — The name that identifies this voice. This will be displayed in the dropdown of the website.
@@ -2333,69 +2292,33 @@ client.voices.get(
-**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. - -
-
- -
- +**files:** `from __future__ import annotations +typing.Optional[typing.List[core.File]]` — See core.File for more documentation + -
- -
client.voices.delete(...) -
-
- -#### 📝 Description - -
-
-Deletes a voice by its ID. -
-
+**remove_background_noise:** `typing.Optional[bool]` — If set will remove background noise for voice samples using our audio isolation model. If the samples do not include background noise, it can make the quality worse. +
-#### 🔌 Usage -
-
-
- -```python -from elevenlabs import ElevenLabs - -client = ElevenLabs( - api_key="YOUR_API_KEY", -) -client.voices.delete( - voice_id="21m00Tcm4TlvDq8ikWAM", -) - -``` -
-
+**description:** `typing.Optional[str]` — A description of the voice. +
-#### ⚙️ Parameters -
-
-
- -**voice_id:** `str` — ID of the voice to be used. You can use the [Get voices](/docs/api-reference/voices/search) endpoint list all the available voices. +**labels:** `typing.Optional[str]` — Serialized labels dictionary for the voice.
@@ -2415,7 +2338,7 @@ client.voices.delete(
-
client.voices.edit_settings(...) +
client.voices.share(...)
@@ -2427,7 +2350,7 @@ client.voices.delete(
-Edit your settings for a specific voice. "similarity_boost" corresponds to "Clarity + Similarity Enhancement" in the web app and "stability" corresponds to "Stability" slider in the web app. +Add a shared voice to your collection of Voices
@@ -2442,20 +2365,15 @@ Edit your settings for a specific voice. "similarity_boost" corresponds to "Clar
```python -from elevenlabs import ElevenLabs, VoiceSettings +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.voices.edit_settings( +client.voices.share( + public_user_id="63e06b7e7cafdc46be4d2e0b3f045940231ae058d508589653d74d1265a574ca", voice_id="21m00Tcm4TlvDq8ikWAM", - request=VoiceSettings( - stability=1.0, - similarity_boost=1.0, - style=0.0, - use_speaker_boost=True, - speed=1.0, - ), + new_name="John Smith", ) ``` @@ -2472,6 +2390,14 @@ client.voices.edit_settings(
+**public_user_id:** `str` — Public user ID used to publicly identify ElevenLabs users. + +
+
+ +
+
+ **voice_id:** `str` — ID of the voice to be used. You can use the [Get voices](/docs/api-reference/voices/search) endpoint list all the available voices.
@@ -2480,7 +2406,7 @@ client.voices.edit_settings(
-**request:** `VoiceSettings` +**new_name:** `str` — The name that identifies this voice. This will be displayed in the dropdown of the website.
@@ -2500,7 +2426,7 @@ client.voices.edit_settings(
-
client.voices.add(...) +
client.voices.get_shared(...)
@@ -2512,7 +2438,7 @@ client.voices.edit_settings(
-Create a voice clone and add it to your Voices +Retrieves a list of shared voices.
@@ -2532,8 +2458,9 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.voices.add( - name="name", +client.voices.get_shared( + featured=True, + reader_app_enabled=True, ) ``` @@ -2550,7 +2477,7 @@ client.voices.add(
-**name:** `str` — The name that identifies this voice. This will be displayed in the dropdown of the website. +**page_size:** `typing.Optional[int]` — How many shared voices to return at maximum. Can not exceed 100, defaults to 30.
@@ -2558,9 +2485,7 @@ client.voices.add(
-**files:** `from __future__ import annotations - -typing.List[core.File]` — See core.File for more documentation +**category:** `typing.Optional[VoicesGetSharedRequestCategory]` — Voice category used for filtering
@@ -2568,7 +2493,7 @@ typing.List[core.File]` — See core.File for more documentation
-**remove_background_noise:** `typing.Optional[bool]` — If set will remove background noise for voice samples using our audio isolation model. If the samples do not include background noise, it can make the quality worse. +**gender:** `typing.Optional[str]` — Gender used for filtering
@@ -2576,7 +2501,7 @@ typing.List[core.File]` — See core.File for more documentation
-**description:** `typing.Optional[str]` — A description of the voice. +**age:** `typing.Optional[str]` — Age used for filtering
@@ -2584,7 +2509,7 @@ typing.List[core.File]` — See core.File for more documentation
-**labels:** `typing.Optional[str]` — Serialized labels dictionary for the voice. +**accent:** `typing.Optional[str]` — Accent used for filtering
@@ -2592,70 +2517,55 @@ typing.List[core.File]` — See core.File for more documentation
-**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. +**language:** `typing.Optional[str]` — Language used for filtering
- -
+
+
+**locale:** `typing.Optional[str]` — Locale used for filtering +
-
-
client.voices.edit(...)
-#### 📝 Description - -
-
+**search:** `typing.Optional[str]` — Search term used for filtering + +
+
-Edit a voice created by you. -
-
+**use_cases:** `typing.Optional[typing.Union[str, typing.Sequence[str]]]` — Use-case used for filtering +
-#### 🔌 Usage - -
-
-
-```python -from elevenlabs import ElevenLabs - -client = ElevenLabs( - api_key="YOUR_API_KEY", -) -client.voices.edit( - voice_id="21m00Tcm4TlvDq8ikWAM", - name="name", -) - -``` -
-
+**descriptives:** `typing.Optional[typing.Union[str, typing.Sequence[str]]]` — Search term used for filtering +
-#### ⚙️ Parameters -
+**featured:** `typing.Optional[bool]` — Filter featured voices + +
+
+
-**voice_id:** `str` — ID of the voice to be used. You can use the [Get voices](/docs/api-reference/voices/search) endpoint list all the available voices. +**min_notice_period_days:** `typing.Optional[int]` — Filter voices with a minimum notice period of the given number of days.
@@ -2663,7 +2573,7 @@ client.voices.edit(
-**name:** `str` — The name that identifies this voice. This will be displayed in the dropdown of the website. +**include_custom_rates:** `typing.Optional[bool]` — Include/exclude voices with custom rates
@@ -2671,9 +2581,7 @@ client.voices.edit(
-**files:** `from __future__ import annotations - -typing.Optional[typing.List[core.File]]` — See core.File for more documentation +**reader_app_enabled:** `typing.Optional[bool]` — Filter voices that are enabled for the reader app
@@ -2681,7 +2589,7 @@ typing.Optional[typing.List[core.File]]` — See core.File for more documentatio
-**remove_background_noise:** `typing.Optional[bool]` — If set will remove background noise for voice samples using our audio isolation model. If the samples do not include background noise, it can make the quality worse. +**owner_id:** `typing.Optional[str]` — Filter voices by public owner ID
@@ -2689,7 +2597,7 @@ typing.Optional[typing.List[core.File]]` — See core.File for more documentatio
-**description:** `typing.Optional[str]` — A description of the voice. +**sort:** `typing.Optional[str]` — Sort criteria
@@ -2697,7 +2605,7 @@ typing.Optional[typing.List[core.File]]` — See core.File for more documentatio
-**labels:** `typing.Optional[str]` — Serialized labels dictionary for the voice. +**page:** `typing.Optional[int]`
@@ -2717,7 +2625,7 @@ typing.Optional[typing.List[core.File]]` — See core.File for more documentatio
-
client.voices.add_sharing_voice(...) +
client.voices.find_similar_voices(...)
@@ -2729,7 +2637,7 @@ typing.Optional[typing.List[core.File]]` — See core.File for more documentatio
-Add a shared voice to your collection of Voices +Returns a list of shared voices similar to the provided audio sample. If neither similarity_threshold nor top_k is provided, we will apply default values.
@@ -2749,11 +2657,7 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.voices.add_sharing_voice( - public_user_id="63e06b7e7cafdc46be4d2e0b3f045940231ae058d508589653d74d1265a574ca", - voice_id="21m00Tcm4TlvDq8ikWAM", - new_name="John Smith", -) +client.voices.find_similar_voices() ``` @@ -2769,7 +2673,704 @@ client.voices.add_sharing_voice(
-**public_user_id:** `str` — Public user ID used to publicly identify ElevenLabs users. +**audio_file:** `from __future__ import annotations + +typing.Optional[core.File]` — See core.File for more documentation + +
+
+ +
+
+ +**similarity_threshold:** `typing.Optional[float]` — Threshold for voice similarity between provided sample and library voices. Values range from 0 to 2. The smaller the value the more similar voices will be returned. + +
+
+ +
+
+ +**top_k:** `typing.Optional[int]` — Number of most similar voices to return. If similarity_threshold is provided, less than this number of voices may be returned. Values range from 1 to 100. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+ +
+ + + + +
+ +## Studio +
client.studio.create_podcast(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Create and auto-convert a podcast project. Currently, the LLM cost is covered by us but you will still be charged for the audio generation. In the future, you will be charged for both the LLM and audio generation costs. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from elevenlabs import ( + ElevenLabs, + PodcastConversationModeData, + PodcastTextSource, +) +from elevenlabs.studio import ( + BodyCreatePodcastV1StudioPodcastsPostMode_Conversation, +) + +client = ElevenLabs( + api_key="YOUR_API_KEY", +) +client.studio.create_podcast( + model_id="21m00Tcm4TlvDq8ikWAM", + mode=BodyCreatePodcastV1StudioPodcastsPostMode_Conversation( + conversation=PodcastConversationModeData( + host_voice_id="aw1NgEzBg83R7vgmiJt6", + guest_voice_id="aw1NgEzBg83R7vgmiJt7", + ), + ), + source=PodcastTextSource( + text="This is a test podcast.", + ), +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**model_id:** `str` — The ID of the model to be used for this Studio project, you can query GET /v1/models to list all available models. + +
+
+ +
+
+ +**mode:** `BodyCreatePodcastV1StudioPodcastsPostMode` — The type of podcast to generate. Can be 'conversation', an interaction between two voices, or 'bulletin', a monologue. + +
+
+ +
+
+ +**source:** `BodyCreatePodcastV1StudioPodcastsPostSource` — The source content for the Podcast. + +
+
+ +
+
+ +**quality_preset:** `typing.Optional[BodyCreatePodcastV1StudioPodcastsPostQualityPreset]` + +Output quality of the generated audio. Must be one of: +standard - standard output format, 128kbps with 44.1kHz sample rate. +high - high quality output format, 192kbps with 44.1kHz sample rate and major improvements on our side. Using this setting increases the credit cost by 20%. +ultra - ultra quality output format, 192kbps with 44.1kHz sample rate and highest improvements on our side. Using this setting increases the credit cost by 50%. +ultra lossless - ultra quality output format, 705.6kbps with 44.1kHz sample rate and highest improvements on our side in a fully lossless format. Using this setting increases the credit cost by 100%. + +
+
+ +
+
+ +**duration_scale:** `typing.Optional[BodyCreatePodcastV1StudioPodcastsPostDurationScale]` + +Duration of the generated podcast. Must be one of: +short - produces podcasts shorter than 3 minutes. +default - produces podcasts roughly between 3-7 minutes. +long - prodces podcasts longer than 7 minutes. + +
+
+ +
+
+ +**language:** `typing.Optional[str]` — An optional language of the Studio project. Two-letter language code (ISO 639-1). + +
+
+ +
+
+ +**highlights:** `typing.Optional[typing.Sequence[str]]` — A brief summary or highlights of the Studio project's content, providing key points or themes. This should be between 10 and 70 characters. + +
+
+ +
+
+ +**callback_url:** `typing.Optional[str]` — A url that will be called by our service when the Studio project is converted. Request will contain a json blob containing the status of the conversion + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Dubbing +
client.dubbing.create(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Dubs a provided audio or video file into given language. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from elevenlabs import ElevenLabs + +client = ElevenLabs( + api_key="YOUR_API_KEY", +) +client.dubbing.create() + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**file:** `from __future__ import annotations + +typing.Optional[core.File]` — See core.File for more documentation + +
+
+ +
+
+ +**csv_file:** `from __future__ import annotations + +typing.Optional[core.File]` — See core.File for more documentation + +
+
+ +
+
+ +**foreground_audio_file:** `from __future__ import annotations + +typing.Optional[core.File]` — See core.File for more documentation + +
+
+ +
+
+ +**background_audio_file:** `from __future__ import annotations + +typing.Optional[core.File]` — See core.File for more documentation + +
+
+ +
+
+ +**name:** `typing.Optional[str]` — Name of the dubbing project. + +
+
+ +
+
+ +**source_url:** `typing.Optional[str]` — URL of the source video/audio file. + +
+
+ +
+
+ +**source_lang:** `typing.Optional[str]` — Source language. + +
+
+ +
+
+ +**target_lang:** `typing.Optional[str]` — The Target language to dub the content into. + +
+
+ +
+
+ +**num_speakers:** `typing.Optional[int]` — Number of speakers to use for the dubbing. Set to 0 to automatically detect the number of speakers + +
+
+ +
+
+ +**watermark:** `typing.Optional[bool]` — Whether to apply watermark to the output video. + +
+
+ +
+
+ +**start_time:** `typing.Optional[int]` — Start time of the source video/audio file. + +
+
+ +
+
+ +**end_time:** `typing.Optional[int]` — End time of the source video/audio file. + +
+
+ +
+
+ +**highest_resolution:** `typing.Optional[bool]` — Whether to use the highest resolution available. + +
+
+ +
+
+ +**drop_background_audio:** `typing.Optional[bool]` — An advanced setting. Whether to drop background audio from the final dub. This can improve dub quality where it's known that audio shouldn't have a background track such as for speeches or monologues. + +
+
+ +
+
+ +**use_profanity_filter:** `typing.Optional[bool]` — [BETA] Whether transcripts should have profanities censored with the words '[censored]' + +
+
+ +
+
+ +**dubbing_studio:** `typing.Optional[bool]` — Whether to prepare dub for edits in dubbing studio or edits as a dubbing resource. + +
+
+ +
+
+ +**disable_voice_cloning:** `typing.Optional[bool]` — [BETA] Instead of using a voice clone in dubbing, use a similar voice from the ElevenLabs Voice Library. + +
+
+ +
+
+ +**mode:** `typing.Optional[str]` — automatic or manual. Manual mode is only supported when creating a dubbing studio project + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.dubbing.get(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Returns metadata about a dubbing project, including whether it's still in progress or not +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from elevenlabs import ElevenLabs + +client = ElevenLabs( + api_key="YOUR_API_KEY", +) +client.dubbing.get( + dubbing_id="dubbing_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**dubbing_id:** `str` — ID of the dubbing project. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.dubbing.delete(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Deletes a dubbing project. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from elevenlabs import ElevenLabs + +client = ElevenLabs( + api_key="YOUR_API_KEY", +) +client.dubbing.delete( + dubbing_id="dubbing_id", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**dubbing_id:** `str` — ID of the dubbing project. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Models +
client.models.list() +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Gets a list of available models. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from elevenlabs import ElevenLabs + +client = ElevenLabs( + api_key="YOUR_API_KEY", +) +client.models.list() + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## AudioNative +
client.audio_native.create(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Creates Audio Native enabled project, optionally starts conversion and returns project ID and embeddable HTML snippet. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from elevenlabs import ElevenLabs + +client = ElevenLabs( + api_key="YOUR_API_KEY", +) +client.audio_native.create( + name="name", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**name:** `str` — Project name. + +
+
+ +
+
+ +**image:** `typing.Optional[str]` — (Deprecated) Image URL used in the player. If not provided, default image set in the Player settings is used. + +
+
+ +
+
+ +**author:** `typing.Optional[str]` — Author used in the player and inserted at the start of the uploaded article. If not provided, the default author set in the Player settings is used. + +
+
+ +
+
+ +**title:** `typing.Optional[str]` — Title used in the player and inserted at the top of the uploaded article. If not provided, the default title set in the Player settings is used. + +
+
+ +
+
+ +**small:** `typing.Optional[bool]` — (Deprecated) Whether to use small player or not. If not provided, default value set in the Player settings is used. + +
+
+ +
+
+ +**text_color:** `typing.Optional[str]` — Text color used in the player. If not provided, default text color set in the Player settings is used.
@@ -2777,7 +3378,7 @@ client.voices.add_sharing_voice(
-**voice_id:** `str` — ID of the voice to be used. You can use the [Get voices](/docs/api-reference/voices/search) endpoint list all the available voices. +**background_color:** `typing.Optional[str]` — Background color used in the player. If not provided, default background color set in the Player settings is used.
@@ -2785,7 +3386,41 @@ client.voices.add_sharing_voice(
-**new_name:** `str` — The name that identifies this voice. This will be displayed in the dropdown of the website. +**sessionization:** `typing.Optional[int]` — (Deprecated) Specifies for how many minutes to persist the session across page reloads. If not provided, default sessionization set in the Player settings is used. + +
+
+ +
+
+ +**voice_id:** `typing.Optional[str]` — Voice ID used to voice the content. If not provided, default voice ID set in the Player settings is used. + +
+
+ +
+
+ +**model_id:** `typing.Optional[str]` — TTS Model ID used in the player. If not provided, default model ID set in the Player settings is used. + +
+
+ +
+
+ +**file:** `from __future__ import annotations + +typing.Optional[core.File]` — See core.File for more documentation + +
+
+ +
+
+ +**auto_convert:** `typing.Optional[bool]` — Whether to auto convert the project to audio or not.
@@ -2805,7 +3440,7 @@ client.voices.add_sharing_voice(
-
client.voices.get_shared(...) +
client.audio_native.get_settings(...)
@@ -2817,7 +3452,7 @@ client.voices.add_sharing_voice(
-Retrieves a list of shared voices. +Get player settings for the specific project.
@@ -2837,9 +3472,8 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.voices.get_shared( - featured=True, - reader_app_enabled=True, +client.audio_native.get_settings( + project_id="21m00Tcm4TlvDq8ikWAM", ) ``` @@ -2856,7 +3490,7 @@ client.voices.get_shared(
-**page_size:** `typing.Optional[int]` — How many shared voices to return at maximum. Can not exceed 100, defaults to 30. +**project_id:** `str` — The ID of the Studio project.
@@ -2864,103 +3498,69 @@ client.voices.get_shared(
-**category:** `typing.Optional[VoicesGetSharedRequestCategory]` — Voice category used for filtering +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration.
- -
-
- -**gender:** `typing.Optional[str]` — Gender used for filtering -
-
-
-**age:** `typing.Optional[str]` — Age used for filtering -
+
+
client.audio_native.update(...)
-**accent:** `typing.Optional[str]` — Accent used for filtering - -
-
+#### 📝 Description
-**language:** `typing.Optional[str]` — Language used for filtering - -
-
-
-**locale:** `typing.Optional[str]` — Locale used for filtering - +Updates content for the specific AudioNative Project.
- -
-
- -**search:** `typing.Optional[str]` — Search term used for filtering -
+#### 🔌 Usage +
-**use_cases:** `typing.Optional[typing.Union[str, typing.Sequence[str]]]` — Use-case used for filtering - -
-
-
-**descriptives:** `typing.Optional[typing.Union[str, typing.Sequence[str]]]` — Search term used for filtering - -
-
+```python +from elevenlabs import ElevenLabs -
-
+client = ElevenLabs( + api_key="YOUR_API_KEY", +) +client.audio_native.update( + project_id="21m00Tcm4TlvDq8ikWAM", +) -**featured:** `typing.Optional[bool]` — Filter featured voices - +```
- -
-
- -**min_notice_period_days:** `typing.Optional[int]` — Filter voices with a minimum notice period of the given number of days. -
+#### ⚙️ Parameters +
-**include_custom_rates:** `typing.Optional[bool]` — Include/exclude voices with custom rates - -
-
-
-**reader_app_enabled:** `typing.Optional[bool]` — Filter voices that are enabled for the reader app +**project_id:** `str` — The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects.
@@ -2968,7 +3568,9 @@ client.voices.get_shared(
-**owner_id:** `typing.Optional[str]` — Filter voices by public owner ID +**file:** `from __future__ import annotations + +typing.Optional[core.File]` — See core.File for more documentation
@@ -2976,7 +3578,7 @@ client.voices.get_shared(
-**sort:** `typing.Optional[str]` — Sort criteria +**auto_convert:** `typing.Optional[bool]` — Whether to auto convert the project to audio or not.
@@ -2984,7 +3586,7 @@ client.voices.get_shared(
-**page:** `typing.Optional[int]` +**auto_publish:** `typing.Optional[bool]` — Whether to auto publish the new project snapshot after it's converted.
@@ -3004,7 +3606,8 @@ client.voices.get_shared(
-
client.voices.get_similar_library_voices(...) +## Usage +
client.usage.get(...)
@@ -3016,7 +3619,7 @@ client.voices.get_shared(
-Returns a list of shared voices similar to the provided audio sample. If neither similarity_threshold nor top_k is provided, we will apply default values. +Returns the usage metrics for the current user or the entire workspace they are part of. The response provides a time axis based on the specified aggregation interval (default: day), with usage values for each interval along that axis. Usage is broken down by the selected breakdown type. For example, breakdown type "voice" will return the usage of each voice for each interval along the time axis.
@@ -3036,7 +3639,10 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.voices.get_similar_library_voices() +client.usage.get( + start_unix=1, + end_unix=1, +) ``` @@ -3052,9 +3658,15 @@ client.voices.get_similar_library_voices()
-**audio_file:** `from __future__ import annotations +**start_unix:** `int` — UTC Unix timestamp for the start of the usage window, in milliseconds. To include the first day of the window, the timestamp should be at 00:00:00 of that day. + +
+
-typing.Optional[core.File]` — See core.File for more documentation +
+
+ +**end_unix:** `int` — UTC Unix timestamp for the end of the usage window, in milliseconds. To include the last day of the window, the timestamp should be at 23:59:59 of that day.
@@ -3062,7 +3674,7 @@ typing.Optional[core.File]` — See core.File for more documentation
-**similarity_threshold:** `typing.Optional[float]` — Threshold for voice similarity between provided sample and library voices. Values range from 0 to 2. The smaller the value the more similar voices will be returned. +**include_workspace_metrics:** `typing.Optional[bool]` — Whether or not to include the statistics of the entire workspace.
@@ -3070,7 +3682,23 @@ typing.Optional[core.File]` — See core.File for more documentation
-**top_k:** `typing.Optional[int]` — Number of most similar voices to return. If similarity_threshold is provided, less than this number of voices may be returned. Values range from 1 to 100. +**breakdown_type:** `typing.Optional[BreakdownTypes]` — How to break down the information. Cannot be "user" if include_workspace_metrics is False. + +
+
+ +
+
+ +**aggregation_interval:** `typing.Optional[UsageAggregationInterval]` — How to aggregate usage data over time. Can be "hour", "day", "week", "month", or "cumulative". + +
+
+ +
+
+ +**metric:** `typing.Optional[MetricType]` — Which metric to aggregate.
@@ -3090,8 +3718,8 @@ typing.Optional[core.File]` — See core.File for more documentation
-## Studio -
client.studio.create_podcast(...) +## PronunciationDictionaries +
client.pronunciation_dictionaries.create_from_file(...)
@@ -3103,7 +3731,7 @@ typing.Optional[core.File]` — See core.File for more documentation
-Create and auto-convert a podcast project. Currently, the LLM cost is covered by us but you will still be charged for the audio generation. In the future, you will be charged for both the LLM and audio generation costs. +Creates a new pronunciation dictionary from a lexicon .PLS file
@@ -3118,29 +3746,13 @@ Create and auto-convert a podcast project. Currently, the LLM cost is covered by
```python -from elevenlabs import ( - ElevenLabs, - PodcastConversationModeData, - PodcastTextSource, -) -from elevenlabs.studio import ( - BodyCreatePodcastV1StudioPodcastsPostMode_Conversation, -) +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.studio.create_podcast( - model_id="21m00Tcm4TlvDq8ikWAM", - mode=BodyCreatePodcastV1StudioPodcastsPostMode_Conversation( - conversation=PodcastConversationModeData( - host_voice_id="aw1NgEzBg83R7vgmiJt6", - guest_voice_id="aw1NgEzBg83R7vgmiJt7", - ), - ), - source=PodcastTextSource( - text="This is a test podcast.", - ), +client.pronunciation_dictionaries.create_from_file( + name="name", ) ``` @@ -3157,7 +3769,7 @@ client.studio.create_podcast(
-**model_id:** `str` — The ID of the model to be used for this Studio project, you can query GET /v1/models to list all available models. +**name:** `str` — The name of the pronunciation dictionary, used for identification only.
@@ -3165,7 +3777,9 @@ client.studio.create_podcast(
-**mode:** `BodyCreatePodcastV1StudioPodcastsPostMode` — The type of podcast to generate. Can be 'conversation', an interaction between two voices, or 'bulletin', a monologue. +**file:** `from __future__ import annotations + +typing.Optional[core.File]` — See core.File for more documentation
@@ -3173,7 +3787,7 @@ client.studio.create_podcast(
-**source:** `BodyCreatePodcastV1StudioPodcastsPostSource` — The source content for the Podcast. +**description:** `typing.Optional[str]` — A description of the pronunciation dictionary, used for identification only.
@@ -3181,13 +3795,7 @@ client.studio.create_podcast(
-**quality_preset:** `typing.Optional[BodyCreatePodcastV1StudioPodcastsPostQualityPreset]` - -Output quality of the generated audio. Must be one of: -standard - standard output format, 128kbps with 44.1kHz sample rate. -high - high quality output format, 192kbps with 44.1kHz sample rate and major improvements on our side. Using this setting increases the credit cost by 20%. -ultra - ultra quality output format, 192kbps with 44.1kHz sample rate and highest improvements on our side. Using this setting increases the credit cost by 50%. -ultra lossless - ultra quality output format, 705.6kbps with 44.1kHz sample rate and highest improvements on our side in a fully lossless format. Using this setting increases the credit cost by 100%. +**workspace_access:** `typing.Optional[PronunciationDictionariesCreateFromFileRequestWorkspaceAccess]` — Should be one of 'admin', 'editor' or 'viewer'. If not provided, defaults to no access.
@@ -3195,75 +3803,70 @@ ultra lossless - ultra quality output format, 705.6kbps with 44.1kHz sample rate
-**duration_scale:** `typing.Optional[BodyCreatePodcastV1StudioPodcastsPostDurationScale]` - -Duration of the generated podcast. Must be one of: -short - produces podcasts shorter than 3 minutes. -default - produces podcasts roughly between 3-7 minutes. -long - prodces podcasts longer than 7 minutes. +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration.
+
+
-
-
-**language:** `typing.Optional[str]` — An optional language of the Studio project. Two-letter language code (ISO 639-1). -
+
+
client.pronunciation_dictionaries.create_from_rules(...)
-**highlights:** `typing.Optional[typing.Sequence[str]]` — A brief summary or highlights of the Studio project's content, providing key points or themes. This should be between 10 and 70 characters. - -
-
+#### 📝 Description
-**callback_url:** `typing.Optional[str]` — A url that will be called by our service when the Studio project is converted. Request will contain a json blob containing the status of the conversion - -
-
-
-**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. - +Creates a new pronunciation dictionary from provided rules.
+#### 🔌 Usage - - -
- -## Dubbing -
client.dubbing.get_dubbing_resource(...)
-#### 📝 Description -
-
-
+```python +from elevenlabs import ElevenLabs +from elevenlabs.pronunciation_dictionaries import ( + BodyAddAPronunciationDictionaryV1PronunciationDictionariesAddFromRulesPostRulesItem_Alias, +) + +client = ElevenLabs( + api_key="YOUR_API_KEY", +) +client.pronunciation_dictionaries.create_from_rules( + rules=[ + BodyAddAPronunciationDictionaryV1PronunciationDictionariesAddFromRulesPostRulesItem_Alias( + string_to_replace="Thailand", + alias="tie-land", + ) + ], + name="My Dictionary", +) -Given a dubbing ID generated from the '/v1/dubbing' endpoint with studio enabled, returns the dubbing resource. +```
-#### 🔌 Usage +#### ⚙️ Parameters
@@ -3271,31 +3874,39 @@ Given a dubbing ID generated from the '/v1/dubbing' endpoint with studio enabled
-```python -from elevenlabs import ElevenLabs - -client = ElevenLabs( - api_key="YOUR_API_KEY", -) -client.dubbing.get_dubbing_resource( - dubbing_id="dubbing_id", -) +**rules:** `typing.Sequence[ + BodyAddAPronunciationDictionaryV1PronunciationDictionariesAddFromRulesPostRulesItem +]` -``` +List of pronunciation rules. Rule can be either: + an alias rule: {'string_to_replace': 'a', 'type': 'alias', 'alias': 'b', } + or a phoneme rule: {'string_to_replace': 'a', 'type': 'phoneme', 'phoneme': 'b', 'alphabet': 'ipa' } +
+ +
+
+ +**name:** `str` — The name of the pronunciation dictionary, used for identification only. +
-#### ⚙️ Parameters -
+**description:** `typing.Optional[str]` — A description of the pronunciation dictionary, used for identification only. + +
+
+
-**dubbing_id:** `str` — ID of the dubbing project. +**workspace_access:** `typing.Optional[ + BodyAddAPronunciationDictionaryV1PronunciationDictionariesAddFromRulesPostWorkspaceAccess +]` — Should be one of 'admin', 'editor' or 'viewer'. If not provided, defaults to no access.
@@ -3315,7 +3926,7 @@ client.dubbing.get_dubbing_resource(
-
client.dubbing.add_language_to_resource(...) +
client.pronunciation_dictionaries.get(...)
@@ -3327,7 +3938,7 @@ client.dubbing.get_dubbing_resource(
-Adds the given ElevenLab Turbo V2/V2.5 language code to the resource. Does not automatically generate transcripts/translations/audio. +Get metadata for a pronunciation dictionary
@@ -3347,8 +3958,8 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.dubbing.add_language_to_resource( - dubbing_id="dubbing_id", +client.pronunciation_dictionaries.get( + pronunciation_dictionary_id="21m00Tcm4TlvDq8ikWAM", ) ``` @@ -3365,15 +3976,7 @@ client.dubbing.add_language_to_resource(
-**dubbing_id:** `str` — ID of the dubbing project. - -
-
- -
-
- -**language:** `typing.Optional[str]` — The Target language. +**pronunciation_dictionary_id:** `str` — The id of the pronunciation dictionary
@@ -3393,7 +3996,7 @@ client.dubbing.add_language_to_resource(
-
client.dubbing.update_segment_language(...) +
client.pronunciation_dictionaries.list(...)
@@ -3405,7 +4008,7 @@ client.dubbing.add_language_to_resource(
-Modifies a single segment with new text and/or start/end times. Will update the values for only a specific language of a segment. Does not automatically regenerate the dub. +Get a list of the pronunciation dictionaries you have access to and their metadata
@@ -3425,11 +4028,7 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.dubbing.update_segment_language( - dubbing_id="dubbing_id", - segment_id="segment_id", - language="language", -) +client.pronunciation_dictionaries.list() ``` @@ -3445,23 +4044,7 @@ client.dubbing.update_segment_language(
-**dubbing_id:** `str` — ID of the dubbing project. - -
-
- -
-
- -**segment_id:** `str` — ID of the segment - -
-
- -
-
- -**language:** `str` — ID of the language. +**cursor:** `typing.Optional[str]` — Used for fetching next page. Cursor is returned in the response.
@@ -3469,7 +4052,7 @@ client.dubbing.update_segment_language(
-**start_time:** `typing.Optional[float]` +**page_size:** `typing.Optional[int]` — How many pronunciation dictionaries to return at maximum. Can not exceed 100, defaults to 30.
@@ -3477,7 +4060,7 @@ client.dubbing.update_segment_language(
-**end_time:** `typing.Optional[float]` +**sort:** `typing.Optional[PronunciationDictionariesListRequestSort]` — Which field to sort by, one of 'created_at_unix' or 'name'.
@@ -3485,7 +4068,7 @@ client.dubbing.update_segment_language(
-**text:** `typing.Optional[str]` +**sort_direction:** `typing.Optional[str]` — Which direction to sort the voices in. 'ascending' or 'descending'.
@@ -3505,7 +4088,8 @@ client.dubbing.update_segment_language(
-
client.dubbing.delete_segment(...) +## SpeechToText +
client.speech_to_text.convert(...)
@@ -3517,7 +4101,7 @@ client.dubbing.update_segment_language(
-Deletes a single segment from the dubbing. +Transcribe an audio or video file.
@@ -3537,9 +4121,8 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.dubbing.delete_segment( - dubbing_id="dubbing_id", - segment_id="segment_id", +client.speech_to_text.convert( + model_id="model_id", ) ``` @@ -3556,7 +4139,7 @@ client.dubbing.delete_segment(
-**dubbing_id:** `str` — ID of the dubbing project. +**model_id:** `str` — The ID of the model to use for transcription, currently only 'scribe_v1' and 'scribe_v1_experimental' are available.
@@ -3564,7 +4147,7 @@ client.dubbing.delete_segment(
-**segment_id:** `str` — ID of the segment +**enable_logging:** `typing.Optional[bool]` — When enable_logging is set to false zero retention mode will be used for the request. This will mean history features are unavailable for this request, including request stitching. Zero retention mode may only be used by enterprise customers.
@@ -3572,70 +4155,65 @@ client.dubbing.delete_segment(
-**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. +**file:** `from __future__ import annotations + +typing.Optional[core.File]` — See core.File for more documentation
- -
+
+
+**language_code:** `typing.Optional[str]` — An ISO-639-1 or ISO-639-3 language_code corresponding to the language of the audio file. Can sometimes improve transcription performance if known beforehand. Defaults to null, in this case the language is predicted automatically. +
-
-
client.dubbing.transcribe_segments(...)
-#### 📝 Description - -
-
+**tag_audio_events:** `typing.Optional[bool]` — Whether to tag audio events like (laughter), (footsteps), etc. in the transcription. + +
+
-Regenerate the transcriptions for the specified segments. Does not automatically regenerate translations or dubs. -
-
+**num_speakers:** `typing.Optional[int]` — The maximum amount of speakers talking in the uploaded file. Can help with predicting who speaks when. The maximum amount of speakers that can be predicted is 32. Defaults to null, in this case the amount of speakers is set to the maximum value the model supports. +
-#### 🔌 Usage -
+**timestamps_granularity:** `typing.Optional[SpeechToTextConvertRequestTimestampsGranularity]` — The granularity of the timestamps in the transcription. 'word' provides word-level timestamps and 'character' provides character-level timestamps per word. + +
+
+
-```python -from elevenlabs import ElevenLabs - -client = ElevenLabs( - api_key="YOUR_API_KEY", -) -client.dubbing.transcribe_segments( - dubbing_id="dubbing_id", - segments=["segments"], -) - -``` -
-
+**diarize:** `typing.Optional[bool]` — Whether to annotate which speaker is currently talking in the uploaded file. + -#### ⚙️ Parameters -
+**additional_formats:** `typing.Optional[AdditionalFormats]` — A list of additional formats to export the transcript to. + +
+
+
-**dubbing_id:** `str` — ID of the dubbing project. +**file_format:** `typing.Optional[SpeechToTextConvertRequestFileFormat]` — The format of input audio. Options are 'pcm_s16le_16' or 'other' For `pcm_s16le_16`, the input audio must be 16-bit PCM at a 16kHz sample rate, single channel (mono), and little-endian byte order. Latency will be lower than with passing an encoded waveform.
@@ -3643,7 +4221,7 @@ client.dubbing.transcribe_segments(
-**segments:** `typing.Sequence[str]` — Transcribe this specific list of segments. +**cloud_storage_url:** `typing.Optional[str]` — The valid AWS S3, Cloudflare R2 or Google Cloud Storage URL of the file to transcribe. Exactly one of the file or cloud_storage_url parameters must be provided. The file must be a valid publicly accessible cloud storage URL. The file size must be less than 2GB. URL can be pre-signed.
@@ -3663,7 +4241,8 @@ client.dubbing.transcribe_segments(
-
client.dubbing.translate_segments(...) +## ForcedAlignment +
client.forced_alignment.create(...)
@@ -3675,7 +4254,7 @@ client.dubbing.transcribe_segments(
-Regenerate the translations for either the entire resource or the specified segments/languages. Will automatically transcribe missing transcriptions. Will not automatically regenerate the dubs. +Force align an audio file to text. Use this endpoint to get the timing information for each character and word in an audio file based on a provided text transcript.
@@ -3695,9 +4274,8 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.dubbing.translate_segments( - dubbing_id="dubbing_id", - segments=["segments"], +client.forced_alignment.create( + text="text", ) ``` @@ -3714,7 +4292,9 @@ client.dubbing.translate_segments(
-**dubbing_id:** `str` — ID of the dubbing project. +**file:** `from __future__ import annotations + +core.File` — See core.File for more documentation
@@ -3722,7 +4302,7 @@ client.dubbing.translate_segments(
-**segments:** `typing.Sequence[str]` — Translate only this list of segments. +**text:** `str` — The text to align with the audio. The input text can be in any format, however diarization is not supported at this time.
@@ -3730,7 +4310,7 @@ client.dubbing.translate_segments(
-**languages:** `typing.Optional[typing.Sequence[str]]` — Translate only these languages for each segment. +**enabled_spooled_file:** `typing.Optional[bool]` — If true, the file will be streamed to the server and processed in chunks. This is useful for large files that cannot be loaded into memory. The default is false.
@@ -3750,7 +4330,8 @@ client.dubbing.translate_segments(
-
client.dubbing.dub_segments(...) +## ConversationalAi +
client.conversational_ai.add_to_knowledge_base(...)
@@ -3762,7 +4343,7 @@ client.dubbing.translate_segments(
-Regenerate the dubs for either the entire resource or the specified segments/languages. Will automatically transcribe and translate any missing transcriptions and translations. +Upload a file or webpage URL to create a knowledge base document.
After creating the document, update the agent's knowledge base by calling [Update agent](/docs/conversational-ai/api-reference/agents/update-agent).
@@ -3782,10 +4363,7 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.dubbing.dub_segments( - dubbing_id="dubbing_id", - segments=["segments"], -) +client.conversational_ai.add_to_knowledge_base() ``` @@ -3801,7 +4379,7 @@ client.dubbing.dub_segments(
-**dubbing_id:** `str` — ID of the dubbing project. +**name:** `typing.Optional[str]` — A custom, human-readable name for the document.
@@ -3809,7 +4387,7 @@ client.dubbing.dub_segments(
-**segments:** `typing.Sequence[str]` — Dub only this list of segments. +**url:** `typing.Optional[str]` — URL to a page of documentation that the agent will have access to in order to interact with users.
@@ -3817,7 +4395,9 @@ client.dubbing.dub_segments(
-**languages:** `typing.Optional[typing.Sequence[str]]` — Dub only these languages for each segment. +**file:** `from __future__ import annotations + +typing.Optional[core.File]` — See core.File for more documentation
@@ -3837,7 +4417,7 @@ client.dubbing.dub_segments(
-
client.dubbing.render_dub(...) +
client.conversational_ai.update_secret(...)
@@ -3849,7 +4429,7 @@ client.dubbing.dub_segments(
-Regenerate the dubs for either the entire resource or the specified segments/languages. Will automatically transcribe and translate any missing transcriptions and translations. +Update an existing secret for the workspace
@@ -3869,10 +4449,10 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.dubbing.render_dub( - dubbing_id="dubbing_id", - language="language", - render_type="mp4", +client.conversational_ai.update_secret( + secret_id="secret_id", + name="name", + value="value", ) ``` @@ -3889,7 +4469,7 @@ client.dubbing.render_dub(
-**dubbing_id:** `str` — ID of the dubbing project. +**secret_id:** `str`
@@ -3897,7 +4477,7 @@ client.dubbing.render_dub(
-**language:** `str` — Render this language +**name:** `str`
@@ -3905,7 +4485,7 @@ client.dubbing.render_dub(
-**render_type:** `RenderType` — The type of the render. One of ['mp4', 'aac', 'mp3', 'wav', 'aaf', 'tracks_zip', 'clips_zip'] +**value:** `str`
@@ -3925,7 +4505,8 @@ client.dubbing.render_dub(
-
client.dubbing.dub_a_video_or_an_audio_file(...) +## ConversationalAi Conversations +
client.conversational_ai.conversations.get_signed_url(...)
@@ -3937,7 +4518,7 @@ client.dubbing.render_dub(
-Dubs a provided audio or video file into given language. +Get a signed url to start a conversation with an agent with an agent that requires authorization
@@ -3957,7 +4538,9 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.dubbing.dub_a_video_or_an_audio_file() +client.conversational_ai.conversations.get_signed_url( + agent_id="21m00Tcm4TlvDq8ikWAM", +) ``` @@ -3973,9 +4556,7 @@ client.dubbing.dub_a_video_or_an_audio_file()
-**file:** `from __future__ import annotations - -typing.Optional[core.File]` — See core.File for more documentation +**agent_id:** `str` — The id of the agent you're taking the action on.
@@ -3983,101 +4564,67 @@ typing.Optional[core.File]` — See core.File for more documentation
-**csv_file:** `from __future__ import annotations - -typing.Optional[core.File]` — See core.File for more documentation +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration.
- -
-
- -**foreground_audio_file:** `from __future__ import annotations - -typing.Optional[core.File]` — See core.File for more documentation -
-
-
- -**background_audio_file:** `from __future__ import annotations -typing.Optional[core.File]` — See core.File for more documentation -
+
+
client.conversational_ai.conversations.list(...)
-**name:** `typing.Optional[str]` — Name of the dubbing project. - -
-
+#### 📝 Description
-**source_url:** `typing.Optional[str]` — URL of the source video/audio file. - -
-
-
-**source_lang:** `typing.Optional[str]` — Source language. - +Get all conversations of agents that user owns. With option to restrict to a specific agent.
- -
-
- -**target_lang:** `typing.Optional[str]` — The Target language to dub the content into. -
+#### 🔌 Usage +
-**num_speakers:** `typing.Optional[int]` — Number of speakers to use for the dubbing. Set to 0 to automatically detect the number of speakers - -
-
-
-**watermark:** `typing.Optional[bool]` — Whether to apply watermark to the output video. - +```python +from elevenlabs import ElevenLabs + +client = ElevenLabs( + api_key="YOUR_API_KEY", +) +client.conversational_ai.conversations.list() + +```
- -
-
- -**start_time:** `typing.Optional[int]` — Start time of the source video/audio file. -
+#### ⚙️ Parameters +
-**end_time:** `typing.Optional[int]` — End time of the source video/audio file. - -
-
-
-**highest_resolution:** `typing.Optional[bool]` — Whether to use the highest resolution available. +**cursor:** `typing.Optional[str]` — Used for fetching next page. Cursor is returned in the response.
@@ -4085,7 +4632,7 @@ typing.Optional[core.File]` — See core.File for more documentation
-**drop_background_audio:** `typing.Optional[bool]` — An advanced setting. Whether to drop background audio from the final dub. This can improve dub quality where it's known that audio shouldn't have a background track such as for speeches or monologues. +**agent_id:** `typing.Optional[str]` — The id of the agent you're taking the action on.
@@ -4093,7 +4640,7 @@ typing.Optional[core.File]` — See core.File for more documentation
-**use_profanity_filter:** `typing.Optional[bool]` — [BETA] Whether transcripts should have profanities censored with the words '[censored]' +**call_successful:** `typing.Optional[EvaluationSuccessResult]` — The result of the success evaluation
@@ -4101,7 +4648,7 @@ typing.Optional[core.File]` — See core.File for more documentation
-**dubbing_studio:** `typing.Optional[bool]` — Whether to prepare dub for edits in dubbing studio or edits as a dubbing resource. +**call_start_before_unix:** `typing.Optional[int]` — Unix timestamp (in seconds) to filter conversations up to this start date.
@@ -4109,7 +4656,7 @@ typing.Optional[core.File]` — See core.File for more documentation
-**disable_voice_cloning:** `typing.Optional[bool]` — [BETA] Instead of using a voice clone in dubbing, use a similar voice from the ElevenLabs Voice Library. +**call_start_after_unix:** `typing.Optional[int]` — Unix timestamp (in seconds) to filter conversations after to this start date.
@@ -4117,7 +4664,7 @@ typing.Optional[core.File]` — See core.File for more documentation
-**mode:** `typing.Optional[str]` — automatic or manual. Manual mode is only supported when creating a dubbing studio project +**page_size:** `typing.Optional[int]` — How many conversations to return at maximum. Can not exceed 100, defaults to 30.
@@ -4137,7 +4684,7 @@ typing.Optional[core.File]` — See core.File for more documentation
-
client.dubbing.get_dubbing_project_metadata(...) +
client.conversational_ai.conversations.get(...)
@@ -4149,7 +4696,7 @@ typing.Optional[core.File]` — See core.File for more documentation
-Returns metadata about a dubbing project, including whether it's still in progress or not +Get the details of a particular conversation
@@ -4169,8 +4716,8 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.dubbing.get_dubbing_project_metadata( - dubbing_id="dubbing_id", +client.conversational_ai.conversations.get( + conversation_id="123", ) ``` @@ -4187,7 +4734,7 @@ client.dubbing.get_dubbing_project_metadata(
-**dubbing_id:** `str` — ID of the dubbing project. +**conversation_id:** `str` — The id of the conversation you're taking the action on.
@@ -4207,7 +4754,7 @@ client.dubbing.get_dubbing_project_metadata(
-
client.dubbing.delete_dubbing_project(...) +
client.conversational_ai.conversations.delete(...)
@@ -4219,7 +4766,7 @@ client.dubbing.get_dubbing_project_metadata(
-Deletes a dubbing project. +Delete a particular conversation
@@ -4239,8 +4786,8 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.dubbing.delete_dubbing_project( - dubbing_id="dubbing_id", +client.conversational_ai.conversations.delete( + conversation_id="21m00Tcm4TlvDq8ikWAM", ) ``` @@ -4257,7 +4804,7 @@ client.dubbing.delete_dubbing_project(
-**dubbing_id:** `str` — ID of the dubbing project. +**conversation_id:** `str` — The id of the conversation you're taking the action on.
@@ -4277,7 +4824,8 @@ client.dubbing.delete_dubbing_project(
-
client.dubbing.get_transcript_for_dub(...) +## ConversationalAi Twilio +
client.conversational_ai.twilio.outbound_call(...)
@@ -4289,7 +4837,7 @@ client.dubbing.delete_dubbing_project(
-Returns transcript for the dub as an SRT or WEBVTT file. +Handle an outbound call via Twilio
@@ -4309,9 +4857,10 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.dubbing.get_transcript_for_dub( - dubbing_id="dubbing_id", - language_code="language_code", +client.conversational_ai.twilio.outbound_call( + agent_id="agent_id", + agent_phone_number_id="agent_phone_number_id", + to_number="to_number", ) ``` @@ -4328,7 +4877,7 @@ client.dubbing.get_transcript_for_dub(
-**dubbing_id:** `str` — ID of the dubbing project. +**agent_id:** `str`
@@ -4336,7 +4885,7 @@ client.dubbing.get_transcript_for_dub(
-**language_code:** `str` — ID of the language. +**agent_phone_number_id:** `str`
@@ -4344,7 +4893,7 @@ client.dubbing.get_transcript_for_dub(
-**format_type:** `typing.Optional[DubbingGetTranscriptForDubRequestFormatType]` — Format to use for the subtitle file, either 'srt' or 'webvtt' +**to_number:** `str`
@@ -4352,63 +4901,10 @@ client.dubbing.get_transcript_for_dub(
-**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. +**conversation_initiation_client_data:** `typing.Optional[ConversationInitiationClientDataRequestInput]`
- -
- - - - -
- -## Models -
client.models.get_all() -
-
- -#### 📝 Description - -
-
- -
-
- -Gets a list of available models. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```python -from elevenlabs import ElevenLabs - -client = ElevenLabs( - api_key="YOUR_API_KEY", -) -client.models.get_all() - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
@@ -4425,8 +4921,8 @@ client.models.get_all()
-## AudioNative -
client.audio_native.create(...) +## ConversationalAi Agents +
client.conversational_ai.agents.create(...)
@@ -4438,7 +4934,7 @@ client.models.get_all()
-Creates Audio Native enabled project, optionally starts conversion and returns project ID and embeddable HTML snippet. +Create an agent from a config object
@@ -4453,13 +4949,13 @@ Creates Audio Native enabled project, optionally starts conversion and returns p
```python -from elevenlabs import ElevenLabs +from elevenlabs import ConversationalConfig, ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.audio_native.create( - name="name", +client.conversational_ai.agents.create( + conversation_config=ConversationalConfig(), ) ``` @@ -4476,7 +4972,7 @@ client.audio_native.create(
-**name:** `str` — Project name. +**conversation_config:** `ConversationalConfig` — Conversation configuration for an agent
@@ -4484,7 +4980,7 @@ client.audio_native.create(
-**image:** `typing.Optional[str]` — (Deprecated) Image URL used in the player. If not provided, default image set in the Player settings is used. +**platform_settings:** `typing.Optional[AgentPlatformSettingsRequestModel]` — Platform settings for the agent are all settings that aren't related to the conversation orchestration and content.
@@ -4492,7 +4988,7 @@ client.audio_native.create(
-**author:** `typing.Optional[str]` — Author used in the player and inserted at the start of the uploaded article. If not provided, the default author set in the Player settings is used. +**name:** `typing.Optional[str]` — A name to make the agent easier to find
@@ -4500,7 +4996,7 @@ client.audio_native.create(
-**title:** `typing.Optional[str]` — Title used in the player and inserted at the top of the uploaded article. If not provided, the default title set in the Player settings is used. +**tags:** `typing.Optional[typing.Sequence[str]]` — Tags to help classify and filter the agent
@@ -4508,65 +5004,69 @@ client.audio_native.create(
-**small:** `typing.Optional[bool]` — (Deprecated) Whether to use small player or not. If not provided, default value set in the Player settings is used. +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration.
+
+
-
-
-**text_color:** `typing.Optional[str]` — Text color used in the player. If not provided, default text color set in the Player settings is used. -
+
+
client.conversational_ai.agents.get(...)
-**background_color:** `typing.Optional[str]` — Background color used in the player. If not provided, default background color set in the Player settings is used. - -
-
+#### 📝 Description
-**sessionization:** `typing.Optional[int]` — (Deprecated) Specifies for how many minutes to persist the session across page reloads. If not provided, default sessionization set in the Player settings is used. - -
-
-
-**voice_id:** `typing.Optional[str]` — Voice ID used to voice the content. If not provided, default voice ID set in the Player settings is used. - +Retrieve config for an agent
+ + + +#### 🔌 Usage
-**model_id:** `typing.Optional[str]` — TTS Model ID used in the player. If not provided, default model ID set in the Player settings is used. - -
-
-
-**file:** `from __future__ import annotations +```python +from elevenlabs import ElevenLabs -typing.Optional[core.File]` — See core.File for more documentation - +client = ElevenLabs( + api_key="YOUR_API_KEY", +) +client.conversational_ai.agents.get( + agent_id="21m00Tcm4TlvDq8ikWAM", +) + +``` +
+
+#### ⚙️ Parameters +
-**auto_convert:** `typing.Optional[bool]` — Whether to auto convert the project to audio or not. +
+
+ +**agent_id:** `str` — The id of an agent. This is returned on agent creation.
@@ -4586,7 +5086,7 @@ typing.Optional[core.File]` — See core.File for more documentation
-
client.audio_native.get_settings(...) +
client.conversational_ai.agents.delete(...)
@@ -4598,7 +5098,7 @@ typing.Optional[core.File]` — See core.File for more documentation
-Get player settings for the specific project. +Delete an agent
@@ -4618,8 +5118,8 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.audio_native.get_settings( - project_id="21m00Tcm4TlvDq8ikWAM", +client.conversational_ai.agents.delete( + agent_id="21m00Tcm4TlvDq8ikWAM", ) ``` @@ -4636,7 +5136,7 @@ client.audio_native.get_settings(
-**project_id:** `str` — The ID of the Studio project. +**agent_id:** `str` — The id of an agent. This is returned on agent creation.
@@ -4656,7 +5156,7 @@ client.audio_native.get_settings(
-
client.audio_native.update_content(...) +
client.conversational_ai.agents.update(...)
@@ -4668,7 +5168,7 @@ client.audio_native.get_settings(
-Updates content for the specific AudioNative Project. +Patches an Agent settings
@@ -4688,8 +5188,8 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.audio_native.update_content( - project_id="21m00Tcm4TlvDq8ikWAM", +client.conversational_ai.agents.update( + agent_id="21m00Tcm4TlvDq8ikWAM", ) ``` @@ -4706,7 +5206,7 @@ client.audio_native.update_content(
-**project_id:** `str` — The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. +**agent_id:** `str` — The id of an agent. This is returned on agent creation.
@@ -4714,9 +5214,15 @@ client.audio_native.update_content(
-**file:** `from __future__ import annotations +**conversation_config:** `typing.Optional[typing.Optional[typing.Any]]` + +
+
-typing.Optional[core.File]` — See core.File for more documentation +
+
+ +**platform_settings:** `typing.Optional[typing.Optional[typing.Any]]`
@@ -4724,7 +5230,7 @@ typing.Optional[core.File]` — See core.File for more documentation
-**auto_convert:** `typing.Optional[bool]` — Whether to auto convert the project to audio or not. +**name:** `typing.Optional[str]` — A name to make the agent easier to find
@@ -4732,7 +5238,7 @@ typing.Optional[core.File]` — See core.File for more documentation
-**auto_publish:** `typing.Optional[bool]` — Whether to auto publish the new project snapshot after it's converted. +**tags:** `typing.Optional[typing.Sequence[str]]` — Tags to help classify and filter the agent
@@ -4752,8 +5258,7 @@ typing.Optional[core.File]` — See core.File for more documentation
-## Usage -
client.usage.get_characters_usage_metrics(...) +
client.conversational_ai.agents.list(...)
@@ -4765,7 +5270,7 @@ typing.Optional[core.File]` — See core.File for more documentation
-Returns the usage metrics for the current user or the entire workspace they are part of. The response provides a time axis based on the specified aggregation interval (default: day), with usage values for each interval along that axis. Usage is broken down by the selected breakdown type. For example, breakdown type "voice" will return the usage of each voice for each interval along the time axis. +Returns a list of your agents and their metadata.
@@ -4785,10 +5290,7 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.usage.get_characters_usage_metrics( - start_unix=1, - end_unix=1, -) +client.conversational_ai.agents.list() ``` @@ -4804,31 +5306,7 @@ client.usage.get_characters_usage_metrics(
-**start_unix:** `int` — UTC Unix timestamp for the start of the usage window, in milliseconds. To include the first day of the window, the timestamp should be at 00:00:00 of that day. - -
-
- -
-
- -**end_unix:** `int` — UTC Unix timestamp for the end of the usage window, in milliseconds. To include the last day of the window, the timestamp should be at 23:59:59 of that day. - -
-
- -
-
- -**include_workspace_metrics:** `typing.Optional[bool]` — Whether or not to include the statistics of the entire workspace. - -
-
- -
-
- -**breakdown_type:** `typing.Optional[BreakdownTypes]` — How to break down the information. Cannot be "user" if include_workspace_metrics is False. +**cursor:** `typing.Optional[str]` — Used for fetching next page. Cursor is returned in the response.
@@ -4836,7 +5314,7 @@ client.usage.get_characters_usage_metrics(
-**aggregation_interval:** `typing.Optional[UsageAggregationInterval]` — How to aggregate usage data over time. Can be "hour", "day", "week", "month", or "cumulative". +**page_size:** `typing.Optional[int]` — How many Agents to return at maximum. Can not exceed 100, defaults to 30.
@@ -4844,7 +5322,7 @@ client.usage.get_characters_usage_metrics(
-**metric:** `typing.Optional[MetricType]` — Which metric to aggregate. +**search:** `typing.Optional[str]` — Search by agents name.
@@ -4864,8 +5342,7 @@ client.usage.get_characters_usage_metrics(
-## PronunciationDictionary -
client.pronunciation_dictionary.add_from_file(...) +
client.conversational_ai.agents.simulate_conversation(...)
@@ -4877,7 +5354,7 @@ client.usage.get_characters_usage_metrics(
-Creates a new pronunciation dictionary from a lexicon .PLS file +Run a conversation between the agent and a simulated user.
@@ -4892,13 +5369,23 @@ Creates a new pronunciation dictionary from a lexicon .PLS file
```python -from elevenlabs import ElevenLabs +from elevenlabs import ( + AgentConfigDbModel, + ConversationSimulationSpecification, + ElevenLabs, +) client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.pronunciation_dictionary.add_from_file( - name="name", +client.conversational_ai.agents.simulate_conversation( + agent_id="21m00Tcm4TlvDq8ikWAM", + simulation_specification=ConversationSimulationSpecification( + simulated_user_config=AgentConfigDbModel( + first_message="Hello, how can I help you today?", + language="en", + ), + ), ) ``` @@ -4915,17 +5402,7 @@ client.pronunciation_dictionary.add_from_file(
-**name:** `str` — The name of the pronunciation dictionary, used for identification only. - -
-
- -
-
- -**file:** `from __future__ import annotations - -typing.Optional[core.File]` — See core.File for more documentation +**agent_id:** `str` — The id of an agent. This is returned on agent creation.
@@ -4933,7 +5410,7 @@ typing.Optional[core.File]` — See core.File for more documentation
-**description:** `typing.Optional[str]` — A description of the pronunciation dictionary, used for identification only. +**simulation_specification:** `ConversationSimulationSpecification` — A specification detailing how the conversation should be simulated
@@ -4941,7 +5418,7 @@ typing.Optional[core.File]` — See core.File for more documentation
-**workspace_access:** `typing.Optional[PronunciationDictionaryAddFromFileRequestWorkspaceAccess]` — Should be one of 'admin', 'editor' or 'viewer'. If not provided, defaults to no access. +**extra_evaluation_criteria:** `typing.Optional[typing.Sequence[PromptEvaluationCriteria]]` — A list of evaluation criteria to test
@@ -4961,7 +5438,7 @@ typing.Optional[core.File]` — See core.File for more documentation
-
client.pronunciation_dictionary.add_from_rules(...) +
client.conversational_ai.agents.simulate_conversation_stream(...)
@@ -4973,7 +5450,7 @@ typing.Optional[core.File]` — See core.File for more documentation
-Creates a new pronunciation dictionary from provided rules. +Run a conversation between the agent and a simulated user and stream back the response. Response is streamed back as partial lists of messages that should be concatenated and once the conversation has complete a single final message with the conversation analysis will be sent.
@@ -4988,22 +5465,23 @@ Creates a new pronunciation dictionary from provided rules.
```python -from elevenlabs import ElevenLabs -from elevenlabs.pronunciation_dictionary import ( - BodyAddAPronunciationDictionaryV1PronunciationDictionariesAddFromRulesPostRulesItem_Alias, +from elevenlabs import ( + AgentConfigDbModel, + ConversationSimulationSpecification, + ElevenLabs, ) client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.pronunciation_dictionary.add_from_rules( - rules=[ - BodyAddAPronunciationDictionaryV1PronunciationDictionariesAddFromRulesPostRulesItem_Alias( - string_to_replace="Thailand", - alias="tie-land", - ) - ], - name="My Dictionary", +client.conversational_ai.agents.simulate_conversation_stream( + agent_id="21m00Tcm4TlvDq8ikWAM", + simulation_specification=ConversationSimulationSpecification( + simulated_user_config=AgentConfigDbModel( + first_message="Hello, how can I help you today?", + language="en", + ), + ), ) ``` @@ -5020,21 +5498,7 @@ client.pronunciation_dictionary.add_from_rules(
-**rules:** `typing.Sequence[ - BodyAddAPronunciationDictionaryV1PronunciationDictionariesAddFromRulesPostRulesItem -]` - -List of pronunciation rules. Rule can be either: - an alias rule: {'string_to_replace': 'a', 'type': 'alias', 'alias': 'b', } - or a phoneme rule: {'string_to_replace': 'a', 'type': 'phoneme', 'phoneme': 'b', 'alphabet': 'ipa' } - -
-
- -
-
- -**name:** `str` — The name of the pronunciation dictionary, used for identification only. +**agent_id:** `str` — The id of an agent. This is returned on agent creation.
@@ -5042,7 +5506,7 @@ List of pronunciation rules. Rule can be either:
-**description:** `typing.Optional[str]` — A description of the pronunciation dictionary, used for identification only. +**simulation_specification:** `ConversationSimulationSpecification` — A specification detailing how the conversation should be simulated
@@ -5050,9 +5514,7 @@ List of pronunciation rules. Rule can be either:
-**workspace_access:** `typing.Optional[ - BodyAddAPronunciationDictionaryV1PronunciationDictionariesAddFromRulesPostWorkspaceAccess -]` — Should be one of 'admin', 'editor' or 'viewer'. If not provided, defaults to no access. +**extra_evaluation_criteria:** `typing.Optional[typing.Sequence[PromptEvaluationCriteria]]` — A list of evaluation criteria to test
@@ -5072,7 +5534,8 @@ List of pronunciation rules. Rule can be either:
-
client.pronunciation_dictionary.add_rules(...) +## ConversationalAi PhoneNumbers +
client.conversational_ai.phone_numbers.create(...)
@@ -5084,7 +5547,7 @@ List of pronunciation rules. Rule can be either:
-Add rules to the pronunciation dictionary +Import Phone Number from provider configuration (Twilio or SIP trunk)
@@ -5100,21 +5563,20 @@ Add rules to the pronunciation dictionary ```python from elevenlabs import ElevenLabs -from elevenlabs.pronunciation_dictionary import ( - PronunciationDictionaryRule_Alias, +from elevenlabs.conversational_ai.phone_numbers import ( + PhoneNumbersCreateRequestBody_Twilio, ) client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.pronunciation_dictionary.add_rules( - pronunciation_dictionary_id="21m00Tcm4TlvDq8ikWAM", - rules=[ - PronunciationDictionaryRule_Alias( - string_to_replace="Thailand", - alias="tie-land", - ) - ], +client.conversational_ai.phone_numbers.create( + request=PhoneNumbersCreateRequestBody_Twilio( + phone_number="phone_number", + label="label", + sid="sid", + token="token", + ), ) ``` @@ -5131,19 +5593,7 @@ client.pronunciation_dictionary.add_rules(
-**pronunciation_dictionary_id:** `str` — The id of the pronunciation dictionary - -
-
- -
-
- -**rules:** `typing.Sequence[PronunciationDictionaryRule]` - -List of pronunciation rules. Rule can be either: - an alias rule: {'string_to_replace': 'a', 'type': 'alias', 'alias': 'b', } - or a phoneme rule: {'string_to_replace': 'a', 'type': 'phoneme', 'phoneme': 'b', 'alphabet': 'ipa' } +**request:** `PhoneNumbersCreateRequestBody`
@@ -5163,7 +5613,7 @@ List of pronunciation rules. Rule can be either:
-
client.pronunciation_dictionary.remove_rules(...) +
client.conversational_ai.phone_numbers.get(...)
@@ -5175,7 +5625,7 @@ List of pronunciation rules. Rule can be either:
-Remove rules from the pronunciation dictionary +Retrieve Phone Number details by ID
@@ -5195,9 +5645,8 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.pronunciation_dictionary.remove_rules( - pronunciation_dictionary_id="21m00Tcm4TlvDq8ikWAM", - rule_strings=["rule_strings"], +client.conversational_ai.phone_numbers.get( + phone_number_id="TeaqRRdTcIfIu2i7BYfT", ) ``` @@ -5214,15 +5663,7 @@ client.pronunciation_dictionary.remove_rules(
-**pronunciation_dictionary_id:** `str` — The id of the pronunciation dictionary - -
-
- -
-
- -**rule_strings:** `typing.Sequence[str]` — List of strings to remove from the pronunciation dictionary. +**phone_number_id:** `str` — The id of an agent. This is returned on agent creation.
@@ -5242,7 +5683,7 @@ client.pronunciation_dictionary.remove_rules(
-
client.pronunciation_dictionary.get(...) +
client.conversational_ai.phone_numbers.delete(...)
@@ -5254,7 +5695,7 @@ client.pronunciation_dictionary.remove_rules(
-Get metadata for a pronunciation dictionary +Delete Phone Number by ID
@@ -5274,8 +5715,8 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.pronunciation_dictionary.get( - pronunciation_dictionary_id="21m00Tcm4TlvDq8ikWAM", +client.conversational_ai.phone_numbers.delete( + phone_number_id="TeaqRRdTcIfIu2i7BYfT", ) ``` @@ -5292,7 +5733,7 @@ client.pronunciation_dictionary.get(
-**pronunciation_dictionary_id:** `str` — The id of the pronunciation dictionary +**phone_number_id:** `str` — The id of an agent. This is returned on agent creation.
@@ -5312,7 +5753,7 @@ client.pronunciation_dictionary.get(
-
client.pronunciation_dictionary.get_all(...) +
client.conversational_ai.phone_numbers.update(...)
@@ -5324,7 +5765,7 @@ client.pronunciation_dictionary.get(
-Get a list of the pronunciation dictionaries you have access to and their metadata +Update Phone Number details by ID
@@ -5344,7 +5785,9 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.pronunciation_dictionary.get_all() +client.conversational_ai.phone_numbers.update( + phone_number_id="TeaqRRdTcIfIu2i7BYfT", +) ``` @@ -5360,23 +5803,7 @@ client.pronunciation_dictionary.get_all()
-**cursor:** `typing.Optional[str]` — Used for fetching next page. Cursor is returned in the response. - -
-
- -
-
- -**page_size:** `typing.Optional[int]` — How many pronunciation dictionaries to return at maximum. Can not exceed 100, defaults to 30. - -
-
- -
-
- -**sort:** `typing.Optional[PronunciationDictionaryGetAllRequestSort]` — Which field to sort by, one of 'created_at_unix' or 'name'. +**phone_number_id:** `str` — The id of an agent. This is returned on agent creation.
@@ -5384,7 +5811,7 @@ client.pronunciation_dictionary.get_all()
-**sort_direction:** `typing.Optional[str]` — Which direction to sort the voices in. 'ascending' or 'descending'. +**agent_id:** `typing.Optional[str]`
@@ -5404,8 +5831,7 @@ client.pronunciation_dictionary.get_all()
-## Workspace -
client.workspace.search_user_groups(...) +
client.conversational_ai.phone_numbers.list()
@@ -5417,7 +5843,7 @@ client.pronunciation_dictionary.get_all()
-Searches for user groups in the workspace. Multiple or no groups may be returned. +Retrieve all Phone Numbers
@@ -5437,9 +5863,7 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.workspace.search_user_groups( - name="name", -) +client.conversational_ai.phone_numbers.list() ``` @@ -5455,14 +5879,6 @@ client.workspace.search_user_groups(
-**name:** `str` — Name of the target group. - -
-
- -
-
- **request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration.
@@ -5475,7 +5891,8 @@ client.workspace.search_user_groups(
-
client.workspace.delete_member_from_user_group(...) +## ConversationalAi KnowledgeBase +
client.conversational_ai.knowledge_base.list(...)
@@ -5487,7 +5904,7 @@ client.workspace.search_user_groups(
-Removes a member from the specified group. This endpoint may only be called by workspace administrators. +Get a list of available knowledge base documents
@@ -5507,10 +5924,7 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.workspace.delete_member_from_user_group( - group_id="group_id", - email="email", -) +client.conversational_ai.knowledge_base.list() ``` @@ -5526,7 +5940,7 @@ client.workspace.delete_member_from_user_group(
-**group_id:** `str` — The ID of the target group. +**cursor:** `typing.Optional[str]` — Used for fetching next page. Cursor is returned in the response.
@@ -5534,7 +5948,7 @@ client.workspace.delete_member_from_user_group(
-**email:** `str` — The email of the target workspace member. +**page_size:** `typing.Optional[int]` — How many documents to return at maximum. Can not exceed 100, defaults to 30.
@@ -5542,70 +5956,27 @@ client.workspace.delete_member_from_user_group(
-**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. +**search:** `typing.Optional[str]` — If specified, the endpoint returns only such knowledge base documents whose names start with this string.
- -
- - - - -
- -
client.workspace.add_member_to_user_group(...) -
-
- -#### 📝 Description - -
-
- -
-
- -Adds a member of your workspace to the specified group. This endpoint may only be called by workspace administrators. -
-
-
-
- -#### 🔌 Usage - -
-
-```python -from elevenlabs import ElevenLabs - -client = ElevenLabs( - api_key="YOUR_API_KEY", -) -client.workspace.add_member_to_user_group( - group_id="group_id", - email="email", -) - -``` -
-
+**show_only_owned_documents:** `typing.Optional[bool]` — If set to true, the endpoint will return only documents owned by you (and not shared from somebody else). +
-#### ⚙️ Parameters - -
-
-
-**group_id:** `str` — The ID of the target group. +**types:** `typing.Optional[ + typing.Union[ + KnowledgeBaseDocumentType, typing.Sequence[KnowledgeBaseDocumentType] + ] +]` — If present, the endpoint will return only documents of the given types.
@@ -5613,7 +5984,7 @@ client.workspace.add_member_to_user_group(
-**email:** `str` — The email of the target workspace member. +**use_typesense:** `typing.Optional[bool]` — If set to true, the endpoint will use typesense DB to search for the documents).
@@ -5633,7 +6004,8 @@ client.workspace.add_member_to_user_group(
-
client.workspace.invite_user(...) +## ConversationalAi Settings +
client.conversational_ai.settings.get()
@@ -5645,7 +6017,7 @@ client.workspace.add_member_to_user_group(
-Sends an email invitation to join your workspace to the provided email. If the user doesn't have an account they will be prompted to create one. If the user accepts this invite they will be added as a user to your workspace and your subscription using one of your seats. This endpoint may only be called by workspace administrators. If the user is already in the workspace a 400 error will be returned. +Retrieve Convai settings for the workspace
@@ -5665,9 +6037,7 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.workspace.invite_user( - email="john.doe@testmail.com", -) +client.conversational_ai.settings.get() ``` @@ -5683,30 +6053,6 @@ client.workspace.invite_user(
-**email:** `str` — The email of the customer - -
-
- -
-
- -**group_ids:** `typing.Optional[typing.Sequence[str]]` — The group ids of the user - -
-
- -
-
- -**workspace_permission:** `typing.Optional[BodyInviteUserV1WorkspaceInvitesAddPostWorkspacePermission]` — The workspace permission of the user - -
-
- -
-
- **request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration.
@@ -5719,7 +6065,7 @@ client.workspace.invite_user(
-
client.workspace.invite_multiple_users(...) +
client.conversational_ai.settings.update(...)
@@ -5731,7 +6077,7 @@ client.workspace.invite_user(
-Sends email invitations to join your workspace to the provided emails. Requires all email addresses to be part of a verified domain. If the users don't have an account they will be prompted to create one. If the users accept these invites they will be added as users to your workspace and your subscription using one of your seats. This endpoint may only be called by workspace administrators. +Update Convai settings for the workspace
@@ -5751,25 +6097,39 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.workspace.invite_multiple_users( - emails=["emails"], -) +client.conversational_ai.settings.update() + +``` + +
+ + + +#### ⚙️ Parameters + +
+
-``` -
-
+
+
+ +**conversation_initiation_client_data_webhook:** `typing.Optional[ConversationInitiationClientDataWebhook]` +
-#### ⚙️ Parameters -
+**webhooks:** `typing.Optional[ConvAiWebhooks]` + +
+
+
-**emails:** `typing.Sequence[str]` — The email of the customer +**can_use_mcp_servers:** `typing.Optional[bool]` — Whether the workspace can use MCP servers
@@ -5777,7 +6137,7 @@ client.workspace.invite_multiple_users(
-**group_ids:** `typing.Optional[typing.Sequence[str]]` — The group ids of the user +**rag_retention_period_days:** `typing.Optional[int]`
@@ -5797,7 +6157,8 @@ client.workspace.invite_multiple_users(
-
client.workspace.delete_existing_invitation(...) +## ConversationalAi Secrets +
client.conversational_ai.secrets.list()
@@ -5809,7 +6170,7 @@ client.workspace.invite_multiple_users(
-Invalidates an existing email invitation. The invitation will still show up in the inbox it has been delivered to, but activating it to join the workspace won't work. This endpoint may only be called by workspace administrators. +Get all workspace secrets for the user
@@ -5829,9 +6190,7 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.workspace.delete_existing_invitation( - email="john.doe@testmail.com", -) +client.conversational_ai.secrets.list() ``` @@ -5847,14 +6206,6 @@ client.workspace.delete_existing_invitation(
-**email:** `str` — The email of the customer - -
-
- -
-
- **request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration.
@@ -5867,7 +6218,7 @@ client.workspace.delete_existing_invitation(
-
client.workspace.update_member(...) +
client.conversational_ai.secrets.create(...)
@@ -5879,7 +6230,7 @@ client.workspace.delete_existing_invitation(
-Updates attributes of a workspace member. Apart from the email identifier, all parameters will remain unchanged unless specified. This endpoint may only be called by workspace administrators. +Create a new secret for the workspace
@@ -5899,8 +6250,9 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.workspace.update_member( - email="email", +client.conversational_ai.secrets.create( + name="name", + value="value", ) ``` @@ -5917,15 +6269,7 @@ client.workspace.update_member(
-**email:** `str` — Email of the target user. - -
-
- -
-
- -**is_locked:** `typing.Optional[bool]` — Whether to lock or unlock the user account. +**name:** `str`
@@ -5933,7 +6277,7 @@ client.workspace.update_member(
-**workspace_role:** `typing.Optional[BodyUpdateMemberV1WorkspaceMembersPostWorkspaceRole]` — Role dictating permissions in the workspace. +**value:** `str`
@@ -5953,7 +6297,7 @@ client.workspace.update_member(
-
client.workspace.delete_member(...) +
client.conversational_ai.secrets.delete(...)
@@ -5965,7 +6309,7 @@ client.workspace.update_member(
-Deletes a workspace member. This endpoint may only be called by workspace administrators. +Delete a workspace secret if it's not in use
@@ -5985,8 +6329,8 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.workspace.delete_member( - email="email", +client.conversational_ai.secrets.delete( + secret_id="secret_id", ) ``` @@ -6003,7 +6347,7 @@ client.workspace.delete_member(
-**email:** `str` — Email of the target user. +**secret_id:** `str`
@@ -6023,7 +6367,8 @@ client.workspace.delete_member(
-
client.workspace.get_resource(...) +## ConversationalAi BatchCalls +
client.conversational_ai.batch_calls.create(...)
@@ -6035,7 +6380,7 @@ client.workspace.delete_member(
-Gets the metadata of a resource by ID. +Submit a batch call request to schedule calls for multiple recipients.
@@ -6050,14 +6395,20 @@ Gets the metadata of a resource by ID.
```python -from elevenlabs import ElevenLabs +from elevenlabs import ElevenLabs, OutboundCallRecipient client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.workspace.get_resource( - resource_id="resource_id", - resource_type="voice", +client.conversational_ai.batch_calls.create( + call_name="call_name", + agent_id="agent_id", + agent_phone_number_id="agent_phone_number_id", + recipients=[ + OutboundCallRecipient( + phone_number="phone_number", + ) + ], ) ``` @@ -6074,7 +6425,7 @@ client.workspace.get_resource(
-**resource_id:** `str` — The ID of the target resource. +**call_name:** `str`
@@ -6082,7 +6433,31 @@ client.workspace.get_resource(
-**resource_type:** `WorkspaceResourceType` — Resource type of the target resource. +**agent_id:** `str` + +
+
+ +
+
+ +**agent_phone_number_id:** `str` + +
+
+ +
+
+ +**recipients:** `typing.Sequence[OutboundCallRecipient]` + +
+
+ +
+
+ +**scheduled_time_unix:** `typing.Optional[int]`
@@ -6102,7 +6477,7 @@ client.workspace.get_resource(
-
client.workspace.share_workspace_resource(...) +
client.conversational_ai.batch_calls.list(...)
@@ -6114,7 +6489,7 @@ client.workspace.get_resource(
-Grants a role on a workspace resource to a user or a group. It overrides any existing role this user/service account/group/workspace api key has on the resource. To target a user or service account, pass only the user email. The user must be in your workspace. To target a group, pass only the group id. To target a workspace api key, pass the api key id. The resource will be shared with the service account associated with the api key. You must have admin access to the resource to share it. +Get all batch calls for the current workspace.
@@ -6134,11 +6509,7 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.workspace.share_workspace_resource( - resource_id="resource_id", - role="admin", - resource_type="voice", -) +client.conversational_ai.batch_calls.list() ``` @@ -6154,39 +6525,7 @@ client.workspace.share_workspace_resource(
-**resource_id:** `str` — The ID of the target resource. - -
-
- -
-
- -**role:** `BodyShareWorkspaceResourceV1WorkspaceResourcesResourceIdSharePostRole` — Role to update the target principal with. - -
-
- -
-
- -**resource_type:** `WorkspaceResourceType` — Resource type of the target resource. - -
-
- -
-
- -**user_email:** `typing.Optional[str]` — The email of the user or service account. - -
-
- -
-
- -**group_id:** `typing.Optional[str]` — The ID of the target group. To target the permissions principals have by default on this resource, use the value 'default'. +**limit:** `typing.Optional[int]`
@@ -6194,7 +6533,7 @@ client.workspace.share_workspace_resource(
-**workspace_api_key_id:** `typing.Optional[str]` — The ID of the target workspace API key. This isn't the same as the key itself that would you pass in the header for authentication. Workspace admins can find this in the workspace settings UI. +**last_doc:** `typing.Optional[str]`
@@ -6214,7 +6553,7 @@ client.workspace.share_workspace_resource(
-
client.workspace.unshare_workspace_resource(...) +
client.conversational_ai.batch_calls.get(...)
@@ -6226,7 +6565,7 @@ client.workspace.share_workspace_resource(
-Removes any existing role on a workspace resource from a user, service account, group or workspace api key. To target a user or service account, pass only the user email. The user must be in your workspace. To target a group, pass only the group id. To target a workspace api key, pass the api key id. The resource will be unshared from the service account associated with the api key. You must have admin access to the resource to unshare it. You cannot remove permissions from the user who created the resource. +Get detailed information about a batch call including all recipients.
@@ -6246,9 +6585,8 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.workspace.unshare_workspace_resource( - resource_id="resource_id", - resource_type="voice", +client.conversational_ai.batch_calls.get( + batch_id="batch_id", ) ``` @@ -6265,39 +6603,7 @@ client.workspace.unshare_workspace_resource(
-**resource_id:** `str` — The ID of the target resource. - -
-
- -
-
- -**resource_type:** `WorkspaceResourceType` — Resource type of the target resource. - -
-
- -
-
- -**user_email:** `typing.Optional[str]` — The email of the user or service account. - -
-
- -
-
- -**group_id:** `typing.Optional[str]` — The ID of the target group. To target the permissions principals have by default on this resource, use the value 'default'. - -
-
- -
-
- -**workspace_api_key_id:** `typing.Optional[str]` — The ID of the target workspace API key. This isn't the same as the key itself that would you pass in the header for authentication. Workspace admins can find this in the workspace settings UI. +**batch_id:** `str`
@@ -6317,8 +6623,8 @@ client.workspace.unshare_workspace_resource(
-## SpeechToText -
client.speech_to_text.convert(...) +## ConversationalAi SipTrunk +
client.conversational_ai.sip_trunk.outbound_call(...)
@@ -6330,7 +6636,7 @@ client.workspace.unshare_workspace_resource(
-Transcribe an audio or video file. +Handle an outbound call via SIP trunk
@@ -6350,8 +6656,10 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.speech_to_text.convert( - model_id="model_id", +client.conversational_ai.sip_trunk.outbound_call( + agent_id="agent_id", + agent_phone_number_id="agent_phone_number_id", + to_number="to_number", ) ``` @@ -6368,7 +6676,7 @@ client.speech_to_text.convert(
-**model_id:** `str` — The ID of the model to use for transcription, currently only 'scribe_v1' and 'scribe_v1_experimental' are available. +**agent_id:** `str`
@@ -6376,7 +6684,7 @@ client.speech_to_text.convert(
-**enable_logging:** `typing.Optional[bool]` — When enable_logging is set to false zero retention mode will be used for the request. This will mean history features are unavailable for this request, including request stitching. Zero retention mode may only be used by enterprise customers. +**agent_phone_number_id:** `str`
@@ -6384,9 +6692,7 @@ client.speech_to_text.convert(
-**file:** `from __future__ import annotations - -typing.Optional[core.File]` — See core.File for more documentation +**to_number:** `str`
@@ -6394,7 +6700,7 @@ typing.Optional[core.File]` — See core.File for more documentation
-**language_code:** `typing.Optional[str]` — An ISO-639-1 or ISO-639-3 language_code corresponding to the language of the audio file. Can sometimes improve transcription performance if known beforehand. Defaults to null, in this case the language is predicted automatically. +**conversation_initiation_client_data:** `typing.Optional[ConversationInitiationClientDataRequestInput]`
@@ -6402,47 +6708,70 @@ typing.Optional[core.File]` — See core.File for more documentation
-**tag_audio_events:** `typing.Optional[bool]` — Whether to tag audio events like (laughter), (footsteps), etc. in the transcription. +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration.
+ +
-
-
-**num_speakers:** `typing.Optional[int]` — The maximum amount of speakers talking in the uploaded file. Can help with predicting who speaks when. The maximum amount of speakers that can be predicted is 32. Defaults to null, in this case the amount of speakers is set to the maximum value the model supports. -
+
+## ConversationalAi Agents Widget +
client.conversational_ai.agents.widget.get(...)
-**timestamps_granularity:** `typing.Optional[SpeechToTextConvertRequestTimestampsGranularity]` — The granularity of the timestamps in the transcription. 'word' provides word-level timestamps and 'character' provides character-level timestamps per word. - -
-
+#### 📝 Description
-**diarize:** `typing.Optional[bool]` — Whether to annotate which speaker is currently talking in the uploaded file. - +
+
+ +Retrieve the widget configuration for an agent +
+
+#### 🔌 Usage +
-**additional_formats:** `typing.Optional[AdditionalFormats]` — A list of additional formats to export the transcript to. - +
+
+ +```python +from elevenlabs import ElevenLabs + +client = ElevenLabs( + api_key="YOUR_API_KEY", +) +client.conversational_ai.agents.widget.get( + agent_id="21m00Tcm4TlvDq8ikWAM", +) + +``` +
+
+#### ⚙️ Parameters +
-**file_format:** `typing.Optional[SpeechToTextConvertRequestFileFormat]` — The format of input audio. Options are 'pcm_s16le_16' or 'other' For `pcm_s16le_16`, the input audio must be 16-bit PCM at a 16kHz sample rate, single channel (mono), and little-endian byte order. Latency will be lower than with passing an encoded waveform. +
+
+ +**agent_id:** `str` — The id of an agent. This is returned on agent creation.
@@ -6450,7 +6779,7 @@ typing.Optional[core.File]` — See core.File for more documentation
-**cloud_storage_url:** `typing.Optional[str]` — The valid AWS S3, Cloudflare R2 or Google Cloud Storage URL of the file to transcribe. Exactly one of the file or cloud_storage_url parameters must be provided. The file must be a valid publicly accessible cloud storage URL. The file size must be less than 2GB. URL can be pre-signed. +**conversation_signature:** `typing.Optional[str]` — An expiring token that enables a websocket conversation to start. These can be generated for an agent using the /v1/convai/conversation/get-signed-url endpoint
@@ -6470,8 +6799,8 @@ typing.Optional[core.File]` — See core.File for more documentation
-## ForcedAlignment -
client.forced_alignment.create(...) +## ConversationalAi Agents Link +
client.conversational_ai.agents.link.get(...)
@@ -6483,7 +6812,7 @@ typing.Optional[core.File]` — See core.File for more documentation
-Force align an audio file to text. Use this endpoint to get the timing information for each character and word in an audio file based on a provided text transcript. +Get the current link used to share the agent with others
@@ -6503,8 +6832,8 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.forced_alignment.create( - text="text", +client.conversational_ai.agents.link.get( + agent_id="21m00Tcm4TlvDq8ikWAM", ) ``` @@ -6521,25 +6850,7 @@ client.forced_alignment.create(
-**file:** `from __future__ import annotations - -core.File` — See core.File for more documentation - -
-
- -
-
- -**text:** `str` — The text to align with the audio. The input text can be in any format, however diarization is not supported at this time. - -
-
- -
-
- -**enabled_spooled_file:** `typing.Optional[bool]` — If true, the file will be streamed to the server and processed in chunks. This is useful for large files that cannot be loaded into memory. The default is false. +**agent_id:** `str` — The id of an agent. This is returned on agent creation.
@@ -6559,8 +6870,8 @@ core.File` — See core.File for more documentation
-## ConversationalAi -
client.conversational_ai.get_signed_url(...) +## ConversationalAi Agents Widget Avatar +
client.conversational_ai.agents.widget.avatar.create(...)
@@ -6572,7 +6883,7 @@ core.File` — See core.File for more documentation
-Get a signed url to start a conversation with an agent with an agent that requires authorization +Sets the avatar for an agent displayed in the widget
@@ -6592,7 +6903,7 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.conversational_ai.get_signed_url( +client.conversational_ai.agents.widget.avatar.create( agent_id="21m00Tcm4TlvDq8ikWAM", ) @@ -6610,7 +6921,17 @@ client.conversational_ai.get_signed_url(
-**agent_id:** `str` — The id of the agent you're taking the action on. +**agent_id:** `str` — The id of an agent. This is returned on agent creation. + +
+
+ +
+
+ +**avatar_file:** `from __future__ import annotations + +core.File` — See core.File for more documentation
@@ -6630,7 +6951,9 @@ client.conversational_ai.get_signed_url(
-
client.conversational_ai.twilio_outbound_call(...) +## ConversationalAi Conversations Audio +## ConversationalAi Conversations Feedback +
client.conversational_ai.conversations.feedback.create(...)
@@ -6642,7 +6965,7 @@ client.conversational_ai.get_signed_url(
-Handle an outbound call via Twilio +Send the feedback for the given conversation
@@ -6662,10 +6985,9 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.conversational_ai.twilio_outbound_call( - agent_id="agent_id", - agent_phone_number_id="agent_phone_number_id", - to_number="to_number", +client.conversational_ai.conversations.feedback.create( + conversation_id="21m00Tcm4TlvDq8ikWAM", + feedback="like", ) ``` @@ -6682,23 +7004,7 @@ client.conversational_ai.twilio_outbound_call(
-**agent_id:** `str` - -
-
- -
-
- -**agent_phone_number_id:** `str` - -
-
- -
-
- -**to_number:** `str` +**conversation_id:** `str` — The id of the conversation you're taking the action on.
@@ -6706,7 +7012,7 @@ client.conversational_ai.twilio_outbound_call(
-**conversation_initiation_client_data:** `typing.Optional[ConversationInitiationClientDataRequestInput]` +**feedback:** `UserFeedbackScore` — Either 'like' or 'dislike' to indicate the feedback for the conversation.
@@ -6726,7 +7032,8 @@ client.conversational_ai.twilio_outbound_call(
-
client.conversational_ai.create_agent(...) +## ConversationalAi Dashboard Settings +
client.conversational_ai.dashboard.settings.get()
@@ -6738,7 +7045,7 @@ client.conversational_ai.twilio_outbound_call(
-Create an agent from a config object +Retrieve Convai dashboard settings for the workspace
@@ -6753,14 +7060,12 @@ Create an agent from a config object
```python -from elevenlabs import ConversationalConfig, ElevenLabs +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.conversational_ai.create_agent( - conversation_config=ConversationalConfig(), -) +client.conversational_ai.dashboard.settings.get() ```
@@ -6776,31 +7081,67 @@ client.conversational_ai.create_agent(
-**conversation_config:** `ConversationalConfig` — Conversation configuration for an agent +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration.
+ +
+ + + + +
+
client.conversational_ai.dashboard.settings.update(...)
-**platform_settings:** `typing.Optional[AgentPlatformSettingsRequestModel]` — Platform settings for the agent are all settings that aren't related to the conversation orchestration and content. - +#### 📝 Description + +
+
+ +
+
+ +Update Convai dashboard settings for the workspace +
+
+#### 🔌 Usage +
-**name:** `typing.Optional[str]` — A name to make the agent easier to find - +
+
+ +```python +from elevenlabs import ElevenLabs + +client = ElevenLabs( + api_key="YOUR_API_KEY", +) +client.conversational_ai.dashboard.settings.update() + +```
+
+
+ +#### ⚙️ Parameters
-**tags:** `typing.Optional[typing.Sequence[str]]` — Tags to help classify and filter the agent +
+
+ +**charts:** `typing.Optional[typing.Sequence[PatchConvAiDashboardSettingsRequestChartsItem]]`
@@ -6820,7 +7161,8 @@ client.conversational_ai.create_agent(
-
client.conversational_ai.get_agent(...) +## ConversationalAi KnowledgeBase Documents +
client.conversational_ai.knowledge_base.documents.create_from_url(...)
@@ -6832,7 +7174,7 @@ client.conversational_ai.create_agent(
-Retrieve config for an agent +Create a knowledge base document generated by scraping the given webpage.
@@ -6852,8 +7194,8 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.conversational_ai.get_agent( - agent_id="21m00Tcm4TlvDq8ikWAM", +client.conversational_ai.knowledge_base.documents.create_from_url( + url="url", ) ``` @@ -6870,7 +7212,15 @@ client.conversational_ai.get_agent(
-**agent_id:** `str` — The id of an agent. This is returned on agent creation. +**url:** `str` — URL to a page of documentation that the agent will have access to in order to interact with users. + +
+
+ +
+
+ +**name:** `typing.Optional[str]` — A custom, human-readable name for the document.
@@ -6890,7 +7240,7 @@ client.conversational_ai.get_agent(
-
client.conversational_ai.delete_agent(...) +
client.conversational_ai.knowledge_base.documents.create_from_file(...)
@@ -6902,7 +7252,7 @@ client.conversational_ai.get_agent(
-Delete an agent +Create a knowledge base document generated form the uploaded file.
@@ -6922,9 +7272,7 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.conversational_ai.delete_agent( - agent_id="21m00Tcm4TlvDq8ikWAM", -) +client.conversational_ai.knowledge_base.documents.create_from_file() ``` @@ -6940,7 +7288,17 @@ client.conversational_ai.delete_agent(
-**agent_id:** `str` — The id of an agent. This is returned on agent creation. +**file:** `from __future__ import annotations + +core.File` — See core.File for more documentation + +
+
+ +
+
+ +**name:** `typing.Optional[str]` — A custom, human-readable name for the document.
@@ -6960,7 +7318,7 @@ client.conversational_ai.delete_agent(
-
client.conversational_ai.update_agent(...) +
client.conversational_ai.knowledge_base.documents.create_from_text(...)
@@ -6972,7 +7330,7 @@ client.conversational_ai.delete_agent(
-Patches an Agent settings +Create a knowledge base document containing the provided text.
@@ -6992,8 +7350,8 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.conversational_ai.update_agent( - agent_id="21m00Tcm4TlvDq8ikWAM", +client.conversational_ai.knowledge_base.documents.create_from_text( + text="text", ) ``` @@ -7010,31 +7368,7 @@ client.conversational_ai.update_agent(
-**agent_id:** `str` — The id of an agent. This is returned on agent creation. - -
-
- -
-
- -**conversation_config:** `typing.Optional[typing.Optional[typing.Any]]` - -
-
- -
-
- -**platform_settings:** `typing.Optional[typing.Optional[typing.Any]]` - -
-
- -
-
- -**name:** `typing.Optional[str]` — A name to make the agent easier to find +**text:** `str` — Text content to be added to the knowledge base.
@@ -7042,7 +7376,7 @@ client.conversational_ai.update_agent(
-**tags:** `typing.Optional[typing.Sequence[str]]` — Tags to help classify and filter the agent +**name:** `typing.Optional[str]` — A custom, human-readable name for the document.
@@ -7062,7 +7396,7 @@ client.conversational_ai.update_agent(
-
client.conversational_ai.get_agent_widget(...) +
client.conversational_ai.knowledge_base.documents.get(...)
@@ -7074,7 +7408,7 @@ client.conversational_ai.update_agent(
-Retrieve the widget configuration for an agent +Get details about a specific documentation making up the agent's knowledge base
@@ -7094,8 +7428,8 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.conversational_ai.get_agent_widget( - agent_id="21m00Tcm4TlvDq8ikWAM", +client.conversational_ai.knowledge_base.documents.get( + documentation_id="21m00Tcm4TlvDq8ikWAM", ) ``` @@ -7112,15 +7446,7 @@ client.conversational_ai.get_agent_widget(
-**agent_id:** `str` — The id of an agent. This is returned on agent creation. - -
-
- -
-
- -**conversation_signature:** `typing.Optional[str]` — An expiring token that enables a websocket conversation to start. These can be generated for an agent using the /v1/convai/conversation/get-signed-url endpoint +**documentation_id:** `str` — The id of a document from the knowledge base. This is returned on document addition.
@@ -7140,7 +7466,7 @@ client.conversational_ai.get_agent_widget(
-
client.conversational_ai.get_agent_link(...) +
client.conversational_ai.knowledge_base.documents.delete(...)
@@ -7152,7 +7478,7 @@ client.conversational_ai.get_agent_widget(
-Get the current link used to share the agent with others +Delete a document from the knowledge base
@@ -7172,8 +7498,8 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.conversational_ai.get_agent_link( - agent_id="21m00Tcm4TlvDq8ikWAM", +client.conversational_ai.knowledge_base.documents.delete( + documentation_id="21m00Tcm4TlvDq8ikWAM", ) ``` @@ -7190,7 +7516,7 @@ client.conversational_ai.get_agent_link(
-**agent_id:** `str` — The id of an agent. This is returned on agent creation. +**documentation_id:** `str` — The id of a document from the knowledge base. This is returned on document addition.
@@ -7210,7 +7536,7 @@ client.conversational_ai.get_agent_link(
-
client.conversational_ai.post_agent_avatar(...) +
client.conversational_ai.knowledge_base.documents.update(...)
@@ -7222,7 +7548,7 @@ client.conversational_ai.get_agent_link(
-Sets the avatar for an agent displayed in the widget +Update the name of a document
@@ -7242,8 +7568,9 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.conversational_ai.post_agent_avatar( - agent_id="21m00Tcm4TlvDq8ikWAM", +client.conversational_ai.knowledge_base.documents.update( + documentation_id="21m00Tcm4TlvDq8ikWAM", + name="name", ) ``` @@ -7260,7 +7587,7 @@ client.conversational_ai.post_agent_avatar(
-**agent_id:** `str` — The id of an agent. This is returned on agent creation. +**documentation_id:** `str` — The id of a document from the knowledge base. This is returned on document addition.
@@ -7268,9 +7595,7 @@ client.conversational_ai.post_agent_avatar(
-**avatar_file:** `from __future__ import annotations - -core.File` — See core.File for more documentation +**name:** `str` — A custom, human-readable name for the document.
@@ -7290,7 +7615,7 @@ core.File` — See core.File for more documentation
-
client.conversational_ai.get_agents(...) +
client.conversational_ai.knowledge_base.documents.get_agents(...)
@@ -7302,7 +7627,7 @@ core.File` — See core.File for more documentation
-Returns a list of your agents and their metadata. +Get a list of agents depending on this knowledge base document
@@ -7322,7 +7647,9 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.conversational_ai.get_agents() +client.conversational_ai.knowledge_base.documents.get_agents( + documentation_id="21m00Tcm4TlvDq8ikWAM", +) ``` @@ -7338,7 +7665,7 @@ client.conversational_ai.get_agents()
-**cursor:** `typing.Optional[str]` — Used for fetching next page. Cursor is returned in the response. +**documentation_id:** `str` — The id of a document from the knowledge base. This is returned on document addition.
@@ -7346,7 +7673,7 @@ client.conversational_ai.get_agents()
-**page_size:** `typing.Optional[int]` — How many Agents to return at maximum. Can not exceed 100, defaults to 30. +**cursor:** `typing.Optional[str]` — Used for fetching next page. Cursor is returned in the response.
@@ -7354,7 +7681,7 @@ client.conversational_ai.get_agents()
-**search:** `typing.Optional[str]` — Search by agents name. +**page_size:** `typing.Optional[int]` — How many documents to return at maximum. Can not exceed 100, defaults to 30.
@@ -7374,7 +7701,7 @@ client.conversational_ai.get_agents()
-
client.conversational_ai.get_conversations(...) +
client.conversational_ai.knowledge_base.documents.get_content(...)
@@ -7386,7 +7713,7 @@ client.conversational_ai.get_agents()
-Get all conversations of agents that user owns. With option to restrict to a specific agent. +Get the entire content of a document from the knowledge base
@@ -7406,7 +7733,9 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.conversational_ai.get_conversations() +client.conversational_ai.knowledge_base.documents.get_content( + documentation_id="21m00Tcm4TlvDq8ikWAM", +) ``` @@ -7422,7 +7751,7 @@ client.conversational_ai.get_conversations()
-**cursor:** `typing.Optional[str]` — Used for fetching next page. Cursor is returned in the response. +**documentation_id:** `str` — The id of a document from the knowledge base. This is returned on document addition.
@@ -7430,31 +7759,71 @@ client.conversational_ai.get_conversations()
-**agent_id:** `typing.Optional[str]` — The id of the agent you're taking the action on. +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration.
+ +
+ + + + +
+## ConversationalAi KnowledgeBase Document +
client.conversational_ai.knowledge_base.document.compute_rag_index(...)
-**call_successful:** `typing.Optional[EvaluationSuccessResult]` — The result of the success evaluation - +#### 📝 Description + +
+
+ +
+
+ +In case the document is not RAG indexed, it triggers rag indexing task, otherwise it just returns the current status.
+
+
+ +#### 🔌 Usage
-**call_start_before_unix:** `typing.Optional[int]` — Unix timestamp (in seconds) to filter conversations up to this start date. - +
+
+ +```python +from elevenlabs import ElevenLabs + +client = ElevenLabs( + api_key="YOUR_API_KEY", +) +client.conversational_ai.knowledge_base.document.compute_rag_index( + documentation_id="21m00Tcm4TlvDq8ikWAM", + model="e5_mistral_7b_instruct", +) + +``` +
+
+#### ⚙️ Parameters +
-**call_start_after_unix:** `typing.Optional[int]` — Unix timestamp (in seconds) to filter conversations after to this start date. +
+
+ +**documentation_id:** `str` — The id of a document from the knowledge base. This is returned on document addition.
@@ -7462,7 +7831,7 @@ client.conversational_ai.get_conversations()
-**page_size:** `typing.Optional[int]` — How many conversations to return at maximum. Can not exceed 100, defaults to 30. +**model:** `EmbeddingModelEnum`
@@ -7482,7 +7851,8 @@ client.conversational_ai.get_conversations()
-
client.conversational_ai.get_conversation(...) +## ConversationalAi KnowledgeBase Documents Chunk +
client.conversational_ai.knowledge_base.documents.chunk.get(...)
@@ -7494,7 +7864,7 @@ client.conversational_ai.get_conversations()
-Get the details of a particular conversation +Get details about a specific documentation part used by RAG.
@@ -7514,8 +7884,9 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.conversational_ai.get_conversation( - conversation_id="123", +client.conversational_ai.knowledge_base.documents.chunk.get( + documentation_id="21m00Tcm4TlvDq8ikWAM", + chunk_id="chunk_id", ) ``` @@ -7532,7 +7903,15 @@ client.conversational_ai.get_conversation(
-**conversation_id:** `str` — The id of the conversation you're taking the action on. +**documentation_id:** `str` — The id of a document from the knowledge base. This is returned on document addition. + +
+
+ +
+
+ +**chunk_id:** `str` — The id of a document RAG chunk from the knowledge base.
@@ -7552,7 +7931,8 @@ client.conversational_ai.get_conversation(
-
client.conversational_ai.delete_conversation(...) +## Dubbing Resource +
client.dubbing.resource.get(...)
@@ -7564,7 +7944,7 @@ client.conversational_ai.get_conversation(
-Delete a particular conversation +Given a dubbing ID generated from the '/v1/dubbing' endpoint with studio enabled, returns the dubbing resource.
@@ -7584,8 +7964,8 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.conversational_ai.delete_conversation( - conversation_id="21m00Tcm4TlvDq8ikWAM", +client.dubbing.resource.get( + dubbing_id="dubbing_id", ) ``` @@ -7602,7 +7982,7 @@ client.conversational_ai.delete_conversation(
-**conversation_id:** `str` — The id of the conversation you're taking the action on. +**dubbing_id:** `str` — ID of the dubbing project.
@@ -7622,7 +8002,7 @@ client.conversational_ai.delete_conversation(
-
client.conversational_ai.post_conversation_feedback(...) +
client.dubbing.resource.transcribe(...)
@@ -7634,7 +8014,7 @@ client.conversational_ai.delete_conversation(
-Send the feedback for the given conversation +Regenerate the transcriptions for the specified segments. Does not automatically regenerate translations or dubs.
@@ -7654,9 +8034,9 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.conversational_ai.post_conversation_feedback( - conversation_id="21m00Tcm4TlvDq8ikWAM", - feedback="like", +client.dubbing.resource.transcribe( + dubbing_id="dubbing_id", + segments=["segments"], ) ``` @@ -7673,7 +8053,7 @@ client.conversational_ai.post_conversation_feedback(
-**conversation_id:** `str` — The id of the conversation you're taking the action on. +**dubbing_id:** `str` — ID of the dubbing project.
@@ -7681,7 +8061,7 @@ client.conversational_ai.post_conversation_feedback(
-**feedback:** `UserFeedbackScore` — Either 'like' or 'dislike' to indicate the feedback for the conversation. +**segments:** `typing.Sequence[str]` — Transcribe this specific list of segments.
@@ -7701,7 +8081,7 @@ client.conversational_ai.post_conversation_feedback(
-
client.conversational_ai.create_phone_number(...) +
client.dubbing.resource.translate(...)
@@ -7713,7 +8093,7 @@ client.conversational_ai.post_conversation_feedback(
-Import Phone Number from provider configuration (Twilio or SIP trunk) +Regenerate the translations for either the entire resource or the specified segments/languages. Will automatically transcribe missing transcriptions. Will not automatically regenerate the dubs.
@@ -7729,20 +8109,13 @@ Import Phone Number from provider configuration (Twilio or SIP trunk) ```python from elevenlabs import ElevenLabs -from elevenlabs.conversational_ai import ( - ConversationalAiCreatePhoneNumberRequestBody_Twilio, -) client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.conversational_ai.create_phone_number( - request=ConversationalAiCreatePhoneNumberRequestBody_Twilio( - phone_number="phone_number", - label="label", - sid="sid", - token="token", - ), +client.dubbing.resource.translate( + dubbing_id="dubbing_id", + segments=["segments"], ) ``` @@ -7759,7 +8132,23 @@ client.conversational_ai.create_phone_number(
-**request:** `ConversationalAiCreatePhoneNumberRequestBody` +**dubbing_id:** `str` — ID of the dubbing project. + +
+
+ +
+
+ +**segments:** `typing.Sequence[str]` — Translate only this list of segments. + +
+
+ +
+
+ +**languages:** `typing.Optional[typing.Sequence[str]]` — Translate only these languages for each segment.
@@ -7779,7 +8168,7 @@ client.conversational_ai.create_phone_number(
-
client.conversational_ai.get_phone_number(...) +
client.dubbing.resource.dub(...)
@@ -7791,7 +8180,7 @@ client.conversational_ai.create_phone_number(
-Retrieve Phone Number details by ID +Regenerate the dubs for either the entire resource or the specified segments/languages. Will automatically transcribe and translate any missing transcriptions and translations.
@@ -7811,8 +8200,9 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.conversational_ai.get_phone_number( - phone_number_id="TeaqRRdTcIfIu2i7BYfT", +client.dubbing.resource.dub( + dubbing_id="dubbing_id", + segments=["segments"], ) ``` @@ -7829,7 +8219,23 @@ client.conversational_ai.get_phone_number(
-**phone_number_id:** `str` — The id of an agent. This is returned on agent creation. +**dubbing_id:** `str` — ID of the dubbing project. + +
+
+ +
+
+ +**segments:** `typing.Sequence[str]` — Dub only this list of segments. + +
+
+ +
+
+ +**languages:** `typing.Optional[typing.Sequence[str]]` — Dub only these languages for each segment.
@@ -7849,7 +8255,7 @@ client.conversational_ai.get_phone_number(
-
client.conversational_ai.delete_phone_number(...) +
client.dubbing.resource.render(...)
@@ -7861,7 +8267,7 @@ client.conversational_ai.get_phone_number(
-Delete Phone Number by ID +Regenerate the output media for a language using the latest Studio state. Please ensure all segments have been dubbed before rendering, otherwise they will be omitted. Renders are generated asynchronously, and to check the status of all renders please use the 'Get Dubbing Resource' endpoint.
@@ -7881,8 +8287,10 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.conversational_ai.delete_phone_number( - phone_number_id="TeaqRRdTcIfIu2i7BYfT", +client.dubbing.resource.render( + dubbing_id="dubbing_id", + language="language", + render_type="mp4", ) ``` @@ -7899,7 +8307,23 @@ client.conversational_ai.delete_phone_number(
-**phone_number_id:** `str` — The id of an agent. This is returned on agent creation. +**dubbing_id:** `str` — ID of the dubbing project. + +
+
+ +
+
+ +**language:** `str` — Render this language + +
+
+ +
+
+ +**render_type:** `RenderType` — The type of the render. One of ['mp4', 'aac', 'mp3', 'wav', 'aaf', 'tracks_zip', 'clips_zip']
@@ -7919,7 +8343,9 @@ client.conversational_ai.delete_phone_number(
-
client.conversational_ai.update_phone_number(...) +## Dubbing Audio +## Dubbing Transcript +
client.dubbing.transcript.get_transcript_for_dub(...)
@@ -7931,7 +8357,7 @@ client.conversational_ai.delete_phone_number(
-Update Phone Number details by ID +Returns transcript for the dub as an SRT or WEBVTT file.
@@ -7951,8 +8377,9 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.conversational_ai.update_phone_number( - phone_number_id="TeaqRRdTcIfIu2i7BYfT", +client.dubbing.transcript.get_transcript_for_dub( + dubbing_id="dubbing_id", + language_code="language_code", ) ``` @@ -7969,7 +8396,7 @@ client.conversational_ai.update_phone_number(
-**phone_number_id:** `str` — The id of an agent. This is returned on agent creation. +**dubbing_id:** `str` — ID of the dubbing project.
@@ -7977,7 +8404,15 @@ client.conversational_ai.update_phone_number(
-**agent_id:** `typing.Optional[str]` +**language_code:** `str` — ID of the language. + +
+
+ +
+
+ +**format_type:** `typing.Optional[TranscriptGetTranscriptForDubRequestFormatType]` — Format to use for the subtitle file, either 'srt' or 'webvtt'
@@ -7997,7 +8432,8 @@ client.conversational_ai.update_phone_number(
-
client.conversational_ai.get_phone_numbers() +## Dubbing Resource Language +
client.dubbing.resource.language.add(...)
@@ -8009,7 +8445,7 @@ client.conversational_ai.update_phone_number(
-Retrieve all Phone Numbers +Adds the given ElevenLab Turbo V2/V2.5 language code to the resource. Does not automatically generate transcripts/translations/audio.
@@ -8029,7 +8465,9 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.conversational_ai.get_phone_numbers() +client.dubbing.resource.language.add( + dubbing_id="dubbing_id", +) ``` @@ -8045,6 +8483,22 @@ client.conversational_ai.get_phone_numbers()
+**dubbing_id:** `str` — ID of the dubbing project. + +
+
+ +
+
+ +**language:** `typing.Optional[str]` — The Target language. + +
+
+ +
+
+ **request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration.
@@ -8057,7 +8511,8 @@ client.conversational_ai.get_phone_numbers()
-
client.conversational_ai.get_knowledge_base_list(...) +## Dubbing Resource Segment +
client.dubbing.resource.segment.update(...)
@@ -8069,7 +8524,7 @@ client.conversational_ai.get_phone_numbers()
-Get a list of available knowledge base documents +Modifies a single segment with new text and/or start/end times. Will update the values for only a specific language of a segment. Does not automatically regenerate the dub.
@@ -8089,7 +8544,11 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.conversational_ai.get_knowledge_base_list() +client.dubbing.resource.segment.update( + dubbing_id="dubbing_id", + segment_id="segment_id", + language="language", +) ``` @@ -8105,7 +8564,7 @@ client.conversational_ai.get_knowledge_base_list()
-**cursor:** `typing.Optional[str]` — Used for fetching next page. Cursor is returned in the response. +**dubbing_id:** `str` — ID of the dubbing project.
@@ -8113,7 +8572,7 @@ client.conversational_ai.get_knowledge_base_list()
-**page_size:** `typing.Optional[int]` — How many documents to return at maximum. Can not exceed 100, defaults to 30. +**segment_id:** `str` — ID of the segment
@@ -8121,7 +8580,7 @@ client.conversational_ai.get_knowledge_base_list()
-**search:** `typing.Optional[str]` — If specified, the endpoint returns only such knowledge base documents whose names start with this string. +**language:** `str` — ID of the language.
@@ -8129,7 +8588,7 @@ client.conversational_ai.get_knowledge_base_list()
-**show_only_owned_documents:** `typing.Optional[bool]` — If set to true, the endpoint will return only documents owned by you (and not shared from somebody else). +**start_time:** `typing.Optional[float]`
@@ -8137,11 +8596,7 @@ client.conversational_ai.get_knowledge_base_list()
-**types:** `typing.Optional[ - typing.Union[ - KnowledgeBaseDocumentType, typing.Sequence[KnowledgeBaseDocumentType] - ] -]` — If present, the endpoint will return only documents of the given types. +**end_time:** `typing.Optional[float]`
@@ -8149,7 +8604,7 @@ client.conversational_ai.get_knowledge_base_list()
-**use_typesense:** `typing.Optional[bool]` — If set to true, the endpoint will use typesense DB to search for the documents). +**text:** `typing.Optional[str]`
@@ -8169,7 +8624,7 @@ client.conversational_ai.get_knowledge_base_list()
-
client.conversational_ai.add_to_knowledge_base(...) +
client.dubbing.resource.segment.delete(...)
@@ -8181,7 +8636,7 @@ client.conversational_ai.get_knowledge_base_list()
-Upload a file or webpage URL to create a knowledge base document.
After creating the document, update the agent's knowledge base by calling [Update agent](/docs/conversational-ai/api-reference/agents/update-agent). +Deletes a single segment from the dubbing.
@@ -8201,7 +8656,10 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.conversational_ai.add_to_knowledge_base() +client.dubbing.resource.segment.delete( + dubbing_id="dubbing_id", + segment_id="segment_id", +) ``` @@ -8217,15 +8675,7 @@ client.conversational_ai.add_to_knowledge_base()
-**name:** `typing.Optional[str]` — A custom, human-readable name for the document. - -
-
- -
-
- -**url:** `typing.Optional[str]` — URL to a page of documentation that the agent will have access to in order to interact with users. +**dubbing_id:** `str` — ID of the dubbing project.
@@ -8233,9 +8683,7 @@ client.conversational_ai.add_to_knowledge_base()
-**file:** `from __future__ import annotations - -typing.Optional[core.File]` — See core.File for more documentation +**segment_id:** `str` — ID of the segment
@@ -8255,7 +8703,8 @@ typing.Optional[core.File]` — See core.File for more documentation
-
client.conversational_ai.create_knowledge_base_url_document(...) +## Dubbing Resource Speaker +
client.dubbing.resource.speaker.update(...)
@@ -8267,7 +8716,7 @@ typing.Optional[core.File]` — See core.File for more documentation
-Create a knowledge base document generated by scraping the given webpage. +Amend the metadata associated with a speaker, such as their voice. Both voice cloning and using voices from the ElevenLabs library are supported.
@@ -8287,8 +8736,9 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.conversational_ai.create_knowledge_base_url_document( - url="url", +client.dubbing.resource.speaker.update( + dubbing_id="dubbing_id", + speaker_id="speaker_id", ) ``` @@ -8305,85 +8755,23 @@ client.conversational_ai.create_knowledge_base_url_document(
-**url:** `str` — URL to a page of documentation that the agent will have access to in order to interact with users. - -
-
- -
-
- -**name:** `typing.Optional[str]` — A custom, human-readable name for the document. - -
-
- -
-
- -**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. - -
-
- -
- - - - -
- -
client.conversational_ai.create_knowledge_base_file_document(...) -
-
- -#### 📝 Description - -
-
- -
-
- -Create a knowledge base document generated form the uploaded file. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```python -from elevenlabs import ElevenLabs - -client = ElevenLabs( - api_key="YOUR_API_KEY", -) -client.conversational_ai.create_knowledge_base_file_document() - -``` -
-
+**dubbing_id:** `str` — ID of the dubbing project. +
-#### ⚙️ Parameters -
+**speaker_id:** `str` — ID of the speaker. + +
+
+
-**file:** `from __future__ import annotations - -core.File` — See core.File for more documentation +**voice_id:** `typing.Optional[str]` — Either the identifier of a voice from the ElevenLabs voice library, or one of ['track-clone', 'clip-clone'].
@@ -8391,7 +8779,7 @@ core.File` — See core.File for more documentation
-**name:** `typing.Optional[str]` — A custom, human-readable name for the document. +**languages:** `typing.Optional[typing.Sequence[str]]` — Languages to apply these changes to. If empty, will apply to all languages.
@@ -8411,7 +8799,7 @@ core.File` — See core.File for more documentation
-
client.conversational_ai.create_knowledge_base_text_document(...) +
client.dubbing.resource.speaker.find_similar_voices(...)
@@ -8423,7 +8811,7 @@ core.File` — See core.File for more documentation
-Create a knowledge base document containing the provided text. +Fetch the top 10 similar voices to a speaker, including the voice IDs, names, descriptions, and, where possible, a sample audio recording.
@@ -8443,8 +8831,9 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.conversational_ai.create_knowledge_base_text_document( - text="text", +client.dubbing.resource.speaker.find_similar_voices( + dubbing_id="dubbing_id", + speaker_id="speaker_id", ) ``` @@ -8461,7 +8850,7 @@ client.conversational_ai.create_knowledge_base_text_document(
-**text:** `str` — Text content to be added to the knowledge base. +**dubbing_id:** `str` — ID of the dubbing project.
@@ -8469,7 +8858,7 @@ client.conversational_ai.create_knowledge_base_text_document(
-**name:** `typing.Optional[str]` — A custom, human-readable name for the document. +**speaker_id:** `str` — ID of the speaker.
@@ -8489,7 +8878,8 @@ client.conversational_ai.create_knowledge_base_text_document(
-
client.conversational_ai.get_knowledge_base_document_by_id(...) +## Dubbing Resource Speaker Segment +
client.dubbing.resource.speaker.segment.create(...)
@@ -8501,7 +8891,7 @@ client.conversational_ai.create_knowledge_base_text_document(
-Get details about a specific documentation making up the agent's knowledge base +Creates a new segment in dubbing resource with a start and end time for the speaker in every available language. Does not automatically generate transcripts/translations/audio.
@@ -8521,8 +8911,11 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.conversational_ai.get_knowledge_base_document_by_id( - documentation_id="21m00Tcm4TlvDq8ikWAM", +client.dubbing.resource.speaker.segment.create( + dubbing_id="dubbing_id", + speaker_id="speaker_id", + start_time=1.1, + end_time=1.1, ) ``` @@ -8539,7 +8932,7 @@ client.conversational_ai.get_knowledge_base_document_by_id(
-**documentation_id:** `str` — The id of a document from the knowledge base. This is returned on document addition. +**dubbing_id:** `str` — ID of the dubbing project.
@@ -8547,69 +8940,39 @@ client.conversational_ai.get_knowledge_base_document_by_id(
-**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. +**speaker_id:** `str` — ID of the speaker.
- -
- - - -
- -
client.conversational_ai.delete_knowledge_base_document(...)
-#### 📝 Description - -
-
+**start_time:** `float` + +
+
-Delete a document from the knowledge base -
-
+**end_time:** `float` +
-#### 🔌 Usage -
-
-
- -```python -from elevenlabs import ElevenLabs - -client = ElevenLabs( - api_key="YOUR_API_KEY", -) -client.conversational_ai.delete_knowledge_base_document( - documentation_id="21m00Tcm4TlvDq8ikWAM", -) - -``` -
-
+**text:** `typing.Optional[str]` +
-#### ⚙️ Parameters - -
-
-
-**documentation_id:** `str` — The id of a document from the knowledge base. This is returned on document addition. +**translations:** `typing.Optional[typing.Dict[str, typing.Optional[str]]]`
@@ -8629,7 +8992,8 @@ client.conversational_ai.delete_knowledge_base_document(
-
client.conversational_ai.update_knowledge_base_document(...) +## PronunciationDictionaries Rules +
client.pronunciation_dictionaries.rules.add(...)
@@ -8641,7 +9005,7 @@ client.conversational_ai.delete_knowledge_base_document(
-Update the name of a document +Add rules to the pronunciation dictionary
@@ -8657,13 +9021,21 @@ Update the name of a document ```python from elevenlabs import ElevenLabs +from elevenlabs.pronunciation_dictionaries.rules import ( + PronunciationDictionaryRule_Alias, +) client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.conversational_ai.update_knowledge_base_document( - documentation_id="21m00Tcm4TlvDq8ikWAM", - name="name", +client.pronunciation_dictionaries.rules.add( + pronunciation_dictionary_id="21m00Tcm4TlvDq8ikWAM", + rules=[ + PronunciationDictionaryRule_Alias( + string_to_replace="Thailand", + alias="tie-land", + ) + ], ) ``` @@ -8680,7 +9052,7 @@ client.conversational_ai.update_knowledge_base_document(
-**documentation_id:** `str` — The id of a document from the knowledge base. This is returned on document addition. +**pronunciation_dictionary_id:** `str` — The id of the pronunciation dictionary
@@ -8688,7 +9060,11 @@ client.conversational_ai.update_knowledge_base_document(
-**name:** `str` — A custom, human-readable name for the document. +**rules:** `typing.Sequence[PronunciationDictionaryRule]` + +List of pronunciation rules. Rule can be either: + an alias rule: {'string_to_replace': 'a', 'type': 'alias', 'alias': 'b', } + or a phoneme rule: {'string_to_replace': 'a', 'type': 'phoneme', 'phoneme': 'b', 'alphabet': 'ipa' }
@@ -8708,7 +9084,7 @@ client.conversational_ai.update_knowledge_base_document(
-
client.conversational_ai.get_dependent_agents(...) +
client.pronunciation_dictionaries.rules.remove(...)
@@ -8720,7 +9096,7 @@ client.conversational_ai.update_knowledge_base_document(
-Get a list of agents depending on this knowledge base document +Remove rules from the pronunciation dictionary
@@ -8740,8 +9116,9 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.conversational_ai.get_dependent_agents( - documentation_id="21m00Tcm4TlvDq8ikWAM", +client.pronunciation_dictionaries.rules.remove( + pronunciation_dictionary_id="21m00Tcm4TlvDq8ikWAM", + rule_strings=["rule_strings"], ) ``` @@ -8758,15 +9135,7 @@ client.conversational_ai.get_dependent_agents(
-**documentation_id:** `str` — The id of a document from the knowledge base. This is returned on document addition. - -
-
- -
-
- -**cursor:** `typing.Optional[str]` — Used for fetching next page. Cursor is returned in the response. +**pronunciation_dictionary_id:** `str` — The id of the pronunciation dictionary
@@ -8774,7 +9143,7 @@ client.conversational_ai.get_dependent_agents(
-**page_size:** `typing.Optional[int]` — How many documents to return at maximum. Can not exceed 100, defaults to 30. +**rule_strings:** `typing.Sequence[str]` — List of strings to remove from the pronunciation dictionary.
@@ -8794,7 +9163,8 @@ client.conversational_ai.get_dependent_agents(
-
client.conversational_ai.get_knowledge_base_document_content(...) +## Studio Projects +
client.studio.projects.list()
@@ -8806,7 +9176,7 @@ client.conversational_ai.get_dependent_agents(
-Get the entire content of a document from the knowledge base +Returns a list of your Studio projects with metadata.
@@ -8826,9 +9196,7 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.conversational_ai.get_knowledge_base_document_content( - documentation_id="21m00Tcm4TlvDq8ikWAM", -) +client.studio.projects.list() ``` @@ -8844,14 +9212,6 @@ client.conversational_ai.get_knowledge_base_document_content(
-**documentation_id:** `str` — The id of a document from the knowledge base. This is returned on document addition. - -
-
- -
-
- **request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration.
@@ -8864,7 +9224,7 @@ client.conversational_ai.get_knowledge_base_document_content(
-
client.conversational_ai.get_knowledge_base_document_part_by_id(...) +
client.studio.projects.create(...)
@@ -8876,7 +9236,7 @@ client.conversational_ai.get_knowledge_base_document_content(
-Get details about a specific documentation part used by RAG. +Creates a new Studio project, it can be either initialized as blank, from a document or from a URL.
@@ -8896,9 +9256,11 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.conversational_ai.get_knowledge_base_document_part_by_id( - documentation_id="21m00Tcm4TlvDq8ikWAM", - chunk_id="chunk_id", +client.studio.projects.create( + name="name", + default_title_voice_id="default_title_voice_id", + default_paragraph_voice_id="default_paragraph_voice_id", + default_model_id="default_model_id", ) ``` @@ -8915,7 +9277,7 @@ client.conversational_ai.get_knowledge_base_document_part_by_id(
-**documentation_id:** `str` — The id of a document from the knowledge base. This is returned on document addition. +**name:** `str` — The name of the Studio project, used for identification only.
@@ -8923,7 +9285,7 @@ client.conversational_ai.get_knowledge_base_document_part_by_id(
-**chunk_id:** `str` — The id of a document RAG chunk from the knowledge base. +**default_title_voice_id:** `str` — The voice_id that corresponds to the default voice used for new titles.
@@ -8931,127 +9293,135 @@ client.conversational_ai.get_knowledge_base_document_part_by_id(
-**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. +**default_paragraph_voice_id:** `str` — The voice_id that corresponds to the default voice used for new paragraphs.
- -
+
+
+**default_model_id:** `str` — The ID of the model to be used for this Studio project, you can query GET /v1/models to list all available models. +
-
-
client.conversational_ai.get_settings()
-#### 📝 Description +**from_url:** `typing.Optional[str]` — An optional URL from which we will extract content to initialize the Studio project. If this is set, 'from_url' must be null. If neither 'from_url' or 'from_document' are provided we will initialize the Studio project as blank. + +
+
-
-
+**from_document:** `from __future__ import annotations -Retrieve Convai settings for the workspace -
-
+typing.Optional[core.File]` — See core.File for more documentation +
-#### 🔌 Usage - -
-
-
-```python -from elevenlabs import ElevenLabs - -client = ElevenLabs( - api_key="YOUR_API_KEY", -) -client.conversational_ai.get_settings() +**quality_preset:** `typing.Optional[str]` -``` -
-
+Output quality of the generated audio. Must be one of: +standard - standard output format, 128kbps with 44.1kHz sample rate. +high - high quality output format, 192kbps with 44.1kHz sample rate and major improvements on our side. Using this setting increases the credit cost by 20%. +ultra - ultra quality output format, 192kbps with 44.1kHz sample rate and highest improvements on our side. Using this setting increases the credit cost by 50%. +ultra lossless - ultra quality output format, 705.6kbps with 44.1kHz sample rate and highest improvements on our side in a fully lossless format. Using this setting increases the credit cost by 100%. +
-#### ⚙️ Parameters -
+**title:** `typing.Optional[str]` — An optional name of the author of the Studio project, this will be added as metadata to the mp3 file on Studio project or chapter download. + +
+
+
-**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. +**author:** `typing.Optional[str]` — An optional name of the author of the Studio project, this will be added as metadata to the mp3 file on Studio project or chapter download.
- - +
+
+**description:** `typing.Optional[str]` — An optional description of the Studio project. +
-
-
client.conversational_ai.update_settings(...)
-#### 📝 Description +**genres:** `typing.Optional[typing.List[str]]` — An optional list of genres associated with the Studio project. + +
+
+**target_audience:** `typing.Optional[ProjectsCreateRequestTargetAudience]` — An optional target audience of the Studio project. + +
+
+
-Update Convai settings for the workspace -
-
+**language:** `typing.Optional[str]` — An optional language of the Studio project. Two-letter language code (ISO 639-1). + -#### 🔌 Usage -
+**content_type:** `typing.Optional[str]` — An optional content type of the Studio project. + +
+
+
-```python -from elevenlabs import ElevenLabs - -client = ElevenLabs( - api_key="YOUR_API_KEY", -) -client.conversational_ai.update_settings() - -``` +**original_publication_date:** `typing.Optional[str]` — An optional original publication date of the Studio project, in the format YYYY-MM-DD or YYYY. +
+ +
+
+ +**mature_content:** `typing.Optional[bool]` — An optional specification of whether this Studio project contains mature content. +
-#### ⚙️ Parameters -
+**isbn_number:** `typing.Optional[str]` — An optional ISBN number of the Studio project you want to create, this will be added as metadata to the mp3 file on Studio project or chapter download. + +
+
+
-**conversation_initiation_client_data_webhook:** `typing.Optional[ConversationInitiationClientDataWebhook]` +**acx_volume_normalization:** `typing.Optional[bool]` — [Deprecated] When the Studio project is downloaded, should the returned audio have postprocessing in order to make it compliant with audiobook normalized volume requirements
@@ -9059,7 +9429,7 @@ client.conversational_ai.update_settings()
-**webhooks:** `typing.Optional[ConvAiWebhooks]` +**volume_normalization:** `typing.Optional[bool]` — When the Studio project is downloaded, should the returned audio have postprocessing in order to make it compliant with audiobook normalized volume requirements
@@ -9067,7 +9437,7 @@ client.conversational_ai.update_settings()
-**rag_retention_period_days:** `typing.Optional[int]` +**pronunciation_dictionary_locators:** `typing.Optional[typing.List[str]]` — A list of pronunciation dictionary locators (pronunciation_dictionary_id, version_id) encoded as a list of JSON strings for pronunciation dictionaries to be applied to the text. A list of json encoded strings is required as adding projects may occur through formData as opposed to jsonBody. To specify multiple dictionaries use multiple --form lines in your curl, such as --form 'pronunciation_dictionary_locators="{\"pronunciation_dictionary_id\":\"Vmd4Zor6fplcA7WrINey\",\"version_id\":\"hRPaxjlTdR7wFMhV4w0b\"}"' --form 'pronunciation_dictionary_locators="{\"pronunciation_dictionary_id\":\"JzWtcGQMJ6bnlWwyMo7e\",\"version_id\":\"lbmwxiLu4q6txYxgdZqn\"}"'. Note that multiple dictionaries are not currently supported by our UI which will only show the first.
@@ -9075,63 +9445,58 @@ client.conversational_ai.update_settings()
-**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. +**callback_url:** `typing.Optional[str]` — A url that will be called by our service when the Studio project is converted. Request will contain a json blob containing the status of the conversion
- - +
+
+**fiction:** `typing.Optional[ProjectsCreateRequestFiction]` — An optional specification of whether the content of this Studio project is fiction. +
-
-
client.conversational_ai.get_dashboard_settings()
-#### 📝 Description - -
-
+**apply_text_normalization:** `typing.Optional[ProjectsCreateRequestApplyTextNormalization]` -
-
-Retrieve Convai dashboard settings for the workspace -
-
+ This parameter controls text normalization with four modes: 'auto', 'on', 'apply_english' and 'off'. + When set to 'auto', the system will automatically decide whether to apply text normalization + (e.g., spelling out numbers). With 'on', text normalization will always be applied, while + with 'off', it will be skipped. 'apply_english' is the same as 'on' but will assume that text is in English. + +
-#### 🔌 Usage -
+**auto_convert:** `typing.Optional[bool]` — Whether to auto convert the Studio project to audio or not. + +
+
+
-```python -from elevenlabs import ElevenLabs - -client = ElevenLabs( - api_key="YOUR_API_KEY", -) -client.conversational_ai.get_dashboard_settings() - -``` -
-
+**auto_assign_voices:** `typing.Optional[bool]` — [Alpha Feature] Whether automatically assign voices to phrases in the create Project. +
-#### ⚙️ Parameters -
+**source_type:** `typing.Optional[ProjectsCreateRequestSourceType]` — The type of Studio project to create. + +
+
+
@@ -9147,7 +9512,7 @@ client.conversational_ai.get_dashboard_settings()
-
client.conversational_ai.update_dashboard_settings(...) +
client.studio.projects.get(...)
@@ -9159,7 +9524,7 @@ client.conversational_ai.get_dashboard_settings()
-Update Convai dashboard settings for the workspace +Returns information about a specific Studio project. This endpoint returns more detailed information about a project than `GET /v1/studio`.
@@ -9179,7 +9544,9 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.conversational_ai.update_dashboard_settings() +client.studio.projects.get( + project_id="21m00Tcm4TlvDq8ikWAM", +) ``` @@ -9195,7 +9562,7 @@ client.conversational_ai.update_dashboard_settings()
-**charts:** `typing.Optional[typing.Sequence[PatchConvAiDashboardSettingsRequestChartsItem]]` +**project_id:** `str` — The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects.
@@ -9215,7 +9582,7 @@ client.conversational_ai.update_dashboard_settings()
-
client.conversational_ai.get_secrets() +
client.studio.projects.update(...)
@@ -9227,7 +9594,7 @@ client.conversational_ai.update_dashboard_settings()
-Get all workspace secrets for the user +Updates the specified Studio project by setting the values of the parameters passed.
@@ -9247,7 +9614,12 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.conversational_ai.get_secrets() +client.studio.projects.update( + project_id="21m00Tcm4TlvDq8ikWAM", + name="Project 1", + default_title_voice_id="21m00Tcm4TlvDq8ikWAM", + default_paragraph_voice_id="21m00Tcm4TlvDq8ikWAM", +) ``` @@ -9263,70 +9635,55 @@ client.conversational_ai.get_secrets()
-**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. +**project_id:** `str` — The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects.
- -
+
+
+**name:** `str` — The name of the Studio project, used for identification only. +
-
-
client.conversational_ai.create_secret(...)
-#### 📝 Description - -
-
+**default_title_voice_id:** `str` — The voice_id that corresponds to the default voice used for new titles. + +
+
-Create a new secret for the workspace -
-
+**default_paragraph_voice_id:** `str` — The voice_id that corresponds to the default voice used for new paragraphs. +
-#### 🔌 Usage - -
-
-
-```python -from elevenlabs import ElevenLabs - -client = ElevenLabs( - api_key="YOUR_API_KEY", -) -client.conversational_ai.create_secret( - name="name", - value="value", -) - -``` -
-
+**title:** `typing.Optional[str]` — An optional name of the author of the Studio project, this will be added as metadata to the mp3 file on Studio project or chapter download. +
-#### ⚙️ Parameters -
+**author:** `typing.Optional[str]` — An optional name of the author of the Studio project, this will be added as metadata to the mp3 file on Studio project or chapter download. + +
+
+
-**name:** `str` +**isbn_number:** `typing.Optional[str]` — An optional ISBN number of the Studio project you want to create, this will be added as metadata to the mp3 file on Studio project or chapter download.
@@ -9334,7 +9691,7 @@ client.conversational_ai.create_secret(
-**value:** `str` +**volume_normalization:** `typing.Optional[bool]` — When the Studio project is downloaded, should the returned audio have postprocessing in order to make it compliant with audiobook normalized volume requirements
@@ -9354,7 +9711,7 @@ client.conversational_ai.create_secret(
-
client.conversational_ai.delete_secret(...) +
client.studio.projects.delete(...)
@@ -9366,7 +9723,7 @@ client.conversational_ai.create_secret(
-Delete a workspace secret if it's not in use +Deletes a Studio project.
@@ -9386,8 +9743,8 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.conversational_ai.delete_secret( - secret_id="secret_id", +client.studio.projects.delete( + project_id="21m00Tcm4TlvDq8ikWAM", ) ``` @@ -9404,7 +9761,7 @@ client.conversational_ai.delete_secret(
-**secret_id:** `str` +**project_id:** `str` — The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects.
@@ -9424,7 +9781,7 @@ client.conversational_ai.delete_secret(
-
client.conversational_ai.get_batch_call(...) +
client.studio.projects.convert(...)
@@ -9436,7 +9793,7 @@ client.conversational_ai.delete_secret(
-Get detailed information about a batch call including all recipients. +Starts conversion of a Studio project and all of its chapters.
@@ -9456,8 +9813,8 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.conversational_ai.get_batch_call( - batch_id="batch_id", +client.studio.projects.convert( + project_id="21m00Tcm4TlvDq8ikWAM", ) ``` @@ -9474,7 +9831,7 @@ client.conversational_ai.get_batch_call(
-**batch_id:** `str` +**project_id:** `str` — The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects.
@@ -9494,8 +9851,8 @@ client.conversational_ai.get_batch_call(
-## ConversationalAi Agents -
client.conversational_ai.agents.simulate_conversation(...) +## Studio Projects Content +
client.studio.projects.content.update(...)
@@ -9507,7 +9864,7 @@ client.conversational_ai.get_batch_call(
-Run a conversation between the agent and a simulated user. +Updates Studio project content.
@@ -9522,23 +9879,13 @@ Run a conversation between the agent and a simulated user.
```python -from elevenlabs import ( - AgentConfigDbModel, - ConversationSimulationSpecification, - ElevenLabs, -) +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.conversational_ai.agents.simulate_conversation( - agent_id="21m00Tcm4TlvDq8ikWAM", - simulation_specification=ConversationSimulationSpecification( - simulated_user_config=AgentConfigDbModel( - first_message="Hello, how can I help you today?", - language="en", - ), - ), +client.studio.projects.content.update( + project_id="21m00Tcm4TlvDq8ikWAM", ) ``` @@ -9555,7 +9902,7 @@ client.conversational_ai.agents.simulate_conversation(
-**agent_id:** `str` — The id of an agent. This is returned on agent creation. +**project_id:** `str` — The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects.
@@ -9563,7 +9910,7 @@ client.conversational_ai.agents.simulate_conversation(
-**simulation_specification:** `ConversationSimulationSpecification` — A specification detailing how the conversation should be simulated +**from_url:** `typing.Optional[str]` — An optional URL from which we will extract content to initialize the Studio project. If this is set, 'from_url' must be null. If neither 'from_url' or 'from_document' are provided we will initialize the Studio project as blank.
@@ -9571,7 +9918,17 @@ client.conversational_ai.agents.simulate_conversation(
-**extra_evaluation_criteria:** `typing.Optional[typing.Sequence[PromptEvaluationCriteria]]` — A list of evaluation criteria to test +**from_document:** `from __future__ import annotations + +typing.Optional[core.File]` — See core.File for more documentation + +
+
+ +
+
+ +**auto_convert:** `typing.Optional[bool]` — Whether to auto convert the Studio project to audio or not.
@@ -9591,7 +9948,8 @@ client.conversational_ai.agents.simulate_conversation(
-
client.conversational_ai.agents.simulate_conversation_stream(...) +## Studio Projects Snapshots +
client.studio.projects.snapshots.list(...)
@@ -9603,7 +9961,7 @@ client.conversational_ai.agents.simulate_conversation(
-Run a conversation between the agent and a simulated user and stream back the response. Response is streamed back as partial lists of messages that should be concatenated and once the conversation has complete a single final message with the conversation analysis will be sent. +Retrieves a list of snapshots for a Studio project.
@@ -9618,23 +9976,13 @@ Run a conversation between the agent and a simulated user and stream back the re
```python -from elevenlabs import ( - AgentConfigDbModel, - ConversationSimulationSpecification, - ElevenLabs, -) +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.conversational_ai.agents.simulate_conversation_stream( - agent_id="21m00Tcm4TlvDq8ikWAM", - simulation_specification=ConversationSimulationSpecification( - simulated_user_config=AgentConfigDbModel( - first_message="Hello, how can I help you today?", - language="en", - ), - ), +client.studio.projects.snapshots.list( + project_id="21m00Tcm4TlvDq8ikWAM", ) ``` @@ -9651,23 +9999,7 @@ client.conversational_ai.agents.simulate_conversation_stream(
-**agent_id:** `str` — The id of an agent. This is returned on agent creation. - -
-
- -
-
- -**simulation_specification:** `ConversationSimulationSpecification` — A specification detailing how the conversation should be simulated - -
-
- -
-
- -**extra_evaluation_criteria:** `typing.Optional[typing.Sequence[PromptEvaluationCriteria]]` — A list of evaluation criteria to test +**project_id:** `str` — The ID of the Studio project.
@@ -9687,8 +10019,7 @@ client.conversational_ai.agents.simulate_conversation_stream(
-## ConversationalAi SipTrunk -
client.conversational_ai.sip_trunk.outbound_call(...) +
client.studio.projects.snapshots.get(...)
@@ -9700,7 +10031,7 @@ client.conversational_ai.agents.simulate_conversation_stream(
-Handle an outbound call via SIP trunk +Returns the project snapshot.
@@ -9720,10 +10051,9 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.conversational_ai.sip_trunk.outbound_call( - agent_id="agent_id", - agent_phone_number_id="agent_phone_number_id", - to_number="to_number", +client.studio.projects.snapshots.get( + project_id="21m00Tcm4TlvDq8ikWAM", + project_snapshot_id="21m00Tcm4TlvDq8ikWAM", ) ``` @@ -9740,23 +10070,7 @@ client.conversational_ai.sip_trunk.outbound_call(
-**agent_id:** `str` - -
-
- -
-
- -**agent_phone_number_id:** `str` - -
-
- -
-
- -**to_number:** `str` +**project_id:** `str` — The ID of the Studio project.
@@ -9764,7 +10078,7 @@ client.conversational_ai.sip_trunk.outbound_call(
-**conversation_initiation_client_data:** `typing.Optional[ConversationInitiationClientDataRequestInput]` +**project_snapshot_id:** `str` — The ID of the Studio project snapshot.
@@ -9784,8 +10098,8 @@ client.conversational_ai.sip_trunk.outbound_call(
-## ConversationalAi KnowledgeBase Document -
client.conversational_ai.knowledge_base.document.compute_rag_index(...) +## Studio Projects Chapters +
client.studio.projects.chapters.list(...)
@@ -9797,7 +10111,7 @@ client.conversational_ai.sip_trunk.outbound_call(
-In case the document is not RAG indexed, it triggers rag indexing task, otherwise it just returns the current status. +Returns a list of a Studio project's chapters.
@@ -9817,9 +10131,8 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.conversational_ai.knowledge_base.document.compute_rag_index( - documentation_id="21m00Tcm4TlvDq8ikWAM", - model="e5_mistral_7b_instruct", +client.studio.projects.chapters.list( + project_id="21m00Tcm4TlvDq8ikWAM", ) ``` @@ -9836,15 +10149,7 @@ client.conversational_ai.knowledge_base.document.compute_rag_index(
-**documentation_id:** `str` — The id of a document from the knowledge base. This is returned on document addition. - -
-
- -
-
- -**model:** `EmbeddingModelEnum` +**project_id:** `str` — The ID of the Studio project.
@@ -9864,8 +10169,7 @@ client.conversational_ai.knowledge_base.document.compute_rag_index(
-## Dubbing Speaker -
client.dubbing.speaker.update(...) +
client.studio.projects.chapters.create(...)
@@ -9877,7 +10181,7 @@ client.conversational_ai.knowledge_base.document.compute_rag_index(
-Amend the metadata associated with a speaker, such as their voice. Both voice cloning and using voices from the ElevenLabs library are supported. +Creates a new chapter either as blank or from a URL.
@@ -9897,10 +10201,10 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.dubbing.speaker.update( - dubbing_id="dubbing_id", - speaker_id="speaker_id", -) +client.studio.projects.chapters.create( + project_id="21m00Tcm4TlvDq8ikWAM", + name="Chapter 1", +) ``` @@ -9916,15 +10220,7 @@ client.dubbing.speaker.update(
-**dubbing_id:** `str` — ID of the dubbing project. - -
-
- -
-
- -**speaker_id:** `str` — ID of the speaker. +**project_id:** `str` — The ID of the Studio project.
@@ -9932,7 +10228,7 @@ client.dubbing.speaker.update(
-**voice_id:** `typing.Optional[str]` — Either the identifier of a voice from the ElevenLabs voice library, or one of ['track-clone', 'clip-clone']. +**name:** `str` — The name of the chapter, used for identification only.
@@ -9940,7 +10236,7 @@ client.dubbing.speaker.update(
-**languages:** `typing.Optional[typing.Sequence[str]]` — Languages to apply these changes to. If empty, will apply to all languages. +**from_url:** `typing.Optional[str]` — An optional URL from which we will extract content to initialize the Studio project. If this is set, 'from_url' must be null. If neither 'from_url' or 'from_document' are provided we will initialize the Studio project as blank.
@@ -9960,7 +10256,7 @@ client.dubbing.speaker.update(
-
client.dubbing.speaker.similar_voices(...) +
client.studio.projects.chapters.get(...)
@@ -9972,7 +10268,7 @@ client.dubbing.speaker.update(
-Fetch the top 10 similar voices to a speaker, including the voice IDs, names, descriptions, and, where possible, a sample audio recording. +Returns information about a specific chapter.
@@ -9992,9 +10288,9 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.dubbing.speaker.similar_voices( - dubbing_id="dubbing_id", - speaker_id="speaker_id", +client.studio.projects.chapters.get( + project_id="21m00Tcm4TlvDq8ikWAM", + chapter_id="21m00Tcm4TlvDq8ikWAM", ) ``` @@ -10011,7 +10307,7 @@ client.dubbing.speaker.similar_voices(
-**dubbing_id:** `str` — ID of the dubbing project. +**project_id:** `str` — The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects.
@@ -10019,7 +10315,7 @@ client.dubbing.speaker.similar_voices(
-**speaker_id:** `str` — ID of the speaker. +**chapter_id:** `str` — The ID of the chapter to be used. You can use the [List project chapters](/docs/api-reference/studio/get-chapters) endpoint to list all the available chapters.
@@ -10039,8 +10335,7 @@ client.dubbing.speaker.similar_voices(
-## Dubbing Speaker Segment -
client.dubbing.speaker.segment.create(...) +
client.studio.projects.chapters.update(...)
@@ -10052,7 +10347,7 @@ client.dubbing.speaker.similar_voices(
-Creates a new segment in dubbing resource with a start and end time for the speaker in every available language. Does not automatically generate transcripts/translations/audio. +Updates a chapter.
@@ -10072,11 +10367,9 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.dubbing.speaker.segment.create( - dubbing_id="dubbing_id", - speaker_id="speaker_id", - start_time=1.1, - end_time=1.1, +client.studio.projects.chapters.update( + project_id="21m00Tcm4TlvDq8ikWAM", + chapter_id="21m00Tcm4TlvDq8ikWAM", ) ``` @@ -10093,23 +10386,7 @@ client.dubbing.speaker.segment.create(
-**dubbing_id:** `str` — ID of the dubbing project. - -
-
- -
-
- -**speaker_id:** `str` — ID of the speaker. - -
-
- -
-
- -**start_time:** `float` +**project_id:** `str` — The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects.
@@ -10117,7 +10394,7 @@ client.dubbing.speaker.segment.create(
-**end_time:** `float` +**chapter_id:** `str` — The ID of the chapter to be used. You can use the [List project chapters](/docs/api-reference/studio/get-chapters) endpoint to list all the available chapters.
@@ -10125,7 +10402,7 @@ client.dubbing.speaker.segment.create(
-**text:** `typing.Optional[str]` +**name:** `typing.Optional[str]` — The name of the chapter, used for identification only.
@@ -10133,7 +10410,7 @@ client.dubbing.speaker.segment.create(
-**translations:** `typing.Optional[typing.Dict[str, typing.Optional[str]]]` +**content:** `typing.Optional[ChapterContentInputModel]` — The chapter content to use.
@@ -10153,8 +10430,7 @@ client.dubbing.speaker.segment.create(
-## Studio Projects -
client.studio.projects.get_all() +
client.studio.projects.chapters.delete(...)
@@ -10166,7 +10442,7 @@ client.dubbing.speaker.segment.create(
-Returns a list of your Studio projects with metadata. +Deletes a chapter.
@@ -10186,7 +10462,10 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.studio.projects.get_all() +client.studio.projects.chapters.delete( + project_id="21m00Tcm4TlvDq8ikWAM", + chapter_id="21m00Tcm4TlvDq8ikWAM", +) ``` @@ -10202,6 +10481,22 @@ client.studio.projects.get_all()
+**project_id:** `str` — The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. + +
+
+ +
+
+ +**chapter_id:** `str` — The ID of the chapter to be used. You can use the [List project chapters](/docs/api-reference/studio/get-chapters) endpoint to list all the available chapters. + +
+
+ +
+
+ **request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration.
@@ -10214,7 +10509,7 @@ client.studio.projects.get_all()
-
client.studio.projects.add(...) +
client.studio.projects.chapters.convert(...)
@@ -10226,7 +10521,7 @@ client.studio.projects.get_all()
-Creates a new Studio project, it can be either initialized as blank, from a document or from a URL. +Starts conversion of a specific chapter.
@@ -10246,11 +10541,9 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.studio.projects.add( - name="name", - default_title_voice_id="default_title_voice_id", - default_paragraph_voice_id="default_paragraph_voice_id", - default_model_id="default_model_id", +client.studio.projects.chapters.convert( + project_id="21m00Tcm4TlvDq8ikWAM", + chapter_id="21m00Tcm4TlvDq8ikWAM", ) ``` @@ -10267,7 +10560,7 @@ client.studio.projects.add(
-**name:** `str` — The name of the Studio project, used for identification only. +**project_id:** `str` — The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects.
@@ -10275,7 +10568,7 @@ client.studio.projects.add(
-**default_title_voice_id:** `str` — The voice_id that corresponds to the default voice used for new titles. +**chapter_id:** `str` — The ID of the chapter to be used. You can use the [List project chapters](/docs/api-reference/studio/get-chapters) endpoint to list all the available chapters.
@@ -10283,103 +10576,75 @@ client.studio.projects.add(
-**default_paragraph_voice_id:** `str` — The voice_id that corresponds to the default voice used for new paragraphs. +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration.
- -
-
- -**default_model_id:** `str` — The ID of the model to be used for this Studio project, you can query GET /v1/models to list all available models. -
-
-
-**from_url:** `typing.Optional[str]` — An optional URL from which we will extract content to initialize the Studio project. If this is set, 'from_url' must be null. If neither 'from_url' or 'from_document' are provided we will initialize the Studio project as blank. -
+
+## Studio Projects PronunciationDictionaries +
client.studio.projects.pronunciation_dictionaries.create(...)
-**from_document:** `from __future__ import annotations - -typing.Optional[core.File]` — See core.File for more documentation - -
-
+#### 📝 Description
-**quality_preset:** `typing.Optional[str]` - -Output quality of the generated audio. Must be one of: -standard - standard output format, 128kbps with 44.1kHz sample rate. -high - high quality output format, 192kbps with 44.1kHz sample rate and major improvements on our side. Using this setting increases the credit cost by 20%. -ultra - ultra quality output format, 192kbps with 44.1kHz sample rate and highest improvements on our side. Using this setting increases the credit cost by 50%. -ultra lossless - ultra quality output format, 705.6kbps with 44.1kHz sample rate and highest improvements on our side in a fully lossless format. Using this setting increases the credit cost by 100%. - -
-
-
-**title:** `typing.Optional[str]` — An optional name of the author of the Studio project, this will be added as metadata to the mp3 file on Studio project or chapter download. - +Create a set of pronunciation dictionaries acting on a project. This will automatically mark text within this project as requiring reconverting where the new dictionary would apply or the old one no longer does.
- -
-
- -**author:** `typing.Optional[str]` — An optional name of the author of the Studio project, this will be added as metadata to the mp3 file on Studio project or chapter download. -
+#### 🔌 Usage +
-**description:** `typing.Optional[str]` — An optional description of the Studio project. - -
-
-
-**genres:** `typing.Optional[typing.List[str]]` — An optional list of genres associated with the Studio project. - -
-
+```python +from elevenlabs import ElevenLabs, PronunciationDictionaryVersionLocator -
-
+client = ElevenLabs( + api_key="YOUR_API_KEY", +) +client.studio.projects.pronunciation_dictionaries.create( + project_id="21m00Tcm4TlvDq8ikWAM", + pronunciation_dictionary_locators=[ + PronunciationDictionaryVersionLocator( + pronunciation_dictionary_id="pronunciation_dictionary_id", + ) + ], +) -**target_audience:** `typing.Optional[ProjectsAddRequestTargetAudience]` — An optional target audience of the Studio project. - +```
+ + + +#### ⚙️ Parameters
-**language:** `typing.Optional[str]` — An optional language of the Studio project. Two-letter language code (ISO 639-1). - -
-
-
-**content_type:** `typing.Optional[str]` — An optional content type of the Studio project. +**project_id:** `str` — The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects.
@@ -10387,7 +10652,7 @@ ultra lossless - ultra quality output format, 705.6kbps with 44.1kHz sample rate
-**original_publication_date:** `typing.Optional[str]` — An optional original publication date of the Studio project, in the format YYYY-MM-DD or YYYY. +**pronunciation_dictionary_locators:** `typing.Sequence[PronunciationDictionaryVersionLocator]` — A list of pronunciation dictionary locators (pronunciation_dictionary_id, version_id) encoded as a list of JSON strings for pronunciation dictionaries to be applied to the text. A list of json encoded strings is required as adding projects may occur through formData as opposed to jsonBody. To specify multiple dictionaries use multiple --form lines in your curl, such as --form 'pronunciation_dictionary_locators="{\"pronunciation_dictionary_id\":\"Vmd4Zor6fplcA7WrINey\",\"version_id\":\"hRPaxjlTdR7wFMhV4w0b\"}"' --form 'pronunciation_dictionary_locators="{\"pronunciation_dictionary_id\":\"JzWtcGQMJ6bnlWwyMo7e\",\"version_id\":\"lbmwxiLu4q6txYxgdZqn\"}"'. Note that multiple dictionaries are not currently supported by our UI which will only show the first.
@@ -10395,7 +10660,7 @@ ultra lossless - ultra quality output format, 705.6kbps with 44.1kHz sample rate
-**mature_content:** `typing.Optional[bool]` — An optional specification of whether this Studio project contains mature content. +**invalidate_affected_text:** `typing.Optional[bool]` — This will automatically mark text in this project for reconversion when the new dictionary applies or the old one no longer does.
@@ -10403,78 +10668,71 @@ ultra lossless - ultra quality output format, 705.6kbps with 44.1kHz sample rate
-**isbn_number:** `typing.Optional[str]` — An optional ISBN number of the Studio project you want to create, this will be added as metadata to the mp3 file on Studio project or chapter download. +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration.
+ + -
-
-**acx_volume_normalization:** `typing.Optional[bool]` — [Deprecated] When the Studio project is downloaded, should the returned audio have postprocessing in order to make it compliant with audiobook normalized volume requirements -
+
+## Studio Projects Chapters Snapshots +
client.studio.projects.chapters.snapshots.list(...)
-**volume_normalization:** `typing.Optional[bool]` — When the Studio project is downloaded, should the returned audio have postprocessing in order to make it compliant with audiobook normalized volume requirements - -
-
+#### 📝 Description
-**pronunciation_dictionary_locators:** `typing.Optional[typing.List[str]]` — A list of pronunciation dictionary locators (pronunciation_dictionary_id, version_id) encoded as a list of JSON strings for pronunciation dictionaries to be applied to the text. A list of json encoded strings is required as adding projects may occur through formData as opposed to jsonBody. To specify multiple dictionaries use multiple --form lines in your curl, such as --form 'pronunciation_dictionary_locators="{\"pronunciation_dictionary_id\":\"Vmd4Zor6fplcA7WrINey\",\"version_id\":\"hRPaxjlTdR7wFMhV4w0b\"}"' --form 'pronunciation_dictionary_locators="{\"pronunciation_dictionary_id\":\"JzWtcGQMJ6bnlWwyMo7e\",\"version_id\":\"lbmwxiLu4q6txYxgdZqn\"}"'. Note that multiple dictionaries are not currently supported by our UI which will only show the first. - -
-
-
-**callback_url:** `typing.Optional[str]` — A url that will be called by our service when the Studio project is converted. Request will contain a json blob containing the status of the conversion - +Gets information about all the snapshots of a chapter. Each snapshot can be downloaded as audio. Whenever a chapter is converted a snapshot will automatically be created. +
+
+#### 🔌 Usage +
-**fiction:** `typing.Optional[ProjectsAddRequestFiction]` — An optional specification of whether the content of this Studio project is fiction. - -
-
-
-**apply_text_normalization:** `typing.Optional[ProjectsAddRequestApplyTextNormalization]` +```python +from elevenlabs import ElevenLabs +client = ElevenLabs( + api_key="YOUR_API_KEY", +) +client.studio.projects.chapters.snapshots.list( + project_id="21m00Tcm4TlvDq8ikWAM", + chapter_id="21m00Tcm4TlvDq8ikWAM", +) - This parameter controls text normalization with four modes: 'auto', 'on', 'apply_english' and 'off'. - When set to 'auto', the system will automatically decide whether to apply text normalization - (e.g., spelling out numbers). With 'on', text normalization will always be applied, while - with 'off', it will be skipped. 'apply_english' is the same as 'on' but will assume that text is in English. - - +```
+ + + +#### ⚙️ Parameters
-**auto_convert:** `typing.Optional[bool]` — Whether to auto convert the Studio project to audio or not. - -
-
-
-**auto_assign_voices:** `typing.Optional[bool]` — [Alpha Feature] Whether automatically assign voices to phrases in the create Project. +**project_id:** `str` — The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects.
@@ -10482,7 +10740,7 @@ ultra lossless - ultra quality output format, 705.6kbps with 44.1kHz sample rate
-**source_type:** `typing.Optional[ProjectsAddRequestSourceType]` — The type of Studio project to create. +**chapter_id:** `str` — The ID of the chapter to be used. You can use the [List project chapters](/docs/api-reference/studio/get-chapters) endpoint to list all the available chapters.
@@ -10502,7 +10760,7 @@ ultra lossless - ultra quality output format, 705.6kbps with 44.1kHz sample rate
-
client.studio.projects.get(...) +
client.studio.projects.chapters.snapshots.get(...)
@@ -10514,7 +10772,7 @@ ultra lossless - ultra quality output format, 705.6kbps with 44.1kHz sample rate
-Returns information about a specific Studio project. This endpoint returns more detailed information about a project than `GET /v1/studio`. +Returns the chapter snapshot.
@@ -10534,8 +10792,10 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.studio.projects.get( +client.studio.projects.chapters.snapshots.get( project_id="21m00Tcm4TlvDq8ikWAM", + chapter_id="21m00Tcm4TlvDq8ikWAM", + chapter_snapshot_id="21m00Tcm4TlvDq8ikWAM", ) ``` @@ -10552,7 +10812,23 @@ client.studio.projects.get(
-**project_id:** `str` — The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. +**project_id:** `str` — The ID of the Studio project. + +
+
+ +
+
+ +**chapter_id:** `str` — The ID of the chapter. + +
+
+ +
+
+ +**chapter_snapshot_id:** `str` — The ID of the chapter snapshot.
@@ -10572,7 +10848,8 @@ client.studio.projects.get(
-
client.studio.projects.update_metadata(...) +## User Subscription +
client.user.subscription.get()
@@ -10584,7 +10861,7 @@ client.studio.projects.get(
-Updates the specified Studio project by setting the values of the parameters passed. +Gets extended information about the users subscription
@@ -10604,12 +10881,7 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.studio.projects.update_metadata( - project_id="21m00Tcm4TlvDq8ikWAM", - name="Project 1", - default_title_voice_id="21m00Tcm4TlvDq8ikWAM", - default_paragraph_voice_id="21m00Tcm4TlvDq8ikWAM", -) +client.user.subscription.get() ``` @@ -10625,67 +10897,64 @@ client.studio.projects.update_metadata(
-**project_id:** `str` — The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration.
+ +
-
-
-**name:** `str` — The name of the Studio project, used for identification only. -
+
+## Voices Settings +
client.voices.settings.get_default()
-**default_title_voice_id:** `str` — The voice_id that corresponds to the default voice used for new titles. - -
-
+#### 📝 Description
-**default_paragraph_voice_id:** `str` — The voice_id that corresponds to the default voice used for new paragraphs. - -
-
-
-**title:** `typing.Optional[str]` — An optional name of the author of the Studio project, this will be added as metadata to the mp3 file on Studio project or chapter download. - +Gets the default settings for voices. "similarity_boost" corresponds to"Clarity + Similarity Enhancement" in the web app and "stability" corresponds to "Stability" slider in the web app. +
+
+#### 🔌 Usage +
-**author:** `typing.Optional[str]` — An optional name of the author of the Studio project, this will be added as metadata to the mp3 file on Studio project or chapter download. - -
-
-
-**isbn_number:** `typing.Optional[str]` — An optional ISBN number of the Studio project you want to create, this will be added as metadata to the mp3 file on Studio project or chapter download. - +```python +from elevenlabs import ElevenLabs + +client = ElevenLabs( + api_key="YOUR_API_KEY", +) +client.voices.settings.get_default() + +```
+ + + +#### ⚙️ Parameters
-**volume_normalization:** `typing.Optional[bool]` — When the Studio project is downloaded, should the returned audio have postprocessing in order to make it compliant with audiobook normalized volume requirements - -
-
-
@@ -10701,7 +10970,7 @@ client.studio.projects.update_metadata(
-
client.studio.projects.delete(...) +
client.voices.settings.get(...)
@@ -10713,7 +10982,7 @@ client.studio.projects.update_metadata(
-Deletes a Studio project. +Returns the settings for a specific voice. "similarity_boost" corresponds to"Clarity + Similarity Enhancement" in the web app and "stability" corresponds to "Stability" slider in the web app.
@@ -10733,8 +11002,8 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.studio.projects.delete( - project_id="21m00Tcm4TlvDq8ikWAM", +client.voices.settings.get( + voice_id="21m00Tcm4TlvDq8ikWAM", ) ``` @@ -10751,7 +11020,7 @@ client.studio.projects.delete(
-**project_id:** `str` — The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. +**voice_id:** `str` — Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices.
@@ -10771,7 +11040,7 @@ client.studio.projects.delete(
-
client.studio.projects.update_content(...) +
client.voices.settings.update(...)
@@ -10783,7 +11052,7 @@ client.studio.projects.delete(
-Updates Studio project content. +Edit your settings for a specific voice. "similarity_boost" corresponds to "Clarity + Similarity Enhancement" in the web app and "stability" corresponds to "Stability" slider in the web app.
@@ -10798,13 +11067,20 @@ Updates Studio project content.
```python -from elevenlabs import ElevenLabs +from elevenlabs import ElevenLabs, VoiceSettings client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.studio.projects.update_content( - project_id="21m00Tcm4TlvDq8ikWAM", +client.voices.settings.update( + voice_id="21m00Tcm4TlvDq8ikWAM", + request=VoiceSettings( + stability=1.0, + similarity_boost=1.0, + style=0.0, + use_speaker_boost=True, + speed=1.0, + ), ) ``` @@ -10821,25 +11097,7 @@ client.studio.projects.update_content(
-**project_id:** `str` — The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. - -
-
- -
-
- -**from_url:** `typing.Optional[str]` — An optional URL from which we will extract content to initialize the Studio project. If this is set, 'from_url' must be null. If neither 'from_url' or 'from_document' are provided we will initialize the Studio project as blank. - -
-
- -
-
- -**from_document:** `from __future__ import annotations - -typing.Optional[core.File]` — See core.File for more documentation +**voice_id:** `str` — ID of the voice to be used. You can use the [Get voices](/docs/api-reference/voices/search) endpoint list all the available voices.
@@ -10847,7 +11105,7 @@ typing.Optional[core.File]` — See core.File for more documentation
-**auto_convert:** `typing.Optional[bool]` — Whether to auto convert the Studio project to audio or not. +**request:** `VoiceSettings`
@@ -10867,7 +11125,8 @@ typing.Optional[core.File]` — See core.File for more documentation
-
client.studio.projects.convert(...) +## Voices Ivc +
client.voices.ivc.create(...)
@@ -10879,7 +11138,7 @@ typing.Optional[core.File]` — See core.File for more documentation
-Starts conversion of a Studio project and all of its chapters. +Create a voice clone and add it to your Voices
@@ -10899,8 +11158,8 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.studio.projects.convert( - project_id="21m00Tcm4TlvDq8ikWAM", +client.voices.ivc.create( + name="name", ) ``` @@ -10917,7 +11176,41 @@ client.studio.projects.convert(
-**project_id:** `str` — The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. +**name:** `str` — The name that identifies this voice. This will be displayed in the dropdown of the website. + +
+
+ +
+
+ +**files:** `from __future__ import annotations + +typing.List[core.File]` — See core.File for more documentation + +
+
+ +
+
+ +**remove_background_noise:** `typing.Optional[bool]` — If set will remove background noise for voice samples using our audio isolation model. If the samples do not include background noise, it can make the quality worse. + +
+
+ +
+
+ +**description:** `typing.Optional[str]` — A description of the voice. + +
+
+ +
+
+ +**labels:** `typing.Optional[str]` — Serialized labels dictionary for the voice.
@@ -10937,7 +11230,8 @@ client.studio.projects.convert(
-
client.studio.projects.get_snapshots(...) +## Voices Pvc +
client.voices.pvc.create(...)
@@ -10949,7 +11243,7 @@ client.studio.projects.convert(
-Retrieves a list of snapshots for a Studio project. +Creates a new PVC voice with metadata but no samples
@@ -10969,8 +11263,9 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.studio.projects.get_snapshots( - project_id="21m00Tcm4TlvDq8ikWAM", +client.voices.pvc.create( + name="John Smith", + language="en", ) ``` @@ -10987,7 +11282,31 @@ client.studio.projects.get_snapshots(
-**project_id:** `str` — The ID of the Studio project. +**name:** `str` — The name that identifies this voice. This will be displayed in the dropdown of the website. + +
+
+ +
+
+ +**language:** `str` — Language used in the samples. + +
+
+ +
+
+ +**description:** `typing.Optional[str]` — Description to use for the created voice. + +
+
+ +
+
+ +**labels:** `typing.Optional[typing.Dict[str, typing.Optional[str]]]` — Serialized labels dictionary for the voice.
@@ -11007,7 +11326,7 @@ client.studio.projects.get_snapshots(
-
client.studio.projects.get_project_snapshot(...) +
client.voices.pvc.update(...)
@@ -11019,7 +11338,7 @@ client.studio.projects.get_snapshots(
-Returns the project snapshot. +Edit PVC voice metadata
@@ -11039,9 +11358,8 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.studio.projects.get_project_snapshot( - project_id="21m00Tcm4TlvDq8ikWAM", - project_snapshot_id="21m00Tcm4TlvDq8ikWAM", +client.voices.pvc.update( + voice_id="21m00Tcm4TlvDq8ikWAM", ) ``` @@ -11058,7 +11376,7 @@ client.studio.projects.get_project_snapshot(
-**project_id:** `str` — The ID of the Studio project. +**voice_id:** `str` — Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices.
@@ -11066,7 +11384,31 @@ client.studio.projects.get_project_snapshot(
-**project_snapshot_id:** `str` — The ID of the Studio project snapshot. +**name:** `typing.Optional[str]` — The name that identifies this voice. This will be displayed in the dropdown of the website. + +
+
+ +
+
+ +**language:** `typing.Optional[str]` — Language used in the samples. + +
+
+ +
+
+ +**description:** `typing.Optional[str]` — Description to use for the created voice. + +
+
+ +
+
+ +**labels:** `typing.Optional[typing.Dict[str, typing.Optional[str]]]` — Serialized labels dictionary for the voice.
@@ -11086,7 +11428,7 @@ client.studio.projects.get_project_snapshot(
-
client.studio.projects.update_pronunciation_dictionaries(...) +
client.voices.pvc.train(...)
@@ -11098,7 +11440,7 @@ client.studio.projects.get_project_snapshot(
-Create a set of pronunciation dictionaries acting on a project. This will automatically mark text within this project as requiring reconverting where the new dictionary would apply or the old one no longer does. +Start PVC training process for a voice.
@@ -11113,18 +11455,13 @@ Create a set of pronunciation dictionaries acting on a project. This will automa
```python -from elevenlabs import ElevenLabs, PronunciationDictionaryVersionLocator +from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.studio.projects.update_pronunciation_dictionaries( - project_id="21m00Tcm4TlvDq8ikWAM", - pronunciation_dictionary_locators=[ - PronunciationDictionaryVersionLocator( - pronunciation_dictionary_id="pronunciation_dictionary_id", - ) - ], +client.voices.pvc.train( + voice_id="21m00Tcm4TlvDq8ikWAM", ) ``` @@ -11141,15 +11478,7 @@ client.studio.projects.update_pronunciation_dictionaries(
-**project_id:** `str` — The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. - -
-
- -
-
- -**pronunciation_dictionary_locators:** `typing.Sequence[PronunciationDictionaryVersionLocator]` — A list of pronunciation dictionary locators (pronunciation_dictionary_id, version_id) encoded as a list of JSON strings for pronunciation dictionaries to be applied to the text. A list of json encoded strings is required as adding projects may occur through formData as opposed to jsonBody. To specify multiple dictionaries use multiple --form lines in your curl, such as --form 'pronunciation_dictionary_locators="{\"pronunciation_dictionary_id\":\"Vmd4Zor6fplcA7WrINey\",\"version_id\":\"hRPaxjlTdR7wFMhV4w0b\"}"' --form 'pronunciation_dictionary_locators="{\"pronunciation_dictionary_id\":\"JzWtcGQMJ6bnlWwyMo7e\",\"version_id\":\"lbmwxiLu4q6txYxgdZqn\"}"'. Note that multiple dictionaries are not currently supported by our UI which will only show the first. +**voice_id:** `str` — Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices.
@@ -11157,7 +11486,7 @@ client.studio.projects.update_pronunciation_dictionaries(
-**invalidate_affected_text:** `typing.Optional[bool]` — This will automatically mark text in this project for reconversion when the new dictionary applies or the old one no longer does. +**model_id:** `typing.Optional[str]` — The model ID to use for the conversion.
@@ -11177,8 +11506,8 @@ client.studio.projects.update_pronunciation_dictionaries(
-## Studio Chapters -
client.studio.chapters.get_all(...) +## Voices Pvc Samples +
client.voices.pvc.samples.create(...)
@@ -11190,7 +11519,7 @@ client.studio.projects.update_pronunciation_dictionaries(
-Returns a list of a Studio project's chapters. +Add audio samples to a PVC voice
@@ -11210,25 +11539,43 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.studio.chapters.get_all( - project_id="21m00Tcm4TlvDq8ikWAM", +client.voices.pvc.samples.create( + voice_id="21m00Tcm4TlvDq8ikWAM", ) -``` - -
+``` + + + + + +#### ⚙️ Parameters + +
+
+ +
+
+ +**voice_id:** `str` — Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices. +
-#### ⚙️ Parameters -
+**files:** `from __future__ import annotations + +typing.List[core.File]` — See core.File for more documentation + +
+
+
-**project_id:** `str` — The ID of the Studio project. +**remove_background_noise:** `typing.Optional[bool]` — If set will remove background noise for voice samples using our audio isolation model. If the samples do not include background noise, it can make the quality worse.
@@ -11248,7 +11595,7 @@ client.studio.chapters.get_all(
-
client.studio.chapters.create(...) +
client.voices.pvc.samples.update(...)
@@ -11260,7 +11607,7 @@ client.studio.chapters.get_all(
-Creates a new chapter either as blank or from a URL. +Update a PVC voice sample - apply noise removal, or select speaker.
@@ -11280,9 +11627,9 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.studio.chapters.create( - project_id="21m00Tcm4TlvDq8ikWAM", - name="Chapter 1", +client.voices.pvc.samples.update( + voice_id="21m00Tcm4TlvDq8ikWAM", + sample_id="VW7YKqPnjY4h39yTbx2L", ) ``` @@ -11299,7 +11646,7 @@ client.studio.chapters.create(
-**project_id:** `str` — The ID of the Studio project. +**voice_id:** `str` — Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices.
@@ -11307,7 +11654,7 @@ client.studio.chapters.create(
-**name:** `str` — The name of the chapter, used for identification only. +**sample_id:** `str` — Sample ID to be used
@@ -11315,7 +11662,31 @@ client.studio.chapters.create(
-**from_url:** `typing.Optional[str]` — An optional URL from which we will extract content to initialize the Studio project. If this is set, 'from_url' must be null. If neither 'from_url' or 'from_document' are provided we will initialize the Studio project as blank. +**remove_background_noise:** `typing.Optional[bool]` — If set will remove background noise for voice samples using our audio isolation model. If the samples do not include background noise, it can make the quality worse. + +
+
+ +
+
+ +**selected_speaker_ids:** `typing.Optional[typing.Sequence[str]]` — Speaker IDs to be used for PVC training. Make sure you send all the speaker IDs you want to use for PVC training in one request because the last request will override the previous ones. + +
+
+ +
+
+ +**trim_start_time:** `typing.Optional[int]` — The start time of the audio to be used for PVC training. Time should be in milliseconds + +
+
+ +
+
+ +**trim_end_time:** `typing.Optional[int]` — The end time of the audio to be used for PVC training. Time should be in milliseconds
@@ -11335,7 +11706,7 @@ client.studio.chapters.create(
-
client.studio.chapters.get(...) +
client.voices.pvc.samples.delete(...)
@@ -11347,7 +11718,7 @@ client.studio.chapters.create(
-Returns information about a specific chapter. +Delete a sample from a PVC voice.
@@ -11367,9 +11738,9 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.studio.chapters.get( - project_id="21m00Tcm4TlvDq8ikWAM", - chapter_id="21m00Tcm4TlvDq8ikWAM", +client.voices.pvc.samples.delete( + voice_id="21m00Tcm4TlvDq8ikWAM", + sample_id="VW7YKqPnjY4h39yTbx2L", ) ``` @@ -11386,7 +11757,7 @@ client.studio.chapters.get(
-**project_id:** `str` — The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. +**voice_id:** `str` — Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices.
@@ -11394,7 +11765,7 @@ client.studio.chapters.get(
-**chapter_id:** `str` — The ID of the chapter to be used. You can use the [List project chapters](/docs/api-reference/studio/get-chapters) endpoint to list all the available chapters. +**sample_id:** `str` — Sample ID to be used
@@ -11414,7 +11785,8 @@ client.studio.chapters.get(
-
client.studio.chapters.edit(...) +## Voices Pvc Verification +
client.voices.pvc.verification.request(...)
@@ -11426,7 +11798,7 @@ client.studio.chapters.get(
-Updates a chapter. +Request manual verification for a PVC voice.
@@ -11446,9 +11818,8 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.studio.chapters.edit( - project_id="21m00Tcm4TlvDq8ikWAM", - chapter_id="21m00Tcm4TlvDq8ikWAM", +client.voices.pvc.verification.request( + voice_id="21m00Tcm4TlvDq8ikWAM", ) ``` @@ -11465,7 +11836,7 @@ client.studio.chapters.edit(
-**project_id:** `str` — The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. +**voice_id:** `str` — Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices.
@@ -11473,15 +11844,9 @@ client.studio.chapters.edit(
-**chapter_id:** `str` — The ID of the chapter to be used. You can use the [List project chapters](/docs/api-reference/studio/get-chapters) endpoint to list all the available chapters. - -
-
- -
-
+**files:** `from __future__ import annotations -**name:** `typing.Optional[str]` — The name of the chapter, used for identification only. +typing.List[core.File]` — See core.File for more documentation
@@ -11489,7 +11854,7 @@ client.studio.chapters.edit(
-**content:** `typing.Optional[ChapterContentInputModel]` — The chapter content to use. +**extra_text:** `typing.Optional[str]` — Extra text to be used in the manual verification process.
@@ -11509,7 +11874,8 @@ client.studio.chapters.edit(
-
client.studio.chapters.delete(...) +## Voices Pvc Samples Audio +
client.voices.pvc.samples.audio.get(...)
@@ -11521,7 +11887,7 @@ client.studio.chapters.edit(
-Deletes a chapter. +Retrieve the first 30 seconds of voice sample audio with or without noise removal.
@@ -11541,9 +11907,9 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.studio.chapters.delete( - project_id="21m00Tcm4TlvDq8ikWAM", - chapter_id="21m00Tcm4TlvDq8ikWAM", +client.voices.pvc.samples.audio.get( + voice_id="21m00Tcm4TlvDq8ikWAM", + sample_id="VW7YKqPnjY4h39yTbx2L", ) ``` @@ -11560,7 +11926,7 @@ client.studio.chapters.delete(
-**project_id:** `str` — The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. +**voice_id:** `str` — Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices.
@@ -11568,7 +11934,7 @@ client.studio.chapters.delete(
-**chapter_id:** `str` — The ID of the chapter to be used. You can use the [List project chapters](/docs/api-reference/studio/get-chapters) endpoint to list all the available chapters. +**sample_id:** `str` — Sample ID to be used
@@ -11588,7 +11954,8 @@ client.studio.chapters.delete(
-
client.studio.chapters.convert(...) +## Voices Pvc Samples Waveform +
client.voices.pvc.samples.waveform.get(...)
@@ -11600,7 +11967,7 @@ client.studio.chapters.delete(
-Starts conversion of a specific chapter. +Retrieve the visual waveform of a voice sample.
@@ -11620,9 +11987,9 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.studio.chapters.convert( - project_id="21m00Tcm4TlvDq8ikWAM", - chapter_id="21m00Tcm4TlvDq8ikWAM", +client.voices.pvc.samples.waveform.get( + voice_id="21m00Tcm4TlvDq8ikWAM", + sample_id="VW7YKqPnjY4h39yTbx2L", ) ``` @@ -11639,7 +12006,7 @@ client.studio.chapters.convert(
-**project_id:** `str` — The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. +**voice_id:** `str` — Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices.
@@ -11647,7 +12014,7 @@ client.studio.chapters.convert(
-**chapter_id:** `str` — The ID of the chapter to be used. You can use the [List project chapters](/docs/api-reference/studio/get-chapters) endpoint to list all the available chapters. +**sample_id:** `str` — Sample ID to be used
@@ -11667,7 +12034,8 @@ client.studio.chapters.convert(
-
client.studio.chapters.get_all_snapshots(...) +## Voices Pvc Samples Speakers +
client.voices.pvc.samples.speakers.get(...)
@@ -11679,7 +12047,7 @@ client.studio.chapters.convert(
-Gets information about all the snapshots of a chapter. Each snapshot can be downloaded as audio. Whenever a chapter is converted a snapshot will automatically be created. +Retrieve the status of the speaker separation process and the list of detected speakers if complete.
@@ -11699,9 +12067,9 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.studio.chapters.get_all_snapshots( - project_id="21m00Tcm4TlvDq8ikWAM", - chapter_id="21m00Tcm4TlvDq8ikWAM", +client.voices.pvc.samples.speakers.get( + voice_id="21m00Tcm4TlvDq8ikWAM", + sample_id="VW7YKqPnjY4h39yTbx2L", ) ``` @@ -11718,7 +12086,7 @@ client.studio.chapters.get_all_snapshots(
-**project_id:** `str` — The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. +**voice_id:** `str` — Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices.
@@ -11726,7 +12094,7 @@ client.studio.chapters.get_all_snapshots(
-**chapter_id:** `str` — The ID of the chapter to be used. You can use the [List project chapters](/docs/api-reference/studio/get-chapters) endpoint to list all the available chapters. +**sample_id:** `str` — Sample ID to be used
@@ -11746,7 +12114,7 @@ client.studio.chapters.get_all_snapshots(
-
client.studio.chapters.get_chapter_snapshot(...) +
client.voices.pvc.samples.speakers.separate(...)
@@ -11758,7 +12126,7 @@ client.studio.chapters.get_all_snapshots(
-Returns the chapter snapshot. +Start speaker separation process for a sample
@@ -11778,10 +12146,9 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.studio.chapters.get_chapter_snapshot( - project_id="21m00Tcm4TlvDq8ikWAM", - chapter_id="21m00Tcm4TlvDq8ikWAM", - chapter_snapshot_id="21m00Tcm4TlvDq8ikWAM", +client.voices.pvc.samples.speakers.separate( + voice_id="21m00Tcm4TlvDq8ikWAM", + sample_id="VW7YKqPnjY4h39yTbx2L", ) ``` @@ -11798,15 +12165,7 @@ client.studio.chapters.get_chapter_snapshot(
-**project_id:** `str` — The ID of the Studio project. - -
-
- -
-
- -**chapter_id:** `str` — The ID of the chapter. +**voice_id:** `str` — Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices.
@@ -11814,7 +12173,7 @@ client.studio.chapters.get_chapter_snapshot(
-**chapter_snapshot_id:** `str` — The ID of the chapter snapshot. +**sample_id:** `str` — Sample ID to be used
@@ -11834,8 +12193,8 @@ client.studio.chapters.get_chapter_snapshot(
-## Voices Pvc -
client.voices.pvc.create(...) +## Voices Pvc Samples Speakers Audio +
client.voices.pvc.samples.speakers.audio.get(...)
@@ -11847,7 +12206,7 @@ client.studio.chapters.get_chapter_snapshot(
-Creates a new PVC voice with metadata but no samples +Retrieve the separated audio for a specific speaker.
@@ -11867,9 +12226,10 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.voices.pvc.create( - name="John Smith", - language="en", +client.voices.pvc.samples.speakers.audio.get( + voice_id="21m00Tcm4TlvDq8ikWAM", + sample_id="VW7YKqPnjY4h39yTbx2L", + speaker_id="VW7YKqPnjY4h39yTbx2L", ) ``` @@ -11886,15 +12246,7 @@ client.voices.pvc.create(
-**name:** `str` — The name that identifies this voice. This will be displayed in the dropdown of the website. - -
-
- -
-
- -**language:** `str` — Language used in the samples. +**voice_id:** `str` — Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices.
@@ -11902,7 +12254,7 @@ client.voices.pvc.create(
-**description:** `typing.Optional[str]` — Description to use for the created voice. +**sample_id:** `str` — Sample ID to be used
@@ -11910,7 +12262,7 @@ client.voices.pvc.create(
-**labels:** `typing.Optional[typing.Dict[str, typing.Optional[str]]]` — Serialized labels dictionary for the voice. +**speaker_id:** `str` — Speaker ID to be used, you can use GET https://api.elevenlabs.io/v1/voices/{voice_id}/samples/{sample_id}/speakers to list all the available speakers for a sample.
@@ -11930,7 +12282,8 @@ client.voices.pvc.create(
-
client.voices.pvc.update(...) +## Voices Pvc Verification Captcha +
client.voices.pvc.verification.captcha.get(...)
@@ -11942,7 +12295,7 @@ client.voices.pvc.create(
-Edit PVC voice metadata +Get captcha for PVC voice verification.
@@ -11962,7 +12315,7 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.voices.pvc.update( +client.voices.pvc.verification.captcha.get( voice_id="21m00Tcm4TlvDq8ikWAM", ) @@ -11988,23 +12341,69 @@ client.voices.pvc.update(
-**name:** `typing.Optional[str]` — The name that identifies this voice. This will be displayed in the dropdown of the website. +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration.
+ +
+ + + + +
+ +
client.voices.pvc.verification.captcha.verify(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Submit captcha verification for PVC voice. +
+
+
+
+ +#### 🔌 Usage
-**language:** `typing.Optional[str]` — Language used in the samples. - +
+
+ +```python +from elevenlabs import ElevenLabs + +client = ElevenLabs( + api_key="YOUR_API_KEY", +) +client.voices.pvc.verification.captcha.verify( + voice_id="21m00Tcm4TlvDq8ikWAM", +) + +```
+
+
+ +#### ⚙️ Parameters
-**description:** `typing.Optional[str]` — Description to use for the created voice. +
+
+ +**voice_id:** `str` — Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices.
@@ -12012,7 +12411,9 @@ client.voices.pvc.update(
-**labels:** `typing.Optional[typing.Dict[str, typing.Optional[str]]]` — Serialized labels dictionary for the voice. +**recording:** `from __future__ import annotations + +core.File` — See core.File for more documentation
@@ -12032,7 +12433,9 @@ client.voices.pvc.update(
-
client.voices.pvc.train(...) +## Voices Samples Audio +## Workspace Groups +
client.workspace.groups.search(...)
@@ -12044,7 +12447,7 @@ client.voices.pvc.update(
-Start PVC training process for a voice. +Searches for user groups in the workspace. Multiple or no groups may be returned.
@@ -12064,8 +12467,8 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.voices.pvc.train( - voice_id="21m00Tcm4TlvDq8ikWAM", +client.workspace.groups.search( + name="name", ) ``` @@ -12082,15 +12485,7 @@ client.voices.pvc.train(
-**voice_id:** `str` — Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices. - -
-
- -
-
- -**model_id:** `typing.Optional[str]` — The model ID to use for the conversion. +**name:** `str` — Name of the target group.
@@ -12110,8 +12505,8 @@ client.voices.pvc.train(
-## Voices Pvc Samples -
client.voices.pvc.samples.create(...) +## Workspace Invites +
client.workspace.invites.create(...)
@@ -12123,7 +12518,7 @@ client.voices.pvc.train(
-Add audio samples to a PVC voice +Sends an email invitation to join your workspace to the provided email. If the user doesn't have an account they will be prompted to create one. If the user accepts this invite they will be added as a user to your workspace and your subscription using one of your seats. This endpoint may only be called by workspace administrators. If the user is already in the workspace a 400 error will be returned.
@@ -12143,8 +12538,8 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.voices.pvc.samples.create( - voice_id="21m00Tcm4TlvDq8ikWAM", +client.workspace.invites.create( + email="john.doe@testmail.com", ) ``` @@ -12161,7 +12556,7 @@ client.voices.pvc.samples.create(
-**voice_id:** `str` — Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices. +**email:** `str` — The email of the customer
@@ -12169,9 +12564,7 @@ client.voices.pvc.samples.create(
-**files:** `from __future__ import annotations - -typing.List[core.File]` — See core.File for more documentation +**group_ids:** `typing.Optional[typing.Sequence[str]]` — The group ids of the user
@@ -12179,7 +12572,7 @@ typing.List[core.File]` — See core.File for more documentation
-**remove_background_noise:** `typing.Optional[bool]` — If set will remove background noise for voice samples using our audio isolation model. If the samples do not include background noise, it can make the quality worse. +**workspace_permission:** `typing.Optional[BodyInviteUserV1WorkspaceInvitesAddPostWorkspacePermission]` — The workspace permission of the user
@@ -12199,7 +12592,7 @@ typing.List[core.File]` — See core.File for more documentation
-
client.voices.pvc.samples.update(...) +
client.workspace.invites.create_batch(...)
@@ -12211,7 +12604,7 @@ typing.List[core.File]` — See core.File for more documentation
-Update a PVC voice sample - apply noise removal, or select speaker. +Sends email invitations to join your workspace to the provided emails. Requires all email addresses to be part of a verified domain. If the users don't have an account they will be prompted to create one. If the users accept these invites they will be added as users to your workspace and your subscription using one of your seats. This endpoint may only be called by workspace administrators.
@@ -12231,9 +12624,8 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.voices.pvc.samples.update( - voice_id="21m00Tcm4TlvDq8ikWAM", - sample_id="VW7YKqPnjY4h39yTbx2L", +client.workspace.invites.create_batch( + emails=["emails"], ) ``` @@ -12250,39 +12642,7 @@ client.voices.pvc.samples.update(
-**voice_id:** `str` — Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices. - -
-
- -
-
- -**sample_id:** `str` — Sample ID to be used - -
-
- -
-
- -**remove_background_noise:** `typing.Optional[bool]` — If set will remove background noise for voice samples using our audio isolation model. If the samples do not include background noise, it can make the quality worse. - -
-
- -
-
- -**selected_speaker_ids:** `typing.Optional[typing.Sequence[str]]` — Speaker IDs to be used for PVC training. Make sure you send all the speaker IDs you want to use for PVC training in one request because the last request will override the previous ones. - -
-
- -
-
- -**trim_start_time:** `typing.Optional[int]` — The start time of the audio to be used for PVC training. Time should be in milliseconds +**emails:** `typing.Sequence[str]` — The email of the customer
@@ -12290,7 +12650,7 @@ client.voices.pvc.samples.update(
-**trim_end_time:** `typing.Optional[int]` — The end time of the audio to be used for PVC training. Time should be in milliseconds +**group_ids:** `typing.Optional[typing.Sequence[str]]` — The group ids of the user
@@ -12310,7 +12670,7 @@ client.voices.pvc.samples.update(
-
client.voices.pvc.samples.delete(...) +
client.workspace.invites.delete(...)
@@ -12322,7 +12682,7 @@ client.voices.pvc.samples.update(
-Delete a sample from a PVC voice. +Invalidates an existing email invitation. The invitation will still show up in the inbox it has been delivered to, but activating it to join the workspace won't work. This endpoint may only be called by workspace administrators.
@@ -12342,9 +12702,8 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.voices.pvc.samples.delete( - voice_id="21m00Tcm4TlvDq8ikWAM", - sample_id="VW7YKqPnjY4h39yTbx2L", +client.workspace.invites.delete( + email="john.doe@testmail.com", ) ``` @@ -12361,15 +12720,7 @@ client.voices.pvc.samples.delete(
-**voice_id:** `str` — Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices. - -
-
- -
-
- -**sample_id:** `str` — Sample ID to be used +**email:** `str` — The email of the customer
@@ -12389,8 +12740,8 @@ client.voices.pvc.samples.delete(
-## Voices Pvc Verification -
client.voices.pvc.verification.request(...) +## Workspace Members +
client.workspace.members.update(...)
@@ -12402,7 +12753,7 @@ client.voices.pvc.samples.delete(
-Request manual verification for a PVC voice. +Updates attributes of a workspace member. Apart from the email identifier, all parameters will remain unchanged unless specified. This endpoint may only be called by workspace administrators.
@@ -12422,8 +12773,8 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.voices.pvc.verification.request( - voice_id="21m00Tcm4TlvDq8ikWAM", +client.workspace.members.update( + email="email", ) ``` @@ -12440,7 +12791,7 @@ client.voices.pvc.verification.request(
-**voice_id:** `str` — Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices. +**email:** `str` — Email of the target user.
@@ -12448,9 +12799,7 @@ client.voices.pvc.verification.request(
-**files:** `from __future__ import annotations - -typing.List[core.File]` — See core.File for more documentation +**is_locked:** `typing.Optional[bool]` — Whether to lock or unlock the user account.
@@ -12458,7 +12807,7 @@ typing.List[core.File]` — See core.File for more documentation
-**extra_text:** `typing.Optional[str]` — Extra text to be used in the manual verification process. +**workspace_role:** `typing.Optional[BodyUpdateMemberV1WorkspaceMembersPostWorkspaceRole]` — Role dictating permissions in the workspace.
@@ -12478,8 +12827,7 @@ typing.List[core.File]` — See core.File for more documentation
-## Voices Pvc Samples Audio -
client.voices.pvc.samples.audio.get(...) +
client.workspace.members.delete(...)
@@ -12491,7 +12839,7 @@ typing.List[core.File]` — See core.File for more documentation
-Retrieve the first 30 seconds of voice sample audio with or without noise removal. +Deletes a workspace member. This endpoint may only be called by workspace administrators.
@@ -12511,9 +12859,8 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.voices.pvc.samples.audio.get( - voice_id="21m00Tcm4TlvDq8ikWAM", - sample_id="VW7YKqPnjY4h39yTbx2L", +client.workspace.members.delete( + email="email", ) ``` @@ -12530,15 +12877,7 @@ client.voices.pvc.samples.audio.get(
-**voice_id:** `str` — Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices. - -
-
- -
-
- -**sample_id:** `str` — Sample ID to be used +**email:** `str` — Email of the target user.
@@ -12558,8 +12897,8 @@ client.voices.pvc.samples.audio.get(
-## Voices Pvc Samples Waveform -
client.voices.pvc.samples.waveform.get(...) +## Workspace Resources +
client.workspace.resources.get(...)
@@ -12571,7 +12910,7 @@ client.voices.pvc.samples.audio.get(
-Retrieve the visual waveform of a voice sample. +Gets the metadata of a resource by ID.
@@ -12591,9 +12930,9 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.voices.pvc.samples.waveform.get( - voice_id="21m00Tcm4TlvDq8ikWAM", - sample_id="VW7YKqPnjY4h39yTbx2L", +client.workspace.resources.get( + resource_id="resource_id", + resource_type="voice", ) ``` @@ -12610,7 +12949,7 @@ client.voices.pvc.samples.waveform.get(
-**voice_id:** `str` — Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices. +**resource_id:** `str` — The ID of the target resource.
@@ -12618,7 +12957,7 @@ client.voices.pvc.samples.waveform.get(
-**sample_id:** `str` — Sample ID to be used +**resource_type:** `WorkspaceResourceType` — Resource type of the target resource.
@@ -12638,8 +12977,7 @@ client.voices.pvc.samples.waveform.get(
-## Voices Pvc Samples Speakers -
client.voices.pvc.samples.speakers.get(...) +
client.workspace.resources.share(...)
@@ -12651,7 +12989,7 @@ client.voices.pvc.samples.waveform.get(
-Retrieve the status of the speaker separation process and the list of detected speakers if complete. +Grants a role on a workspace resource to a user or a group. It overrides any existing role this user/service account/group/workspace api key has on the resource. To target a user or service account, pass only the user email. The user must be in your workspace. To target a group, pass only the group id. To target a workspace api key, pass the api key id. The resource will be shared with the service account associated with the api key. You must have admin access to the resource to share it.
@@ -12671,9 +13009,10 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.voices.pvc.samples.speakers.get( - voice_id="21m00Tcm4TlvDq8ikWAM", - sample_id="VW7YKqPnjY4h39yTbx2L", +client.workspace.resources.share( + resource_id="resource_id", + role="admin", + resource_type="voice", ) ``` @@ -12690,7 +13029,7 @@ client.voices.pvc.samples.speakers.get(
-**voice_id:** `str` — Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices. +**resource_id:** `str` — The ID of the target resource.
@@ -12698,7 +13037,7 @@ client.voices.pvc.samples.speakers.get(
-**sample_id:** `str` — Sample ID to be used +**role:** `BodyShareWorkspaceResourceV1WorkspaceResourcesResourceIdSharePostRole` — Role to update the target principal with.
@@ -12706,70 +13045,23 @@ client.voices.pvc.samples.speakers.get(
-**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. +**resource_type:** `WorkspaceResourceType` — Resource type of the target resource.
- -
- - - - -
- -
client.voices.pvc.samples.speakers.separate(...) -
-
- -#### 📝 Description - -
-
- -
-
- -Start speaker separation process for a sample -
-
-
-
- -#### 🔌 Usage - -
-
-```python -from elevenlabs import ElevenLabs - -client = ElevenLabs( - api_key="YOUR_API_KEY", -) -client.voices.pvc.samples.speakers.separate( - voice_id="21m00Tcm4TlvDq8ikWAM", - sample_id="VW7YKqPnjY4h39yTbx2L", -) - -``` -
-
+**user_email:** `typing.Optional[str]` — The email of the user or service account. +
-#### ⚙️ Parameters - -
-
-
-**voice_id:** `str` — Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices. +**group_id:** `typing.Optional[str]` — The ID of the target group. To target the permissions principals have by default on this resource, use the value 'default'.
@@ -12777,7 +13069,7 @@ client.voices.pvc.samples.speakers.separate(
-**sample_id:** `str` — Sample ID to be used +**workspace_api_key_id:** `typing.Optional[str]` — The ID of the target workspace API key. This isn't the same as the key itself that would you pass in the header for authentication. Workspace admins can find this in the workspace settings UI.
@@ -12797,8 +13089,7 @@ client.voices.pvc.samples.speakers.separate(
-## Voices Pvc Samples Speakers Audio -
client.voices.pvc.samples.speakers.audio.get(...) +
client.workspace.resources.unshare(...)
@@ -12810,7 +13101,7 @@ client.voices.pvc.samples.speakers.separate(
-Retrieve the separated audio for a specific speaker. +Removes any existing role on a workspace resource from a user, service account, group or workspace api key. To target a user or service account, pass only the user email. The user must be in your workspace. To target a group, pass only the group id. To target a workspace api key, pass the api key id. The resource will be unshared from the service account associated with the api key. You must have admin access to the resource to unshare it. You cannot remove permissions from the user who created the resource.
@@ -12830,10 +13121,9 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.voices.pvc.samples.speakers.audio.get( - voice_id="21m00Tcm4TlvDq8ikWAM", - sample_id="VW7YKqPnjY4h39yTbx2L", - speaker_id="VW7YKqPnjY4h39yTbx2L", +client.workspace.resources.unshare( + resource_id="resource_id", + resource_type="voice", ) ``` @@ -12850,7 +13140,7 @@ client.voices.pvc.samples.speakers.audio.get(
-**voice_id:** `str` — Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices. +**resource_id:** `str` — The ID of the target resource.
@@ -12858,7 +13148,7 @@ client.voices.pvc.samples.speakers.audio.get(
-**sample_id:** `str` — Sample ID to be used +**resource_type:** `WorkspaceResourceType` — Resource type of the target resource.
@@ -12866,7 +13156,23 @@ client.voices.pvc.samples.speakers.audio.get(
-**speaker_id:** `str` — Speaker ID to be used, you can use GET https://api.elevenlabs.io/v1/voices/{voice_id}/samples/{sample_id}/speakers to list all the available speakers for a sample. +**user_email:** `typing.Optional[str]` — The email of the user or service account. + +
+
+ +
+
+ +**group_id:** `typing.Optional[str]` — The ID of the target group. To target the permissions principals have by default on this resource, use the value 'default'. + +
+
+ +
+
+ +**workspace_api_key_id:** `typing.Optional[str]` — The ID of the target workspace API key. This isn't the same as the key itself that would you pass in the header for authentication. Workspace admins can find this in the workspace settings UI.
@@ -12886,8 +13192,8 @@ client.voices.pvc.samples.speakers.audio.get(
-## Voices Pvc Verification Captcha -
client.voices.pvc.verification.captcha.get(...) +## Workspace Groups Members +
client.workspace.groups.members.remove(...)
@@ -12899,7 +13205,7 @@ client.voices.pvc.samples.speakers.audio.get(
-Get captcha for PVC voice verification. +Removes a member from the specified group. This endpoint may only be called by workspace administrators.
@@ -12919,8 +13225,9 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.voices.pvc.verification.captcha.get( - voice_id="21m00Tcm4TlvDq8ikWAM", +client.workspace.groups.members.remove( + group_id="group_id", + email="email", ) ``` @@ -12937,7 +13244,15 @@ client.voices.pvc.verification.captcha.get(
-**voice_id:** `str` — Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices. +**group_id:** `str` — The ID of the target group. + +
+
+ +
+
+ +**email:** `str` — The email of the target workspace member.
@@ -12957,7 +13272,7 @@ client.voices.pvc.verification.captcha.get(
-
client.voices.pvc.verification.captcha.verify(...) +
client.workspace.groups.members.add(...)
@@ -12969,7 +13284,7 @@ client.voices.pvc.verification.captcha.get(
-Submit captcha verification for PVC voice. +Adds a member of your workspace to the specified group. This endpoint may only be called by workspace administrators.
@@ -12989,8 +13304,9 @@ from elevenlabs import ElevenLabs client = ElevenLabs( api_key="YOUR_API_KEY", ) -client.voices.pvc.verification.captcha.verify( - voice_id="21m00Tcm4TlvDq8ikWAM", +client.workspace.groups.members.add( + group_id="group_id", + email="email", ) ``` @@ -13007,7 +13323,7 @@ client.voices.pvc.verification.captcha.verify(
-**voice_id:** `str` — Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices. +**group_id:** `str` — The ID of the target group.
@@ -13015,9 +13331,7 @@ client.voices.pvc.verification.captcha.verify(
-**recording:** `from __future__ import annotations - -core.File` — See core.File for more documentation +**email:** `str` — The email of the target workspace member.
diff --git a/requirements.txt b/requirements.txt index a033ef89..90ceac30 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ httpx>=0.21.2 pyaudio>=0.2.14 pydantic>= 1.9.2 -pydantic-core==^2.18.2 +pydantic-core==2.18.2 requests>=2.20 typing_extensions>= 4.0.0 websockets>=11.0 diff --git a/src/elevenlabs/__init__.py b/src/elevenlabs/__init__.py index 31eae064..bb15439e 100644 --- a/src/elevenlabs/__init__.py +++ b/src/elevenlabs/__init__.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# isort: skip_file + from .types import ( AddChapterResponseModel, AddKnowledgeBaseResponseModel, @@ -51,6 +53,7 @@ BanReasonType, BatchCallDetailedResponse, BatchCallRecipientStatus, + BatchCallResponse, BatchCallStatus, BodyAddChapterToAProjectV1ProjectsProjectIdChaptersAddPost, BodyAddProjectV1ProjectsAddPostApplyTextNormalization, @@ -105,6 +108,7 @@ CloseConnection, CloseContext, CloseSocket, + ConvAiDynamicVariable, ConvAiSecretLocator, ConvAiStoredSecretDependencies, ConvAiStoredSecretDependenciesAgentToolsItem, @@ -121,6 +125,8 @@ ConversationConfigClientOverrideConfigOutput, ConversationConfigClientOverrideInput, ConversationConfigClientOverrideOutput, + ConversationConfigOverride, + ConversationConfigOverrideConfig, ConversationDeletionSettings, ConversationHistoryAnalysisCommonModel, ConversationHistoryBatchCallModel, @@ -136,8 +142,10 @@ ConversationHistorySipTrunkingPhoneCallModelDirection, ConversationHistoryTranscriptCommonModelInput, ConversationHistoryTranscriptCommonModelInputRole, + ConversationHistoryTranscriptCommonModelInputSourceMedium, ConversationHistoryTranscriptCommonModelOutput, ConversationHistoryTranscriptCommonModelOutputRole, + ConversationHistoryTranscriptCommonModelOutputSourceMedium, ConversationHistoryTranscriptToolCallClientDetails, ConversationHistoryTranscriptToolCallCommonModel, ConversationHistoryTranscriptToolCallCommonModelToolDetails, @@ -357,6 +365,7 @@ ObjectJsonSchemaPropertyOutput, ObjectJsonSchemaPropertyOutputPropertiesValue, OrbAvatar, + OutboundCallRecipient, OutboundCallRecipientResponseModel, OutputFormat, PdfExportOptions, @@ -480,8 +489,6 @@ SrtExportOptions, StartPvcVoiceTrainingResponseModel, StartSpeakerSeparationResponseModel, - StreamInputQueryParameters, - StreamInputQueryParametersOptimizeStreamingLatency, StreamingAudioChunkWithTimestampsResponse, Subscription, SubscriptionExtrasResponseModel, @@ -575,6 +582,7 @@ WidgetConfigResponseModelAvatar_Url, WidgetExpandable, WidgetFeedbackMode, + WorkspaceBatchCallsResponse, WorkspaceGroupByNameResponseModel, WorkspaceResourceType, ) @@ -587,7 +595,7 @@ forced_alignment, history, models, - pronunciation_dictionary, + pronunciation_dictionaries, samples, speech_to_speech, speech_to_text, @@ -602,57 +610,24 @@ voices, workspace, ) -from .audio_isolation import ( - AudioIsolationAudioIsolationRequestFileFormat, - AudioIsolationAudioIsolationStreamRequestFileFormat, -) +from .audio_isolation import AudioIsolationConvertRequestFileFormat, AudioIsolationStreamRequestFileFormat from .client import AsyncElevenLabs, ElevenLabs -from .conversational_ai import ( - ConversationalAiCreatePhoneNumberRequestBody, - ConversationalAiCreatePhoneNumberRequestBody_SipTrunk, - ConversationalAiCreatePhoneNumberRequestBody_Twilio, - ConversationalAiGetKnowledgeBaseDocumentByIdResponse, - ConversationalAiGetKnowledgeBaseDocumentByIdResponse_File, - ConversationalAiGetKnowledgeBaseDocumentByIdResponse_Text, - ConversationalAiGetKnowledgeBaseDocumentByIdResponse_Url, - ConversationalAiGetPhoneNumberResponse, - ConversationalAiGetPhoneNumberResponse_SipTrunk, - ConversationalAiGetPhoneNumberResponse_Twilio, - ConversationalAiGetPhoneNumbersResponseItem, - ConversationalAiGetPhoneNumbersResponseItem_SipTrunk, - ConversationalAiGetPhoneNumbersResponseItem_Twilio, - ConversationalAiUpdateKnowledgeBaseDocumentResponse, - ConversationalAiUpdateKnowledgeBaseDocumentResponse_File, - ConversationalAiUpdateKnowledgeBaseDocumentResponse_Text, - ConversationalAiUpdateKnowledgeBaseDocumentResponse_Url, - ConversationalAiUpdatePhoneNumberResponse, - ConversationalAiUpdatePhoneNumberResponse_SipTrunk, - ConversationalAiUpdatePhoneNumberResponse_Twilio, - PatchConvAiDashboardSettingsRequestChartsItem, - PatchConvAiDashboardSettingsRequestChartsItem_CallSuccess, - PatchConvAiDashboardSettingsRequestChartsItem_Criteria, - PatchConvAiDashboardSettingsRequestChartsItem_DataCollection, -) -from .dubbing import DubbingGetTranscriptForDubRequestFormatType from .environment import ElevenLabsEnvironment -from .history import HistoryGetAllRequestSource +from .history import HistoryListRequestSource from .play import play, save, stream -from .pronunciation_dictionary import ( +from .pronunciation_dictionaries import ( BodyAddAPronunciationDictionaryV1PronunciationDictionariesAddFromRulesPostRulesItem, BodyAddAPronunciationDictionaryV1PronunciationDictionariesAddFromRulesPostRulesItem_Alias, BodyAddAPronunciationDictionaryV1PronunciationDictionariesAddFromRulesPostRulesItem_Phoneme, BodyAddAPronunciationDictionaryV1PronunciationDictionariesAddFromRulesPostWorkspaceAccess, - PronunciationDictionaryAddFromFileRequestWorkspaceAccess, - PronunciationDictionaryGetAllRequestSort, - PronunciationDictionaryRule, - PronunciationDictionaryRule_Alias, - PronunciationDictionaryRule_Phoneme, + PronunciationDictionariesCreateFromFileRequestWorkspaceAccess, + PronunciationDictionariesListRequestSort, ) from .speech_to_speech import ( - SpeechToSpeechConvertAsStreamRequestFileFormat, - SpeechToSpeechConvertAsStreamRequestOutputFormat, SpeechToSpeechConvertRequestFileFormat, SpeechToSpeechConvertRequestOutputFormat, + SpeechToSpeechStreamRequestFileFormat, + SpeechToSpeechStreamRequestOutputFormat, ) from .speech_to_text import SpeechToTextConvertRequestFileFormat, SpeechToTextConvertRequestTimestampsGranularity from .studio import ( @@ -672,26 +647,16 @@ BodyTextToSpeechStreamingWithTimestampsV1TextToSpeechVoiceIdStreamWithTimestampsPostApplyTextNormalization, BodyTextToSpeechV1TextToSpeechVoiceIdPostApplyTextNormalization, BodyTextToSpeechWithTimestampsV1TextToSpeechVoiceIdWithTimestampsPostApplyTextNormalization, - TextToSpeechConvertAsStreamRequestOutputFormat, TextToSpeechConvertRequestOutputFormat, TextToSpeechConvertWithTimestampsRequestOutputFormat, + TextToSpeechStreamRequestOutputFormat, TextToSpeechStreamWithTimestampsRequestOutputFormat, ) from .text_to_voice import TextToVoiceCreatePreviewsRequestOutputFormat -from .v_1_text_to_speech_voice_id_multi_stream_input import ( - ReceiveMessageMulti, - SendMessageMulti, - TextToSpeechApplyTextNormalization, - TextToSpeechOutputFormat, -) +from .v_1_text_to_speech_voice_id_multi_stream_input import ReceiveMessageMulti, SendMessageMulti from .v_1_text_to_speech_voice_id_stream_input import ReceiveMessage, SendMessage from .version import __version__ from .voices import VoicesGetSharedRequestCategory -from .workspace import ( - BodyInviteUserV1WorkspaceInvitesAddPostWorkspacePermission, - BodyShareWorkspaceResourceV1WorkspaceResourcesResourceIdSharePostRole, - BodyUpdateMemberV1WorkspaceMembersPostWorkspaceRole, -) __all__ = [ "AddChapterResponseModel", @@ -733,8 +698,8 @@ "AsrProvider", "AsrQuality", "AsyncElevenLabs", - "AudioIsolationAudioIsolationRequestFileFormat", - "AudioIsolationAudioIsolationStreamRequestFileFormat", + "AudioIsolationConvertRequestFileFormat", + "AudioIsolationStreamRequestFileFormat", "AudioNativeCreateProjectResponseModel", "AudioNativeEditContentResponseModel", "AudioNativeProjectSettingsResponseModel", @@ -748,6 +713,7 @@ "BanReasonType", "BatchCallDetailedResponse", "BatchCallRecipientStatus", + "BatchCallResponse", "BatchCallStatus", "BodyAddAPronunciationDictionaryV1PronunciationDictionariesAddFromRulesPostRulesItem", "BodyAddAPronunciationDictionaryV1PronunciationDictionariesAddFromRulesPostRulesItem_Alias", @@ -784,16 +750,13 @@ "BodyEditProjectContentV1ProjectsProjectIdContentPost", "BodyGenerateARandomVoiceV1VoiceGenerationGenerateVoicePostAge", "BodyGenerateARandomVoiceV1VoiceGenerationGenerateVoicePostGender", - "BodyInviteUserV1WorkspaceInvitesAddPostWorkspacePermission", "BodyRetrieveVoiceSampleAudioV1VoicesPvcVoiceIdSamplesSampleIdAudioGet", - "BodyShareWorkspaceResourceV1WorkspaceResourcesResourceIdSharePostRole", "BodyStreamChapterAudioV1ProjectsProjectIdChaptersChapterIdSnapshotsChapterSnapshotIdStreamPost", "BodyStreamProjectAudioV1ProjectsProjectIdSnapshotsProjectSnapshotIdStreamPost", "BodyTextToSpeechStreamingV1TextToSpeechVoiceIdStreamPostApplyTextNormalization", "BodyTextToSpeechStreamingWithTimestampsV1TextToSpeechVoiceIdStreamWithTimestampsPostApplyTextNormalization", "BodyTextToSpeechV1TextToSpeechVoiceIdPostApplyTextNormalization", "BodyTextToSpeechWithTimestampsV1TextToSpeechVoiceIdWithTimestampsPostApplyTextNormalization", - "BodyUpdateMemberV1WorkspaceMembersPostWorkspaceRole", "BreakdownTypes", "ChapterContentBlockExtendableNodeResponseModel", "ChapterContentBlockInputModel", @@ -822,6 +785,7 @@ "CloseConnection", "CloseContext", "CloseSocket", + "ConvAiDynamicVariable", "ConvAiSecretLocator", "ConvAiStoredSecretDependencies", "ConvAiStoredSecretDependenciesAgentToolsItem", @@ -838,6 +802,8 @@ "ConversationConfigClientOverrideConfigOutput", "ConversationConfigClientOverrideInput", "ConversationConfigClientOverrideOutput", + "ConversationConfigOverride", + "ConversationConfigOverrideConfig", "ConversationDeletionSettings", "ConversationHistoryAnalysisCommonModel", "ConversationHistoryBatchCallModel", @@ -853,8 +819,10 @@ "ConversationHistorySipTrunkingPhoneCallModelDirection", "ConversationHistoryTranscriptCommonModelInput", "ConversationHistoryTranscriptCommonModelInputRole", + "ConversationHistoryTranscriptCommonModelInputSourceMedium", "ConversationHistoryTranscriptCommonModelOutput", "ConversationHistoryTranscriptCommonModelOutputRole", + "ConversationHistoryTranscriptCommonModelOutputSourceMedium", "ConversationHistoryTranscriptToolCallClientDetails", "ConversationHistoryTranscriptToolCallCommonModel", "ConversationHistoryTranscriptToolCallCommonModelToolDetails", @@ -881,26 +849,6 @@ "ConversationTokenDbModel", "ConversationTokenPurpose", "ConversationTurnMetrics", - "ConversationalAiCreatePhoneNumberRequestBody", - "ConversationalAiCreatePhoneNumberRequestBody_SipTrunk", - "ConversationalAiCreatePhoneNumberRequestBody_Twilio", - "ConversationalAiGetKnowledgeBaseDocumentByIdResponse", - "ConversationalAiGetKnowledgeBaseDocumentByIdResponse_File", - "ConversationalAiGetKnowledgeBaseDocumentByIdResponse_Text", - "ConversationalAiGetKnowledgeBaseDocumentByIdResponse_Url", - "ConversationalAiGetPhoneNumberResponse", - "ConversationalAiGetPhoneNumberResponse_SipTrunk", - "ConversationalAiGetPhoneNumberResponse_Twilio", - "ConversationalAiGetPhoneNumbersResponseItem", - "ConversationalAiGetPhoneNumbersResponseItem_SipTrunk", - "ConversationalAiGetPhoneNumbersResponseItem_Twilio", - "ConversationalAiUpdateKnowledgeBaseDocumentResponse", - "ConversationalAiUpdateKnowledgeBaseDocumentResponse_File", - "ConversationalAiUpdateKnowledgeBaseDocumentResponse_Text", - "ConversationalAiUpdateKnowledgeBaseDocumentResponse_Url", - "ConversationalAiUpdatePhoneNumberResponse", - "ConversationalAiUpdatePhoneNumberResponse_SipTrunk", - "ConversationalAiUpdatePhoneNumberResponse_Twilio", "ConversationalConfig", "ConvertChapterResponseModel", "ConvertProjectResponseModel", @@ -943,7 +891,6 @@ "DocumentUsageModeEnum", "DocxExportOptions", "DubbedSegment", - "DubbingGetTranscriptForDubRequestFormatType", "DubbingMediaMetadata", "DubbingMediaReference", "DubbingMetadataResponse", @@ -1050,8 +997,8 @@ "GetWorkspaceSecretsResponseModel", "HistoryAlignmentResponseModel", "HistoryAlignmentsResponseModel", - "HistoryGetAllRequestSource", "HistoryItemResponse", + "HistoryListRequestSource", "HtmlExportOptions", "HttpValidationError", "ImageAvatar", @@ -1100,12 +1047,9 @@ "ObjectJsonSchemaPropertyOutput", "ObjectJsonSchemaPropertyOutputPropertiesValue", "OrbAvatar", + "OutboundCallRecipient", "OutboundCallRecipientResponseModel", "OutputFormat", - "PatchConvAiDashboardSettingsRequestChartsItem", - "PatchConvAiDashboardSettingsRequestChartsItem_CallSuccess", - "PatchConvAiDashboardSettingsRequestChartsItem_Criteria", - "PatchConvAiDashboardSettingsRequestChartsItem_DataCollection", "PdfExportOptions", "PhoneNumberAgentInfo", "PhoneNumberTransfer", @@ -1158,15 +1102,12 @@ "PromptAgentOverride", "PromptAgentOverrideConfig", "PromptEvaluationCriteria", - "PronunciationDictionaryAddFromFileRequestWorkspaceAccess", + "PronunciationDictionariesCreateFromFileRequestWorkspaceAccess", + "PronunciationDictionariesListRequestSort", "PronunciationDictionaryAliasRuleRequestModel", - "PronunciationDictionaryGetAllRequestSort", "PronunciationDictionaryLocator", "PronunciationDictionaryLocatorResponseModel", "PronunciationDictionaryPhonemeRuleRequestModel", - "PronunciationDictionaryRule", - "PronunciationDictionaryRule_Alias", - "PronunciationDictionaryRule_Phoneme", "PronunciationDictionaryRulesResponseModel", "PronunciationDictionaryVersionLocator", "PronunciationDictionaryVersionResponseModel", @@ -1229,10 +1170,10 @@ "SpeechHistoryItemResponse", "SpeechHistoryItemResponseModelSource", "SpeechHistoryItemResponseModelVoiceCategory", - "SpeechToSpeechConvertAsStreamRequestFileFormat", - "SpeechToSpeechConvertAsStreamRequestOutputFormat", "SpeechToSpeechConvertRequestFileFormat", "SpeechToSpeechConvertRequestOutputFormat", + "SpeechToSpeechStreamRequestFileFormat", + "SpeechToSpeechStreamRequestOutputFormat", "SpeechToTextCharacterResponseModel", "SpeechToTextChunkResponseModel", "SpeechToTextConvertRequestFileFormat", @@ -1242,8 +1183,6 @@ "SrtExportOptions", "StartPvcVoiceTrainingResponseModel", "StartSpeakerSeparationResponseModel", - "StreamInputQueryParameters", - "StreamInputQueryParametersOptimizeStreamingLatency", "StreamingAudioChunkWithTimestampsResponse", "Subscription", "SubscriptionExtrasResponseModel", @@ -1267,14 +1206,12 @@ "SystemToolConfigOutputParams_TransferToNumber", "TelephonyProvider", "TextToSoundEffectsConvertRequestOutputFormat", - "TextToSpeechApplyTextNormalization", "TextToSpeechApplyTextNormalizationEnum", - "TextToSpeechConvertAsStreamRequestOutputFormat", "TextToSpeechConvertRequestOutputFormat", "TextToSpeechConvertWithTimestampsRequestOutputFormat", - "TextToSpeechOutputFormat", "TextToSpeechOutputFormatEnum", "TextToSpeechStreamRequest", + "TextToSpeechStreamRequestOutputFormat", "TextToSpeechStreamWithTimestampsRequestOutputFormat", "TextToVoiceCreatePreviewsRequestOutputFormat", "TooEarlyError", @@ -1348,6 +1285,7 @@ "WidgetConfigResponseModelAvatar_Url", "WidgetExpandable", "WidgetFeedbackMode", + "WorkspaceBatchCallsResponse", "WorkspaceGroupByNameResponseModel", "WorkspaceResourceType", "__version__", @@ -1359,7 +1297,7 @@ "history", "models", "play", - "pronunciation_dictionary", + "pronunciation_dictionaries", "samples", "save", "speech_to_speech", diff --git a/src/elevenlabs/audio_isolation/__init__.py b/src/elevenlabs/audio_isolation/__init__.py index 817dc5b3..6602e7aa 100644 --- a/src/elevenlabs/audio_isolation/__init__.py +++ b/src/elevenlabs/audio_isolation/__init__.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. -from .types import AudioIsolationAudioIsolationRequestFileFormat, AudioIsolationAudioIsolationStreamRequestFileFormat +# isort: skip_file -__all__ = ["AudioIsolationAudioIsolationRequestFileFormat", "AudioIsolationAudioIsolationStreamRequestFileFormat"] +from .types import AudioIsolationConvertRequestFileFormat, AudioIsolationStreamRequestFileFormat + +__all__ = ["AudioIsolationConvertRequestFileFormat", "AudioIsolationStreamRequestFileFormat"] diff --git a/src/elevenlabs/audio_isolation/client.py b/src/elevenlabs/audio_isolation/client.py index e475aa4b..3773c0ee 100644 --- a/src/elevenlabs/audio_isolation/client.py +++ b/src/elevenlabs/audio_isolation/client.py @@ -1,21 +1,13 @@ # This file was auto-generated by Fern from our API Definition. import typing -from ..core.client_wrapper import SyncClientWrapper + from .. import core -from .types.audio_isolation_audio_isolation_request_file_format import ( - AudioIsolationAudioIsolationRequestFileFormat, -) +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ..core.request_options import RequestOptions -from ..errors.unprocessable_entity_error import UnprocessableEntityError -from ..types.http_validation_error import HttpValidationError -from ..core.unchecked_base_model import construct_type -from json.decoder import JSONDecodeError -from ..core.api_error import ApiError -from .types.audio_isolation_audio_isolation_stream_request_file_format import ( - AudioIsolationAudioIsolationStreamRequestFileFormat, -) -from ..core.client_wrapper import AsyncClientWrapper +from .raw_client import AsyncRawAudioIsolationClient, RawAudioIsolationClient +from .types.audio_isolation_convert_request_file_format import AudioIsolationConvertRequestFileFormat +from .types.audio_isolation_stream_request_file_format import AudioIsolationStreamRequestFileFormat # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -23,13 +15,24 @@ class AudioIsolationClient: def __init__(self, *, client_wrapper: SyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = RawAudioIsolationClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawAudioIsolationClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawAudioIsolationClient + """ + return self._raw_client - def audio_isolation( + def convert( self, *, audio: core.File, - file_format: typing.Optional[AudioIsolationAudioIsolationRequestFileFormat] = OMIT, + file_format: typing.Optional[AudioIsolationConvertRequestFileFormat] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> typing.Iterator[bytes]: """ @@ -40,57 +43,25 @@ def audio_isolation( audio : core.File See core.File for more documentation - file_format : typing.Optional[AudioIsolationAudioIsolationRequestFileFormat] + file_format : typing.Optional[AudioIsolationConvertRequestFileFormat] The format of input audio. Options are 'pcm_s16le_16' or 'other' For `pcm_s16le_16`, the input audio must be 16-bit PCM at a 16kHz sample rate, single channel (mono), and little-endian byte order. Latency will be lower than with passing an encoded waveform. request_options : typing.Optional[RequestOptions] Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. - Yields - ------ + Returns + ------- typing.Iterator[bytes] Successful Response """ - with self._client_wrapper.httpx_client.stream( - "v1/audio-isolation", - base_url=self._client_wrapper.get_environment().base, - method="POST", - data={ - "file_format": file_format, - }, - files={ - "audio": audio, - }, - request_options=request_options, - omit=OMIT, - ) as _response: - try: - if 200 <= _response.status_code < 300: - _chunk_size = request_options.get("chunk_size", 1024) if request_options is not None else 1024 - for _chunk in _response.iter_bytes(chunk_size=_chunk_size): - yield _chunk - return - _response.read() - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + with self._raw_client.convert(audio=audio, file_format=file_format, request_options=request_options) as r: + yield from r.data - def audio_isolation_stream( + def stream( self, *, audio: core.File, - file_format: typing.Optional[AudioIsolationAudioIsolationStreamRequestFileFormat] = OMIT, + file_format: typing.Optional[AudioIsolationStreamRequestFileFormat] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> typing.Iterator[bytes]: """ @@ -101,62 +72,41 @@ def audio_isolation_stream( audio : core.File See core.File for more documentation - file_format : typing.Optional[AudioIsolationAudioIsolationStreamRequestFileFormat] + file_format : typing.Optional[AudioIsolationStreamRequestFileFormat] The format of input audio. Options are 'pcm_s16le_16' or 'other' For `pcm_s16le_16`, the input audio must be 16-bit PCM at a 16kHz sample rate, single channel (mono), and little-endian byte order. Latency will be lower than with passing an encoded waveform. request_options : typing.Optional[RequestOptions] Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. - Yields - ------ + Returns + ------- typing.Iterator[bytes] Successful Response """ - with self._client_wrapper.httpx_client.stream( - "v1/audio-isolation/stream", - base_url=self._client_wrapper.get_environment().base, - method="POST", - data={ - "file_format": file_format, - }, - files={ - "audio": audio, - }, - request_options=request_options, - omit=OMIT, - ) as _response: - try: - if 200 <= _response.status_code < 300: - _chunk_size = request_options.get("chunk_size", 1024) if request_options is not None else 1024 - for _chunk in _response.iter_bytes(chunk_size=_chunk_size): - yield _chunk - return - _response.read() - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + with self._raw_client.stream(audio=audio, file_format=file_format, request_options=request_options) as r: + yield from r.data class AsyncAudioIsolationClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = AsyncRawAudioIsolationClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawAudioIsolationClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawAudioIsolationClient + """ + return self._raw_client - async def audio_isolation( + async def convert( self, *, audio: core.File, - file_format: typing.Optional[AudioIsolationAudioIsolationRequestFileFormat] = OMIT, + file_format: typing.Optional[AudioIsolationConvertRequestFileFormat] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> typing.AsyncIterator[bytes]: """ @@ -167,57 +117,26 @@ async def audio_isolation( audio : core.File See core.File for more documentation - file_format : typing.Optional[AudioIsolationAudioIsolationRequestFileFormat] + file_format : typing.Optional[AudioIsolationConvertRequestFileFormat] The format of input audio. Options are 'pcm_s16le_16' or 'other' For `pcm_s16le_16`, the input audio must be 16-bit PCM at a 16kHz sample rate, single channel (mono), and little-endian byte order. Latency will be lower than with passing an encoded waveform. request_options : typing.Optional[RequestOptions] Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. - Yields - ------ + Returns + ------- typing.AsyncIterator[bytes] Successful Response """ - async with self._client_wrapper.httpx_client.stream( - "v1/audio-isolation", - base_url=self._client_wrapper.get_environment().base, - method="POST", - data={ - "file_format": file_format, - }, - files={ - "audio": audio, - }, - request_options=request_options, - omit=OMIT, - ) as _response: - try: - if 200 <= _response.status_code < 300: - _chunk_size = request_options.get("chunk_size", 1024) if request_options is not None else 1024 - async for _chunk in _response.aiter_bytes(chunk_size=_chunk_size): - yield _chunk - return - await _response.aread() - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + async with self._raw_client.convert(audio=audio, file_format=file_format, request_options=request_options) as r: + async for _chunk in r.data: + yield _chunk - async def audio_isolation_stream( + async def stream( self, *, audio: core.File, - file_format: typing.Optional[AudioIsolationAudioIsolationStreamRequestFileFormat] = OMIT, + file_format: typing.Optional[AudioIsolationStreamRequestFileFormat] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> typing.AsyncIterator[bytes]: """ @@ -228,48 +147,17 @@ async def audio_isolation_stream( audio : core.File See core.File for more documentation - file_format : typing.Optional[AudioIsolationAudioIsolationStreamRequestFileFormat] + file_format : typing.Optional[AudioIsolationStreamRequestFileFormat] The format of input audio. Options are 'pcm_s16le_16' or 'other' For `pcm_s16le_16`, the input audio must be 16-bit PCM at a 16kHz sample rate, single channel (mono), and little-endian byte order. Latency will be lower than with passing an encoded waveform. request_options : typing.Optional[RequestOptions] Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. - Yields - ------ + Returns + ------- typing.AsyncIterator[bytes] Successful Response """ - async with self._client_wrapper.httpx_client.stream( - "v1/audio-isolation/stream", - base_url=self._client_wrapper.get_environment().base, - method="POST", - data={ - "file_format": file_format, - }, - files={ - "audio": audio, - }, - request_options=request_options, - omit=OMIT, - ) as _response: - try: - if 200 <= _response.status_code < 300: - _chunk_size = request_options.get("chunk_size", 1024) if request_options is not None else 1024 - async for _chunk in _response.aiter_bytes(chunk_size=_chunk_size): - yield _chunk - return - await _response.aread() - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + async with self._raw_client.stream(audio=audio, file_format=file_format, request_options=request_options) as r: + async for _chunk in r.data: + yield _chunk diff --git a/src/elevenlabs/audio_isolation/raw_client.py b/src/elevenlabs/audio_isolation/raw_client.py new file mode 100644 index 00000000..03ed2241 --- /dev/null +++ b/src/elevenlabs/audio_isolation/raw_client.py @@ -0,0 +1,311 @@ +# This file was auto-generated by Fern from our API Definition. + +import contextlib +import typing +from json.decoder import JSONDecodeError + +from .. import core +from ..core.api_error import ApiError +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ..core.http_response import AsyncHttpResponse, HttpResponse +from ..core.request_options import RequestOptions +from ..core.unchecked_base_model import construct_type +from ..errors.unprocessable_entity_error import UnprocessableEntityError +from ..types.http_validation_error import HttpValidationError +from .types.audio_isolation_convert_request_file_format import AudioIsolationConvertRequestFileFormat +from .types.audio_isolation_stream_request_file_format import AudioIsolationStreamRequestFileFormat + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RawAudioIsolationClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + @contextlib.contextmanager + def convert( + self, + *, + audio: core.File, + file_format: typing.Optional[AudioIsolationConvertRequestFileFormat] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> typing.Iterator[HttpResponse[typing.Iterator[bytes]]]: + """ + Removes background noise from audio. + + Parameters + ---------- + audio : core.File + See core.File for more documentation + + file_format : typing.Optional[AudioIsolationConvertRequestFileFormat] + The format of input audio. Options are 'pcm_s16le_16' or 'other' For `pcm_s16le_16`, the input audio must be 16-bit PCM at a 16kHz sample rate, single channel (mono), and little-endian byte order. Latency will be lower than with passing an encoded waveform. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. + + Returns + ------- + typing.Iterator[HttpResponse[typing.Iterator[bytes]]] + Successful Response + """ + with self._client_wrapper.httpx_client.stream( + "v1/audio-isolation", + base_url=self._client_wrapper.get_environment().base, + method="POST", + data={ + "file_format": file_format, + }, + files={ + "audio": audio, + }, + request_options=request_options, + omit=OMIT, + force_multipart=True, + ) as _response: + + def _stream() -> HttpResponse[typing.Iterator[bytes]]: + try: + if 200 <= _response.status_code < 300: + _chunk_size = request_options.get("chunk_size", 1024) if request_options is not None else 1024 + return HttpResponse( + response=_response, data=(_chunk for _chunk in _response.iter_bytes(chunk_size=_chunk_size)) + ) + _response.read() + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + yield _stream() + + @contextlib.contextmanager + def stream( + self, + *, + audio: core.File, + file_format: typing.Optional[AudioIsolationStreamRequestFileFormat] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> typing.Iterator[HttpResponse[typing.Iterator[bytes]]]: + """ + Removes background noise from audio. + + Parameters + ---------- + audio : core.File + See core.File for more documentation + + file_format : typing.Optional[AudioIsolationStreamRequestFileFormat] + The format of input audio. Options are 'pcm_s16le_16' or 'other' For `pcm_s16le_16`, the input audio must be 16-bit PCM at a 16kHz sample rate, single channel (mono), and little-endian byte order. Latency will be lower than with passing an encoded waveform. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. + + Returns + ------- + typing.Iterator[HttpResponse[typing.Iterator[bytes]]] + Successful Response + """ + with self._client_wrapper.httpx_client.stream( + "v1/audio-isolation/stream", + base_url=self._client_wrapper.get_environment().base, + method="POST", + data={ + "file_format": file_format, + }, + files={ + "audio": audio, + }, + request_options=request_options, + omit=OMIT, + force_multipart=True, + ) as _response: + + def _stream() -> HttpResponse[typing.Iterator[bytes]]: + try: + if 200 <= _response.status_code < 300: + _chunk_size = request_options.get("chunk_size", 1024) if request_options is not None else 1024 + return HttpResponse( + response=_response, data=(_chunk for _chunk in _response.iter_bytes(chunk_size=_chunk_size)) + ) + _response.read() + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + yield _stream() + + +class AsyncRawAudioIsolationClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + @contextlib.asynccontextmanager + async def convert( + self, + *, + audio: core.File, + file_format: typing.Optional[AudioIsolationConvertRequestFileFormat] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> typing.AsyncIterator[AsyncHttpResponse[typing.AsyncIterator[bytes]]]: + """ + Removes background noise from audio. + + Parameters + ---------- + audio : core.File + See core.File for more documentation + + file_format : typing.Optional[AudioIsolationConvertRequestFileFormat] + The format of input audio. Options are 'pcm_s16le_16' or 'other' For `pcm_s16le_16`, the input audio must be 16-bit PCM at a 16kHz sample rate, single channel (mono), and little-endian byte order. Latency will be lower than with passing an encoded waveform. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. + + Returns + ------- + typing.AsyncIterator[AsyncHttpResponse[typing.AsyncIterator[bytes]]] + Successful Response + """ + async with self._client_wrapper.httpx_client.stream( + "v1/audio-isolation", + base_url=self._client_wrapper.get_environment().base, + method="POST", + data={ + "file_format": file_format, + }, + files={ + "audio": audio, + }, + request_options=request_options, + omit=OMIT, + force_multipart=True, + ) as _response: + + async def _stream() -> AsyncHttpResponse[typing.AsyncIterator[bytes]]: + try: + if 200 <= _response.status_code < 300: + _chunk_size = request_options.get("chunk_size", 1024) if request_options is not None else 1024 + return AsyncHttpResponse( + response=_response, + data=(_chunk async for _chunk in _response.aiter_bytes(chunk_size=_chunk_size)), + ) + await _response.aread() + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + yield await _stream() + + @contextlib.asynccontextmanager + async def stream( + self, + *, + audio: core.File, + file_format: typing.Optional[AudioIsolationStreamRequestFileFormat] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> typing.AsyncIterator[AsyncHttpResponse[typing.AsyncIterator[bytes]]]: + """ + Removes background noise from audio. + + Parameters + ---------- + audio : core.File + See core.File for more documentation + + file_format : typing.Optional[AudioIsolationStreamRequestFileFormat] + The format of input audio. Options are 'pcm_s16le_16' or 'other' For `pcm_s16le_16`, the input audio must be 16-bit PCM at a 16kHz sample rate, single channel (mono), and little-endian byte order. Latency will be lower than with passing an encoded waveform. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. + + Returns + ------- + typing.AsyncIterator[AsyncHttpResponse[typing.AsyncIterator[bytes]]] + Successful Response + """ + async with self._client_wrapper.httpx_client.stream( + "v1/audio-isolation/stream", + base_url=self._client_wrapper.get_environment().base, + method="POST", + data={ + "file_format": file_format, + }, + files={ + "audio": audio, + }, + request_options=request_options, + omit=OMIT, + force_multipart=True, + ) as _response: + + async def _stream() -> AsyncHttpResponse[typing.AsyncIterator[bytes]]: + try: + if 200 <= _response.status_code < 300: + _chunk_size = request_options.get("chunk_size", 1024) if request_options is not None else 1024 + return AsyncHttpResponse( + response=_response, + data=(_chunk async for _chunk in _response.aiter_bytes(chunk_size=_chunk_size)), + ) + await _response.aread() + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + yield await _stream() diff --git a/src/elevenlabs/audio_isolation/types/__init__.py b/src/elevenlabs/audio_isolation/types/__init__.py index 9d2b6440..61975f84 100644 --- a/src/elevenlabs/audio_isolation/types/__init__.py +++ b/src/elevenlabs/audio_isolation/types/__init__.py @@ -1,8 +1,8 @@ # This file was auto-generated by Fern from our API Definition. -from .audio_isolation_audio_isolation_request_file_format import AudioIsolationAudioIsolationRequestFileFormat -from .audio_isolation_audio_isolation_stream_request_file_format import ( - AudioIsolationAudioIsolationStreamRequestFileFormat, -) +# isort: skip_file -__all__ = ["AudioIsolationAudioIsolationRequestFileFormat", "AudioIsolationAudioIsolationStreamRequestFileFormat"] +from .audio_isolation_convert_request_file_format import AudioIsolationConvertRequestFileFormat +from .audio_isolation_stream_request_file_format import AudioIsolationStreamRequestFileFormat + +__all__ = ["AudioIsolationConvertRequestFileFormat", "AudioIsolationStreamRequestFileFormat"] diff --git a/src/elevenlabs/audio_isolation/types/audio_isolation_audio_isolation_request_file_format.py b/src/elevenlabs/audio_isolation/types/audio_isolation_audio_isolation_request_file_format.py deleted file mode 100644 index 2aa55c29..00000000 --- a/src/elevenlabs/audio_isolation/types/audio_isolation_audio_isolation_request_file_format.py +++ /dev/null @@ -1,5 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import typing - -AudioIsolationAudioIsolationRequestFileFormat = typing.Union[typing.Literal["pcm_s16le_16", "other"], typing.Any] diff --git a/src/elevenlabs/audio_isolation/types/audio_isolation_audio_isolation_stream_request_file_format.py b/src/elevenlabs/audio_isolation/types/audio_isolation_audio_isolation_stream_request_file_format.py deleted file mode 100644 index c09bafec..00000000 --- a/src/elevenlabs/audio_isolation/types/audio_isolation_audio_isolation_stream_request_file_format.py +++ /dev/null @@ -1,5 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import typing - -AudioIsolationAudioIsolationStreamRequestFileFormat = typing.Union[typing.Literal["pcm_s16le_16", "other"], typing.Any] diff --git a/src/elevenlabs/audio_isolation/types/audio_isolation_convert_request_file_format.py b/src/elevenlabs/audio_isolation/types/audio_isolation_convert_request_file_format.py new file mode 100644 index 00000000..4b4db621 --- /dev/null +++ b/src/elevenlabs/audio_isolation/types/audio_isolation_convert_request_file_format.py @@ -0,0 +1,5 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +AudioIsolationConvertRequestFileFormat = typing.Union[typing.Literal["pcm_s16le_16", "other"], typing.Any] diff --git a/src/elevenlabs/audio_isolation/types/audio_isolation_stream_request_file_format.py b/src/elevenlabs/audio_isolation/types/audio_isolation_stream_request_file_format.py new file mode 100644 index 00000000..739aef42 --- /dev/null +++ b/src/elevenlabs/audio_isolation/types/audio_isolation_stream_request_file_format.py @@ -0,0 +1,5 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +AudioIsolationStreamRequestFileFormat = typing.Union[typing.Literal["pcm_s16le_16", "other"], typing.Any] diff --git a/src/elevenlabs/audio_native/__init__.py b/src/elevenlabs/audio_native/__init__.py index f3ea2659..5cde0202 100644 --- a/src/elevenlabs/audio_native/__init__.py +++ b/src/elevenlabs/audio_native/__init__.py @@ -1,2 +1,4 @@ # This file was auto-generated by Fern from our API Definition. +# isort: skip_file + diff --git a/src/elevenlabs/audio_native/client.py b/src/elevenlabs/audio_native/client.py index 1017b0b3..9ca194b8 100644 --- a/src/elevenlabs/audio_native/client.py +++ b/src/elevenlabs/audio_native/client.py @@ -1,25 +1,14 @@ # This file was auto-generated by Fern from our API Definition. import typing -from ..core.client_wrapper import SyncClientWrapper + from .. import core +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ..core.request_options import RequestOptions -from ..types.audio_native_create_project_response_model import ( - AudioNativeCreateProjectResponseModel, -) -from ..core.unchecked_base_model import construct_type -from ..errors.unprocessable_entity_error import UnprocessableEntityError -from ..types.http_validation_error import HttpValidationError -from json.decoder import JSONDecodeError -from ..core.api_error import ApiError -from ..types.get_audio_native_project_settings_response_model import ( - GetAudioNativeProjectSettingsResponseModel, -) -from ..core.jsonable_encoder import jsonable_encoder -from ..types.audio_native_edit_content_response_model import ( - AudioNativeEditContentResponseModel, -) -from ..core.client_wrapper import AsyncClientWrapper +from ..types.audio_native_create_project_response_model import AudioNativeCreateProjectResponseModel +from ..types.audio_native_edit_content_response_model import AudioNativeEditContentResponseModel +from ..types.get_audio_native_project_settings_response_model import GetAudioNativeProjectSettingsResponseModel +from .raw_client import AsyncRawAudioNativeClient, RawAudioNativeClient # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -27,7 +16,18 @@ class AudioNativeClient: def __init__(self, *, client_wrapper: SyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = RawAudioNativeClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawAudioNativeClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawAudioNativeClient + """ + return self._raw_client def create( self, @@ -106,58 +106,25 @@ def create( name="name", ) """ - _response = self._client_wrapper.httpx_client.request( - "v1/audio-native", - base_url=self._client_wrapper.get_environment().base, - method="POST", - data={ - "name": name, - "image": image, - "author": author, - "title": title, - "small": small, - "text_color": text_color, - "background_color": background_color, - "sessionization": sessionization, - "voice_id": voice_id, - "model_id": model_id, - "auto_convert": auto_convert, - }, - files={ - "file": file, - }, + _response = self._raw_client.create( + name=name, + image=image, + author=author, + title=title, + small=small, + text_color=text_color, + background_color=background_color, + sessionization=sessionization, + voice_id=voice_id, + model_id=model_id, + file=file, + auto_convert=auto_convert, request_options=request_options, - omit=OMIT, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - AudioNativeCreateProjectResponseModel, - construct_type( - type_=AudioNativeCreateProjectResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + return _response.data def get_settings( - self, - project_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, + self, project_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> GetAudioNativeProjectSettingsResponseModel: """ Get player settings for the specific project. @@ -186,37 +153,10 @@ def get_settings( project_id="21m00Tcm4TlvDq8ikWAM", ) """ - _response = self._client_wrapper.httpx_client.request( - f"v1/audio-native/{jsonable_encoder(project_id)}/settings", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - GetAudioNativeProjectSettingsResponseModel, - construct_type( - type_=GetAudioNativeProjectSettingsResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def update_content( + _response = self._raw_client.get_settings(project_id, request_options=request_options) + return _response.data + + def update( self, project_id: str, *, @@ -257,52 +197,30 @@ def update_content( client = ElevenLabs( api_key="YOUR_API_KEY", ) - client.audio_native.update_content( + client.audio_native.update( project_id="21m00Tcm4TlvDq8ikWAM", ) """ - _response = self._client_wrapper.httpx_client.request( - f"v1/audio-native/{jsonable_encoder(project_id)}/content", - base_url=self._client_wrapper.get_environment().base, - method="POST", - data={ - "auto_convert": auto_convert, - "auto_publish": auto_publish, - }, - files={ - "file": file, - }, - request_options=request_options, - omit=OMIT, + _response = self._raw_client.update( + project_id, file=file, auto_convert=auto_convert, auto_publish=auto_publish, request_options=request_options ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - AudioNativeEditContentResponseModel, - construct_type( - type_=AudioNativeEditContentResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + return _response.data class AsyncAudioNativeClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = AsyncRawAudioNativeClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawAudioNativeClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawAudioNativeClient + """ + return self._raw_client async def create( self, @@ -389,58 +307,25 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - "v1/audio-native", - base_url=self._client_wrapper.get_environment().base, - method="POST", - data={ - "name": name, - "image": image, - "author": author, - "title": title, - "small": small, - "text_color": text_color, - "background_color": background_color, - "sessionization": sessionization, - "voice_id": voice_id, - "model_id": model_id, - "auto_convert": auto_convert, - }, - files={ - "file": file, - }, + _response = await self._raw_client.create( + name=name, + image=image, + author=author, + title=title, + small=small, + text_color=text_color, + background_color=background_color, + sessionization=sessionization, + voice_id=voice_id, + model_id=model_id, + file=file, + auto_convert=auto_convert, request_options=request_options, - omit=OMIT, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - AudioNativeCreateProjectResponseModel, - construct_type( - type_=AudioNativeCreateProjectResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + return _response.data async def get_settings( - self, - project_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, + self, project_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> GetAudioNativeProjectSettingsResponseModel: """ Get player settings for the specific project. @@ -477,37 +362,10 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/audio-native/{jsonable_encoder(project_id)}/settings", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - GetAudioNativeProjectSettingsResponseModel, - construct_type( - type_=GetAudioNativeProjectSettingsResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def update_content( + _response = await self._raw_client.get_settings(project_id, request_options=request_options) + return _response.data + + async def update( self, project_id: str, *, @@ -553,47 +411,14 @@ async def update_content( async def main() -> None: - await client.audio_native.update_content( + await client.audio_native.update( project_id="21m00Tcm4TlvDq8ikWAM", ) asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/audio-native/{jsonable_encoder(project_id)}/content", - base_url=self._client_wrapper.get_environment().base, - method="POST", - data={ - "auto_convert": auto_convert, - "auto_publish": auto_publish, - }, - files={ - "file": file, - }, - request_options=request_options, - omit=OMIT, + _response = await self._raw_client.update( + project_id, file=file, auto_convert=auto_convert, auto_publish=auto_publish, request_options=request_options ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - AudioNativeEditContentResponseModel, - construct_type( - type_=AudioNativeEditContentResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + return _response.data diff --git a/src/elevenlabs/audio_native/raw_client.py b/src/elevenlabs/audio_native/raw_client.py new file mode 100644 index 00000000..9000e3ba --- /dev/null +++ b/src/elevenlabs/audio_native/raw_client.py @@ -0,0 +1,514 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from .. import core +from ..core.api_error import ApiError +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ..core.http_response import AsyncHttpResponse, HttpResponse +from ..core.jsonable_encoder import jsonable_encoder +from ..core.request_options import RequestOptions +from ..core.unchecked_base_model import construct_type +from ..errors.unprocessable_entity_error import UnprocessableEntityError +from ..types.audio_native_create_project_response_model import AudioNativeCreateProjectResponseModel +from ..types.audio_native_edit_content_response_model import AudioNativeEditContentResponseModel +from ..types.get_audio_native_project_settings_response_model import GetAudioNativeProjectSettingsResponseModel +from ..types.http_validation_error import HttpValidationError + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RawAudioNativeClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def create( + self, + *, + name: str, + image: typing.Optional[str] = OMIT, + author: typing.Optional[str] = OMIT, + title: typing.Optional[str] = OMIT, + small: typing.Optional[bool] = OMIT, + text_color: typing.Optional[str] = OMIT, + background_color: typing.Optional[str] = OMIT, + sessionization: typing.Optional[int] = OMIT, + voice_id: typing.Optional[str] = OMIT, + model_id: typing.Optional[str] = OMIT, + file: typing.Optional[core.File] = OMIT, + auto_convert: typing.Optional[bool] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[AudioNativeCreateProjectResponseModel]: + """ + Creates Audio Native enabled project, optionally starts conversion and returns project ID and embeddable HTML snippet. + + Parameters + ---------- + name : str + Project name. + + image : typing.Optional[str] + (Deprecated) Image URL used in the player. If not provided, default image set in the Player settings is used. + + author : typing.Optional[str] + Author used in the player and inserted at the start of the uploaded article. If not provided, the default author set in the Player settings is used. + + title : typing.Optional[str] + Title used in the player and inserted at the top of the uploaded article. If not provided, the default title set in the Player settings is used. + + small : typing.Optional[bool] + (Deprecated) Whether to use small player or not. If not provided, default value set in the Player settings is used. + + text_color : typing.Optional[str] + Text color used in the player. If not provided, default text color set in the Player settings is used. + + background_color : typing.Optional[str] + Background color used in the player. If not provided, default background color set in the Player settings is used. + + sessionization : typing.Optional[int] + (Deprecated) Specifies for how many minutes to persist the session across page reloads. If not provided, default sessionization set in the Player settings is used. + + voice_id : typing.Optional[str] + Voice ID used to voice the content. If not provided, default voice ID set in the Player settings is used. + + model_id : typing.Optional[str] + TTS Model ID used in the player. If not provided, default model ID set in the Player settings is used. + + file : typing.Optional[core.File] + See core.File for more documentation + + auto_convert : typing.Optional[bool] + Whether to auto convert the project to audio or not. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[AudioNativeCreateProjectResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + "v1/audio-native", + base_url=self._client_wrapper.get_environment().base, + method="POST", + data={ + "name": name, + "image": image, + "author": author, + "title": title, + "small": small, + "text_color": text_color, + "background_color": background_color, + "sessionization": sessionization, + "voice_id": voice_id, + "model_id": model_id, + "auto_convert": auto_convert, + }, + files={ + **({"file": file} if file is not None else {}), + }, + request_options=request_options, + omit=OMIT, + force_multipart=True, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + AudioNativeCreateProjectResponseModel, + construct_type( + type_=AudioNativeCreateProjectResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def get_settings( + self, project_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[GetAudioNativeProjectSettingsResponseModel]: + """ + Get player settings for the specific project. + + Parameters + ---------- + project_id : str + The ID of the Studio project. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[GetAudioNativeProjectSettingsResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/audio-native/{jsonable_encoder(project_id)}/settings", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetAudioNativeProjectSettingsResponseModel, + construct_type( + type_=GetAudioNativeProjectSettingsResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def update( + self, + project_id: str, + *, + file: typing.Optional[core.File] = OMIT, + auto_convert: typing.Optional[bool] = OMIT, + auto_publish: typing.Optional[bool] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[AudioNativeEditContentResponseModel]: + """ + Updates content for the specific AudioNative Project. + + Parameters + ---------- + project_id : str + The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. + + file : typing.Optional[core.File] + See core.File for more documentation + + auto_convert : typing.Optional[bool] + Whether to auto convert the project to audio or not. + + auto_publish : typing.Optional[bool] + Whether to auto publish the new project snapshot after it's converted. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[AudioNativeEditContentResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/audio-native/{jsonable_encoder(project_id)}/content", + base_url=self._client_wrapper.get_environment().base, + method="POST", + data={ + "auto_convert": auto_convert, + "auto_publish": auto_publish, + }, + files={ + **({"file": file} if file is not None else {}), + }, + request_options=request_options, + omit=OMIT, + force_multipart=True, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + AudioNativeEditContentResponseModel, + construct_type( + type_=AudioNativeEditContentResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + +class AsyncRawAudioNativeClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def create( + self, + *, + name: str, + image: typing.Optional[str] = OMIT, + author: typing.Optional[str] = OMIT, + title: typing.Optional[str] = OMIT, + small: typing.Optional[bool] = OMIT, + text_color: typing.Optional[str] = OMIT, + background_color: typing.Optional[str] = OMIT, + sessionization: typing.Optional[int] = OMIT, + voice_id: typing.Optional[str] = OMIT, + model_id: typing.Optional[str] = OMIT, + file: typing.Optional[core.File] = OMIT, + auto_convert: typing.Optional[bool] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[AudioNativeCreateProjectResponseModel]: + """ + Creates Audio Native enabled project, optionally starts conversion and returns project ID and embeddable HTML snippet. + + Parameters + ---------- + name : str + Project name. + + image : typing.Optional[str] + (Deprecated) Image URL used in the player. If not provided, default image set in the Player settings is used. + + author : typing.Optional[str] + Author used in the player and inserted at the start of the uploaded article. If not provided, the default author set in the Player settings is used. + + title : typing.Optional[str] + Title used in the player and inserted at the top of the uploaded article. If not provided, the default title set in the Player settings is used. + + small : typing.Optional[bool] + (Deprecated) Whether to use small player or not. If not provided, default value set in the Player settings is used. + + text_color : typing.Optional[str] + Text color used in the player. If not provided, default text color set in the Player settings is used. + + background_color : typing.Optional[str] + Background color used in the player. If not provided, default background color set in the Player settings is used. + + sessionization : typing.Optional[int] + (Deprecated) Specifies for how many minutes to persist the session across page reloads. If not provided, default sessionization set in the Player settings is used. + + voice_id : typing.Optional[str] + Voice ID used to voice the content. If not provided, default voice ID set in the Player settings is used. + + model_id : typing.Optional[str] + TTS Model ID used in the player. If not provided, default model ID set in the Player settings is used. + + file : typing.Optional[core.File] + See core.File for more documentation + + auto_convert : typing.Optional[bool] + Whether to auto convert the project to audio or not. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[AudioNativeCreateProjectResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + "v1/audio-native", + base_url=self._client_wrapper.get_environment().base, + method="POST", + data={ + "name": name, + "image": image, + "author": author, + "title": title, + "small": small, + "text_color": text_color, + "background_color": background_color, + "sessionization": sessionization, + "voice_id": voice_id, + "model_id": model_id, + "auto_convert": auto_convert, + }, + files={ + **({"file": file} if file is not None else {}), + }, + request_options=request_options, + omit=OMIT, + force_multipart=True, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + AudioNativeCreateProjectResponseModel, + construct_type( + type_=AudioNativeCreateProjectResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def get_settings( + self, project_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[GetAudioNativeProjectSettingsResponseModel]: + """ + Get player settings for the specific project. + + Parameters + ---------- + project_id : str + The ID of the Studio project. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[GetAudioNativeProjectSettingsResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/audio-native/{jsonable_encoder(project_id)}/settings", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetAudioNativeProjectSettingsResponseModel, + construct_type( + type_=GetAudioNativeProjectSettingsResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def update( + self, + project_id: str, + *, + file: typing.Optional[core.File] = OMIT, + auto_convert: typing.Optional[bool] = OMIT, + auto_publish: typing.Optional[bool] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[AudioNativeEditContentResponseModel]: + """ + Updates content for the specific AudioNative Project. + + Parameters + ---------- + project_id : str + The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. + + file : typing.Optional[core.File] + See core.File for more documentation + + auto_convert : typing.Optional[bool] + Whether to auto convert the project to audio or not. + + auto_publish : typing.Optional[bool] + Whether to auto publish the new project snapshot after it's converted. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[AudioNativeEditContentResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/audio-native/{jsonable_encoder(project_id)}/content", + base_url=self._client_wrapper.get_environment().base, + method="POST", + data={ + "auto_convert": auto_convert, + "auto_publish": auto_publish, + }, + files={ + **({"file": file} if file is not None else {}), + }, + request_options=request_options, + omit=OMIT, + force_multipart=True, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + AudioNativeEditContentResponseModel, + construct_type( + type_=AudioNativeEditContentResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/elevenlabs/base_client.py b/src/elevenlabs/base_client.py index 65877496..ba706601 100644 --- a/src/elevenlabs/base_client.py +++ b/src/elevenlabs/base_client.py @@ -1,49 +1,30 @@ # This file was auto-generated by Fern from our API Definition. -from .environment import ElevenLabsEnvironment -import typing import os +import typing + import httpx -from .core.client_wrapper import SyncClientWrapper -from .history.client import HistoryClient -from .text_to_sound_effects.client import TextToSoundEffectsClient -from .audio_isolation.client import AudioIsolationClient -from .samples.client import SamplesClient -from .text_to_speech.client import TextToSpeechClient -from .speech_to_speech.client import SpeechToSpeechClient -from .text_to_voice.client import TextToVoiceClient -from .user.client import UserClient -from .voices.client import VoicesClient -from .studio.client import StudioClient -from .dubbing.client import DubbingClient -from .models.client import ModelsClient -from .audio_native.client import AudioNativeClient -from .usage.client import UsageClient -from .pronunciation_dictionary.client import PronunciationDictionaryClient -from .workspace.client import WorkspaceClient -from .speech_to_text.client import SpeechToTextClient -from .forced_alignment.client import ForcedAlignmentClient -from .conversational_ai.client import ConversationalAiClient -from .core.client_wrapper import AsyncClientWrapper -from .history.client import AsyncHistoryClient -from .text_to_sound_effects.client import AsyncTextToSoundEffectsClient -from .audio_isolation.client import AsyncAudioIsolationClient -from .samples.client import AsyncSamplesClient -from .text_to_speech.client import AsyncTextToSpeechClient -from .speech_to_speech.client import AsyncSpeechToSpeechClient -from .text_to_voice.client import AsyncTextToVoiceClient -from .user.client import AsyncUserClient -from .voices.client import AsyncVoicesClient -from .studio.client import AsyncStudioClient -from .dubbing.client import AsyncDubbingClient -from .models.client import AsyncModelsClient -from .audio_native.client import AsyncAudioNativeClient -from .usage.client import AsyncUsageClient -from .pronunciation_dictionary.client import AsyncPronunciationDictionaryClient -from .workspace.client import AsyncWorkspaceClient -from .speech_to_text.client import AsyncSpeechToTextClient -from .forced_alignment.client import AsyncForcedAlignmentClient -from .conversational_ai.client import AsyncConversationalAiClient +from .audio_isolation.client import AsyncAudioIsolationClient, AudioIsolationClient +from .audio_native.client import AsyncAudioNativeClient, AudioNativeClient +from .conversational_ai.client import AsyncConversationalAiClient, ConversationalAiClient +from .core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from .dubbing.client import AsyncDubbingClient, DubbingClient +from .environment import ElevenLabsEnvironment +from .forced_alignment.client import AsyncForcedAlignmentClient, ForcedAlignmentClient +from .history.client import AsyncHistoryClient, HistoryClient +from .models.client import AsyncModelsClient, ModelsClient +from .pronunciation_dictionaries.client import AsyncPronunciationDictionariesClient, PronunciationDictionariesClient +from .samples.client import AsyncSamplesClient, SamplesClient +from .speech_to_speech.client import AsyncSpeechToSpeechClient, SpeechToSpeechClient +from .speech_to_text.client import AsyncSpeechToTextClient, SpeechToTextClient +from .studio.client import AsyncStudioClient, StudioClient +from .text_to_sound_effects.client import AsyncTextToSoundEffectsClient, TextToSoundEffectsClient +from .text_to_speech.client import AsyncTextToSpeechClient, TextToSpeechClient +from .text_to_voice.client import AsyncTextToVoiceClient, TextToVoiceClient +from .usage.client import AsyncUsageClient, UsageClient +from .user.client import AsyncUserClient, UserClient +from .voices.client import AsyncVoicesClient, VoicesClient +from .workspace.client import AsyncWorkspaceClient, WorkspaceClient class BaseElevenLabs: @@ -116,11 +97,11 @@ def __init__( self.models = ModelsClient(client_wrapper=self._client_wrapper) self.audio_native = AudioNativeClient(client_wrapper=self._client_wrapper) self.usage = UsageClient(client_wrapper=self._client_wrapper) - self.pronunciation_dictionary = PronunciationDictionaryClient(client_wrapper=self._client_wrapper) - self.workspace = WorkspaceClient(client_wrapper=self._client_wrapper) + self.pronunciation_dictionaries = PronunciationDictionariesClient(client_wrapper=self._client_wrapper) self.speech_to_text = SpeechToTextClient(client_wrapper=self._client_wrapper) self.forced_alignment = ForcedAlignmentClient(client_wrapper=self._client_wrapper) self.conversational_ai = ConversationalAiClient(client_wrapper=self._client_wrapper) + self.workspace = WorkspaceClient(client_wrapper=self._client_wrapper) class AsyncBaseElevenLabs: @@ -193,8 +174,8 @@ def __init__( self.models = AsyncModelsClient(client_wrapper=self._client_wrapper) self.audio_native = AsyncAudioNativeClient(client_wrapper=self._client_wrapper) self.usage = AsyncUsageClient(client_wrapper=self._client_wrapper) - self.pronunciation_dictionary = AsyncPronunciationDictionaryClient(client_wrapper=self._client_wrapper) - self.workspace = AsyncWorkspaceClient(client_wrapper=self._client_wrapper) + self.pronunciation_dictionaries = AsyncPronunciationDictionariesClient(client_wrapper=self._client_wrapper) self.speech_to_text = AsyncSpeechToTextClient(client_wrapper=self._client_wrapper) self.forced_alignment = AsyncForcedAlignmentClient(client_wrapper=self._client_wrapper) self.conversational_ai = AsyncConversationalAiClient(client_wrapper=self._client_wrapper) + self.workspace = AsyncWorkspaceClient(client_wrapper=self._client_wrapper) diff --git a/src/elevenlabs/conversational_ai/__init__.py b/src/elevenlabs/conversational_ai/__init__.py index ac442394..f5b2647e 100644 --- a/src/elevenlabs/conversational_ai/__init__.py +++ b/src/elevenlabs/conversational_ai/__init__.py @@ -1,59 +1,55 @@ # This file was auto-generated by Fern from our API Definition. -from .types import ( - ConversationalAiCreatePhoneNumberRequestBody, - ConversationalAiCreatePhoneNumberRequestBody_SipTrunk, - ConversationalAiCreatePhoneNumberRequestBody_Twilio, - ConversationalAiGetKnowledgeBaseDocumentByIdResponse, - ConversationalAiGetKnowledgeBaseDocumentByIdResponse_File, - ConversationalAiGetKnowledgeBaseDocumentByIdResponse_Text, - ConversationalAiGetKnowledgeBaseDocumentByIdResponse_Url, - ConversationalAiGetPhoneNumberResponse, - ConversationalAiGetPhoneNumberResponse_SipTrunk, - ConversationalAiGetPhoneNumberResponse_Twilio, - ConversationalAiGetPhoneNumbersResponseItem, - ConversationalAiGetPhoneNumbersResponseItem_SipTrunk, - ConversationalAiGetPhoneNumbersResponseItem_Twilio, - ConversationalAiUpdateKnowledgeBaseDocumentResponse, - ConversationalAiUpdateKnowledgeBaseDocumentResponse_File, - ConversationalAiUpdateKnowledgeBaseDocumentResponse_Text, - ConversationalAiUpdateKnowledgeBaseDocumentResponse_Url, - ConversationalAiUpdatePhoneNumberResponse, - ConversationalAiUpdatePhoneNumberResponse_SipTrunk, - ConversationalAiUpdatePhoneNumberResponse_Twilio, - PatchConvAiDashboardSettingsRequestChartsItem, - PatchConvAiDashboardSettingsRequestChartsItem_CallSuccess, - PatchConvAiDashboardSettingsRequestChartsItem_Criteria, - PatchConvAiDashboardSettingsRequestChartsItem_DataCollection, +# isort: skip_file + +from . import ( + agents, + batch_calls, + conversations, + dashboard, + knowledge_base, + phone_numbers, + secrets, + settings, + sip_trunk, + twilio, +) +from .phone_numbers import ( + PhoneNumbersCreateRequestBody, + PhoneNumbersCreateRequestBody_SipTrunk, + PhoneNumbersCreateRequestBody_Twilio, + PhoneNumbersGetResponse, + PhoneNumbersGetResponse_SipTrunk, + PhoneNumbersGetResponse_Twilio, + PhoneNumbersListResponseItem, + PhoneNumbersListResponseItem_SipTrunk, + PhoneNumbersListResponseItem_Twilio, + PhoneNumbersUpdateResponse, + PhoneNumbersUpdateResponse_SipTrunk, + PhoneNumbersUpdateResponse_Twilio, ) -from . import agents, knowledge_base, sip_trunk __all__ = [ - "ConversationalAiCreatePhoneNumberRequestBody", - "ConversationalAiCreatePhoneNumberRequestBody_SipTrunk", - "ConversationalAiCreatePhoneNumberRequestBody_Twilio", - "ConversationalAiGetKnowledgeBaseDocumentByIdResponse", - "ConversationalAiGetKnowledgeBaseDocumentByIdResponse_File", - "ConversationalAiGetKnowledgeBaseDocumentByIdResponse_Text", - "ConversationalAiGetKnowledgeBaseDocumentByIdResponse_Url", - "ConversationalAiGetPhoneNumberResponse", - "ConversationalAiGetPhoneNumberResponse_SipTrunk", - "ConversationalAiGetPhoneNumberResponse_Twilio", - "ConversationalAiGetPhoneNumbersResponseItem", - "ConversationalAiGetPhoneNumbersResponseItem_SipTrunk", - "ConversationalAiGetPhoneNumbersResponseItem_Twilio", - "ConversationalAiUpdateKnowledgeBaseDocumentResponse", - "ConversationalAiUpdateKnowledgeBaseDocumentResponse_File", - "ConversationalAiUpdateKnowledgeBaseDocumentResponse_Text", - "ConversationalAiUpdateKnowledgeBaseDocumentResponse_Url", - "ConversationalAiUpdatePhoneNumberResponse", - "ConversationalAiUpdatePhoneNumberResponse_SipTrunk", - "ConversationalAiUpdatePhoneNumberResponse_Twilio", - "PatchConvAiDashboardSettingsRequestChartsItem", - "PatchConvAiDashboardSettingsRequestChartsItem_CallSuccess", - "PatchConvAiDashboardSettingsRequestChartsItem_Criteria", - "PatchConvAiDashboardSettingsRequestChartsItem_DataCollection", + "PhoneNumbersCreateRequestBody", + "PhoneNumbersCreateRequestBody_SipTrunk", + "PhoneNumbersCreateRequestBody_Twilio", + "PhoneNumbersGetResponse", + "PhoneNumbersGetResponse_SipTrunk", + "PhoneNumbersGetResponse_Twilio", + "PhoneNumbersListResponseItem", + "PhoneNumbersListResponseItem_SipTrunk", + "PhoneNumbersListResponseItem_Twilio", + "PhoneNumbersUpdateResponse", + "PhoneNumbersUpdateResponse_SipTrunk", + "PhoneNumbersUpdateResponse_Twilio", "agents", + "batch_calls", + "conversations", + "dashboard", "knowledge_base", + "phone_numbers", + "secrets", + "settings", "sip_trunk", + "twilio", ] diff --git a/src/elevenlabs/conversational_ai/agents/__init__.py b/src/elevenlabs/conversational_ai/agents/__init__.py index f3ea2659..6a432eaa 100644 --- a/src/elevenlabs/conversational_ai/agents/__init__.py +++ b/src/elevenlabs/conversational_ai/agents/__init__.py @@ -1,2 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# isort: skip_file + +from . import link, widget + +__all__ = ["link", "widget"] diff --git a/src/elevenlabs/conversational_ai/agents/client.py b/src/elevenlabs/conversational_ai/agents/client.py index 338d44b7..d52ac81e 100644 --- a/src/elevenlabs/conversational_ai/agents/client.py +++ b/src/elevenlabs/conversational_ai/agents/client.py @@ -1,23 +1,20 @@ # This file was auto-generated by Fern from our API Definition. import typing -from ...core.client_wrapper import SyncClientWrapper -from ...types.conversation_simulation_specification import ( - ConversationSimulationSpecification, -) -from ...types.prompt_evaluation_criteria import PromptEvaluationCriteria + +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ...core.request_options import RequestOptions -from ...types.agent_simulated_chat_test_response_model import ( - AgentSimulatedChatTestResponseModel, -) -from ...core.jsonable_encoder import jsonable_encoder -from ...core.serialization import convert_and_respect_annotation_metadata -from ...core.unchecked_base_model import construct_type -from ...errors.unprocessable_entity_error import UnprocessableEntityError -from ...types.http_validation_error import HttpValidationError -from json.decoder import JSONDecodeError -from ...core.api_error import ApiError -from ...core.client_wrapper import AsyncClientWrapper +from ...types.agent_platform_settings_request_model import AgentPlatformSettingsRequestModel +from ...types.agent_simulated_chat_test_response_model import AgentSimulatedChatTestResponseModel +from ...types.conversation_simulation_specification import ConversationSimulationSpecification +from ...types.conversational_config import ConversationalConfig +from ...types.create_agent_response_model import CreateAgentResponseModel +from ...types.get_agent_response_model import GetAgentResponseModel +from ...types.get_agents_page_response_model import GetAgentsPageResponseModel +from ...types.prompt_evaluation_criteria import PromptEvaluationCriteria +from .link.client import AsyncLinkClient, LinkClient +from .raw_client import AsyncRawAgentsClient, RawAgentsClient +from .widget.client import AsyncWidgetClient, WidgetClient # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -25,7 +22,237 @@ class AgentsClient: def __init__(self, *, client_wrapper: SyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = RawAgentsClient(client_wrapper=client_wrapper) + self.widget = WidgetClient(client_wrapper=client_wrapper) + + self.link = LinkClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawAgentsClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawAgentsClient + """ + return self._raw_client + + def create( + self, + *, + conversation_config: ConversationalConfig, + platform_settings: typing.Optional[AgentPlatformSettingsRequestModel] = OMIT, + name: typing.Optional[str] = OMIT, + tags: typing.Optional[typing.Sequence[str]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> CreateAgentResponseModel: + """ + Create an agent from a config object + + Parameters + ---------- + conversation_config : ConversationalConfig + Conversation configuration for an agent + + platform_settings : typing.Optional[AgentPlatformSettingsRequestModel] + Platform settings for the agent are all settings that aren't related to the conversation orchestration and content. + + name : typing.Optional[str] + A name to make the agent easier to find + + tags : typing.Optional[typing.Sequence[str]] + Tags to help classify and filter the agent + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + CreateAgentResponseModel + Successful Response + + Examples + -------- + from elevenlabs import ConversationalConfig, ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.conversational_ai.agents.create( + conversation_config=ConversationalConfig(), + ) + """ + _response = self._raw_client.create( + conversation_config=conversation_config, + platform_settings=platform_settings, + name=name, + tags=tags, + request_options=request_options, + ) + return _response.data + + def get(self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> GetAgentResponseModel: + """ + Retrieve config for an agent + + Parameters + ---------- + agent_id : str + The id of an agent. This is returned on agent creation. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + GetAgentResponseModel + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.conversational_ai.agents.get( + agent_id="21m00Tcm4TlvDq8ikWAM", + ) + """ + _response = self._raw_client.get(agent_id, request_options=request_options) + return _response.data + + def delete(self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None: + """ + Delete an agent + + Parameters + ---------- + agent_id : str + The id of an agent. This is returned on agent creation. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + None + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.conversational_ai.agents.delete( + agent_id="21m00Tcm4TlvDq8ikWAM", + ) + """ + _response = self._raw_client.delete(agent_id, request_options=request_options) + return _response.data + + def update( + self, + agent_id: str, + *, + conversation_config: typing.Optional[typing.Optional[typing.Any]] = OMIT, + platform_settings: typing.Optional[typing.Optional[typing.Any]] = OMIT, + name: typing.Optional[str] = OMIT, + tags: typing.Optional[typing.Sequence[str]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> GetAgentResponseModel: + """ + Patches an Agent settings + + Parameters + ---------- + agent_id : str + The id of an agent. This is returned on agent creation. + + conversation_config : typing.Optional[typing.Optional[typing.Any]] + + platform_settings : typing.Optional[typing.Optional[typing.Any]] + + name : typing.Optional[str] + A name to make the agent easier to find + + tags : typing.Optional[typing.Sequence[str]] + Tags to help classify and filter the agent + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + GetAgentResponseModel + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.conversational_ai.agents.update( + agent_id="21m00Tcm4TlvDq8ikWAM", + ) + """ + _response = self._raw_client.update( + agent_id, + conversation_config=conversation_config, + platform_settings=platform_settings, + name=name, + tags=tags, + request_options=request_options, + ) + return _response.data + + def list( + self, + *, + cursor: typing.Optional[str] = None, + page_size: typing.Optional[int] = None, + search: typing.Optional[str] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> GetAgentsPageResponseModel: + """ + Returns a list of your agents and their metadata. + + Parameters + ---------- + cursor : typing.Optional[str] + Used for fetching next page. Cursor is returned in the response. + + page_size : typing.Optional[int] + How many Agents to return at maximum. Can not exceed 100, defaults to 30. + + search : typing.Optional[str] + Search by agents name. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + GetAgentsPageResponseModel + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.conversational_ai.agents.list() + """ + _response = self._raw_client.list( + cursor=cursor, page_size=page_size, search=search, request_options=request_options + ) + return _response.data def simulate_conversation( self, @@ -78,51 +305,13 @@ def simulate_conversation( ), ) """ - _response = self._client_wrapper.httpx_client.request( - f"v1/convai/agents/{jsonable_encoder(agent_id)}/simulate-conversation", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "simulation_specification": convert_and_respect_annotation_metadata( - object_=simulation_specification, - annotation=ConversationSimulationSpecification, - direction="write", - ), - "extra_evaluation_criteria": convert_and_respect_annotation_metadata( - object_=extra_evaluation_criteria, - annotation=typing.Sequence[PromptEvaluationCriteria], - direction="write", - ), - }, - headers={ - "content-type": "application/json", - }, + _response = self._raw_client.simulate_conversation( + agent_id, + simulation_specification=simulation_specification, + extra_evaluation_criteria=extra_evaluation_criteria, request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - AgentSimulatedChatTestResponseModel, - construct_type( - type_=AgentSimulatedChatTestResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + ) + return _response.data def simulate_conversation_stream( self, @@ -174,50 +363,290 @@ def simulate_conversation_stream( ), ) """ - _response = self._client_wrapper.httpx_client.request( - f"v1/convai/agents/{jsonable_encoder(agent_id)}/simulate-conversation/stream", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "simulation_specification": convert_and_respect_annotation_metadata( - object_=simulation_specification, - annotation=ConversationSimulationSpecification, - direction="write", - ), - "extra_evaluation_criteria": convert_and_respect_annotation_metadata( - object_=extra_evaluation_criteria, - annotation=typing.Sequence[PromptEvaluationCriteria], - direction="write", - ), - }, - headers={ - "content-type": "application/json", - }, + _response = self._raw_client.simulate_conversation_stream( + agent_id, + simulation_specification=simulation_specification, + extra_evaluation_criteria=extra_evaluation_criteria, request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + ) + return _response.data class AsyncAgentsClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = AsyncRawAgentsClient(client_wrapper=client_wrapper) + self.widget = AsyncWidgetClient(client_wrapper=client_wrapper) + + self.link = AsyncLinkClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawAgentsClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawAgentsClient + """ + return self._raw_client + + async def create( + self, + *, + conversation_config: ConversationalConfig, + platform_settings: typing.Optional[AgentPlatformSettingsRequestModel] = OMIT, + name: typing.Optional[str] = OMIT, + tags: typing.Optional[typing.Sequence[str]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> CreateAgentResponseModel: + """ + Create an agent from a config object + + Parameters + ---------- + conversation_config : ConversationalConfig + Conversation configuration for an agent + + platform_settings : typing.Optional[AgentPlatformSettingsRequestModel] + Platform settings for the agent are all settings that aren't related to the conversation orchestration and content. + + name : typing.Optional[str] + A name to make the agent easier to find + + tags : typing.Optional[typing.Sequence[str]] + Tags to help classify and filter the agent + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + CreateAgentResponseModel + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs, ConversationalConfig + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.conversational_ai.agents.create( + conversation_config=ConversationalConfig(), + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.create( + conversation_config=conversation_config, + platform_settings=platform_settings, + name=name, + tags=tags, + request_options=request_options, + ) + return _response.data + + async def get( + self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> GetAgentResponseModel: + """ + Retrieve config for an agent + + Parameters + ---------- + agent_id : str + The id of an agent. This is returned on agent creation. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + GetAgentResponseModel + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.conversational_ai.agents.get( + agent_id="21m00Tcm4TlvDq8ikWAM", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.get(agent_id, request_options=request_options) + return _response.data + + async def delete(self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None: + """ + Delete an agent + + Parameters + ---------- + agent_id : str + The id of an agent. This is returned on agent creation. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + None + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.conversational_ai.agents.delete( + agent_id="21m00Tcm4TlvDq8ikWAM", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.delete(agent_id, request_options=request_options) + return _response.data + + async def update( + self, + agent_id: str, + *, + conversation_config: typing.Optional[typing.Optional[typing.Any]] = OMIT, + platform_settings: typing.Optional[typing.Optional[typing.Any]] = OMIT, + name: typing.Optional[str] = OMIT, + tags: typing.Optional[typing.Sequence[str]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> GetAgentResponseModel: + """ + Patches an Agent settings + + Parameters + ---------- + agent_id : str + The id of an agent. This is returned on agent creation. + + conversation_config : typing.Optional[typing.Optional[typing.Any]] + + platform_settings : typing.Optional[typing.Optional[typing.Any]] + + name : typing.Optional[str] + A name to make the agent easier to find + + tags : typing.Optional[typing.Sequence[str]] + Tags to help classify and filter the agent + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + GetAgentResponseModel + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.conversational_ai.agents.update( + agent_id="21m00Tcm4TlvDq8ikWAM", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.update( + agent_id, + conversation_config=conversation_config, + platform_settings=platform_settings, + name=name, + tags=tags, + request_options=request_options, + ) + return _response.data + + async def list( + self, + *, + cursor: typing.Optional[str] = None, + page_size: typing.Optional[int] = None, + search: typing.Optional[str] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> GetAgentsPageResponseModel: + """ + Returns a list of your agents and their metadata. + + Parameters + ---------- + cursor : typing.Optional[str] + Used for fetching next page. Cursor is returned in the response. + + page_size : typing.Optional[int] + How many Agents to return at maximum. Can not exceed 100, defaults to 30. + + search : typing.Optional[str] + Search by agents name. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + GetAgentsPageResponseModel + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.conversational_ai.agents.list() + + + asyncio.run(main()) + """ + _response = await self._raw_client.list( + cursor=cursor, page_size=page_size, search=search, request_options=request_options + ) + return _response.data async def simulate_conversation( self, @@ -278,51 +707,13 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/convai/agents/{jsonable_encoder(agent_id)}/simulate-conversation", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "simulation_specification": convert_and_respect_annotation_metadata( - object_=simulation_specification, - annotation=ConversationSimulationSpecification, - direction="write", - ), - "extra_evaluation_criteria": convert_and_respect_annotation_metadata( - object_=extra_evaluation_criteria, - annotation=typing.Sequence[PromptEvaluationCriteria], - direction="write", - ), - }, - headers={ - "content-type": "application/json", - }, + _response = await self._raw_client.simulate_conversation( + agent_id, + simulation_specification=simulation_specification, + extra_evaluation_criteria=extra_evaluation_criteria, request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - AgentSimulatedChatTestResponseModel, - construct_type( - type_=AgentSimulatedChatTestResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + ) + return _response.data async def simulate_conversation_stream( self, @@ -382,42 +773,10 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/convai/agents/{jsonable_encoder(agent_id)}/simulate-conversation/stream", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "simulation_specification": convert_and_respect_annotation_metadata( - object_=simulation_specification, - annotation=ConversationSimulationSpecification, - direction="write", - ), - "extra_evaluation_criteria": convert_and_respect_annotation_metadata( - object_=extra_evaluation_criteria, - annotation=typing.Sequence[PromptEvaluationCriteria], - direction="write", - ), - }, - headers={ - "content-type": "application/json", - }, + _response = await self._raw_client.simulate_conversation_stream( + agent_id, + simulation_specification=simulation_specification, + extra_evaluation_criteria=extra_evaluation_criteria, request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + ) + return _response.data diff --git a/src/elevenlabs/dubbing/speaker/segment/__init__.py b/src/elevenlabs/conversational_ai/agents/link/__init__.py similarity index 76% rename from src/elevenlabs/dubbing/speaker/segment/__init__.py rename to src/elevenlabs/conversational_ai/agents/link/__init__.py index f3ea2659..5cde0202 100644 --- a/src/elevenlabs/dubbing/speaker/segment/__init__.py +++ b/src/elevenlabs/conversational_ai/agents/link/__init__.py @@ -1,2 +1,4 @@ # This file was auto-generated by Fern from our API Definition. +# isort: skip_file + diff --git a/src/elevenlabs/conversational_ai/agents/link/client.py b/src/elevenlabs/conversational_ai/agents/link/client.py new file mode 100644 index 00000000..284f56b9 --- /dev/null +++ b/src/elevenlabs/conversational_ai/agents/link/client.py @@ -0,0 +1,114 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +from ....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ....core.request_options import RequestOptions +from ....types.get_agent_link_response_model import GetAgentLinkResponseModel +from .raw_client import AsyncRawLinkClient, RawLinkClient + + +class LinkClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._raw_client = RawLinkClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawLinkClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawLinkClient + """ + return self._raw_client + + def get( + self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> GetAgentLinkResponseModel: + """ + Get the current link used to share the agent with others + + Parameters + ---------- + agent_id : str + The id of an agent. This is returned on agent creation. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + GetAgentLinkResponseModel + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.conversational_ai.agents.link.get( + agent_id="21m00Tcm4TlvDq8ikWAM", + ) + """ + _response = self._raw_client.get(agent_id, request_options=request_options) + return _response.data + + +class AsyncLinkClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawLinkClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawLinkClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawLinkClient + """ + return self._raw_client + + async def get( + self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> GetAgentLinkResponseModel: + """ + Get the current link used to share the agent with others + + Parameters + ---------- + agent_id : str + The id of an agent. This is returned on agent creation. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + GetAgentLinkResponseModel + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.conversational_ai.agents.link.get( + agent_id="21m00Tcm4TlvDq8ikWAM", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.get(agent_id, request_options=request_options) + return _response.data diff --git a/src/elevenlabs/conversational_ai/agents/link/raw_client.py b/src/elevenlabs/conversational_ai/agents/link/raw_client.py new file mode 100644 index 00000000..ce44ff82 --- /dev/null +++ b/src/elevenlabs/conversational_ai/agents/link/raw_client.py @@ -0,0 +1,126 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ....core.api_error import ApiError +from ....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ....core.http_response import AsyncHttpResponse, HttpResponse +from ....core.jsonable_encoder import jsonable_encoder +from ....core.request_options import RequestOptions +from ....core.unchecked_base_model import construct_type +from ....errors.unprocessable_entity_error import UnprocessableEntityError +from ....types.get_agent_link_response_model import GetAgentLinkResponseModel +from ....types.http_validation_error import HttpValidationError + + +class RawLinkClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def get( + self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[GetAgentLinkResponseModel]: + """ + Get the current link used to share the agent with others + + Parameters + ---------- + agent_id : str + The id of an agent. This is returned on agent creation. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[GetAgentLinkResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/convai/agents/{jsonable_encoder(agent_id)}/link", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetAgentLinkResponseModel, + construct_type( + type_=GetAgentLinkResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + +class AsyncRawLinkClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def get( + self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[GetAgentLinkResponseModel]: + """ + Get the current link used to share the agent with others + + Parameters + ---------- + agent_id : str + The id of an agent. This is returned on agent creation. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[GetAgentLinkResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/convai/agents/{jsonable_encoder(agent_id)}/link", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetAgentLinkResponseModel, + construct_type( + type_=GetAgentLinkResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/elevenlabs/conversational_ai/agents/raw_client.py b/src/elevenlabs/conversational_ai/agents/raw_client.py new file mode 100644 index 00000000..be56ba6a --- /dev/null +++ b/src/elevenlabs/conversational_ai/agents/raw_client.py @@ -0,0 +1,959 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ...core.api_error import ApiError +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ...core.http_response import AsyncHttpResponse, HttpResponse +from ...core.jsonable_encoder import jsonable_encoder +from ...core.request_options import RequestOptions +from ...core.serialization import convert_and_respect_annotation_metadata +from ...core.unchecked_base_model import construct_type +from ...errors.unprocessable_entity_error import UnprocessableEntityError +from ...types.agent_platform_settings_request_model import AgentPlatformSettingsRequestModel +from ...types.agent_simulated_chat_test_response_model import AgentSimulatedChatTestResponseModel +from ...types.conversation_simulation_specification import ConversationSimulationSpecification +from ...types.conversational_config import ConversationalConfig +from ...types.create_agent_response_model import CreateAgentResponseModel +from ...types.get_agent_response_model import GetAgentResponseModel +from ...types.get_agents_page_response_model import GetAgentsPageResponseModel +from ...types.http_validation_error import HttpValidationError +from ...types.prompt_evaluation_criteria import PromptEvaluationCriteria + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RawAgentsClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def create( + self, + *, + conversation_config: ConversationalConfig, + platform_settings: typing.Optional[AgentPlatformSettingsRequestModel] = OMIT, + name: typing.Optional[str] = OMIT, + tags: typing.Optional[typing.Sequence[str]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[CreateAgentResponseModel]: + """ + Create an agent from a config object + + Parameters + ---------- + conversation_config : ConversationalConfig + Conversation configuration for an agent + + platform_settings : typing.Optional[AgentPlatformSettingsRequestModel] + Platform settings for the agent are all settings that aren't related to the conversation orchestration and content. + + name : typing.Optional[str] + A name to make the agent easier to find + + tags : typing.Optional[typing.Sequence[str]] + Tags to help classify and filter the agent + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[CreateAgentResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + "v1/convai/agents/create", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "conversation_config": convert_and_respect_annotation_metadata( + object_=conversation_config, annotation=ConversationalConfig, direction="write" + ), + "platform_settings": convert_and_respect_annotation_metadata( + object_=platform_settings, annotation=AgentPlatformSettingsRequestModel, direction="write" + ), + "name": name, + "tags": tags, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + CreateAgentResponseModel, + construct_type( + type_=CreateAgentResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def get( + self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[GetAgentResponseModel]: + """ + Retrieve config for an agent + + Parameters + ---------- + agent_id : str + The id of an agent. This is returned on agent creation. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[GetAgentResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/convai/agents/{jsonable_encoder(agent_id)}", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetAgentResponseModel, + construct_type( + type_=GetAgentResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def delete(self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> HttpResponse[None]: + """ + Delete an agent + + Parameters + ---------- + agent_id : str + The id of an agent. This is returned on agent creation. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[None] + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/convai/agents/{jsonable_encoder(agent_id)}", + base_url=self._client_wrapper.get_environment().base, + method="DELETE", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return HttpResponse(response=_response, data=None) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def update( + self, + agent_id: str, + *, + conversation_config: typing.Optional[typing.Optional[typing.Any]] = OMIT, + platform_settings: typing.Optional[typing.Optional[typing.Any]] = OMIT, + name: typing.Optional[str] = OMIT, + tags: typing.Optional[typing.Sequence[str]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[GetAgentResponseModel]: + """ + Patches an Agent settings + + Parameters + ---------- + agent_id : str + The id of an agent. This is returned on agent creation. + + conversation_config : typing.Optional[typing.Optional[typing.Any]] + + platform_settings : typing.Optional[typing.Optional[typing.Any]] + + name : typing.Optional[str] + A name to make the agent easier to find + + tags : typing.Optional[typing.Sequence[str]] + Tags to help classify and filter the agent + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[GetAgentResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/convai/agents/{jsonable_encoder(agent_id)}", + base_url=self._client_wrapper.get_environment().base, + method="PATCH", + json={ + "conversation_config": conversation_config, + "platform_settings": platform_settings, + "name": name, + "tags": tags, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetAgentResponseModel, + construct_type( + type_=GetAgentResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def list( + self, + *, + cursor: typing.Optional[str] = None, + page_size: typing.Optional[int] = None, + search: typing.Optional[str] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[GetAgentsPageResponseModel]: + """ + Returns a list of your agents and their metadata. + + Parameters + ---------- + cursor : typing.Optional[str] + Used for fetching next page. Cursor is returned in the response. + + page_size : typing.Optional[int] + How many Agents to return at maximum. Can not exceed 100, defaults to 30. + + search : typing.Optional[str] + Search by agents name. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[GetAgentsPageResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + "v1/convai/agents", + base_url=self._client_wrapper.get_environment().base, + method="GET", + params={ + "cursor": cursor, + "page_size": page_size, + "search": search, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetAgentsPageResponseModel, + construct_type( + type_=GetAgentsPageResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def simulate_conversation( + self, + agent_id: str, + *, + simulation_specification: ConversationSimulationSpecification, + extra_evaluation_criteria: typing.Optional[typing.Sequence[PromptEvaluationCriteria]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[AgentSimulatedChatTestResponseModel]: + """ + Run a conversation between the agent and a simulated user. + + Parameters + ---------- + agent_id : str + The id of an agent. This is returned on agent creation. + + simulation_specification : ConversationSimulationSpecification + A specification detailing how the conversation should be simulated + + extra_evaluation_criteria : typing.Optional[typing.Sequence[PromptEvaluationCriteria]] + A list of evaluation criteria to test + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[AgentSimulatedChatTestResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/convai/agents/{jsonable_encoder(agent_id)}/simulate-conversation", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "simulation_specification": convert_and_respect_annotation_metadata( + object_=simulation_specification, annotation=ConversationSimulationSpecification, direction="write" + ), + "extra_evaluation_criteria": convert_and_respect_annotation_metadata( + object_=extra_evaluation_criteria, + annotation=typing.Sequence[PromptEvaluationCriteria], + direction="write", + ), + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + AgentSimulatedChatTestResponseModel, + construct_type( + type_=AgentSimulatedChatTestResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def simulate_conversation_stream( + self, + agent_id: str, + *, + simulation_specification: ConversationSimulationSpecification, + extra_evaluation_criteria: typing.Optional[typing.Sequence[PromptEvaluationCriteria]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[None]: + """ + Run a conversation between the agent and a simulated user and stream back the response. Response is streamed back as partial lists of messages that should be concatenated and once the conversation has complete a single final message with the conversation analysis will be sent. + + Parameters + ---------- + agent_id : str + The id of an agent. This is returned on agent creation. + + simulation_specification : ConversationSimulationSpecification + A specification detailing how the conversation should be simulated + + extra_evaluation_criteria : typing.Optional[typing.Sequence[PromptEvaluationCriteria]] + A list of evaluation criteria to test + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[None] + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/convai/agents/{jsonable_encoder(agent_id)}/simulate-conversation/stream", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "simulation_specification": convert_and_respect_annotation_metadata( + object_=simulation_specification, annotation=ConversationSimulationSpecification, direction="write" + ), + "extra_evaluation_criteria": convert_and_respect_annotation_metadata( + object_=extra_evaluation_criteria, + annotation=typing.Sequence[PromptEvaluationCriteria], + direction="write", + ), + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return HttpResponse(response=_response, data=None) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + +class AsyncRawAgentsClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def create( + self, + *, + conversation_config: ConversationalConfig, + platform_settings: typing.Optional[AgentPlatformSettingsRequestModel] = OMIT, + name: typing.Optional[str] = OMIT, + tags: typing.Optional[typing.Sequence[str]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[CreateAgentResponseModel]: + """ + Create an agent from a config object + + Parameters + ---------- + conversation_config : ConversationalConfig + Conversation configuration for an agent + + platform_settings : typing.Optional[AgentPlatformSettingsRequestModel] + Platform settings for the agent are all settings that aren't related to the conversation orchestration and content. + + name : typing.Optional[str] + A name to make the agent easier to find + + tags : typing.Optional[typing.Sequence[str]] + Tags to help classify and filter the agent + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[CreateAgentResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + "v1/convai/agents/create", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "conversation_config": convert_and_respect_annotation_metadata( + object_=conversation_config, annotation=ConversationalConfig, direction="write" + ), + "platform_settings": convert_and_respect_annotation_metadata( + object_=platform_settings, annotation=AgentPlatformSettingsRequestModel, direction="write" + ), + "name": name, + "tags": tags, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + CreateAgentResponseModel, + construct_type( + type_=CreateAgentResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def get( + self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[GetAgentResponseModel]: + """ + Retrieve config for an agent + + Parameters + ---------- + agent_id : str + The id of an agent. This is returned on agent creation. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[GetAgentResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/convai/agents/{jsonable_encoder(agent_id)}", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetAgentResponseModel, + construct_type( + type_=GetAgentResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def delete( + self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[None]: + """ + Delete an agent + + Parameters + ---------- + agent_id : str + The id of an agent. This is returned on agent creation. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[None] + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/convai/agents/{jsonable_encoder(agent_id)}", + base_url=self._client_wrapper.get_environment().base, + method="DELETE", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return AsyncHttpResponse(response=_response, data=None) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def update( + self, + agent_id: str, + *, + conversation_config: typing.Optional[typing.Optional[typing.Any]] = OMIT, + platform_settings: typing.Optional[typing.Optional[typing.Any]] = OMIT, + name: typing.Optional[str] = OMIT, + tags: typing.Optional[typing.Sequence[str]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[GetAgentResponseModel]: + """ + Patches an Agent settings + + Parameters + ---------- + agent_id : str + The id of an agent. This is returned on agent creation. + + conversation_config : typing.Optional[typing.Optional[typing.Any]] + + platform_settings : typing.Optional[typing.Optional[typing.Any]] + + name : typing.Optional[str] + A name to make the agent easier to find + + tags : typing.Optional[typing.Sequence[str]] + Tags to help classify and filter the agent + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[GetAgentResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/convai/agents/{jsonable_encoder(agent_id)}", + base_url=self._client_wrapper.get_environment().base, + method="PATCH", + json={ + "conversation_config": conversation_config, + "platform_settings": platform_settings, + "name": name, + "tags": tags, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetAgentResponseModel, + construct_type( + type_=GetAgentResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def list( + self, + *, + cursor: typing.Optional[str] = None, + page_size: typing.Optional[int] = None, + search: typing.Optional[str] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[GetAgentsPageResponseModel]: + """ + Returns a list of your agents and their metadata. + + Parameters + ---------- + cursor : typing.Optional[str] + Used for fetching next page. Cursor is returned in the response. + + page_size : typing.Optional[int] + How many Agents to return at maximum. Can not exceed 100, defaults to 30. + + search : typing.Optional[str] + Search by agents name. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[GetAgentsPageResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + "v1/convai/agents", + base_url=self._client_wrapper.get_environment().base, + method="GET", + params={ + "cursor": cursor, + "page_size": page_size, + "search": search, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetAgentsPageResponseModel, + construct_type( + type_=GetAgentsPageResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def simulate_conversation( + self, + agent_id: str, + *, + simulation_specification: ConversationSimulationSpecification, + extra_evaluation_criteria: typing.Optional[typing.Sequence[PromptEvaluationCriteria]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[AgentSimulatedChatTestResponseModel]: + """ + Run a conversation between the agent and a simulated user. + + Parameters + ---------- + agent_id : str + The id of an agent. This is returned on agent creation. + + simulation_specification : ConversationSimulationSpecification + A specification detailing how the conversation should be simulated + + extra_evaluation_criteria : typing.Optional[typing.Sequence[PromptEvaluationCriteria]] + A list of evaluation criteria to test + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[AgentSimulatedChatTestResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/convai/agents/{jsonable_encoder(agent_id)}/simulate-conversation", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "simulation_specification": convert_and_respect_annotation_metadata( + object_=simulation_specification, annotation=ConversationSimulationSpecification, direction="write" + ), + "extra_evaluation_criteria": convert_and_respect_annotation_metadata( + object_=extra_evaluation_criteria, + annotation=typing.Sequence[PromptEvaluationCriteria], + direction="write", + ), + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + AgentSimulatedChatTestResponseModel, + construct_type( + type_=AgentSimulatedChatTestResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def simulate_conversation_stream( + self, + agent_id: str, + *, + simulation_specification: ConversationSimulationSpecification, + extra_evaluation_criteria: typing.Optional[typing.Sequence[PromptEvaluationCriteria]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[None]: + """ + Run a conversation between the agent and a simulated user and stream back the response. Response is streamed back as partial lists of messages that should be concatenated and once the conversation has complete a single final message with the conversation analysis will be sent. + + Parameters + ---------- + agent_id : str + The id of an agent. This is returned on agent creation. + + simulation_specification : ConversationSimulationSpecification + A specification detailing how the conversation should be simulated + + extra_evaluation_criteria : typing.Optional[typing.Sequence[PromptEvaluationCriteria]] + A list of evaluation criteria to test + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[None] + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/convai/agents/{jsonable_encoder(agent_id)}/simulate-conversation/stream", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "simulation_specification": convert_and_respect_annotation_metadata( + object_=simulation_specification, annotation=ConversationSimulationSpecification, direction="write" + ), + "extra_evaluation_criteria": convert_and_respect_annotation_metadata( + object_=extra_evaluation_criteria, + annotation=typing.Sequence[PromptEvaluationCriteria], + direction="write", + ), + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return AsyncHttpResponse(response=_response, data=None) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/elevenlabs/conversational_ai/agents/widget/__init__.py b/src/elevenlabs/conversational_ai/agents/widget/__init__.py new file mode 100644 index 00000000..9cc7846b --- /dev/null +++ b/src/elevenlabs/conversational_ai/agents/widget/__init__.py @@ -0,0 +1,7 @@ +# This file was auto-generated by Fern from our API Definition. + +# isort: skip_file + +from . import avatar + +__all__ = ["avatar"] diff --git a/src/elevenlabs/studio/chapters/__init__.py b/src/elevenlabs/conversational_ai/agents/widget/avatar/__init__.py similarity index 76% rename from src/elevenlabs/studio/chapters/__init__.py rename to src/elevenlabs/conversational_ai/agents/widget/avatar/__init__.py index f3ea2659..5cde0202 100644 --- a/src/elevenlabs/studio/chapters/__init__.py +++ b/src/elevenlabs/conversational_ai/agents/widget/avatar/__init__.py @@ -1,2 +1,4 @@ # This file was auto-generated by Fern from our API Definition. +# isort: skip_file + diff --git a/src/elevenlabs/conversational_ai/agents/widget/avatar/client.py b/src/elevenlabs/conversational_ai/agents/widget/avatar/client.py new file mode 100644 index 00000000..239f14f2 --- /dev/null +++ b/src/elevenlabs/conversational_ai/agents/widget/avatar/client.py @@ -0,0 +1,124 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +from ..... import core +from .....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from .....core.request_options import RequestOptions +from .....types.post_agent_avatar_response_model import PostAgentAvatarResponseModel +from .raw_client import AsyncRawAvatarClient, RawAvatarClient + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class AvatarClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._raw_client = RawAvatarClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawAvatarClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawAvatarClient + """ + return self._raw_client + + def create( + self, agent_id: str, *, avatar_file: core.File, request_options: typing.Optional[RequestOptions] = None + ) -> PostAgentAvatarResponseModel: + """ + Sets the avatar for an agent displayed in the widget + + Parameters + ---------- + agent_id : str + The id of an agent. This is returned on agent creation. + + avatar_file : core.File + See core.File for more documentation + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + PostAgentAvatarResponseModel + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.conversational_ai.agents.widget.avatar.create( + agent_id="21m00Tcm4TlvDq8ikWAM", + ) + """ + _response = self._raw_client.create(agent_id, avatar_file=avatar_file, request_options=request_options) + return _response.data + + +class AsyncAvatarClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawAvatarClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawAvatarClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawAvatarClient + """ + return self._raw_client + + async def create( + self, agent_id: str, *, avatar_file: core.File, request_options: typing.Optional[RequestOptions] = None + ) -> PostAgentAvatarResponseModel: + """ + Sets the avatar for an agent displayed in the widget + + Parameters + ---------- + agent_id : str + The id of an agent. This is returned on agent creation. + + avatar_file : core.File + See core.File for more documentation + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + PostAgentAvatarResponseModel + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.conversational_ai.agents.widget.avatar.create( + agent_id="21m00Tcm4TlvDq8ikWAM", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.create(agent_id, avatar_file=avatar_file, request_options=request_options) + return _response.data diff --git a/src/elevenlabs/conversational_ai/agents/widget/avatar/raw_client.py b/src/elevenlabs/conversational_ai/agents/widget/avatar/raw_client.py new file mode 100644 index 00000000..cb484f87 --- /dev/null +++ b/src/elevenlabs/conversational_ai/agents/widget/avatar/raw_client.py @@ -0,0 +1,148 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ..... import core +from .....core.api_error import ApiError +from .....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from .....core.http_response import AsyncHttpResponse, HttpResponse +from .....core.jsonable_encoder import jsonable_encoder +from .....core.request_options import RequestOptions +from .....core.unchecked_base_model import construct_type +from .....errors.unprocessable_entity_error import UnprocessableEntityError +from .....types.http_validation_error import HttpValidationError +from .....types.post_agent_avatar_response_model import PostAgentAvatarResponseModel + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RawAvatarClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def create( + self, agent_id: str, *, avatar_file: core.File, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[PostAgentAvatarResponseModel]: + """ + Sets the avatar for an agent displayed in the widget + + Parameters + ---------- + agent_id : str + The id of an agent. This is returned on agent creation. + + avatar_file : core.File + See core.File for more documentation + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[PostAgentAvatarResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/convai/agents/{jsonable_encoder(agent_id)}/avatar", + base_url=self._client_wrapper.get_environment().base, + method="POST", + data={}, + files={ + "avatar_file": avatar_file, + }, + request_options=request_options, + omit=OMIT, + force_multipart=True, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + PostAgentAvatarResponseModel, + construct_type( + type_=PostAgentAvatarResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + +class AsyncRawAvatarClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def create( + self, agent_id: str, *, avatar_file: core.File, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[PostAgentAvatarResponseModel]: + """ + Sets the avatar for an agent displayed in the widget + + Parameters + ---------- + agent_id : str + The id of an agent. This is returned on agent creation. + + avatar_file : core.File + See core.File for more documentation + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[PostAgentAvatarResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/convai/agents/{jsonable_encoder(agent_id)}/avatar", + base_url=self._client_wrapper.get_environment().base, + method="POST", + data={}, + files={ + "avatar_file": avatar_file, + }, + request_options=request_options, + omit=OMIT, + force_multipart=True, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + PostAgentAvatarResponseModel, + construct_type( + type_=PostAgentAvatarResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/elevenlabs/conversational_ai/agents/widget/client.py b/src/elevenlabs/conversational_ai/agents/widget/client.py new file mode 100644 index 00000000..5e09adac --- /dev/null +++ b/src/elevenlabs/conversational_ai/agents/widget/client.py @@ -0,0 +1,135 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +from ....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ....core.request_options import RequestOptions +from ....types.get_agent_embed_response_model import GetAgentEmbedResponseModel +from .avatar.client import AsyncAvatarClient, AvatarClient +from .raw_client import AsyncRawWidgetClient, RawWidgetClient + + +class WidgetClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._raw_client = RawWidgetClient(client_wrapper=client_wrapper) + self.avatar = AvatarClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawWidgetClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawWidgetClient + """ + return self._raw_client + + def get( + self, + agent_id: str, + *, + conversation_signature: typing.Optional[str] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> GetAgentEmbedResponseModel: + """ + Retrieve the widget configuration for an agent + + Parameters + ---------- + agent_id : str + The id of an agent. This is returned on agent creation. + + conversation_signature : typing.Optional[str] + An expiring token that enables a websocket conversation to start. These can be generated for an agent using the /v1/convai/conversation/get-signed-url endpoint + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + GetAgentEmbedResponseModel + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.conversational_ai.agents.widget.get( + agent_id="21m00Tcm4TlvDq8ikWAM", + ) + """ + _response = self._raw_client.get( + agent_id, conversation_signature=conversation_signature, request_options=request_options + ) + return _response.data + + +class AsyncWidgetClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawWidgetClient(client_wrapper=client_wrapper) + self.avatar = AsyncAvatarClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawWidgetClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawWidgetClient + """ + return self._raw_client + + async def get( + self, + agent_id: str, + *, + conversation_signature: typing.Optional[str] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> GetAgentEmbedResponseModel: + """ + Retrieve the widget configuration for an agent + + Parameters + ---------- + agent_id : str + The id of an agent. This is returned on agent creation. + + conversation_signature : typing.Optional[str] + An expiring token that enables a websocket conversation to start. These can be generated for an agent using the /v1/convai/conversation/get-signed-url endpoint + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + GetAgentEmbedResponseModel + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.conversational_ai.agents.widget.get( + agent_id="21m00Tcm4TlvDq8ikWAM", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.get( + agent_id, conversation_signature=conversation_signature, request_options=request_options + ) + return _response.data diff --git a/src/elevenlabs/conversational_ai/agents/widget/raw_client.py b/src/elevenlabs/conversational_ai/agents/widget/raw_client.py new file mode 100644 index 00000000..9c732af3 --- /dev/null +++ b/src/elevenlabs/conversational_ai/agents/widget/raw_client.py @@ -0,0 +1,146 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ....core.api_error import ApiError +from ....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ....core.http_response import AsyncHttpResponse, HttpResponse +from ....core.jsonable_encoder import jsonable_encoder +from ....core.request_options import RequestOptions +from ....core.unchecked_base_model import construct_type +from ....errors.unprocessable_entity_error import UnprocessableEntityError +from ....types.get_agent_embed_response_model import GetAgentEmbedResponseModel +from ....types.http_validation_error import HttpValidationError + + +class RawWidgetClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def get( + self, + agent_id: str, + *, + conversation_signature: typing.Optional[str] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[GetAgentEmbedResponseModel]: + """ + Retrieve the widget configuration for an agent + + Parameters + ---------- + agent_id : str + The id of an agent. This is returned on agent creation. + + conversation_signature : typing.Optional[str] + An expiring token that enables a websocket conversation to start. These can be generated for an agent using the /v1/convai/conversation/get-signed-url endpoint + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[GetAgentEmbedResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/convai/agents/{jsonable_encoder(agent_id)}/widget", + base_url=self._client_wrapper.get_environment().base, + method="GET", + params={ + "conversation_signature": conversation_signature, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetAgentEmbedResponseModel, + construct_type( + type_=GetAgentEmbedResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + +class AsyncRawWidgetClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def get( + self, + agent_id: str, + *, + conversation_signature: typing.Optional[str] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[GetAgentEmbedResponseModel]: + """ + Retrieve the widget configuration for an agent + + Parameters + ---------- + agent_id : str + The id of an agent. This is returned on agent creation. + + conversation_signature : typing.Optional[str] + An expiring token that enables a websocket conversation to start. These can be generated for an agent using the /v1/convai/conversation/get-signed-url endpoint + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[GetAgentEmbedResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/convai/agents/{jsonable_encoder(agent_id)}/widget", + base_url=self._client_wrapper.get_environment().base, + method="GET", + params={ + "conversation_signature": conversation_signature, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetAgentEmbedResponseModel, + construct_type( + type_=GetAgentEmbedResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/elevenlabs/conversational_ai/batch_calls/__init__.py b/src/elevenlabs/conversational_ai/batch_calls/__init__.py new file mode 100644 index 00000000..5cde0202 --- /dev/null +++ b/src/elevenlabs/conversational_ai/batch_calls/__init__.py @@ -0,0 +1,4 @@ +# This file was auto-generated by Fern from our API Definition. + +# isort: skip_file + diff --git a/src/elevenlabs/conversational_ai/batch_calls/client.py b/src/elevenlabs/conversational_ai/batch_calls/client.py new file mode 100644 index 00000000..96cd09be --- /dev/null +++ b/src/elevenlabs/conversational_ai/batch_calls/client.py @@ -0,0 +1,328 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ...core.request_options import RequestOptions +from ...types.batch_call_detailed_response import BatchCallDetailedResponse +from ...types.batch_call_response import BatchCallResponse +from ...types.outbound_call_recipient import OutboundCallRecipient +from ...types.workspace_batch_calls_response import WorkspaceBatchCallsResponse +from .raw_client import AsyncRawBatchCallsClient, RawBatchCallsClient + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class BatchCallsClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._raw_client = RawBatchCallsClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawBatchCallsClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawBatchCallsClient + """ + return self._raw_client + + def create( + self, + *, + call_name: str, + agent_id: str, + agent_phone_number_id: str, + recipients: typing.Sequence[OutboundCallRecipient], + scheduled_time_unix: typing.Optional[int] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> BatchCallResponse: + """ + Submit a batch call request to schedule calls for multiple recipients. + + Parameters + ---------- + call_name : str + + agent_id : str + + agent_phone_number_id : str + + recipients : typing.Sequence[OutboundCallRecipient] + + scheduled_time_unix : typing.Optional[int] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + BatchCallResponse + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs, OutboundCallRecipient + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.conversational_ai.batch_calls.create( + call_name="call_name", + agent_id="agent_id", + agent_phone_number_id="agent_phone_number_id", + recipients=[ + OutboundCallRecipient( + phone_number="phone_number", + ) + ], + ) + """ + _response = self._raw_client.create( + call_name=call_name, + agent_id=agent_id, + agent_phone_number_id=agent_phone_number_id, + recipients=recipients, + scheduled_time_unix=scheduled_time_unix, + request_options=request_options, + ) + return _response.data + + def list( + self, + *, + limit: typing.Optional[int] = None, + last_doc: typing.Optional[str] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> WorkspaceBatchCallsResponse: + """ + Get all batch calls for the current workspace. + + Parameters + ---------- + limit : typing.Optional[int] + + last_doc : typing.Optional[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + WorkspaceBatchCallsResponse + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.conversational_ai.batch_calls.list() + """ + _response = self._raw_client.list(limit=limit, last_doc=last_doc, request_options=request_options) + return _response.data + + def get( + self, batch_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> BatchCallDetailedResponse: + """ + Get detailed information about a batch call including all recipients. + + Parameters + ---------- + batch_id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + BatchCallDetailedResponse + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.conversational_ai.batch_calls.get( + batch_id="batch_id", + ) + """ + _response = self._raw_client.get(batch_id, request_options=request_options) + return _response.data + + +class AsyncBatchCallsClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawBatchCallsClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawBatchCallsClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawBatchCallsClient + """ + return self._raw_client + + async def create( + self, + *, + call_name: str, + agent_id: str, + agent_phone_number_id: str, + recipients: typing.Sequence[OutboundCallRecipient], + scheduled_time_unix: typing.Optional[int] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> BatchCallResponse: + """ + Submit a batch call request to schedule calls for multiple recipients. + + Parameters + ---------- + call_name : str + + agent_id : str + + agent_phone_number_id : str + + recipients : typing.Sequence[OutboundCallRecipient] + + scheduled_time_unix : typing.Optional[int] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + BatchCallResponse + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs, OutboundCallRecipient + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.conversational_ai.batch_calls.create( + call_name="call_name", + agent_id="agent_id", + agent_phone_number_id="agent_phone_number_id", + recipients=[ + OutboundCallRecipient( + phone_number="phone_number", + ) + ], + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.create( + call_name=call_name, + agent_id=agent_id, + agent_phone_number_id=agent_phone_number_id, + recipients=recipients, + scheduled_time_unix=scheduled_time_unix, + request_options=request_options, + ) + return _response.data + + async def list( + self, + *, + limit: typing.Optional[int] = None, + last_doc: typing.Optional[str] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> WorkspaceBatchCallsResponse: + """ + Get all batch calls for the current workspace. + + Parameters + ---------- + limit : typing.Optional[int] + + last_doc : typing.Optional[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + WorkspaceBatchCallsResponse + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.conversational_ai.batch_calls.list() + + + asyncio.run(main()) + """ + _response = await self._raw_client.list(limit=limit, last_doc=last_doc, request_options=request_options) + return _response.data + + async def get( + self, batch_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> BatchCallDetailedResponse: + """ + Get detailed information about a batch call including all recipients. + + Parameters + ---------- + batch_id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + BatchCallDetailedResponse + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.conversational_ai.batch_calls.get( + batch_id="batch_id", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.get(batch_id, request_options=request_options) + return _response.data diff --git a/src/elevenlabs/conversational_ai/batch_calls/raw_client.py b/src/elevenlabs/conversational_ai/batch_calls/raw_client.py new file mode 100644 index 00000000..c01b9648 --- /dev/null +++ b/src/elevenlabs/conversational_ai/batch_calls/raw_client.py @@ -0,0 +1,407 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ...core.api_error import ApiError +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ...core.http_response import AsyncHttpResponse, HttpResponse +from ...core.jsonable_encoder import jsonable_encoder +from ...core.request_options import RequestOptions +from ...core.serialization import convert_and_respect_annotation_metadata +from ...core.unchecked_base_model import construct_type +from ...errors.unprocessable_entity_error import UnprocessableEntityError +from ...types.batch_call_detailed_response import BatchCallDetailedResponse +from ...types.batch_call_response import BatchCallResponse +from ...types.http_validation_error import HttpValidationError +from ...types.outbound_call_recipient import OutboundCallRecipient +from ...types.workspace_batch_calls_response import WorkspaceBatchCallsResponse + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RawBatchCallsClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def create( + self, + *, + call_name: str, + agent_id: str, + agent_phone_number_id: str, + recipients: typing.Sequence[OutboundCallRecipient], + scheduled_time_unix: typing.Optional[int] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[BatchCallResponse]: + """ + Submit a batch call request to schedule calls for multiple recipients. + + Parameters + ---------- + call_name : str + + agent_id : str + + agent_phone_number_id : str + + recipients : typing.Sequence[OutboundCallRecipient] + + scheduled_time_unix : typing.Optional[int] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[BatchCallResponse] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + "v1/convai/batch-calling/submit", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "call_name": call_name, + "agent_id": agent_id, + "agent_phone_number_id": agent_phone_number_id, + "scheduled_time_unix": scheduled_time_unix, + "recipients": convert_and_respect_annotation_metadata( + object_=recipients, annotation=typing.Sequence[OutboundCallRecipient], direction="write" + ), + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + BatchCallResponse, + construct_type( + type_=BatchCallResponse, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def list( + self, + *, + limit: typing.Optional[int] = None, + last_doc: typing.Optional[str] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[WorkspaceBatchCallsResponse]: + """ + Get all batch calls for the current workspace. + + Parameters + ---------- + limit : typing.Optional[int] + + last_doc : typing.Optional[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[WorkspaceBatchCallsResponse] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + "v1/convai/batch-calling/workspace", + base_url=self._client_wrapper.get_environment().base, + method="GET", + params={ + "limit": limit, + "last_doc": last_doc, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + WorkspaceBatchCallsResponse, + construct_type( + type_=WorkspaceBatchCallsResponse, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def get( + self, batch_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[BatchCallDetailedResponse]: + """ + Get detailed information about a batch call including all recipients. + + Parameters + ---------- + batch_id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[BatchCallDetailedResponse] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/convai/batch-calling/{jsonable_encoder(batch_id)}", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + BatchCallDetailedResponse, + construct_type( + type_=BatchCallDetailedResponse, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + +class AsyncRawBatchCallsClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def create( + self, + *, + call_name: str, + agent_id: str, + agent_phone_number_id: str, + recipients: typing.Sequence[OutboundCallRecipient], + scheduled_time_unix: typing.Optional[int] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[BatchCallResponse]: + """ + Submit a batch call request to schedule calls for multiple recipients. + + Parameters + ---------- + call_name : str + + agent_id : str + + agent_phone_number_id : str + + recipients : typing.Sequence[OutboundCallRecipient] + + scheduled_time_unix : typing.Optional[int] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[BatchCallResponse] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + "v1/convai/batch-calling/submit", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "call_name": call_name, + "agent_id": agent_id, + "agent_phone_number_id": agent_phone_number_id, + "scheduled_time_unix": scheduled_time_unix, + "recipients": convert_and_respect_annotation_metadata( + object_=recipients, annotation=typing.Sequence[OutboundCallRecipient], direction="write" + ), + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + BatchCallResponse, + construct_type( + type_=BatchCallResponse, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def list( + self, + *, + limit: typing.Optional[int] = None, + last_doc: typing.Optional[str] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[WorkspaceBatchCallsResponse]: + """ + Get all batch calls for the current workspace. + + Parameters + ---------- + limit : typing.Optional[int] + + last_doc : typing.Optional[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[WorkspaceBatchCallsResponse] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + "v1/convai/batch-calling/workspace", + base_url=self._client_wrapper.get_environment().base, + method="GET", + params={ + "limit": limit, + "last_doc": last_doc, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + WorkspaceBatchCallsResponse, + construct_type( + type_=WorkspaceBatchCallsResponse, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def get( + self, batch_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[BatchCallDetailedResponse]: + """ + Get detailed information about a batch call including all recipients. + + Parameters + ---------- + batch_id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[BatchCallDetailedResponse] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/convai/batch-calling/{jsonable_encoder(batch_id)}", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + BatchCallDetailedResponse, + construct_type( + type_=BatchCallDetailedResponse, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/elevenlabs/conversational_ai/client.py b/src/elevenlabs/conversational_ai/client.py index 6ff1508c..1df37532 100644 --- a/src/elevenlabs/conversational_ai/client.py +++ b/src/elevenlabs/conversational_ai/client.py @@ -1,5517 +1,207 @@ # This file was auto-generated by Fern from our API Definition. import typing -from ..core.client_wrapper import SyncClientWrapper -from .agents.client import AgentsClient -from .sip_trunk.client import SipTrunkClient -from .knowledge_base.client import KnowledgeBaseClient -from ..core.request_options import RequestOptions -from ..types.conversation_signed_url_response_model import ( - ConversationSignedUrlResponseModel, -) -from ..core.unchecked_base_model import construct_type -from ..errors.unprocessable_entity_error import UnprocessableEntityError -from ..types.http_validation_error import HttpValidationError -from json.decoder import JSONDecodeError -from ..core.api_error import ApiError -from ..types.conversation_initiation_client_data_request_input import ( - ConversationInitiationClientDataRequestInput, -) -from ..types.twilio_outbound_call_response import TwilioOutboundCallResponse -from ..core.serialization import convert_and_respect_annotation_metadata -from ..types.conversational_config import ConversationalConfig -from ..types.agent_platform_settings_request_model import ( - AgentPlatformSettingsRequestModel, -) -from ..types.create_agent_response_model import CreateAgentResponseModel -from ..types.get_agent_response_model import GetAgentResponseModel -from ..core.jsonable_encoder import jsonable_encoder -from ..types.get_agent_embed_response_model import GetAgentEmbedResponseModel -from ..types.get_agent_link_response_model import GetAgentLinkResponseModel + from .. import core -from ..types.post_agent_avatar_response_model import PostAgentAvatarResponseModel -from ..types.get_agents_page_response_model import GetAgentsPageResponseModel -from ..types.evaluation_success_result import EvaluationSuccessResult -from ..types.get_conversations_page_response_model import ( - GetConversationsPageResponseModel, -) -from ..types.get_conversation_response_model import GetConversationResponseModel -from ..types.user_feedback_score import UserFeedbackScore -from .types.conversational_ai_create_phone_number_request_body import ( - ConversationalAiCreatePhoneNumberRequestBody, -) -from ..types.create_phone_number_response_model import CreatePhoneNumberResponseModel -from .types.conversational_ai_get_phone_number_response import ( - ConversationalAiGetPhoneNumberResponse, -) -from .types.conversational_ai_update_phone_number_response import ( - ConversationalAiUpdatePhoneNumberResponse, -) -from .types.conversational_ai_get_phone_numbers_response_item import ( - ConversationalAiGetPhoneNumbersResponseItem, -) -from ..types.knowledge_base_document_type import KnowledgeBaseDocumentType -from ..types.get_knowledge_base_list_response_model import ( - GetKnowledgeBaseListResponseModel, -) +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ..core.request_options import RequestOptions from ..types.add_knowledge_base_response_model import AddKnowledgeBaseResponseModel -from .types.conversational_ai_get_knowledge_base_document_by_id_response import ( - ConversationalAiGetKnowledgeBaseDocumentByIdResponse, -) -from .types.conversational_ai_update_knowledge_base_document_response import ( - ConversationalAiUpdateKnowledgeBaseDocumentResponse, -) -from ..types.get_knowledge_base_dependent_agents_response_model import ( - GetKnowledgeBaseDependentAgentsResponseModel, -) -from ..types.knowledge_base_document_chunk_response_model import ( - KnowledgeBaseDocumentChunkResponseModel, -) -from ..types.get_conv_ai_settings_response_model import GetConvAiSettingsResponseModel -from ..types.conversation_initiation_client_data_webhook import ( - ConversationInitiationClientDataWebhook, -) -from ..types.conv_ai_webhooks import ConvAiWebhooks -from ..types.get_conv_ai_dashboard_settings_response_model import ( - GetConvAiDashboardSettingsResponseModel, -) -from .types.patch_conv_ai_dashboard_settings_request_charts_item import ( - PatchConvAiDashboardSettingsRequestChartsItem, -) -from ..types.get_workspace_secrets_response_model import ( - GetWorkspaceSecretsResponseModel, -) -from ..types.post_workspace_secret_response_model import ( - PostWorkspaceSecretResponseModel, -) -from ..types.batch_call_detailed_response import BatchCallDetailedResponse -from ..core.client_wrapper import AsyncClientWrapper -from .agents.client import AsyncAgentsClient -from .sip_trunk.client import AsyncSipTrunkClient -from .knowledge_base.client import AsyncKnowledgeBaseClient +from ..types.post_workspace_secret_response_model import PostWorkspaceSecretResponseModel +from .agents.client import AgentsClient, AsyncAgentsClient +from .batch_calls.client import AsyncBatchCallsClient, BatchCallsClient +from .conversations.client import AsyncConversationsClient, ConversationsClient +from .dashboard.client import AsyncDashboardClient, DashboardClient +from .knowledge_base.client import AsyncKnowledgeBaseClient, KnowledgeBaseClient +from .phone_numbers.client import AsyncPhoneNumbersClient, PhoneNumbersClient +from .raw_client import AsyncRawConversationalAiClient, RawConversationalAiClient +from .secrets.client import AsyncSecretsClient, SecretsClient +from .settings.client import AsyncSettingsClient, SettingsClient +from .sip_trunk.client import AsyncSipTrunkClient, SipTrunkClient +from .twilio.client import AsyncTwilioClient, TwilioClient # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) -class ConversationalAiClient: - def __init__(self, *, client_wrapper: SyncClientWrapper): - self._client_wrapper = client_wrapper - self.agents = AgentsClient(client_wrapper=self._client_wrapper) - self.sip_trunk = SipTrunkClient(client_wrapper=self._client_wrapper) - self.knowledge_base = KnowledgeBaseClient(client_wrapper=self._client_wrapper) - - def get_signed_url( - self, *, agent_id: str, request_options: typing.Optional[RequestOptions] = None - ) -> ConversationSignedUrlResponseModel: - """ - Get a signed url to start a conversation with an agent with an agent that requires authorization - - Parameters - ---------- - agent_id : str - The id of the agent you're taking the action on. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - ConversationSignedUrlResponseModel - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.conversational_ai.get_signed_url( - agent_id="21m00Tcm4TlvDq8ikWAM", - ) - """ - _response = self._client_wrapper.httpx_client.request( - "v1/convai/conversation/get-signed-url", - base_url=self._client_wrapper.get_environment().base, - method="GET", - params={ - "agent_id": agent_id, - }, - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ConversationSignedUrlResponseModel, - construct_type( - type_=ConversationSignedUrlResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def twilio_outbound_call( - self, - *, - agent_id: str, - agent_phone_number_id: str, - to_number: str, - conversation_initiation_client_data: typing.Optional[ConversationInitiationClientDataRequestInput] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> TwilioOutboundCallResponse: - """ - Handle an outbound call via Twilio - - Parameters - ---------- - agent_id : str - - agent_phone_number_id : str - - to_number : str - - conversation_initiation_client_data : typing.Optional[ConversationInitiationClientDataRequestInput] - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - TwilioOutboundCallResponse - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.conversational_ai.twilio_outbound_call( - agent_id="agent_id", - agent_phone_number_id="agent_phone_number_id", - to_number="to_number", - ) - """ - _response = self._client_wrapper.httpx_client.request( - "v1/convai/twilio/outbound-call", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "agent_id": agent_id, - "agent_phone_number_id": agent_phone_number_id, - "to_number": to_number, - "conversation_initiation_client_data": convert_and_respect_annotation_metadata( - object_=conversation_initiation_client_data, - annotation=ConversationInitiationClientDataRequestInput, - direction="write", - ), - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - TwilioOutboundCallResponse, - construct_type( - type_=TwilioOutboundCallResponse, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def create_agent( - self, - *, - conversation_config: ConversationalConfig, - platform_settings: typing.Optional[AgentPlatformSettingsRequestModel] = OMIT, - name: typing.Optional[str] = OMIT, - tags: typing.Optional[typing.Sequence[str]] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> CreateAgentResponseModel: - """ - Create an agent from a config object - - Parameters - ---------- - conversation_config : ConversationalConfig - Conversation configuration for an agent - - platform_settings : typing.Optional[AgentPlatformSettingsRequestModel] - Platform settings for the agent are all settings that aren't related to the conversation orchestration and content. - - name : typing.Optional[str] - A name to make the agent easier to find - - tags : typing.Optional[typing.Sequence[str]] - Tags to help classify and filter the agent - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - CreateAgentResponseModel - Successful Response - - Examples - -------- - from elevenlabs import ConversationalConfig, ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.conversational_ai.create_agent( - conversation_config=ConversationalConfig(), - ) - """ - _response = self._client_wrapper.httpx_client.request( - "v1/convai/agents/create", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "conversation_config": convert_and_respect_annotation_metadata( - object_=conversation_config, - annotation=ConversationalConfig, - direction="write", - ), - "platform_settings": convert_and_respect_annotation_metadata( - object_=platform_settings, - annotation=AgentPlatformSettingsRequestModel, - direction="write", - ), - "name": name, - "tags": tags, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - CreateAgentResponseModel, - construct_type( - type_=CreateAgentResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def get_agent( - self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None - ) -> GetAgentResponseModel: - """ - Retrieve config for an agent - - Parameters - ---------- - agent_id : str - The id of an agent. This is returned on agent creation. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - GetAgentResponseModel - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.conversational_ai.get_agent( - agent_id="21m00Tcm4TlvDq8ikWAM", - ) - """ - _response = self._client_wrapper.httpx_client.request( - f"v1/convai/agents/{jsonable_encoder(agent_id)}", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - GetAgentResponseModel, - construct_type( - type_=GetAgentResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def delete_agent(self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None: - """ - Delete an agent - - Parameters - ---------- - agent_id : str - The id of an agent. This is returned on agent creation. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - None - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.conversational_ai.delete_agent( - agent_id="21m00Tcm4TlvDq8ikWAM", - ) - """ - _response = self._client_wrapper.httpx_client.request( - f"v1/convai/agents/{jsonable_encoder(agent_id)}", - base_url=self._client_wrapper.get_environment().base, - method="DELETE", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def update_agent( - self, - agent_id: str, - *, - conversation_config: typing.Optional[typing.Optional[typing.Any]] = OMIT, - platform_settings: typing.Optional[typing.Optional[typing.Any]] = OMIT, - name: typing.Optional[str] = OMIT, - tags: typing.Optional[typing.Sequence[str]] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> GetAgentResponseModel: - """ - Patches an Agent settings - - Parameters - ---------- - agent_id : str - The id of an agent. This is returned on agent creation. - - conversation_config : typing.Optional[typing.Optional[typing.Any]] - - platform_settings : typing.Optional[typing.Optional[typing.Any]] - - name : typing.Optional[str] - A name to make the agent easier to find - - tags : typing.Optional[typing.Sequence[str]] - Tags to help classify and filter the agent - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - GetAgentResponseModel - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.conversational_ai.update_agent( - agent_id="21m00Tcm4TlvDq8ikWAM", - ) - """ - _response = self._client_wrapper.httpx_client.request( - f"v1/convai/agents/{jsonable_encoder(agent_id)}", - base_url=self._client_wrapper.get_environment().base, - method="PATCH", - json={ - "conversation_config": conversation_config, - "platform_settings": platform_settings, - "name": name, - "tags": tags, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - GetAgentResponseModel, - construct_type( - type_=GetAgentResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def get_agent_widget( - self, - agent_id: str, - *, - conversation_signature: typing.Optional[str] = None, - request_options: typing.Optional[RequestOptions] = None, - ) -> GetAgentEmbedResponseModel: - """ - Retrieve the widget configuration for an agent - - Parameters - ---------- - agent_id : str - The id of an agent. This is returned on agent creation. - - conversation_signature : typing.Optional[str] - An expiring token that enables a websocket conversation to start. These can be generated for an agent using the /v1/convai/conversation/get-signed-url endpoint - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - GetAgentEmbedResponseModel - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.conversational_ai.get_agent_widget( - agent_id="21m00Tcm4TlvDq8ikWAM", - ) - """ - _response = self._client_wrapper.httpx_client.request( - f"v1/convai/agents/{jsonable_encoder(agent_id)}/widget", - base_url=self._client_wrapper.get_environment().base, - method="GET", - params={ - "conversation_signature": conversation_signature, - }, - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - GetAgentEmbedResponseModel, - construct_type( - type_=GetAgentEmbedResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def get_agent_link( - self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None - ) -> GetAgentLinkResponseModel: - """ - Get the current link used to share the agent with others - - Parameters - ---------- - agent_id : str - The id of an agent. This is returned on agent creation. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - GetAgentLinkResponseModel - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.conversational_ai.get_agent_link( - agent_id="21m00Tcm4TlvDq8ikWAM", - ) - """ - _response = self._client_wrapper.httpx_client.request( - f"v1/convai/agents/{jsonable_encoder(agent_id)}/link", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - GetAgentLinkResponseModel, - construct_type( - type_=GetAgentLinkResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def post_agent_avatar( - self, - agent_id: str, - *, - avatar_file: core.File, - request_options: typing.Optional[RequestOptions] = None, - ) -> PostAgentAvatarResponseModel: - """ - Sets the avatar for an agent displayed in the widget - - Parameters - ---------- - agent_id : str - The id of an agent. This is returned on agent creation. - - avatar_file : core.File - See core.File for more documentation - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - PostAgentAvatarResponseModel - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.conversational_ai.post_agent_avatar( - agent_id="21m00Tcm4TlvDq8ikWAM", - ) - """ - _response = self._client_wrapper.httpx_client.request( - f"v1/convai/agents/{jsonable_encoder(agent_id)}/avatar", - base_url=self._client_wrapper.get_environment().base, - method="POST", - data={}, - files={ - "avatar_file": avatar_file, - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - PostAgentAvatarResponseModel, - construct_type( - type_=PostAgentAvatarResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def get_agents( - self, - *, - cursor: typing.Optional[str] = None, - page_size: typing.Optional[int] = None, - search: typing.Optional[str] = None, - request_options: typing.Optional[RequestOptions] = None, - ) -> GetAgentsPageResponseModel: - """ - Returns a list of your agents and their metadata. - - Parameters - ---------- - cursor : typing.Optional[str] - Used for fetching next page. Cursor is returned in the response. - - page_size : typing.Optional[int] - How many Agents to return at maximum. Can not exceed 100, defaults to 30. - - search : typing.Optional[str] - Search by agents name. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - GetAgentsPageResponseModel - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.conversational_ai.get_agents() - """ - _response = self._client_wrapper.httpx_client.request( - "v1/convai/agents", - base_url=self._client_wrapper.get_environment().base, - method="GET", - params={ - "cursor": cursor, - "page_size": page_size, - "search": search, - }, - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - GetAgentsPageResponseModel, - construct_type( - type_=GetAgentsPageResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def get_conversations( - self, - *, - cursor: typing.Optional[str] = None, - agent_id: typing.Optional[str] = None, - call_successful: typing.Optional[EvaluationSuccessResult] = None, - call_start_before_unix: typing.Optional[int] = None, - call_start_after_unix: typing.Optional[int] = None, - page_size: typing.Optional[int] = None, - request_options: typing.Optional[RequestOptions] = None, - ) -> GetConversationsPageResponseModel: - """ - Get all conversations of agents that user owns. With option to restrict to a specific agent. - - Parameters - ---------- - cursor : typing.Optional[str] - Used for fetching next page. Cursor is returned in the response. - - agent_id : typing.Optional[str] - The id of the agent you're taking the action on. - - call_successful : typing.Optional[EvaluationSuccessResult] - The result of the success evaluation - - call_start_before_unix : typing.Optional[int] - Unix timestamp (in seconds) to filter conversations up to this start date. - - call_start_after_unix : typing.Optional[int] - Unix timestamp (in seconds) to filter conversations after to this start date. - - page_size : typing.Optional[int] - How many conversations to return at maximum. Can not exceed 100, defaults to 30. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - GetConversationsPageResponseModel - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.conversational_ai.get_conversations() - """ - _response = self._client_wrapper.httpx_client.request( - "v1/convai/conversations", - base_url=self._client_wrapper.get_environment().base, - method="GET", - params={ - "cursor": cursor, - "agent_id": agent_id, - "call_successful": call_successful, - "call_start_before_unix": call_start_before_unix, - "call_start_after_unix": call_start_after_unix, - "page_size": page_size, - }, - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - GetConversationsPageResponseModel, - construct_type( - type_=GetConversationsPageResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def get_conversation( - self, - conversation_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, - ) -> GetConversationResponseModel: - """ - Get the details of a particular conversation - - Parameters - ---------- - conversation_id : str - The id of the conversation you're taking the action on. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - GetConversationResponseModel - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.conversational_ai.get_conversation( - conversation_id="123", - ) - """ - _response = self._client_wrapper.httpx_client.request( - f"v1/convai/conversations/{jsonable_encoder(conversation_id)}", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - GetConversationResponseModel, - construct_type( - type_=GetConversationResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def delete_conversation( - self, - conversation_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, - ) -> typing.Optional[typing.Any]: - """ - Delete a particular conversation - - Parameters - ---------- - conversation_id : str - The id of the conversation you're taking the action on. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - typing.Optional[typing.Any] - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.conversational_ai.delete_conversation( - conversation_id="21m00Tcm4TlvDq8ikWAM", - ) - """ - _response = self._client_wrapper.httpx_client.request( - f"v1/convai/conversations/{jsonable_encoder(conversation_id)}", - base_url=self._client_wrapper.get_environment().base, - method="DELETE", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def get_conversation_audio( - self, - conversation_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, - ) -> typing.Iterator[bytes]: - """ - Get the audio recording of a particular conversation - - Parameters - ---------- - conversation_id : str - The id of the conversation you're taking the action on. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. - - Yields - ------ - typing.Iterator[bytes] - Successful Response - """ - with self._client_wrapper.httpx_client.stream( - f"v1/convai/conversations/{jsonable_encoder(conversation_id)}/audio", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) as _response: - try: - if 200 <= _response.status_code < 300: - _chunk_size = request_options.get("chunk_size", 1024) if request_options is not None else 1024 - for _chunk in _response.iter_bytes(chunk_size=_chunk_size): - yield _chunk - return - _response.read() - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def post_conversation_feedback( - self, - conversation_id: str, - *, - feedback: UserFeedbackScore, - request_options: typing.Optional[RequestOptions] = None, - ) -> typing.Optional[typing.Any]: - """ - Send the feedback for the given conversation - - Parameters - ---------- - conversation_id : str - The id of the conversation you're taking the action on. - - feedback : UserFeedbackScore - Either 'like' or 'dislike' to indicate the feedback for the conversation. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - typing.Optional[typing.Any] - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.conversational_ai.post_conversation_feedback( - conversation_id="21m00Tcm4TlvDq8ikWAM", - feedback="like", - ) - """ - _response = self._client_wrapper.httpx_client.request( - f"v1/convai/conversations/{jsonable_encoder(conversation_id)}/feedback", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "feedback": feedback, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def create_phone_number( - self, - *, - request: ConversationalAiCreatePhoneNumberRequestBody, - request_options: typing.Optional[RequestOptions] = None, - ) -> CreatePhoneNumberResponseModel: - """ - Import Phone Number from provider configuration (Twilio or SIP trunk) - - Parameters - ---------- - request : ConversationalAiCreatePhoneNumberRequestBody - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - CreatePhoneNumberResponseModel - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - from elevenlabs.conversational_ai import ( - ConversationalAiCreatePhoneNumberRequestBody_Twilio, - ) - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.conversational_ai.create_phone_number( - request=ConversationalAiCreatePhoneNumberRequestBody_Twilio( - phone_number="phone_number", - label="label", - sid="sid", - token="token", - ), - ) - """ - _response = self._client_wrapper.httpx_client.request( - "v1/convai/phone-numbers/create", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json=convert_and_respect_annotation_metadata( - object_=request, - annotation=ConversationalAiCreatePhoneNumberRequestBody, - direction="write", - ), - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - CreatePhoneNumberResponseModel, - construct_type( - type_=CreatePhoneNumberResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def get_phone_number( - self, - phone_number_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, - ) -> ConversationalAiGetPhoneNumberResponse: - """ - Retrieve Phone Number details by ID - - Parameters - ---------- - phone_number_id : str - The id of an agent. This is returned on agent creation. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - ConversationalAiGetPhoneNumberResponse - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.conversational_ai.get_phone_number( - phone_number_id="TeaqRRdTcIfIu2i7BYfT", - ) - """ - _response = self._client_wrapper.httpx_client.request( - f"v1/convai/phone-numbers/{jsonable_encoder(phone_number_id)}", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ConversationalAiGetPhoneNumberResponse, - construct_type( - type_=ConversationalAiGetPhoneNumberResponse, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def delete_phone_number( - self, - phone_number_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, - ) -> typing.Optional[typing.Any]: - """ - Delete Phone Number by ID - - Parameters - ---------- - phone_number_id : str - The id of an agent. This is returned on agent creation. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - typing.Optional[typing.Any] - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.conversational_ai.delete_phone_number( - phone_number_id="TeaqRRdTcIfIu2i7BYfT", - ) - """ - _response = self._client_wrapper.httpx_client.request( - f"v1/convai/phone-numbers/{jsonable_encoder(phone_number_id)}", - base_url=self._client_wrapper.get_environment().base, - method="DELETE", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def update_phone_number( - self, - phone_number_id: str, - *, - agent_id: typing.Optional[str] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> ConversationalAiUpdatePhoneNumberResponse: - """ - Update Phone Number details by ID - - Parameters - ---------- - phone_number_id : str - The id of an agent. This is returned on agent creation. - - agent_id : typing.Optional[str] - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - ConversationalAiUpdatePhoneNumberResponse - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.conversational_ai.update_phone_number( - phone_number_id="TeaqRRdTcIfIu2i7BYfT", - ) - """ - _response = self._client_wrapper.httpx_client.request( - f"v1/convai/phone-numbers/{jsonable_encoder(phone_number_id)}", - base_url=self._client_wrapper.get_environment().base, - method="PATCH", - json={ - "agent_id": agent_id, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ConversationalAiUpdatePhoneNumberResponse, - construct_type( - type_=ConversationalAiUpdatePhoneNumberResponse, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def get_phone_numbers( - self, *, request_options: typing.Optional[RequestOptions] = None - ) -> typing.List[ConversationalAiGetPhoneNumbersResponseItem]: - """ - Retrieve all Phone Numbers - - Parameters - ---------- - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - typing.List[ConversationalAiGetPhoneNumbersResponseItem] - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.conversational_ai.get_phone_numbers() - """ - _response = self._client_wrapper.httpx_client.request( - "v1/convai/phone-numbers/", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - typing.List[ConversationalAiGetPhoneNumbersResponseItem], - construct_type( - type_=typing.List[ConversationalAiGetPhoneNumbersResponseItem], # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def get_knowledge_base_list( - self, - *, - cursor: typing.Optional[str] = None, - page_size: typing.Optional[int] = None, - search: typing.Optional[str] = None, - show_only_owned_documents: typing.Optional[bool] = None, - types: typing.Optional[ - typing.Union[KnowledgeBaseDocumentType, typing.Sequence[KnowledgeBaseDocumentType]] - ] = None, - use_typesense: typing.Optional[bool] = None, - request_options: typing.Optional[RequestOptions] = None, - ) -> GetKnowledgeBaseListResponseModel: - """ - Get a list of available knowledge base documents - - Parameters - ---------- - cursor : typing.Optional[str] - Used for fetching next page. Cursor is returned in the response. - - page_size : typing.Optional[int] - How many documents to return at maximum. Can not exceed 100, defaults to 30. - - search : typing.Optional[str] - If specified, the endpoint returns only such knowledge base documents whose names start with this string. - - show_only_owned_documents : typing.Optional[bool] - If set to true, the endpoint will return only documents owned by you (and not shared from somebody else). - - types : typing.Optional[typing.Union[KnowledgeBaseDocumentType, typing.Sequence[KnowledgeBaseDocumentType]]] - If present, the endpoint will return only documents of the given types. - - use_typesense : typing.Optional[bool] - If set to true, the endpoint will use typesense DB to search for the documents). - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - GetKnowledgeBaseListResponseModel - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.conversational_ai.get_knowledge_base_list() - """ - _response = self._client_wrapper.httpx_client.request( - "v1/convai/knowledge-base", - base_url=self._client_wrapper.get_environment().base, - method="GET", - params={ - "cursor": cursor, - "page_size": page_size, - "search": search, - "show_only_owned_documents": show_only_owned_documents, - "types": types, - "use_typesense": use_typesense, - }, - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - GetKnowledgeBaseListResponseModel, - construct_type( - type_=GetKnowledgeBaseListResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def add_to_knowledge_base( - self, - *, - name: typing.Optional[str] = OMIT, - url: typing.Optional[str] = OMIT, - file: typing.Optional[core.File] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> AddKnowledgeBaseResponseModel: - """ - Upload a file or webpage URL to create a knowledge base document.
After creating the document, update the agent's knowledge base by calling [Update agent](/docs/conversational-ai/api-reference/agents/update-agent). - - Parameters - ---------- - name : typing.Optional[str] - A custom, human-readable name for the document. - - url : typing.Optional[str] - URL to a page of documentation that the agent will have access to in order to interact with users. - - file : typing.Optional[core.File] - See core.File for more documentation - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - AddKnowledgeBaseResponseModel - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.conversational_ai.add_to_knowledge_base() - """ - _response = self._client_wrapper.httpx_client.request( - "v1/convai/knowledge-base", - base_url=self._client_wrapper.get_environment().base, - method="POST", - data={ - "name": name, - "url": url, - }, - files={ - "file": file, - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - AddKnowledgeBaseResponseModel, - construct_type( - type_=AddKnowledgeBaseResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def create_knowledge_base_url_document( - self, - *, - url: str, - name: typing.Optional[str] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> AddKnowledgeBaseResponseModel: - """ - Create a knowledge base document generated by scraping the given webpage. - - Parameters - ---------- - url : str - URL to a page of documentation that the agent will have access to in order to interact with users. - - name : typing.Optional[str] - A custom, human-readable name for the document. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - AddKnowledgeBaseResponseModel - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.conversational_ai.create_knowledge_base_url_document( - url="url", - ) - """ - _response = self._client_wrapper.httpx_client.request( - "v1/convai/knowledge-base/url", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "url": url, - "name": name, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - AddKnowledgeBaseResponseModel, - construct_type( - type_=AddKnowledgeBaseResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def create_knowledge_base_file_document( - self, - *, - file: core.File, - name: typing.Optional[str] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> AddKnowledgeBaseResponseModel: - """ - Create a knowledge base document generated form the uploaded file. - - Parameters - ---------- - file : core.File - See core.File for more documentation - - name : typing.Optional[str] - A custom, human-readable name for the document. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - AddKnowledgeBaseResponseModel - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.conversational_ai.create_knowledge_base_file_document() - """ - _response = self._client_wrapper.httpx_client.request( - "v1/convai/knowledge-base/file", - base_url=self._client_wrapper.get_environment().base, - method="POST", - data={ - "name": name, - }, - files={ - "file": file, - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - AddKnowledgeBaseResponseModel, - construct_type( - type_=AddKnowledgeBaseResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def create_knowledge_base_text_document( - self, - *, - text: str, - name: typing.Optional[str] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> AddKnowledgeBaseResponseModel: - """ - Create a knowledge base document containing the provided text. - - Parameters - ---------- - text : str - Text content to be added to the knowledge base. - - name : typing.Optional[str] - A custom, human-readable name for the document. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - AddKnowledgeBaseResponseModel - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.conversational_ai.create_knowledge_base_text_document( - text="text", - ) - """ - _response = self._client_wrapper.httpx_client.request( - "v1/convai/knowledge-base/text", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "text": text, - "name": name, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - AddKnowledgeBaseResponseModel, - construct_type( - type_=AddKnowledgeBaseResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def get_knowledge_base_document_by_id( - self, - documentation_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, - ) -> ConversationalAiGetKnowledgeBaseDocumentByIdResponse: - """ - Get details about a specific documentation making up the agent's knowledge base - - Parameters - ---------- - documentation_id : str - The id of a document from the knowledge base. This is returned on document addition. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - ConversationalAiGetKnowledgeBaseDocumentByIdResponse - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.conversational_ai.get_knowledge_base_document_by_id( - documentation_id="21m00Tcm4TlvDq8ikWAM", - ) - """ - _response = self._client_wrapper.httpx_client.request( - f"v1/convai/knowledge-base/{jsonable_encoder(documentation_id)}", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ConversationalAiGetKnowledgeBaseDocumentByIdResponse, - construct_type( - type_=ConversationalAiGetKnowledgeBaseDocumentByIdResponse, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def delete_knowledge_base_document( - self, - documentation_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, - ) -> typing.Optional[typing.Any]: - """ - Delete a document from the knowledge base - - Parameters - ---------- - documentation_id : str - The id of a document from the knowledge base. This is returned on document addition. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - typing.Optional[typing.Any] - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.conversational_ai.delete_knowledge_base_document( - documentation_id="21m00Tcm4TlvDq8ikWAM", - ) - """ - _response = self._client_wrapper.httpx_client.request( - f"v1/convai/knowledge-base/{jsonable_encoder(documentation_id)}", - base_url=self._client_wrapper.get_environment().base, - method="DELETE", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def update_knowledge_base_document( - self, - documentation_id: str, - *, - name: str, - request_options: typing.Optional[RequestOptions] = None, - ) -> ConversationalAiUpdateKnowledgeBaseDocumentResponse: - """ - Update the name of a document - - Parameters - ---------- - documentation_id : str - The id of a document from the knowledge base. This is returned on document addition. - - name : str - A custom, human-readable name for the document. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - ConversationalAiUpdateKnowledgeBaseDocumentResponse - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.conversational_ai.update_knowledge_base_document( - documentation_id="21m00Tcm4TlvDq8ikWAM", - name="name", - ) - """ - _response = self._client_wrapper.httpx_client.request( - f"v1/convai/knowledge-base/{jsonable_encoder(documentation_id)}", - base_url=self._client_wrapper.get_environment().base, - method="PATCH", - json={ - "name": name, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ConversationalAiUpdateKnowledgeBaseDocumentResponse, - construct_type( - type_=ConversationalAiUpdateKnowledgeBaseDocumentResponse, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def get_dependent_agents( - self, - documentation_id: str, - *, - cursor: typing.Optional[str] = None, - page_size: typing.Optional[int] = None, - request_options: typing.Optional[RequestOptions] = None, - ) -> GetKnowledgeBaseDependentAgentsResponseModel: - """ - Get a list of agents depending on this knowledge base document - - Parameters - ---------- - documentation_id : str - The id of a document from the knowledge base. This is returned on document addition. - - cursor : typing.Optional[str] - Used for fetching next page. Cursor is returned in the response. - - page_size : typing.Optional[int] - How many documents to return at maximum. Can not exceed 100, defaults to 30. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - GetKnowledgeBaseDependentAgentsResponseModel - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.conversational_ai.get_dependent_agents( - documentation_id="21m00Tcm4TlvDq8ikWAM", - ) - """ - _response = self._client_wrapper.httpx_client.request( - f"v1/convai/knowledge-base/{jsonable_encoder(documentation_id)}/dependent-agents", - base_url=self._client_wrapper.get_environment().base, - method="GET", - params={ - "cursor": cursor, - "page_size": page_size, - }, - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - GetKnowledgeBaseDependentAgentsResponseModel, - construct_type( - type_=GetKnowledgeBaseDependentAgentsResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def get_knowledge_base_document_content( - self, - documentation_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, - ) -> None: - """ - Get the entire content of a document from the knowledge base - - Parameters - ---------- - documentation_id : str - The id of a document from the knowledge base. This is returned on document addition. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - None - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.conversational_ai.get_knowledge_base_document_content( - documentation_id="21m00Tcm4TlvDq8ikWAM", - ) - """ - _response = self._client_wrapper.httpx_client.request( - f"v1/convai/knowledge-base/{jsonable_encoder(documentation_id)}/content", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def get_knowledge_base_document_part_by_id( - self, - documentation_id: str, - chunk_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, - ) -> KnowledgeBaseDocumentChunkResponseModel: - """ - Get details about a specific documentation part used by RAG. - - Parameters - ---------- - documentation_id : str - The id of a document from the knowledge base. This is returned on document addition. - - chunk_id : str - The id of a document RAG chunk from the knowledge base. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - KnowledgeBaseDocumentChunkResponseModel - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.conversational_ai.get_knowledge_base_document_part_by_id( - documentation_id="21m00Tcm4TlvDq8ikWAM", - chunk_id="chunk_id", - ) - """ - _response = self._client_wrapper.httpx_client.request( - f"v1/convai/knowledge-base/{jsonable_encoder(documentation_id)}/chunk/{jsonable_encoder(chunk_id)}", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - KnowledgeBaseDocumentChunkResponseModel, - construct_type( - type_=KnowledgeBaseDocumentChunkResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def get_settings( - self, *, request_options: typing.Optional[RequestOptions] = None - ) -> GetConvAiSettingsResponseModel: - """ - Retrieve Convai settings for the workspace - - Parameters - ---------- - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - GetConvAiSettingsResponseModel - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.conversational_ai.get_settings() - """ - _response = self._client_wrapper.httpx_client.request( - "v1/convai/settings", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - GetConvAiSettingsResponseModel, - construct_type( - type_=GetConvAiSettingsResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def update_settings( - self, - *, - conversation_initiation_client_data_webhook: typing.Optional[ConversationInitiationClientDataWebhook] = OMIT, - webhooks: typing.Optional[ConvAiWebhooks] = OMIT, - rag_retention_period_days: typing.Optional[int] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> GetConvAiSettingsResponseModel: - """ - Update Convai settings for the workspace - - Parameters - ---------- - conversation_initiation_client_data_webhook : typing.Optional[ConversationInitiationClientDataWebhook] - - webhooks : typing.Optional[ConvAiWebhooks] - - rag_retention_period_days : typing.Optional[int] - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - GetConvAiSettingsResponseModel - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.conversational_ai.update_settings() - """ - _response = self._client_wrapper.httpx_client.request( - "v1/convai/settings", - base_url=self._client_wrapper.get_environment().base, - method="PATCH", - json={ - "conversation_initiation_client_data_webhook": convert_and_respect_annotation_metadata( - object_=conversation_initiation_client_data_webhook, - annotation=ConversationInitiationClientDataWebhook, - direction="write", - ), - "webhooks": convert_and_respect_annotation_metadata( - object_=webhooks, annotation=ConvAiWebhooks, direction="write" - ), - "rag_retention_period_days": rag_retention_period_days, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - GetConvAiSettingsResponseModel, - construct_type( - type_=GetConvAiSettingsResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def get_dashboard_settings( - self, *, request_options: typing.Optional[RequestOptions] = None - ) -> GetConvAiDashboardSettingsResponseModel: - """ - Retrieve Convai dashboard settings for the workspace - - Parameters - ---------- - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - GetConvAiDashboardSettingsResponseModel - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.conversational_ai.get_dashboard_settings() - """ - _response = self._client_wrapper.httpx_client.request( - "v1/convai/settings/dashboard", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - GetConvAiDashboardSettingsResponseModel, - construct_type( - type_=GetConvAiDashboardSettingsResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def update_dashboard_settings( - self, - *, - charts: typing.Optional[typing.Sequence[PatchConvAiDashboardSettingsRequestChartsItem]] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> GetConvAiDashboardSettingsResponseModel: - """ - Update Convai dashboard settings for the workspace - - Parameters - ---------- - charts : typing.Optional[typing.Sequence[PatchConvAiDashboardSettingsRequestChartsItem]] - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - GetConvAiDashboardSettingsResponseModel - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.conversational_ai.update_dashboard_settings() - """ - _response = self._client_wrapper.httpx_client.request( - "v1/convai/settings/dashboard", - base_url=self._client_wrapper.get_environment().base, - method="PATCH", - json={ - "charts": convert_and_respect_annotation_metadata( - object_=charts, - annotation=typing.Sequence[PatchConvAiDashboardSettingsRequestChartsItem], - direction="write", - ), - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - GetConvAiDashboardSettingsResponseModel, - construct_type( - type_=GetConvAiDashboardSettingsResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def get_secrets( - self, *, request_options: typing.Optional[RequestOptions] = None - ) -> GetWorkspaceSecretsResponseModel: - """ - Get all workspace secrets for the user - - Parameters - ---------- - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - GetWorkspaceSecretsResponseModel - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.conversational_ai.get_secrets() - """ - _response = self._client_wrapper.httpx_client.request( - "v1/convai/secrets", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - GetWorkspaceSecretsResponseModel, - construct_type( - type_=GetWorkspaceSecretsResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def create_secret( - self, - *, - name: str, - value: str, - request_options: typing.Optional[RequestOptions] = None, - ) -> PostWorkspaceSecretResponseModel: - """ - Create a new secret for the workspace - - Parameters - ---------- - name : str - - value : str - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - PostWorkspaceSecretResponseModel - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.conversational_ai.create_secret( - name="name", - value="value", - ) - """ - _response = self._client_wrapper.httpx_client.request( - "v1/convai/secrets", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "name": name, - "value": value, - "type": "new", - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - PostWorkspaceSecretResponseModel, - construct_type( - type_=PostWorkspaceSecretResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def delete_secret(self, secret_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None: - """ - Delete a workspace secret if it's not in use - - Parameters - ---------- - secret_id : str - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - None - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.conversational_ai.delete_secret( - secret_id="secret_id", - ) - """ - _response = self._client_wrapper.httpx_client.request( - f"v1/convai/secrets/{jsonable_encoder(secret_id)}", - base_url=self._client_wrapper.get_environment().base, - method="DELETE", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def get_batch_call( - self, batch_id: str, *, request_options: typing.Optional[RequestOptions] = None - ) -> BatchCallDetailedResponse: - """ - Get detailed information about a batch call including all recipients. - - Parameters - ---------- - batch_id : str - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - BatchCallDetailedResponse - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.conversational_ai.get_batch_call( - batch_id="batch_id", - ) - """ - _response = self._client_wrapper.httpx_client.request( - f"v1/convai/batch-calling/{jsonable_encoder(batch_id)}", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - BatchCallDetailedResponse, - construct_type( - type_=BatchCallDetailedResponse, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - -class AsyncConversationalAiClient: - def __init__(self, *, client_wrapper: AsyncClientWrapper): - self._client_wrapper = client_wrapper - self.agents = AsyncAgentsClient(client_wrapper=self._client_wrapper) - self.sip_trunk = AsyncSipTrunkClient(client_wrapper=self._client_wrapper) - self.knowledge_base = AsyncKnowledgeBaseClient(client_wrapper=self._client_wrapper) - - async def get_signed_url( - self, *, agent_id: str, request_options: typing.Optional[RequestOptions] = None - ) -> ConversationSignedUrlResponseModel: - """ - Get a signed url to start a conversation with an agent with an agent that requires authorization - - Parameters - ---------- - agent_id : str - The id of the agent you're taking the action on. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - ConversationSignedUrlResponseModel - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.conversational_ai.get_signed_url( - agent_id="21m00Tcm4TlvDq8ikWAM", - ) - - - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - "v1/convai/conversation/get-signed-url", - base_url=self._client_wrapper.get_environment().base, - method="GET", - params={ - "agent_id": agent_id, - }, - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ConversationSignedUrlResponseModel, - construct_type( - type_=ConversationSignedUrlResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def twilio_outbound_call( - self, - *, - agent_id: str, - agent_phone_number_id: str, - to_number: str, - conversation_initiation_client_data: typing.Optional[ConversationInitiationClientDataRequestInput] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> TwilioOutboundCallResponse: - """ - Handle an outbound call via Twilio - - Parameters - ---------- - agent_id : str - - agent_phone_number_id : str - - to_number : str - - conversation_initiation_client_data : typing.Optional[ConversationInitiationClientDataRequestInput] - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - TwilioOutboundCallResponse - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.conversational_ai.twilio_outbound_call( - agent_id="agent_id", - agent_phone_number_id="agent_phone_number_id", - to_number="to_number", - ) - - - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - "v1/convai/twilio/outbound-call", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "agent_id": agent_id, - "agent_phone_number_id": agent_phone_number_id, - "to_number": to_number, - "conversation_initiation_client_data": convert_and_respect_annotation_metadata( - object_=conversation_initiation_client_data, - annotation=ConversationInitiationClientDataRequestInput, - direction="write", - ), - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - TwilioOutboundCallResponse, - construct_type( - type_=TwilioOutboundCallResponse, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def create_agent( - self, - *, - conversation_config: ConversationalConfig, - platform_settings: typing.Optional[AgentPlatformSettingsRequestModel] = OMIT, - name: typing.Optional[str] = OMIT, - tags: typing.Optional[typing.Sequence[str]] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> CreateAgentResponseModel: - """ - Create an agent from a config object - - Parameters - ---------- - conversation_config : ConversationalConfig - Conversation configuration for an agent - - platform_settings : typing.Optional[AgentPlatformSettingsRequestModel] - Platform settings for the agent are all settings that aren't related to the conversation orchestration and content. - - name : typing.Optional[str] - A name to make the agent easier to find - - tags : typing.Optional[typing.Sequence[str]] - Tags to help classify and filter the agent - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - CreateAgentResponseModel - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs, ConversationalConfig - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.conversational_ai.create_agent( - conversation_config=ConversationalConfig(), - ) - - - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - "v1/convai/agents/create", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "conversation_config": convert_and_respect_annotation_metadata( - object_=conversation_config, - annotation=ConversationalConfig, - direction="write", - ), - "platform_settings": convert_and_respect_annotation_metadata( - object_=platform_settings, - annotation=AgentPlatformSettingsRequestModel, - direction="write", - ), - "name": name, - "tags": tags, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - CreateAgentResponseModel, - construct_type( - type_=CreateAgentResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def get_agent( - self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None - ) -> GetAgentResponseModel: - """ - Retrieve config for an agent - - Parameters - ---------- - agent_id : str - The id of an agent. This is returned on agent creation. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - GetAgentResponseModel - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.conversational_ai.get_agent( - agent_id="21m00Tcm4TlvDq8ikWAM", - ) - - - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/convai/agents/{jsonable_encoder(agent_id)}", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - GetAgentResponseModel, - construct_type( - type_=GetAgentResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def delete_agent(self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None: - """ - Delete an agent - - Parameters - ---------- - agent_id : str - The id of an agent. This is returned on agent creation. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - None - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.conversational_ai.delete_agent( - agent_id="21m00Tcm4TlvDq8ikWAM", - ) - - - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/convai/agents/{jsonable_encoder(agent_id)}", - base_url=self._client_wrapper.get_environment().base, - method="DELETE", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def update_agent( - self, - agent_id: str, - *, - conversation_config: typing.Optional[typing.Optional[typing.Any]] = OMIT, - platform_settings: typing.Optional[typing.Optional[typing.Any]] = OMIT, - name: typing.Optional[str] = OMIT, - tags: typing.Optional[typing.Sequence[str]] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> GetAgentResponseModel: - """ - Patches an Agent settings - - Parameters - ---------- - agent_id : str - The id of an agent. This is returned on agent creation. - - conversation_config : typing.Optional[typing.Optional[typing.Any]] - - platform_settings : typing.Optional[typing.Optional[typing.Any]] - - name : typing.Optional[str] - A name to make the agent easier to find - - tags : typing.Optional[typing.Sequence[str]] - Tags to help classify and filter the agent - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - GetAgentResponseModel - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.conversational_ai.update_agent( - agent_id="21m00Tcm4TlvDq8ikWAM", - ) - - - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/convai/agents/{jsonable_encoder(agent_id)}", - base_url=self._client_wrapper.get_environment().base, - method="PATCH", - json={ - "conversation_config": conversation_config, - "platform_settings": platform_settings, - "name": name, - "tags": tags, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - GetAgentResponseModel, - construct_type( - type_=GetAgentResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def get_agent_widget( - self, - agent_id: str, - *, - conversation_signature: typing.Optional[str] = None, - request_options: typing.Optional[RequestOptions] = None, - ) -> GetAgentEmbedResponseModel: - """ - Retrieve the widget configuration for an agent - - Parameters - ---------- - agent_id : str - The id of an agent. This is returned on agent creation. - - conversation_signature : typing.Optional[str] - An expiring token that enables a websocket conversation to start. These can be generated for an agent using the /v1/convai/conversation/get-signed-url endpoint - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - GetAgentEmbedResponseModel - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.conversational_ai.get_agent_widget( - agent_id="21m00Tcm4TlvDq8ikWAM", - ) - - - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/convai/agents/{jsonable_encoder(agent_id)}/widget", - base_url=self._client_wrapper.get_environment().base, - method="GET", - params={ - "conversation_signature": conversation_signature, - }, - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - GetAgentEmbedResponseModel, - construct_type( - type_=GetAgentEmbedResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def get_agent_link( - self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None - ) -> GetAgentLinkResponseModel: - """ - Get the current link used to share the agent with others - - Parameters - ---------- - agent_id : str - The id of an agent. This is returned on agent creation. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - GetAgentLinkResponseModel - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.conversational_ai.get_agent_link( - agent_id="21m00Tcm4TlvDq8ikWAM", - ) - - - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/convai/agents/{jsonable_encoder(agent_id)}/link", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - GetAgentLinkResponseModel, - construct_type( - type_=GetAgentLinkResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def post_agent_avatar( - self, - agent_id: str, - *, - avatar_file: core.File, - request_options: typing.Optional[RequestOptions] = None, - ) -> PostAgentAvatarResponseModel: - """ - Sets the avatar for an agent displayed in the widget - - Parameters - ---------- - agent_id : str - The id of an agent. This is returned on agent creation. - - avatar_file : core.File - See core.File for more documentation - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - PostAgentAvatarResponseModel - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.conversational_ai.post_agent_avatar( - agent_id="21m00Tcm4TlvDq8ikWAM", - ) - - - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/convai/agents/{jsonable_encoder(agent_id)}/avatar", - base_url=self._client_wrapper.get_environment().base, - method="POST", - data={}, - files={ - "avatar_file": avatar_file, - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - PostAgentAvatarResponseModel, - construct_type( - type_=PostAgentAvatarResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def get_agents( - self, - *, - cursor: typing.Optional[str] = None, - page_size: typing.Optional[int] = None, - search: typing.Optional[str] = None, - request_options: typing.Optional[RequestOptions] = None, - ) -> GetAgentsPageResponseModel: - """ - Returns a list of your agents and their metadata. - - Parameters - ---------- - cursor : typing.Optional[str] - Used for fetching next page. Cursor is returned in the response. - - page_size : typing.Optional[int] - How many Agents to return at maximum. Can not exceed 100, defaults to 30. - - search : typing.Optional[str] - Search by agents name. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - GetAgentsPageResponseModel - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.conversational_ai.get_agents() - - - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - "v1/convai/agents", - base_url=self._client_wrapper.get_environment().base, - method="GET", - params={ - "cursor": cursor, - "page_size": page_size, - "search": search, - }, - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - GetAgentsPageResponseModel, - construct_type( - type_=GetAgentsPageResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def get_conversations( - self, - *, - cursor: typing.Optional[str] = None, - agent_id: typing.Optional[str] = None, - call_successful: typing.Optional[EvaluationSuccessResult] = None, - call_start_before_unix: typing.Optional[int] = None, - call_start_after_unix: typing.Optional[int] = None, - page_size: typing.Optional[int] = None, - request_options: typing.Optional[RequestOptions] = None, - ) -> GetConversationsPageResponseModel: - """ - Get all conversations of agents that user owns. With option to restrict to a specific agent. - - Parameters - ---------- - cursor : typing.Optional[str] - Used for fetching next page. Cursor is returned in the response. - - agent_id : typing.Optional[str] - The id of the agent you're taking the action on. - - call_successful : typing.Optional[EvaluationSuccessResult] - The result of the success evaluation - - call_start_before_unix : typing.Optional[int] - Unix timestamp (in seconds) to filter conversations up to this start date. - - call_start_after_unix : typing.Optional[int] - Unix timestamp (in seconds) to filter conversations after to this start date. - - page_size : typing.Optional[int] - How many conversations to return at maximum. Can not exceed 100, defaults to 30. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - GetConversationsPageResponseModel - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.conversational_ai.get_conversations() - - - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - "v1/convai/conversations", - base_url=self._client_wrapper.get_environment().base, - method="GET", - params={ - "cursor": cursor, - "agent_id": agent_id, - "call_successful": call_successful, - "call_start_before_unix": call_start_before_unix, - "call_start_after_unix": call_start_after_unix, - "page_size": page_size, - }, - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - GetConversationsPageResponseModel, - construct_type( - type_=GetConversationsPageResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def get_conversation( - self, - conversation_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, - ) -> GetConversationResponseModel: - """ - Get the details of a particular conversation - - Parameters - ---------- - conversation_id : str - The id of the conversation you're taking the action on. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - GetConversationResponseModel - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.conversational_ai.get_conversation( - conversation_id="123", - ) - - - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/convai/conversations/{jsonable_encoder(conversation_id)}", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - GetConversationResponseModel, - construct_type( - type_=GetConversationResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def delete_conversation( - self, - conversation_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, - ) -> typing.Optional[typing.Any]: - """ - Delete a particular conversation - - Parameters - ---------- - conversation_id : str - The id of the conversation you're taking the action on. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - typing.Optional[typing.Any] - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.conversational_ai.delete_conversation( - conversation_id="21m00Tcm4TlvDq8ikWAM", - ) - - - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/convai/conversations/{jsonable_encoder(conversation_id)}", - base_url=self._client_wrapper.get_environment().base, - method="DELETE", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def get_conversation_audio( - self, - conversation_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, - ) -> typing.AsyncIterator[bytes]: - """ - Get the audio recording of a particular conversation - - Parameters - ---------- - conversation_id : str - The id of the conversation you're taking the action on. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. - - Yields - ------ - typing.AsyncIterator[bytes] - Successful Response - """ - async with self._client_wrapper.httpx_client.stream( - f"v1/convai/conversations/{jsonable_encoder(conversation_id)}/audio", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) as _response: - try: - if 200 <= _response.status_code < 300: - _chunk_size = request_options.get("chunk_size", 1024) if request_options is not None else 1024 - async for _chunk in _response.aiter_bytes(chunk_size=_chunk_size): - yield _chunk - return - await _response.aread() - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def post_conversation_feedback( - self, - conversation_id: str, - *, - feedback: UserFeedbackScore, - request_options: typing.Optional[RequestOptions] = None, - ) -> typing.Optional[typing.Any]: - """ - Send the feedback for the given conversation - - Parameters - ---------- - conversation_id : str - The id of the conversation you're taking the action on. - - feedback : UserFeedbackScore - Either 'like' or 'dislike' to indicate the feedback for the conversation. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - typing.Optional[typing.Any] - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.conversational_ai.post_conversation_feedback( - conversation_id="21m00Tcm4TlvDq8ikWAM", - feedback="like", - ) - - - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/convai/conversations/{jsonable_encoder(conversation_id)}/feedback", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "feedback": feedback, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def create_phone_number( - self, - *, - request: ConversationalAiCreatePhoneNumberRequestBody, - request_options: typing.Optional[RequestOptions] = None, - ) -> CreatePhoneNumberResponseModel: - """ - Import Phone Number from provider configuration (Twilio or SIP trunk) - - Parameters - ---------- - request : ConversationalAiCreatePhoneNumberRequestBody - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - CreatePhoneNumberResponseModel - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - from elevenlabs.conversational_ai import ( - ConversationalAiCreatePhoneNumberRequestBody_Twilio, - ) - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.conversational_ai.create_phone_number( - request=ConversationalAiCreatePhoneNumberRequestBody_Twilio( - phone_number="phone_number", - label="label", - sid="sid", - token="token", - ), - ) - - - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - "v1/convai/phone-numbers/create", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json=convert_and_respect_annotation_metadata( - object_=request, - annotation=ConversationalAiCreatePhoneNumberRequestBody, - direction="write", - ), - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - CreatePhoneNumberResponseModel, - construct_type( - type_=CreatePhoneNumberResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def get_phone_number( - self, - phone_number_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, - ) -> ConversationalAiGetPhoneNumberResponse: - """ - Retrieve Phone Number details by ID - - Parameters - ---------- - phone_number_id : str - The id of an agent. This is returned on agent creation. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - ConversationalAiGetPhoneNumberResponse - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.conversational_ai.get_phone_number( - phone_number_id="TeaqRRdTcIfIu2i7BYfT", - ) - - - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/convai/phone-numbers/{jsonable_encoder(phone_number_id)}", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ConversationalAiGetPhoneNumberResponse, - construct_type( - type_=ConversationalAiGetPhoneNumberResponse, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def delete_phone_number( - self, - phone_number_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, - ) -> typing.Optional[typing.Any]: - """ - Delete Phone Number by ID - - Parameters - ---------- - phone_number_id : str - The id of an agent. This is returned on agent creation. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - typing.Optional[typing.Any] - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.conversational_ai.delete_phone_number( - phone_number_id="TeaqRRdTcIfIu2i7BYfT", - ) - - - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/convai/phone-numbers/{jsonable_encoder(phone_number_id)}", - base_url=self._client_wrapper.get_environment().base, - method="DELETE", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def update_phone_number( - self, - phone_number_id: str, - *, - agent_id: typing.Optional[str] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> ConversationalAiUpdatePhoneNumberResponse: - """ - Update Phone Number details by ID - - Parameters - ---------- - phone_number_id : str - The id of an agent. This is returned on agent creation. - - agent_id : typing.Optional[str] - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - ConversationalAiUpdatePhoneNumberResponse - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.conversational_ai.update_phone_number( - phone_number_id="TeaqRRdTcIfIu2i7BYfT", - ) - - - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/convai/phone-numbers/{jsonable_encoder(phone_number_id)}", - base_url=self._client_wrapper.get_environment().base, - method="PATCH", - json={ - "agent_id": agent_id, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ConversationalAiUpdatePhoneNumberResponse, - construct_type( - type_=ConversationalAiUpdatePhoneNumberResponse, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def get_phone_numbers( - self, *, request_options: typing.Optional[RequestOptions] = None - ) -> typing.List[ConversationalAiGetPhoneNumbersResponseItem]: - """ - Retrieve all Phone Numbers - - Parameters - ---------- - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - typing.List[ConversationalAiGetPhoneNumbersResponseItem] - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.conversational_ai.get_phone_numbers() - - - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - "v1/convai/phone-numbers/", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - typing.List[ConversationalAiGetPhoneNumbersResponseItem], - construct_type( - type_=typing.List[ConversationalAiGetPhoneNumbersResponseItem], # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def get_knowledge_base_list( - self, - *, - cursor: typing.Optional[str] = None, - page_size: typing.Optional[int] = None, - search: typing.Optional[str] = None, - show_only_owned_documents: typing.Optional[bool] = None, - types: typing.Optional[ - typing.Union[KnowledgeBaseDocumentType, typing.Sequence[KnowledgeBaseDocumentType]] - ] = None, - use_typesense: typing.Optional[bool] = None, - request_options: typing.Optional[RequestOptions] = None, - ) -> GetKnowledgeBaseListResponseModel: - """ - Get a list of available knowledge base documents - - Parameters - ---------- - cursor : typing.Optional[str] - Used for fetching next page. Cursor is returned in the response. - - page_size : typing.Optional[int] - How many documents to return at maximum. Can not exceed 100, defaults to 30. - - search : typing.Optional[str] - If specified, the endpoint returns only such knowledge base documents whose names start with this string. - - show_only_owned_documents : typing.Optional[bool] - If set to true, the endpoint will return only documents owned by you (and not shared from somebody else). - - types : typing.Optional[typing.Union[KnowledgeBaseDocumentType, typing.Sequence[KnowledgeBaseDocumentType]]] - If present, the endpoint will return only documents of the given types. - - use_typesense : typing.Optional[bool] - If set to true, the endpoint will use typesense DB to search for the documents). - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - GetKnowledgeBaseListResponseModel - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.conversational_ai.get_knowledge_base_list() - - - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - "v1/convai/knowledge-base", - base_url=self._client_wrapper.get_environment().base, - method="GET", - params={ - "cursor": cursor, - "page_size": page_size, - "search": search, - "show_only_owned_documents": show_only_owned_documents, - "types": types, - "use_typesense": use_typesense, - }, - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - GetKnowledgeBaseListResponseModel, - construct_type( - type_=GetKnowledgeBaseListResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def add_to_knowledge_base( - self, - *, - name: typing.Optional[str] = OMIT, - url: typing.Optional[str] = OMIT, - file: typing.Optional[core.File] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> AddKnowledgeBaseResponseModel: - """ - Upload a file or webpage URL to create a knowledge base document.
After creating the document, update the agent's knowledge base by calling [Update agent](/docs/conversational-ai/api-reference/agents/update-agent). - - Parameters - ---------- - name : typing.Optional[str] - A custom, human-readable name for the document. - - url : typing.Optional[str] - URL to a page of documentation that the agent will have access to in order to interact with users. - - file : typing.Optional[core.File] - See core.File for more documentation - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - AddKnowledgeBaseResponseModel - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.conversational_ai.add_to_knowledge_base() - - - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - "v1/convai/knowledge-base", - base_url=self._client_wrapper.get_environment().base, - method="POST", - data={ - "name": name, - "url": url, - }, - files={ - "file": file, - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - AddKnowledgeBaseResponseModel, - construct_type( - type_=AddKnowledgeBaseResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def create_knowledge_base_url_document( - self, - *, - url: str, - name: typing.Optional[str] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> AddKnowledgeBaseResponseModel: - """ - Create a knowledge base document generated by scraping the given webpage. - - Parameters - ---------- - url : str - URL to a page of documentation that the agent will have access to in order to interact with users. - - name : typing.Optional[str] - A custom, human-readable name for the document. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - AddKnowledgeBaseResponseModel - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.conversational_ai.create_knowledge_base_url_document( - url="url", - ) - - - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - "v1/convai/knowledge-base/url", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "url": url, - "name": name, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - AddKnowledgeBaseResponseModel, - construct_type( - type_=AddKnowledgeBaseResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def create_knowledge_base_file_document( - self, - *, - file: core.File, - name: typing.Optional[str] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> AddKnowledgeBaseResponseModel: - """ - Create a knowledge base document generated form the uploaded file. - - Parameters - ---------- - file : core.File - See core.File for more documentation - - name : typing.Optional[str] - A custom, human-readable name for the document. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - AddKnowledgeBaseResponseModel - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.conversational_ai.create_knowledge_base_file_document() - - - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - "v1/convai/knowledge-base/file", - base_url=self._client_wrapper.get_environment().base, - method="POST", - data={ - "name": name, - }, - files={ - "file": file, - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - AddKnowledgeBaseResponseModel, - construct_type( - type_=AddKnowledgeBaseResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def create_knowledge_base_text_document( - self, - *, - text: str, - name: typing.Optional[str] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> AddKnowledgeBaseResponseModel: - """ - Create a knowledge base document containing the provided text. - - Parameters - ---------- - text : str - Text content to be added to the knowledge base. - - name : typing.Optional[str] - A custom, human-readable name for the document. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - AddKnowledgeBaseResponseModel - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.conversational_ai.create_knowledge_base_text_document( - text="text", - ) - - - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - "v1/convai/knowledge-base/text", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "text": text, - "name": name, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - AddKnowledgeBaseResponseModel, - construct_type( - type_=AddKnowledgeBaseResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def get_knowledge_base_document_by_id( - self, - documentation_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, - ) -> ConversationalAiGetKnowledgeBaseDocumentByIdResponse: - """ - Get details about a specific documentation making up the agent's knowledge base - - Parameters - ---------- - documentation_id : str - The id of a document from the knowledge base. This is returned on document addition. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - ConversationalAiGetKnowledgeBaseDocumentByIdResponse - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.conversational_ai.get_knowledge_base_document_by_id( - documentation_id="21m00Tcm4TlvDq8ikWAM", - ) - - - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/convai/knowledge-base/{jsonable_encoder(documentation_id)}", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ConversationalAiGetKnowledgeBaseDocumentByIdResponse, - construct_type( - type_=ConversationalAiGetKnowledgeBaseDocumentByIdResponse, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def delete_knowledge_base_document( - self, - documentation_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, - ) -> typing.Optional[typing.Any]: - """ - Delete a document from the knowledge base - - Parameters - ---------- - documentation_id : str - The id of a document from the knowledge base. This is returned on document addition. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - typing.Optional[typing.Any] - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.conversational_ai.delete_knowledge_base_document( - documentation_id="21m00Tcm4TlvDq8ikWAM", - ) - - - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/convai/knowledge-base/{jsonable_encoder(documentation_id)}", - base_url=self._client_wrapper.get_environment().base, - method="DELETE", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def update_knowledge_base_document( - self, - documentation_id: str, - *, - name: str, - request_options: typing.Optional[RequestOptions] = None, - ) -> ConversationalAiUpdateKnowledgeBaseDocumentResponse: - """ - Update the name of a document - - Parameters - ---------- - documentation_id : str - The id of a document from the knowledge base. This is returned on document addition. - - name : str - A custom, human-readable name for the document. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - ConversationalAiUpdateKnowledgeBaseDocumentResponse - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.conversational_ai.update_knowledge_base_document( - documentation_id="21m00Tcm4TlvDq8ikWAM", - name="name", - ) - - - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/convai/knowledge-base/{jsonable_encoder(documentation_id)}", - base_url=self._client_wrapper.get_environment().base, - method="PATCH", - json={ - "name": name, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ConversationalAiUpdateKnowledgeBaseDocumentResponse, - construct_type( - type_=ConversationalAiUpdateKnowledgeBaseDocumentResponse, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def get_dependent_agents( - self, - documentation_id: str, - *, - cursor: typing.Optional[str] = None, - page_size: typing.Optional[int] = None, - request_options: typing.Optional[RequestOptions] = None, - ) -> GetKnowledgeBaseDependentAgentsResponseModel: - """ - Get a list of agents depending on this knowledge base document - - Parameters - ---------- - documentation_id : str - The id of a document from the knowledge base. This is returned on document addition. - - cursor : typing.Optional[str] - Used for fetching next page. Cursor is returned in the response. - - page_size : typing.Optional[int] - How many documents to return at maximum. Can not exceed 100, defaults to 30. +class ConversationalAiClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._raw_client = RawConversationalAiClient(client_wrapper=client_wrapper) + self.conversations = ConversationsClient(client_wrapper=client_wrapper) - request_options : typing.Optional[RequestOptions] - Request-specific configuration. + self.twilio = TwilioClient(client_wrapper=client_wrapper) - Returns - ------- - GetKnowledgeBaseDependentAgentsResponseModel - Successful Response + self.agents = AgentsClient(client_wrapper=client_wrapper) - Examples - -------- - import asyncio + self.phone_numbers = PhoneNumbersClient(client_wrapper=client_wrapper) - from elevenlabs import AsyncElevenLabs + self.knowledge_base = KnowledgeBaseClient(client_wrapper=client_wrapper) - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) + self.settings = SettingsClient(client_wrapper=client_wrapper) + self.secrets = SecretsClient(client_wrapper=client_wrapper) - async def main() -> None: - await client.conversational_ai.get_dependent_agents( - documentation_id="21m00Tcm4TlvDq8ikWAM", - ) + self.batch_calls = BatchCallsClient(client_wrapper=client_wrapper) + self.sip_trunk = SipTrunkClient(client_wrapper=client_wrapper) - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/convai/knowledge-base/{jsonable_encoder(documentation_id)}/dependent-agents", - base_url=self._client_wrapper.get_environment().base, - method="GET", - params={ - "cursor": cursor, - "page_size": page_size, - }, - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - GetKnowledgeBaseDependentAgentsResponseModel, - construct_type( - type_=GetKnowledgeBaseDependentAgentsResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + self.dashboard = DashboardClient(client_wrapper=client_wrapper) - async def get_knowledge_base_document_content( - self, - documentation_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, - ) -> None: + @property + def with_raw_response(self) -> RawConversationalAiClient: """ - Get the entire content of a document from the knowledge base - - Parameters - ---------- - documentation_id : str - The id of a document from the knowledge base. This is returned on document addition. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. + Retrieves a raw implementation of this client that returns raw responses. Returns ------- - None - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.conversational_ai.get_knowledge_base_document_content( - documentation_id="21m00Tcm4TlvDq8ikWAM", - ) - - - asyncio.run(main()) + RawConversationalAiClient """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/convai/knowledge-base/{jsonable_encoder(documentation_id)}/content", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + return self._raw_client - async def get_knowledge_base_document_part_by_id( + def add_to_knowledge_base( self, - documentation_id: str, - chunk_id: str, *, + name: typing.Optional[str] = OMIT, + url: typing.Optional[str] = OMIT, + file: typing.Optional[core.File] = OMIT, request_options: typing.Optional[RequestOptions] = None, - ) -> KnowledgeBaseDocumentChunkResponseModel: + ) -> AddKnowledgeBaseResponseModel: """ - Get details about a specific documentation part used by RAG. + Upload a file or webpage URL to create a knowledge base document.
After creating the document, update the agent's knowledge base by calling [Update agent](/docs/conversational-ai/api-reference/agents/update-agent). Parameters ---------- - documentation_id : str - The id of a document from the knowledge base. This is returned on document addition. + name : typing.Optional[str] + A custom, human-readable name for the document. + + url : typing.Optional[str] + URL to a page of documentation that the agent will have access to in order to interact with users. - chunk_id : str - The id of a document RAG chunk from the knowledge base. + file : typing.Optional[core.File] + See core.File for more documentation request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- - KnowledgeBaseDocumentChunkResponseModel + AddKnowledgeBaseResponseModel Successful Response Examples -------- - import asyncio - - from elevenlabs import AsyncElevenLabs + from elevenlabs import ElevenLabs - client = AsyncElevenLabs( + client = ElevenLabs( api_key="YOUR_API_KEY", ) - - - async def main() -> None: - await client.conversational_ai.get_knowledge_base_document_part_by_id( - documentation_id="21m00Tcm4TlvDq8ikWAM", - chunk_id="chunk_id", - ) - - - asyncio.run(main()) + client.conversational_ai.add_to_knowledge_base() """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/convai/knowledge-base/{jsonable_encoder(documentation_id)}/chunk/{jsonable_encoder(chunk_id)}", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, + _response = self._raw_client.add_to_knowledge_base( + name=name, url=url, file=file, request_options=request_options ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - KnowledgeBaseDocumentChunkResponseModel, - construct_type( - type_=KnowledgeBaseDocumentChunkResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + return _response.data - async def get_settings( - self, *, request_options: typing.Optional[RequestOptions] = None - ) -> GetConvAiSettingsResponseModel: + def update_secret( + self, secret_id: str, *, name: str, value: str, request_options: typing.Optional[RequestOptions] = None + ) -> PostWorkspaceSecretResponseModel: """ - Retrieve Convai settings for the workspace + Update an existing secret for the workspace Parameters ---------- + secret_id : str + + name : str + + value : str + request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- - GetConvAiSettingsResponseModel + PostWorkspaceSecretResponseModel Successful Response Examples -------- - import asyncio - - from elevenlabs import AsyncElevenLabs + from elevenlabs import ElevenLabs - client = AsyncElevenLabs( + client = ElevenLabs( api_key="YOUR_API_KEY", ) - - - async def main() -> None: - await client.conversational_ai.get_settings() - - - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - "v1/convai/settings", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, + client.conversational_ai.update_secret( + secret_id="secret_id", + name="name", + value="value", ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - GetConvAiSettingsResponseModel, - construct_type( - type_=GetConvAiSettingsResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def update_settings( - self, - *, - conversation_initiation_client_data_webhook: typing.Optional[ConversationInitiationClientDataWebhook] = OMIT, - webhooks: typing.Optional[ConvAiWebhooks] = OMIT, - rag_retention_period_days: typing.Optional[int] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> GetConvAiSettingsResponseModel: """ - Update Convai settings for the workspace - - Parameters - ---------- - conversation_initiation_client_data_webhook : typing.Optional[ConversationInitiationClientDataWebhook] + _response = self._raw_client.update_secret(secret_id, name=name, value=value, request_options=request_options) + return _response.data - webhooks : typing.Optional[ConvAiWebhooks] - rag_retention_period_days : typing.Optional[int] +class AsyncConversationalAiClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawConversationalAiClient(client_wrapper=client_wrapper) + self.conversations = AsyncConversationsClient(client_wrapper=client_wrapper) - request_options : typing.Optional[RequestOptions] - Request-specific configuration. + self.twilio = AsyncTwilioClient(client_wrapper=client_wrapper) - Returns - ------- - GetConvAiSettingsResponseModel - Successful Response + self.agents = AsyncAgentsClient(client_wrapper=client_wrapper) - Examples - -------- - import asyncio + self.phone_numbers = AsyncPhoneNumbersClient(client_wrapper=client_wrapper) - from elevenlabs import AsyncElevenLabs + self.knowledge_base = AsyncKnowledgeBaseClient(client_wrapper=client_wrapper) - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) + self.settings = AsyncSettingsClient(client_wrapper=client_wrapper) + self.secrets = AsyncSecretsClient(client_wrapper=client_wrapper) - async def main() -> None: - await client.conversational_ai.update_settings() + self.batch_calls = AsyncBatchCallsClient(client_wrapper=client_wrapper) + self.sip_trunk = AsyncSipTrunkClient(client_wrapper=client_wrapper) - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - "v1/convai/settings", - base_url=self._client_wrapper.get_environment().base, - method="PATCH", - json={ - "conversation_initiation_client_data_webhook": convert_and_respect_annotation_metadata( - object_=conversation_initiation_client_data_webhook, - annotation=ConversationInitiationClientDataWebhook, - direction="write", - ), - "webhooks": convert_and_respect_annotation_metadata( - object_=webhooks, annotation=ConvAiWebhooks, direction="write" - ), - "rag_retention_period_days": rag_retention_period_days, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - GetConvAiSettingsResponseModel, - construct_type( - type_=GetConvAiSettingsResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + self.dashboard = AsyncDashboardClient(client_wrapper=client_wrapper) - async def get_dashboard_settings( - self, *, request_options: typing.Optional[RequestOptions] = None - ) -> GetConvAiDashboardSettingsResponseModel: + @property + def with_raw_response(self) -> AsyncRawConversationalAiClient: """ - Retrieve Convai dashboard settings for the workspace - - Parameters - ---------- - request_options : typing.Optional[RequestOptions] - Request-specific configuration. + Retrieves a raw implementation of this client that returns raw responses. Returns ------- - GetConvAiDashboardSettingsResponseModel - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.conversational_ai.get_dashboard_settings() - - - asyncio.run(main()) + AsyncRawConversationalAiClient """ - _response = await self._client_wrapper.httpx_client.request( - "v1/convai/settings/dashboard", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - GetConvAiDashboardSettingsResponseModel, - construct_type( - type_=GetConvAiDashboardSettingsResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + return self._raw_client - async def update_dashboard_settings( + async def add_to_knowledge_base( self, *, - charts: typing.Optional[typing.Sequence[PatchConvAiDashboardSettingsRequestChartsItem]] = OMIT, + name: typing.Optional[str] = OMIT, + url: typing.Optional[str] = OMIT, + file: typing.Optional[core.File] = OMIT, request_options: typing.Optional[RequestOptions] = None, - ) -> GetConvAiDashboardSettingsResponseModel: + ) -> AddKnowledgeBaseResponseModel: """ - Update Convai dashboard settings for the workspace + Upload a file or webpage URL to create a knowledge base document.
After creating the document, update the agent's knowledge base by calling [Update agent](/docs/conversational-ai/api-reference/agents/update-agent). Parameters ---------- - charts : typing.Optional[typing.Sequence[PatchConvAiDashboardSettingsRequestChartsItem]] - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - GetConvAiDashboardSettingsResponseModel - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.conversational_ai.update_dashboard_settings() - + name : typing.Optional[str] + A custom, human-readable name for the document. - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - "v1/convai/settings/dashboard", - base_url=self._client_wrapper.get_environment().base, - method="PATCH", - json={ - "charts": convert_and_respect_annotation_metadata( - object_=charts, - annotation=typing.Sequence[PatchConvAiDashboardSettingsRequestChartsItem], - direction="write", - ), - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - GetConvAiDashboardSettingsResponseModel, - construct_type( - type_=GetConvAiDashboardSettingsResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + url : typing.Optional[str] + URL to a page of documentation that the agent will have access to in order to interact with users. - async def get_secrets( - self, *, request_options: typing.Optional[RequestOptions] = None - ) -> GetWorkspaceSecretsResponseModel: - """ - Get all workspace secrets for the user + file : typing.Optional[core.File] + See core.File for more documentation - Parameters - ---------- request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- - GetWorkspaceSecretsResponseModel + AddKnowledgeBaseResponseModel Successful Response Examples @@ -5526,53 +216,26 @@ async def get_secrets( async def main() -> None: - await client.conversational_ai.get_secrets() + await client.conversational_ai.add_to_knowledge_base() asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - "v1/convai/secrets", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, + _response = await self._raw_client.add_to_knowledge_base( + name=name, url=url, file=file, request_options=request_options ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - GetWorkspaceSecretsResponseModel, - construct_type( - type_=GetWorkspaceSecretsResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + return _response.data - async def create_secret( - self, - *, - name: str, - value: str, - request_options: typing.Optional[RequestOptions] = None, + async def update_secret( + self, secret_id: str, *, name: str, value: str, request_options: typing.Optional[RequestOptions] = None ) -> PostWorkspaceSecretResponseModel: """ - Create a new secret for the workspace + Update an existing secret for the workspace Parameters ---------- + secret_id : str + name : str value : str @@ -5597,7 +260,8 @@ async def create_secret( async def main() -> None: - await client.conversational_ai.create_secret( + await client.conversational_ai.update_secret( + secret_id="secret_id", name="name", value="value", ) @@ -5605,166 +269,7 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - "v1/convai/secrets", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "name": name, - "value": value, - "type": "new", - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - PostWorkspaceSecretResponseModel, - construct_type( - type_=PostWorkspaceSecretResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def delete_secret(self, secret_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None: - """ - Delete a workspace secret if it's not in use - - Parameters - ---------- - secret_id : str - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - None - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.conversational_ai.delete_secret( - secret_id="secret_id", - ) - - - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/convai/secrets/{jsonable_encoder(secret_id)}", - base_url=self._client_wrapper.get_environment().base, - method="DELETE", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def get_batch_call( - self, batch_id: str, *, request_options: typing.Optional[RequestOptions] = None - ) -> BatchCallDetailedResponse: - """ - Get detailed information about a batch call including all recipients. - - Parameters - ---------- - batch_id : str - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - BatchCallDetailedResponse - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.conversational_ai.get_batch_call( - batch_id="batch_id", - ) - - - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/convai/batch-calling/{jsonable_encoder(batch_id)}", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, + _response = await self._raw_client.update_secret( + secret_id, name=name, value=value, request_options=request_options ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - BatchCallDetailedResponse, - construct_type( - type_=BatchCallDetailedResponse, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + return _response.data diff --git a/src/elevenlabs/conversational_ai/conversations/__init__.py b/src/elevenlabs/conversational_ai/conversations/__init__.py new file mode 100644 index 00000000..1e383816 --- /dev/null +++ b/src/elevenlabs/conversational_ai/conversations/__init__.py @@ -0,0 +1,7 @@ +# This file was auto-generated by Fern from our API Definition. + +# isort: skip_file + +from . import audio, feedback + +__all__ = ["audio", "feedback"] diff --git a/src/elevenlabs/conversational_ai/conversations/audio/__init__.py b/src/elevenlabs/conversational_ai/conversations/audio/__init__.py new file mode 100644 index 00000000..5cde0202 --- /dev/null +++ b/src/elevenlabs/conversational_ai/conversations/audio/__init__.py @@ -0,0 +1,4 @@ +# This file was auto-generated by Fern from our API Definition. + +# isort: skip_file + diff --git a/src/elevenlabs/conversational_ai/conversations/audio/client.py b/src/elevenlabs/conversational_ai/conversations/audio/client.py new file mode 100644 index 00000000..5a1ae56f --- /dev/null +++ b/src/elevenlabs/conversational_ai/conversations/audio/client.py @@ -0,0 +1,84 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +from ....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ....core.request_options import RequestOptions +from .raw_client import AsyncRawAudioClient, RawAudioClient + + +class AudioClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._raw_client = RawAudioClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawAudioClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawAudioClient + """ + return self._raw_client + + def get( + self, conversation_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> typing.Iterator[bytes]: + """ + Get the audio recording of a particular conversation + + Parameters + ---------- + conversation_id : str + The id of the conversation you're taking the action on. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. + + Returns + ------- + typing.Iterator[bytes] + Successful Response + """ + with self._raw_client.get(conversation_id, request_options=request_options) as r: + yield from r.data + + +class AsyncAudioClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawAudioClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawAudioClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawAudioClient + """ + return self._raw_client + + async def get( + self, conversation_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> typing.AsyncIterator[bytes]: + """ + Get the audio recording of a particular conversation + + Parameters + ---------- + conversation_id : str + The id of the conversation you're taking the action on. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. + + Returns + ------- + typing.AsyncIterator[bytes] + Successful Response + """ + async with self._raw_client.get(conversation_id, request_options=request_options) as r: + async for _chunk in r.data: + yield _chunk diff --git a/src/elevenlabs/conversational_ai/conversations/audio/raw_client.py b/src/elevenlabs/conversational_ai/conversations/audio/raw_client.py new file mode 100644 index 00000000..ebabd7b2 --- /dev/null +++ b/src/elevenlabs/conversational_ai/conversations/audio/raw_client.py @@ -0,0 +1,135 @@ +# This file was auto-generated by Fern from our API Definition. + +import contextlib +import typing +from json.decoder import JSONDecodeError + +from ....core.api_error import ApiError +from ....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ....core.http_response import AsyncHttpResponse, HttpResponse +from ....core.jsonable_encoder import jsonable_encoder +from ....core.request_options import RequestOptions +from ....core.unchecked_base_model import construct_type +from ....errors.unprocessable_entity_error import UnprocessableEntityError +from ....types.http_validation_error import HttpValidationError + + +class RawAudioClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + @contextlib.contextmanager + def get( + self, conversation_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> typing.Iterator[HttpResponse[typing.Iterator[bytes]]]: + """ + Get the audio recording of a particular conversation + + Parameters + ---------- + conversation_id : str + The id of the conversation you're taking the action on. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. + + Returns + ------- + typing.Iterator[HttpResponse[typing.Iterator[bytes]]] + Successful Response + """ + with self._client_wrapper.httpx_client.stream( + f"v1/convai/conversations/{jsonable_encoder(conversation_id)}/audio", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) as _response: + + def _stream() -> HttpResponse[typing.Iterator[bytes]]: + try: + if 200 <= _response.status_code < 300: + _chunk_size = request_options.get("chunk_size", 1024) if request_options is not None else 1024 + return HttpResponse( + response=_response, data=(_chunk for _chunk in _response.iter_bytes(chunk_size=_chunk_size)) + ) + _response.read() + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + yield _stream() + + +class AsyncRawAudioClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + @contextlib.asynccontextmanager + async def get( + self, conversation_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> typing.AsyncIterator[AsyncHttpResponse[typing.AsyncIterator[bytes]]]: + """ + Get the audio recording of a particular conversation + + Parameters + ---------- + conversation_id : str + The id of the conversation you're taking the action on. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. + + Returns + ------- + typing.AsyncIterator[AsyncHttpResponse[typing.AsyncIterator[bytes]]] + Successful Response + """ + async with self._client_wrapper.httpx_client.stream( + f"v1/convai/conversations/{jsonable_encoder(conversation_id)}/audio", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) as _response: + + async def _stream() -> AsyncHttpResponse[typing.AsyncIterator[bytes]]: + try: + if 200 <= _response.status_code < 300: + _chunk_size = request_options.get("chunk_size", 1024) if request_options is not None else 1024 + return AsyncHttpResponse( + response=_response, + data=(_chunk async for _chunk in _response.aiter_bytes(chunk_size=_chunk_size)), + ) + await _response.aread() + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + yield await _stream() diff --git a/src/elevenlabs/conversational_ai/conversations/client.py b/src/elevenlabs/conversational_ai/conversations/client.py new file mode 100644 index 00000000..a661fbd0 --- /dev/null +++ b/src/elevenlabs/conversational_ai/conversations/client.py @@ -0,0 +1,405 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ...core.request_options import RequestOptions +from ...types.conversation_signed_url_response_model import ConversationSignedUrlResponseModel +from ...types.evaluation_success_result import EvaluationSuccessResult +from ...types.get_conversation_response_model import GetConversationResponseModel +from ...types.get_conversations_page_response_model import GetConversationsPageResponseModel +from .audio.client import AsyncAudioClient, AudioClient +from .feedback.client import AsyncFeedbackClient, FeedbackClient +from .raw_client import AsyncRawConversationsClient, RawConversationsClient + + +class ConversationsClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._raw_client = RawConversationsClient(client_wrapper=client_wrapper) + self.audio = AudioClient(client_wrapper=client_wrapper) + + self.feedback = FeedbackClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawConversationsClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawConversationsClient + """ + return self._raw_client + + def get_signed_url( + self, *, agent_id: str, request_options: typing.Optional[RequestOptions] = None + ) -> ConversationSignedUrlResponseModel: + """ + Get a signed url to start a conversation with an agent with an agent that requires authorization + + Parameters + ---------- + agent_id : str + The id of the agent you're taking the action on. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ConversationSignedUrlResponseModel + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.conversational_ai.conversations.get_signed_url( + agent_id="21m00Tcm4TlvDq8ikWAM", + ) + """ + _response = self._raw_client.get_signed_url(agent_id=agent_id, request_options=request_options) + return _response.data + + def list( + self, + *, + cursor: typing.Optional[str] = None, + agent_id: typing.Optional[str] = None, + call_successful: typing.Optional[EvaluationSuccessResult] = None, + call_start_before_unix: typing.Optional[int] = None, + call_start_after_unix: typing.Optional[int] = None, + page_size: typing.Optional[int] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> GetConversationsPageResponseModel: + """ + Get all conversations of agents that user owns. With option to restrict to a specific agent. + + Parameters + ---------- + cursor : typing.Optional[str] + Used for fetching next page. Cursor is returned in the response. + + agent_id : typing.Optional[str] + The id of the agent you're taking the action on. + + call_successful : typing.Optional[EvaluationSuccessResult] + The result of the success evaluation + + call_start_before_unix : typing.Optional[int] + Unix timestamp (in seconds) to filter conversations up to this start date. + + call_start_after_unix : typing.Optional[int] + Unix timestamp (in seconds) to filter conversations after to this start date. + + page_size : typing.Optional[int] + How many conversations to return at maximum. Can not exceed 100, defaults to 30. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + GetConversationsPageResponseModel + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.conversational_ai.conversations.list() + """ + _response = self._raw_client.list( + cursor=cursor, + agent_id=agent_id, + call_successful=call_successful, + call_start_before_unix=call_start_before_unix, + call_start_after_unix=call_start_after_unix, + page_size=page_size, + request_options=request_options, + ) + return _response.data + + def get( + self, conversation_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> GetConversationResponseModel: + """ + Get the details of a particular conversation + + Parameters + ---------- + conversation_id : str + The id of the conversation you're taking the action on. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + GetConversationResponseModel + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.conversational_ai.conversations.get( + conversation_id="123", + ) + """ + _response = self._raw_client.get(conversation_id, request_options=request_options) + return _response.data + + def delete( + self, conversation_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> typing.Optional[typing.Any]: + """ + Delete a particular conversation + + Parameters + ---------- + conversation_id : str + The id of the conversation you're taking the action on. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + typing.Optional[typing.Any] + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.conversational_ai.conversations.delete( + conversation_id="21m00Tcm4TlvDq8ikWAM", + ) + """ + _response = self._raw_client.delete(conversation_id, request_options=request_options) + return _response.data + + +class AsyncConversationsClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawConversationsClient(client_wrapper=client_wrapper) + self.audio = AsyncAudioClient(client_wrapper=client_wrapper) + + self.feedback = AsyncFeedbackClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawConversationsClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawConversationsClient + """ + return self._raw_client + + async def get_signed_url( + self, *, agent_id: str, request_options: typing.Optional[RequestOptions] = None + ) -> ConversationSignedUrlResponseModel: + """ + Get a signed url to start a conversation with an agent with an agent that requires authorization + + Parameters + ---------- + agent_id : str + The id of the agent you're taking the action on. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ConversationSignedUrlResponseModel + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.conversational_ai.conversations.get_signed_url( + agent_id="21m00Tcm4TlvDq8ikWAM", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.get_signed_url(agent_id=agent_id, request_options=request_options) + return _response.data + + async def list( + self, + *, + cursor: typing.Optional[str] = None, + agent_id: typing.Optional[str] = None, + call_successful: typing.Optional[EvaluationSuccessResult] = None, + call_start_before_unix: typing.Optional[int] = None, + call_start_after_unix: typing.Optional[int] = None, + page_size: typing.Optional[int] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> GetConversationsPageResponseModel: + """ + Get all conversations of agents that user owns. With option to restrict to a specific agent. + + Parameters + ---------- + cursor : typing.Optional[str] + Used for fetching next page. Cursor is returned in the response. + + agent_id : typing.Optional[str] + The id of the agent you're taking the action on. + + call_successful : typing.Optional[EvaluationSuccessResult] + The result of the success evaluation + + call_start_before_unix : typing.Optional[int] + Unix timestamp (in seconds) to filter conversations up to this start date. + + call_start_after_unix : typing.Optional[int] + Unix timestamp (in seconds) to filter conversations after to this start date. + + page_size : typing.Optional[int] + How many conversations to return at maximum. Can not exceed 100, defaults to 30. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + GetConversationsPageResponseModel + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.conversational_ai.conversations.list() + + + asyncio.run(main()) + """ + _response = await self._raw_client.list( + cursor=cursor, + agent_id=agent_id, + call_successful=call_successful, + call_start_before_unix=call_start_before_unix, + call_start_after_unix=call_start_after_unix, + page_size=page_size, + request_options=request_options, + ) + return _response.data + + async def get( + self, conversation_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> GetConversationResponseModel: + """ + Get the details of a particular conversation + + Parameters + ---------- + conversation_id : str + The id of the conversation you're taking the action on. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + GetConversationResponseModel + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.conversational_ai.conversations.get( + conversation_id="123", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.get(conversation_id, request_options=request_options) + return _response.data + + async def delete( + self, conversation_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> typing.Optional[typing.Any]: + """ + Delete a particular conversation + + Parameters + ---------- + conversation_id : str + The id of the conversation you're taking the action on. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + typing.Optional[typing.Any] + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.conversational_ai.conversations.delete( + conversation_id="21m00Tcm4TlvDq8ikWAM", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.delete(conversation_id, request_options=request_options) + return _response.data diff --git a/src/elevenlabs/conversational_ai/conversations/feedback/__init__.py b/src/elevenlabs/conversational_ai/conversations/feedback/__init__.py new file mode 100644 index 00000000..5cde0202 --- /dev/null +++ b/src/elevenlabs/conversational_ai/conversations/feedback/__init__.py @@ -0,0 +1,4 @@ +# This file was auto-generated by Fern from our API Definition. + +# isort: skip_file + diff --git a/src/elevenlabs/conversational_ai/conversations/feedback/client.py b/src/elevenlabs/conversational_ai/conversations/feedback/client.py new file mode 100644 index 00000000..51762bb7 --- /dev/null +++ b/src/elevenlabs/conversational_ai/conversations/feedback/client.py @@ -0,0 +1,133 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +from ....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ....core.request_options import RequestOptions +from ....types.user_feedback_score import UserFeedbackScore +from .raw_client import AsyncRawFeedbackClient, RawFeedbackClient + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class FeedbackClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._raw_client = RawFeedbackClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawFeedbackClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawFeedbackClient + """ + return self._raw_client + + def create( + self, + conversation_id: str, + *, + feedback: UserFeedbackScore, + request_options: typing.Optional[RequestOptions] = None, + ) -> typing.Optional[typing.Any]: + """ + Send the feedback for the given conversation + + Parameters + ---------- + conversation_id : str + The id of the conversation you're taking the action on. + + feedback : UserFeedbackScore + Either 'like' or 'dislike' to indicate the feedback for the conversation. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + typing.Optional[typing.Any] + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.conversational_ai.conversations.feedback.create( + conversation_id="21m00Tcm4TlvDq8ikWAM", + feedback="like", + ) + """ + _response = self._raw_client.create(conversation_id, feedback=feedback, request_options=request_options) + return _response.data + + +class AsyncFeedbackClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawFeedbackClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawFeedbackClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawFeedbackClient + """ + return self._raw_client + + async def create( + self, + conversation_id: str, + *, + feedback: UserFeedbackScore, + request_options: typing.Optional[RequestOptions] = None, + ) -> typing.Optional[typing.Any]: + """ + Send the feedback for the given conversation + + Parameters + ---------- + conversation_id : str + The id of the conversation you're taking the action on. + + feedback : UserFeedbackScore + Either 'like' or 'dislike' to indicate the feedback for the conversation. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + typing.Optional[typing.Any] + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.conversational_ai.conversations.feedback.create( + conversation_id="21m00Tcm4TlvDq8ikWAM", + feedback="like", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.create(conversation_id, feedback=feedback, request_options=request_options) + return _response.data diff --git a/src/elevenlabs/conversational_ai/conversations/feedback/raw_client.py b/src/elevenlabs/conversational_ai/conversations/feedback/raw_client.py new file mode 100644 index 00000000..468b674a --- /dev/null +++ b/src/elevenlabs/conversational_ai/conversations/feedback/raw_client.py @@ -0,0 +1,157 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ....core.api_error import ApiError +from ....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ....core.http_response import AsyncHttpResponse, HttpResponse +from ....core.jsonable_encoder import jsonable_encoder +from ....core.request_options import RequestOptions +from ....core.unchecked_base_model import construct_type +from ....errors.unprocessable_entity_error import UnprocessableEntityError +from ....types.http_validation_error import HttpValidationError +from ....types.user_feedback_score import UserFeedbackScore + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RawFeedbackClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def create( + self, + conversation_id: str, + *, + feedback: UserFeedbackScore, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[typing.Optional[typing.Any]]: + """ + Send the feedback for the given conversation + + Parameters + ---------- + conversation_id : str + The id of the conversation you're taking the action on. + + feedback : UserFeedbackScore + Either 'like' or 'dislike' to indicate the feedback for the conversation. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[typing.Optional[typing.Any]] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/convai/conversations/{jsonable_encoder(conversation_id)}/feedback", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "feedback": feedback, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + typing.Optional[typing.Any], + construct_type( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + +class AsyncRawFeedbackClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def create( + self, + conversation_id: str, + *, + feedback: UserFeedbackScore, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[typing.Optional[typing.Any]]: + """ + Send the feedback for the given conversation + + Parameters + ---------- + conversation_id : str + The id of the conversation you're taking the action on. + + feedback : UserFeedbackScore + Either 'like' or 'dislike' to indicate the feedback for the conversation. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[typing.Optional[typing.Any]] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/convai/conversations/{jsonable_encoder(conversation_id)}/feedback", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "feedback": feedback, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + typing.Optional[typing.Any], + construct_type( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/elevenlabs/conversational_ai/conversations/raw_client.py b/src/elevenlabs/conversational_ai/conversations/raw_client.py new file mode 100644 index 00000000..4f54ced7 --- /dev/null +++ b/src/elevenlabs/conversational_ai/conversations/raw_client.py @@ -0,0 +1,503 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ...core.api_error import ApiError +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ...core.http_response import AsyncHttpResponse, HttpResponse +from ...core.jsonable_encoder import jsonable_encoder +from ...core.request_options import RequestOptions +from ...core.unchecked_base_model import construct_type +from ...errors.unprocessable_entity_error import UnprocessableEntityError +from ...types.conversation_signed_url_response_model import ConversationSignedUrlResponseModel +from ...types.evaluation_success_result import EvaluationSuccessResult +from ...types.get_conversation_response_model import GetConversationResponseModel +from ...types.get_conversations_page_response_model import GetConversationsPageResponseModel +from ...types.http_validation_error import HttpValidationError + + +class RawConversationsClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def get_signed_url( + self, *, agent_id: str, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[ConversationSignedUrlResponseModel]: + """ + Get a signed url to start a conversation with an agent with an agent that requires authorization + + Parameters + ---------- + agent_id : str + The id of the agent you're taking the action on. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[ConversationSignedUrlResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + "v1/convai/conversation/get-signed-url", + base_url=self._client_wrapper.get_environment().base, + method="GET", + params={ + "agent_id": agent_id, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ConversationSignedUrlResponseModel, + construct_type( + type_=ConversationSignedUrlResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def list( + self, + *, + cursor: typing.Optional[str] = None, + agent_id: typing.Optional[str] = None, + call_successful: typing.Optional[EvaluationSuccessResult] = None, + call_start_before_unix: typing.Optional[int] = None, + call_start_after_unix: typing.Optional[int] = None, + page_size: typing.Optional[int] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[GetConversationsPageResponseModel]: + """ + Get all conversations of agents that user owns. With option to restrict to a specific agent. + + Parameters + ---------- + cursor : typing.Optional[str] + Used for fetching next page. Cursor is returned in the response. + + agent_id : typing.Optional[str] + The id of the agent you're taking the action on. + + call_successful : typing.Optional[EvaluationSuccessResult] + The result of the success evaluation + + call_start_before_unix : typing.Optional[int] + Unix timestamp (in seconds) to filter conversations up to this start date. + + call_start_after_unix : typing.Optional[int] + Unix timestamp (in seconds) to filter conversations after to this start date. + + page_size : typing.Optional[int] + How many conversations to return at maximum. Can not exceed 100, defaults to 30. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[GetConversationsPageResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + "v1/convai/conversations", + base_url=self._client_wrapper.get_environment().base, + method="GET", + params={ + "cursor": cursor, + "agent_id": agent_id, + "call_successful": call_successful, + "call_start_before_unix": call_start_before_unix, + "call_start_after_unix": call_start_after_unix, + "page_size": page_size, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetConversationsPageResponseModel, + construct_type( + type_=GetConversationsPageResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def get( + self, conversation_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[GetConversationResponseModel]: + """ + Get the details of a particular conversation + + Parameters + ---------- + conversation_id : str + The id of the conversation you're taking the action on. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[GetConversationResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/convai/conversations/{jsonable_encoder(conversation_id)}", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetConversationResponseModel, + construct_type( + type_=GetConversationResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def delete( + self, conversation_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[typing.Optional[typing.Any]]: + """ + Delete a particular conversation + + Parameters + ---------- + conversation_id : str + The id of the conversation you're taking the action on. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[typing.Optional[typing.Any]] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/convai/conversations/{jsonable_encoder(conversation_id)}", + base_url=self._client_wrapper.get_environment().base, + method="DELETE", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + typing.Optional[typing.Any], + construct_type( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + +class AsyncRawConversationsClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def get_signed_url( + self, *, agent_id: str, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[ConversationSignedUrlResponseModel]: + """ + Get a signed url to start a conversation with an agent with an agent that requires authorization + + Parameters + ---------- + agent_id : str + The id of the agent you're taking the action on. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[ConversationSignedUrlResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + "v1/convai/conversation/get-signed-url", + base_url=self._client_wrapper.get_environment().base, + method="GET", + params={ + "agent_id": agent_id, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ConversationSignedUrlResponseModel, + construct_type( + type_=ConversationSignedUrlResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def list( + self, + *, + cursor: typing.Optional[str] = None, + agent_id: typing.Optional[str] = None, + call_successful: typing.Optional[EvaluationSuccessResult] = None, + call_start_before_unix: typing.Optional[int] = None, + call_start_after_unix: typing.Optional[int] = None, + page_size: typing.Optional[int] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[GetConversationsPageResponseModel]: + """ + Get all conversations of agents that user owns. With option to restrict to a specific agent. + + Parameters + ---------- + cursor : typing.Optional[str] + Used for fetching next page. Cursor is returned in the response. + + agent_id : typing.Optional[str] + The id of the agent you're taking the action on. + + call_successful : typing.Optional[EvaluationSuccessResult] + The result of the success evaluation + + call_start_before_unix : typing.Optional[int] + Unix timestamp (in seconds) to filter conversations up to this start date. + + call_start_after_unix : typing.Optional[int] + Unix timestamp (in seconds) to filter conversations after to this start date. + + page_size : typing.Optional[int] + How many conversations to return at maximum. Can not exceed 100, defaults to 30. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[GetConversationsPageResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + "v1/convai/conversations", + base_url=self._client_wrapper.get_environment().base, + method="GET", + params={ + "cursor": cursor, + "agent_id": agent_id, + "call_successful": call_successful, + "call_start_before_unix": call_start_before_unix, + "call_start_after_unix": call_start_after_unix, + "page_size": page_size, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetConversationsPageResponseModel, + construct_type( + type_=GetConversationsPageResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def get( + self, conversation_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[GetConversationResponseModel]: + """ + Get the details of a particular conversation + + Parameters + ---------- + conversation_id : str + The id of the conversation you're taking the action on. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[GetConversationResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/convai/conversations/{jsonable_encoder(conversation_id)}", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetConversationResponseModel, + construct_type( + type_=GetConversationResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def delete( + self, conversation_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[typing.Optional[typing.Any]]: + """ + Delete a particular conversation + + Parameters + ---------- + conversation_id : str + The id of the conversation you're taking the action on. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[typing.Optional[typing.Any]] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/convai/conversations/{jsonable_encoder(conversation_id)}", + base_url=self._client_wrapper.get_environment().base, + method="DELETE", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + typing.Optional[typing.Any], + construct_type( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/elevenlabs/conversational_ai/dashboard/__init__.py b/src/elevenlabs/conversational_ai/dashboard/__init__.py new file mode 100644 index 00000000..537589e2 --- /dev/null +++ b/src/elevenlabs/conversational_ai/dashboard/__init__.py @@ -0,0 +1,19 @@ +# This file was auto-generated by Fern from our API Definition. + +# isort: skip_file + +from . import settings +from .settings import ( + PatchConvAiDashboardSettingsRequestChartsItem, + PatchConvAiDashboardSettingsRequestChartsItem_CallSuccess, + PatchConvAiDashboardSettingsRequestChartsItem_Criteria, + PatchConvAiDashboardSettingsRequestChartsItem_DataCollection, +) + +__all__ = [ + "PatchConvAiDashboardSettingsRequestChartsItem", + "PatchConvAiDashboardSettingsRequestChartsItem_CallSuccess", + "PatchConvAiDashboardSettingsRequestChartsItem_Criteria", + "PatchConvAiDashboardSettingsRequestChartsItem_DataCollection", + "settings", +] diff --git a/src/elevenlabs/conversational_ai/dashboard/client.py b/src/elevenlabs/conversational_ai/dashboard/client.py new file mode 100644 index 00000000..ea2c3d6c --- /dev/null +++ b/src/elevenlabs/conversational_ai/dashboard/client.py @@ -0,0 +1,39 @@ +# This file was auto-generated by Fern from our API Definition. + +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from .raw_client import AsyncRawDashboardClient, RawDashboardClient +from .settings.client import AsyncSettingsClient, SettingsClient + + +class DashboardClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._raw_client = RawDashboardClient(client_wrapper=client_wrapper) + self.settings = SettingsClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawDashboardClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawDashboardClient + """ + return self._raw_client + + +class AsyncDashboardClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawDashboardClient(client_wrapper=client_wrapper) + self.settings = AsyncSettingsClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawDashboardClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawDashboardClient + """ + return self._raw_client diff --git a/src/elevenlabs/conversational_ai/dashboard/raw_client.py b/src/elevenlabs/conversational_ai/dashboard/raw_client.py new file mode 100644 index 00000000..2dc83b3d --- /dev/null +++ b/src/elevenlabs/conversational_ai/dashboard/raw_client.py @@ -0,0 +1,13 @@ +# This file was auto-generated by Fern from our API Definition. + +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper + + +class RawDashboardClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + +class AsyncRawDashboardClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper diff --git a/src/elevenlabs/conversational_ai/dashboard/settings/__init__.py b/src/elevenlabs/conversational_ai/dashboard/settings/__init__.py new file mode 100644 index 00000000..56676bd9 --- /dev/null +++ b/src/elevenlabs/conversational_ai/dashboard/settings/__init__.py @@ -0,0 +1,17 @@ +# This file was auto-generated by Fern from our API Definition. + +# isort: skip_file + +from .types import ( + PatchConvAiDashboardSettingsRequestChartsItem, + PatchConvAiDashboardSettingsRequestChartsItem_CallSuccess, + PatchConvAiDashboardSettingsRequestChartsItem_Criteria, + PatchConvAiDashboardSettingsRequestChartsItem_DataCollection, +) + +__all__ = [ + "PatchConvAiDashboardSettingsRequestChartsItem", + "PatchConvAiDashboardSettingsRequestChartsItem_CallSuccess", + "PatchConvAiDashboardSettingsRequestChartsItem_Criteria", + "PatchConvAiDashboardSettingsRequestChartsItem_DataCollection", +] diff --git a/src/elevenlabs/conversational_ai/dashboard/settings/client.py b/src/elevenlabs/conversational_ai/dashboard/settings/client.py new file mode 100644 index 00000000..2a71c5de --- /dev/null +++ b/src/elevenlabs/conversational_ai/dashboard/settings/client.py @@ -0,0 +1,182 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +from ....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ....core.request_options import RequestOptions +from ....types.get_conv_ai_dashboard_settings_response_model import GetConvAiDashboardSettingsResponseModel +from .raw_client import AsyncRawSettingsClient, RawSettingsClient +from .types.patch_conv_ai_dashboard_settings_request_charts_item import PatchConvAiDashboardSettingsRequestChartsItem + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class SettingsClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._raw_client = RawSettingsClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawSettingsClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawSettingsClient + """ + return self._raw_client + + def get( + self, *, request_options: typing.Optional[RequestOptions] = None + ) -> GetConvAiDashboardSettingsResponseModel: + """ + Retrieve Convai dashboard settings for the workspace + + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + GetConvAiDashboardSettingsResponseModel + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.conversational_ai.dashboard.settings.get() + """ + _response = self._raw_client.get(request_options=request_options) + return _response.data + + def update( + self, + *, + charts: typing.Optional[typing.Sequence[PatchConvAiDashboardSettingsRequestChartsItem]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> GetConvAiDashboardSettingsResponseModel: + """ + Update Convai dashboard settings for the workspace + + Parameters + ---------- + charts : typing.Optional[typing.Sequence[PatchConvAiDashboardSettingsRequestChartsItem]] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + GetConvAiDashboardSettingsResponseModel + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.conversational_ai.dashboard.settings.update() + """ + _response = self._raw_client.update(charts=charts, request_options=request_options) + return _response.data + + +class AsyncSettingsClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawSettingsClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawSettingsClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawSettingsClient + """ + return self._raw_client + + async def get( + self, *, request_options: typing.Optional[RequestOptions] = None + ) -> GetConvAiDashboardSettingsResponseModel: + """ + Retrieve Convai dashboard settings for the workspace + + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + GetConvAiDashboardSettingsResponseModel + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.conversational_ai.dashboard.settings.get() + + + asyncio.run(main()) + """ + _response = await self._raw_client.get(request_options=request_options) + return _response.data + + async def update( + self, + *, + charts: typing.Optional[typing.Sequence[PatchConvAiDashboardSettingsRequestChartsItem]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> GetConvAiDashboardSettingsResponseModel: + """ + Update Convai dashboard settings for the workspace + + Parameters + ---------- + charts : typing.Optional[typing.Sequence[PatchConvAiDashboardSettingsRequestChartsItem]] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + GetConvAiDashboardSettingsResponseModel + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.conversational_ai.dashboard.settings.update() + + + asyncio.run(main()) + """ + _response = await self._raw_client.update(charts=charts, request_options=request_options) + return _response.data diff --git a/src/elevenlabs/conversational_ai/dashboard/settings/raw_client.py b/src/elevenlabs/conversational_ai/dashboard/settings/raw_client.py new file mode 100644 index 00000000..921c103b --- /dev/null +++ b/src/elevenlabs/conversational_ai/dashboard/settings/raw_client.py @@ -0,0 +1,252 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ....core.api_error import ApiError +from ....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ....core.http_response import AsyncHttpResponse, HttpResponse +from ....core.request_options import RequestOptions +from ....core.serialization import convert_and_respect_annotation_metadata +from ....core.unchecked_base_model import construct_type +from ....errors.unprocessable_entity_error import UnprocessableEntityError +from ....types.get_conv_ai_dashboard_settings_response_model import GetConvAiDashboardSettingsResponseModel +from ....types.http_validation_error import HttpValidationError +from .types.patch_conv_ai_dashboard_settings_request_charts_item import PatchConvAiDashboardSettingsRequestChartsItem + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RawSettingsClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def get( + self, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[GetConvAiDashboardSettingsResponseModel]: + """ + Retrieve Convai dashboard settings for the workspace + + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[GetConvAiDashboardSettingsResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + "v1/convai/settings/dashboard", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetConvAiDashboardSettingsResponseModel, + construct_type( + type_=GetConvAiDashboardSettingsResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def update( + self, + *, + charts: typing.Optional[typing.Sequence[PatchConvAiDashboardSettingsRequestChartsItem]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[GetConvAiDashboardSettingsResponseModel]: + """ + Update Convai dashboard settings for the workspace + + Parameters + ---------- + charts : typing.Optional[typing.Sequence[PatchConvAiDashboardSettingsRequestChartsItem]] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[GetConvAiDashboardSettingsResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + "v1/convai/settings/dashboard", + base_url=self._client_wrapper.get_environment().base, + method="PATCH", + json={ + "charts": convert_and_respect_annotation_metadata( + object_=charts, + annotation=typing.Sequence[PatchConvAiDashboardSettingsRequestChartsItem], + direction="write", + ), + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetConvAiDashboardSettingsResponseModel, + construct_type( + type_=GetConvAiDashboardSettingsResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + +class AsyncRawSettingsClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def get( + self, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[GetConvAiDashboardSettingsResponseModel]: + """ + Retrieve Convai dashboard settings for the workspace + + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[GetConvAiDashboardSettingsResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + "v1/convai/settings/dashboard", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetConvAiDashboardSettingsResponseModel, + construct_type( + type_=GetConvAiDashboardSettingsResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def update( + self, + *, + charts: typing.Optional[typing.Sequence[PatchConvAiDashboardSettingsRequestChartsItem]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[GetConvAiDashboardSettingsResponseModel]: + """ + Update Convai dashboard settings for the workspace + + Parameters + ---------- + charts : typing.Optional[typing.Sequence[PatchConvAiDashboardSettingsRequestChartsItem]] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[GetConvAiDashboardSettingsResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + "v1/convai/settings/dashboard", + base_url=self._client_wrapper.get_environment().base, + method="PATCH", + json={ + "charts": convert_and_respect_annotation_metadata( + object_=charts, + annotation=typing.Sequence[PatchConvAiDashboardSettingsRequestChartsItem], + direction="write", + ), + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetConvAiDashboardSettingsResponseModel, + construct_type( + type_=GetConvAiDashboardSettingsResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/elevenlabs/conversational_ai/dashboard/settings/types/__init__.py b/src/elevenlabs/conversational_ai/dashboard/settings/types/__init__.py new file mode 100644 index 00000000..999149de --- /dev/null +++ b/src/elevenlabs/conversational_ai/dashboard/settings/types/__init__.py @@ -0,0 +1,17 @@ +# This file was auto-generated by Fern from our API Definition. + +# isort: skip_file + +from .patch_conv_ai_dashboard_settings_request_charts_item import ( + PatchConvAiDashboardSettingsRequestChartsItem, + PatchConvAiDashboardSettingsRequestChartsItem_CallSuccess, + PatchConvAiDashboardSettingsRequestChartsItem_Criteria, + PatchConvAiDashboardSettingsRequestChartsItem_DataCollection, +) + +__all__ = [ + "PatchConvAiDashboardSettingsRequestChartsItem", + "PatchConvAiDashboardSettingsRequestChartsItem_CallSuccess", + "PatchConvAiDashboardSettingsRequestChartsItem_Criteria", + "PatchConvAiDashboardSettingsRequestChartsItem_DataCollection", +] diff --git a/src/elevenlabs/conversational_ai/types/patch_conv_ai_dashboard_settings_request_charts_item.py b/src/elevenlabs/conversational_ai/dashboard/settings/types/patch_conv_ai_dashboard_settings_request_charts_item.py similarity index 91% rename from src/elevenlabs/conversational_ai/types/patch_conv_ai_dashboard_settings_request_charts_item.py rename to src/elevenlabs/conversational_ai/dashboard/settings/types/patch_conv_ai_dashboard_settings_request_charts_item.py index 54756eff..faf19ea5 100644 --- a/src/elevenlabs/conversational_ai/types/patch_conv_ai_dashboard_settings_request_charts_item.py +++ b/src/elevenlabs/conversational_ai/dashboard/settings/types/patch_conv_ai_dashboard_settings_request_charts_item.py @@ -1,12 +1,13 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -from ...core.unchecked_base_model import UncheckedBaseModel + import typing -from ...core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic import typing_extensions -from ...core.unchecked_base_model import UnionMetadata +from .....core.pydantic_utilities import IS_PYDANTIC_V2 +from .....core.unchecked_base_model import UncheckedBaseModel, UnionMetadata class PatchConvAiDashboardSettingsRequestChartsItem_CallSuccess(UncheckedBaseModel): diff --git a/src/elevenlabs/conversational_ai/knowledge_base/__init__.py b/src/elevenlabs/conversational_ai/knowledge_base/__init__.py index 0136afe9..f800ab36 100644 --- a/src/elevenlabs/conversational_ai/knowledge_base/__init__.py +++ b/src/elevenlabs/conversational_ai/knowledge_base/__init__.py @@ -1,5 +1,28 @@ # This file was auto-generated by Fern from our API Definition. -from . import document +# isort: skip_file -__all__ = ["document"] +from . import document, documents +from .documents import ( + DocumentsGetResponse, + DocumentsGetResponse_File, + DocumentsGetResponse_Text, + DocumentsGetResponse_Url, + DocumentsUpdateResponse, + DocumentsUpdateResponse_File, + DocumentsUpdateResponse_Text, + DocumentsUpdateResponse_Url, +) + +__all__ = [ + "DocumentsGetResponse", + "DocumentsGetResponse_File", + "DocumentsGetResponse_Text", + "DocumentsGetResponse_Url", + "DocumentsUpdateResponse", + "DocumentsUpdateResponse_File", + "DocumentsUpdateResponse_Text", + "DocumentsUpdateResponse_Url", + "document", + "documents", +] diff --git a/src/elevenlabs/conversational_ai/knowledge_base/client.py b/src/elevenlabs/conversational_ai/knowledge_base/client.py index 391d7cc8..b64f9c04 100644 --- a/src/elevenlabs/conversational_ai/knowledge_base/client.py +++ b/src/elevenlabs/conversational_ai/knowledge_base/client.py @@ -1,18 +1,185 @@ # This file was auto-generated by Fern from our API Definition. -from ...core.client_wrapper import SyncClientWrapper -from .document.client import DocumentClient -from ...core.client_wrapper import AsyncClientWrapper -from .document.client import AsyncDocumentClient +import typing + +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ...core.request_options import RequestOptions +from ...types.get_knowledge_base_list_response_model import GetKnowledgeBaseListResponseModel +from ...types.knowledge_base_document_type import KnowledgeBaseDocumentType +from .document.client import AsyncDocumentClient, DocumentClient +from .documents.client import AsyncDocumentsClient, DocumentsClient +from .raw_client import AsyncRawKnowledgeBaseClient, RawKnowledgeBaseClient class KnowledgeBaseClient: def __init__(self, *, client_wrapper: SyncClientWrapper): - self._client_wrapper = client_wrapper - self.document = DocumentClient(client_wrapper=self._client_wrapper) + self._raw_client = RawKnowledgeBaseClient(client_wrapper=client_wrapper) + self.documents = DocumentsClient(client_wrapper=client_wrapper) + + self.document = DocumentClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawKnowledgeBaseClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawKnowledgeBaseClient + """ + return self._raw_client + + def list( + self, + *, + cursor: typing.Optional[str] = None, + page_size: typing.Optional[int] = None, + search: typing.Optional[str] = None, + show_only_owned_documents: typing.Optional[bool] = None, + types: typing.Optional[ + typing.Union[KnowledgeBaseDocumentType, typing.Sequence[KnowledgeBaseDocumentType]] + ] = None, + use_typesense: typing.Optional[bool] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> GetKnowledgeBaseListResponseModel: + """ + Get a list of available knowledge base documents + + Parameters + ---------- + cursor : typing.Optional[str] + Used for fetching next page. Cursor is returned in the response. + + page_size : typing.Optional[int] + How many documents to return at maximum. Can not exceed 100, defaults to 30. + + search : typing.Optional[str] + If specified, the endpoint returns only such knowledge base documents whose names start with this string. + + show_only_owned_documents : typing.Optional[bool] + If set to true, the endpoint will return only documents owned by you (and not shared from somebody else). + + types : typing.Optional[typing.Union[KnowledgeBaseDocumentType, typing.Sequence[KnowledgeBaseDocumentType]]] + If present, the endpoint will return only documents of the given types. + + use_typesense : typing.Optional[bool] + If set to true, the endpoint will use typesense DB to search for the documents). + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + GetKnowledgeBaseListResponseModel + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.conversational_ai.knowledge_base.list() + """ + _response = self._raw_client.list( + cursor=cursor, + page_size=page_size, + search=search, + show_only_owned_documents=show_only_owned_documents, + types=types, + use_typesense=use_typesense, + request_options=request_options, + ) + return _response.data class AsyncKnowledgeBaseClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): - self._client_wrapper = client_wrapper - self.document = AsyncDocumentClient(client_wrapper=self._client_wrapper) + self._raw_client = AsyncRawKnowledgeBaseClient(client_wrapper=client_wrapper) + self.documents = AsyncDocumentsClient(client_wrapper=client_wrapper) + + self.document = AsyncDocumentClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawKnowledgeBaseClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawKnowledgeBaseClient + """ + return self._raw_client + + async def list( + self, + *, + cursor: typing.Optional[str] = None, + page_size: typing.Optional[int] = None, + search: typing.Optional[str] = None, + show_only_owned_documents: typing.Optional[bool] = None, + types: typing.Optional[ + typing.Union[KnowledgeBaseDocumentType, typing.Sequence[KnowledgeBaseDocumentType]] + ] = None, + use_typesense: typing.Optional[bool] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> GetKnowledgeBaseListResponseModel: + """ + Get a list of available knowledge base documents + + Parameters + ---------- + cursor : typing.Optional[str] + Used for fetching next page. Cursor is returned in the response. + + page_size : typing.Optional[int] + How many documents to return at maximum. Can not exceed 100, defaults to 30. + + search : typing.Optional[str] + If specified, the endpoint returns only such knowledge base documents whose names start with this string. + + show_only_owned_documents : typing.Optional[bool] + If set to true, the endpoint will return only documents owned by you (and not shared from somebody else). + + types : typing.Optional[typing.Union[KnowledgeBaseDocumentType, typing.Sequence[KnowledgeBaseDocumentType]]] + If present, the endpoint will return only documents of the given types. + + use_typesense : typing.Optional[bool] + If set to true, the endpoint will use typesense DB to search for the documents). + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + GetKnowledgeBaseListResponseModel + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.conversational_ai.knowledge_base.list() + + + asyncio.run(main()) + """ + _response = await self._raw_client.list( + cursor=cursor, + page_size=page_size, + search=search, + show_only_owned_documents=show_only_owned_documents, + types=types, + use_typesense=use_typesense, + request_options=request_options, + ) + return _response.data diff --git a/src/elevenlabs/conversational_ai/knowledge_base/document/__init__.py b/src/elevenlabs/conversational_ai/knowledge_base/document/__init__.py index f3ea2659..5cde0202 100644 --- a/src/elevenlabs/conversational_ai/knowledge_base/document/__init__.py +++ b/src/elevenlabs/conversational_ai/knowledge_base/document/__init__.py @@ -1,2 +1,4 @@ # This file was auto-generated by Fern from our API Definition. +# isort: skip_file + diff --git a/src/elevenlabs/conversational_ai/knowledge_base/document/client.py b/src/elevenlabs/conversational_ai/knowledge_base/document/client.py index 2dc35a44..46befcc9 100644 --- a/src/elevenlabs/conversational_ai/knowledge_base/document/client.py +++ b/src/elevenlabs/conversational_ai/knowledge_base/document/client.py @@ -1,17 +1,12 @@ # This file was auto-generated by Fern from our API Definition. import typing -from ....core.client_wrapper import SyncClientWrapper -from ....types.embedding_model_enum import EmbeddingModelEnum + +from ....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ....core.request_options import RequestOptions +from ....types.embedding_model_enum import EmbeddingModelEnum from ....types.rag_index_response_model import RagIndexResponseModel -from ....core.jsonable_encoder import jsonable_encoder -from ....core.unchecked_base_model import construct_type -from ....errors.unprocessable_entity_error import UnprocessableEntityError -from ....types.http_validation_error import HttpValidationError -from json.decoder import JSONDecodeError -from ....core.api_error import ApiError -from ....core.client_wrapper import AsyncClientWrapper +from .raw_client import AsyncRawDocumentClient, RawDocumentClient # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -19,7 +14,18 @@ class DocumentClient: def __init__(self, *, client_wrapper: SyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = RawDocumentClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawDocumentClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawDocumentClient + """ + return self._raw_client def compute_rag_index( self, @@ -58,47 +64,24 @@ def compute_rag_index( model="e5_mistral_7b_instruct", ) """ - _response = self._client_wrapper.httpx_client.request( - f"v1/convai/knowledge-base/{jsonable_encoder(documentation_id)}/rag-index", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "model": model, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - RagIndexResponseModel, - construct_type( - type_=RagIndexResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.compute_rag_index(documentation_id, model=model, request_options=request_options) + return _response.data class AsyncDocumentClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = AsyncRawDocumentClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawDocumentClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawDocumentClient + """ + return self._raw_client async def compute_rag_index( self, @@ -145,39 +128,7 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/convai/knowledge-base/{jsonable_encoder(documentation_id)}/rag-index", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "model": model, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, + _response = await self._raw_client.compute_rag_index( + documentation_id, model=model, request_options=request_options ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - RagIndexResponseModel, - construct_type( - type_=RagIndexResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + return _response.data diff --git a/src/elevenlabs/conversational_ai/knowledge_base/document/raw_client.py b/src/elevenlabs/conversational_ai/knowledge_base/document/raw_client.py new file mode 100644 index 00000000..8ba4b695 --- /dev/null +++ b/src/elevenlabs/conversational_ai/knowledge_base/document/raw_client.py @@ -0,0 +1,156 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ....core.api_error import ApiError +from ....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ....core.http_response import AsyncHttpResponse, HttpResponse +from ....core.jsonable_encoder import jsonable_encoder +from ....core.request_options import RequestOptions +from ....core.unchecked_base_model import construct_type +from ....errors.unprocessable_entity_error import UnprocessableEntityError +from ....types.embedding_model_enum import EmbeddingModelEnum +from ....types.http_validation_error import HttpValidationError +from ....types.rag_index_response_model import RagIndexResponseModel + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RawDocumentClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def compute_rag_index( + self, + documentation_id: str, + *, + model: EmbeddingModelEnum, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[RagIndexResponseModel]: + """ + In case the document is not RAG indexed, it triggers rag indexing task, otherwise it just returns the current status. + + Parameters + ---------- + documentation_id : str + The id of a document from the knowledge base. This is returned on document addition. + + model : EmbeddingModelEnum + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[RagIndexResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/convai/knowledge-base/{jsonable_encoder(documentation_id)}/rag-index", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "model": model, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + RagIndexResponseModel, + construct_type( + type_=RagIndexResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + +class AsyncRawDocumentClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def compute_rag_index( + self, + documentation_id: str, + *, + model: EmbeddingModelEnum, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[RagIndexResponseModel]: + """ + In case the document is not RAG indexed, it triggers rag indexing task, otherwise it just returns the current status. + + Parameters + ---------- + documentation_id : str + The id of a document from the knowledge base. This is returned on document addition. + + model : EmbeddingModelEnum + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[RagIndexResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/convai/knowledge-base/{jsonable_encoder(documentation_id)}/rag-index", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "model": model, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + RagIndexResponseModel, + construct_type( + type_=RagIndexResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/elevenlabs/conversational_ai/knowledge_base/documents/__init__.py b/src/elevenlabs/conversational_ai/knowledge_base/documents/__init__.py new file mode 100644 index 00000000..2bd0a775 --- /dev/null +++ b/src/elevenlabs/conversational_ai/knowledge_base/documents/__init__.py @@ -0,0 +1,27 @@ +# This file was auto-generated by Fern from our API Definition. + +# isort: skip_file + +from .types import ( + DocumentsGetResponse, + DocumentsGetResponse_File, + DocumentsGetResponse_Text, + DocumentsGetResponse_Url, + DocumentsUpdateResponse, + DocumentsUpdateResponse_File, + DocumentsUpdateResponse_Text, + DocumentsUpdateResponse_Url, +) +from . import chunk + +__all__ = [ + "DocumentsGetResponse", + "DocumentsGetResponse_File", + "DocumentsGetResponse_Text", + "DocumentsGetResponse_Url", + "DocumentsUpdateResponse", + "DocumentsUpdateResponse_File", + "DocumentsUpdateResponse_Text", + "DocumentsUpdateResponse_Url", + "chunk", +] diff --git a/src/elevenlabs/conversational_ai/knowledge_base/documents/chunk/__init__.py b/src/elevenlabs/conversational_ai/knowledge_base/documents/chunk/__init__.py new file mode 100644 index 00000000..5cde0202 --- /dev/null +++ b/src/elevenlabs/conversational_ai/knowledge_base/documents/chunk/__init__.py @@ -0,0 +1,4 @@ +# This file was auto-generated by Fern from our API Definition. + +# isort: skip_file + diff --git a/src/elevenlabs/conversational_ai/knowledge_base/documents/chunk/client.py b/src/elevenlabs/conversational_ai/knowledge_base/documents/chunk/client.py new file mode 100644 index 00000000..7fd1af03 --- /dev/null +++ b/src/elevenlabs/conversational_ai/knowledge_base/documents/chunk/client.py @@ -0,0 +1,122 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +from .....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from .....core.request_options import RequestOptions +from .....types.knowledge_base_document_chunk_response_model import KnowledgeBaseDocumentChunkResponseModel +from .raw_client import AsyncRawChunkClient, RawChunkClient + + +class ChunkClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._raw_client = RawChunkClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawChunkClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawChunkClient + """ + return self._raw_client + + def get( + self, documentation_id: str, chunk_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> KnowledgeBaseDocumentChunkResponseModel: + """ + Get details about a specific documentation part used by RAG. + + Parameters + ---------- + documentation_id : str + The id of a document from the knowledge base. This is returned on document addition. + + chunk_id : str + The id of a document RAG chunk from the knowledge base. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + KnowledgeBaseDocumentChunkResponseModel + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.conversational_ai.knowledge_base.documents.chunk.get( + documentation_id="21m00Tcm4TlvDq8ikWAM", + chunk_id="chunk_id", + ) + """ + _response = self._raw_client.get(documentation_id, chunk_id, request_options=request_options) + return _response.data + + +class AsyncChunkClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawChunkClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawChunkClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawChunkClient + """ + return self._raw_client + + async def get( + self, documentation_id: str, chunk_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> KnowledgeBaseDocumentChunkResponseModel: + """ + Get details about a specific documentation part used by RAG. + + Parameters + ---------- + documentation_id : str + The id of a document from the knowledge base. This is returned on document addition. + + chunk_id : str + The id of a document RAG chunk from the knowledge base. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + KnowledgeBaseDocumentChunkResponseModel + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.conversational_ai.knowledge_base.documents.chunk.get( + documentation_id="21m00Tcm4TlvDq8ikWAM", + chunk_id="chunk_id", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.get(documentation_id, chunk_id, request_options=request_options) + return _response.data diff --git a/src/elevenlabs/conversational_ai/knowledge_base/documents/chunk/raw_client.py b/src/elevenlabs/conversational_ai/knowledge_base/documents/chunk/raw_client.py new file mode 100644 index 00000000..80d3bb2e --- /dev/null +++ b/src/elevenlabs/conversational_ai/knowledge_base/documents/chunk/raw_client.py @@ -0,0 +1,132 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from .....core.api_error import ApiError +from .....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from .....core.http_response import AsyncHttpResponse, HttpResponse +from .....core.jsonable_encoder import jsonable_encoder +from .....core.request_options import RequestOptions +from .....core.unchecked_base_model import construct_type +from .....errors.unprocessable_entity_error import UnprocessableEntityError +from .....types.http_validation_error import HttpValidationError +from .....types.knowledge_base_document_chunk_response_model import KnowledgeBaseDocumentChunkResponseModel + + +class RawChunkClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def get( + self, documentation_id: str, chunk_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[KnowledgeBaseDocumentChunkResponseModel]: + """ + Get details about a specific documentation part used by RAG. + + Parameters + ---------- + documentation_id : str + The id of a document from the knowledge base. This is returned on document addition. + + chunk_id : str + The id of a document RAG chunk from the knowledge base. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[KnowledgeBaseDocumentChunkResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/convai/knowledge-base/{jsonable_encoder(documentation_id)}/chunk/{jsonable_encoder(chunk_id)}", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + KnowledgeBaseDocumentChunkResponseModel, + construct_type( + type_=KnowledgeBaseDocumentChunkResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + +class AsyncRawChunkClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def get( + self, documentation_id: str, chunk_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[KnowledgeBaseDocumentChunkResponseModel]: + """ + Get details about a specific documentation part used by RAG. + + Parameters + ---------- + documentation_id : str + The id of a document from the knowledge base. This is returned on document addition. + + chunk_id : str + The id of a document RAG chunk from the knowledge base. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[KnowledgeBaseDocumentChunkResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/convai/knowledge-base/{jsonable_encoder(documentation_id)}/chunk/{jsonable_encoder(chunk_id)}", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + KnowledgeBaseDocumentChunkResponseModel, + construct_type( + type_=KnowledgeBaseDocumentChunkResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/elevenlabs/conversational_ai/knowledge_base/documents/client.py b/src/elevenlabs/conversational_ai/knowledge_base/documents/client.py new file mode 100644 index 00000000..eefaee7e --- /dev/null +++ b/src/elevenlabs/conversational_ai/knowledge_base/documents/client.py @@ -0,0 +1,694 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +from .... import core +from ....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ....core.request_options import RequestOptions +from ....types.add_knowledge_base_response_model import AddKnowledgeBaseResponseModel +from ....types.get_knowledge_base_dependent_agents_response_model import GetKnowledgeBaseDependentAgentsResponseModel +from .chunk.client import AsyncChunkClient, ChunkClient +from .raw_client import AsyncRawDocumentsClient, RawDocumentsClient +from .types.documents_get_response import DocumentsGetResponse +from .types.documents_update_response import DocumentsUpdateResponse + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class DocumentsClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._raw_client = RawDocumentsClient(client_wrapper=client_wrapper) + self.chunk = ChunkClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawDocumentsClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawDocumentsClient + """ + return self._raw_client + + def create_from_url( + self, *, url: str, name: typing.Optional[str] = OMIT, request_options: typing.Optional[RequestOptions] = None + ) -> AddKnowledgeBaseResponseModel: + """ + Create a knowledge base document generated by scraping the given webpage. + + Parameters + ---------- + url : str + URL to a page of documentation that the agent will have access to in order to interact with users. + + name : typing.Optional[str] + A custom, human-readable name for the document. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AddKnowledgeBaseResponseModel + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.conversational_ai.knowledge_base.documents.create_from_url( + url="url", + ) + """ + _response = self._raw_client.create_from_url(url=url, name=name, request_options=request_options) + return _response.data + + def create_from_file( + self, + *, + file: core.File, + name: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AddKnowledgeBaseResponseModel: + """ + Create a knowledge base document generated form the uploaded file. + + Parameters + ---------- + file : core.File + See core.File for more documentation + + name : typing.Optional[str] + A custom, human-readable name for the document. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AddKnowledgeBaseResponseModel + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.conversational_ai.knowledge_base.documents.create_from_file() + """ + _response = self._raw_client.create_from_file(file=file, name=name, request_options=request_options) + return _response.data + + def create_from_text( + self, *, text: str, name: typing.Optional[str] = OMIT, request_options: typing.Optional[RequestOptions] = None + ) -> AddKnowledgeBaseResponseModel: + """ + Create a knowledge base document containing the provided text. + + Parameters + ---------- + text : str + Text content to be added to the knowledge base. + + name : typing.Optional[str] + A custom, human-readable name for the document. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AddKnowledgeBaseResponseModel + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.conversational_ai.knowledge_base.documents.create_from_text( + text="text", + ) + """ + _response = self._raw_client.create_from_text(text=text, name=name, request_options=request_options) + return _response.data + + def get( + self, documentation_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> DocumentsGetResponse: + """ + Get details about a specific documentation making up the agent's knowledge base + + Parameters + ---------- + documentation_id : str + The id of a document from the knowledge base. This is returned on document addition. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + DocumentsGetResponse + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.conversational_ai.knowledge_base.documents.get( + documentation_id="21m00Tcm4TlvDq8ikWAM", + ) + """ + _response = self._raw_client.get(documentation_id, request_options=request_options) + return _response.data + + def delete( + self, documentation_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> typing.Optional[typing.Any]: + """ + Delete a document from the knowledge base + + Parameters + ---------- + documentation_id : str + The id of a document from the knowledge base. This is returned on document addition. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + typing.Optional[typing.Any] + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.conversational_ai.knowledge_base.documents.delete( + documentation_id="21m00Tcm4TlvDq8ikWAM", + ) + """ + _response = self._raw_client.delete(documentation_id, request_options=request_options) + return _response.data + + def update( + self, documentation_id: str, *, name: str, request_options: typing.Optional[RequestOptions] = None + ) -> DocumentsUpdateResponse: + """ + Update the name of a document + + Parameters + ---------- + documentation_id : str + The id of a document from the knowledge base. This is returned on document addition. + + name : str + A custom, human-readable name for the document. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + DocumentsUpdateResponse + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.conversational_ai.knowledge_base.documents.update( + documentation_id="21m00Tcm4TlvDq8ikWAM", + name="name", + ) + """ + _response = self._raw_client.update(documentation_id, name=name, request_options=request_options) + return _response.data + + def get_agents( + self, + documentation_id: str, + *, + cursor: typing.Optional[str] = None, + page_size: typing.Optional[int] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> GetKnowledgeBaseDependentAgentsResponseModel: + """ + Get a list of agents depending on this knowledge base document + + Parameters + ---------- + documentation_id : str + The id of a document from the knowledge base. This is returned on document addition. + + cursor : typing.Optional[str] + Used for fetching next page. Cursor is returned in the response. + + page_size : typing.Optional[int] + How many documents to return at maximum. Can not exceed 100, defaults to 30. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + GetKnowledgeBaseDependentAgentsResponseModel + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.conversational_ai.knowledge_base.documents.get_agents( + documentation_id="21m00Tcm4TlvDq8ikWAM", + ) + """ + _response = self._raw_client.get_agents( + documentation_id, cursor=cursor, page_size=page_size, request_options=request_options + ) + return _response.data + + def get_content(self, documentation_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None: + """ + Get the entire content of a document from the knowledge base + + Parameters + ---------- + documentation_id : str + The id of a document from the knowledge base. This is returned on document addition. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + None + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.conversational_ai.knowledge_base.documents.get_content( + documentation_id="21m00Tcm4TlvDq8ikWAM", + ) + """ + _response = self._raw_client.get_content(documentation_id, request_options=request_options) + return _response.data + + +class AsyncDocumentsClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawDocumentsClient(client_wrapper=client_wrapper) + self.chunk = AsyncChunkClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawDocumentsClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawDocumentsClient + """ + return self._raw_client + + async def create_from_url( + self, *, url: str, name: typing.Optional[str] = OMIT, request_options: typing.Optional[RequestOptions] = None + ) -> AddKnowledgeBaseResponseModel: + """ + Create a knowledge base document generated by scraping the given webpage. + + Parameters + ---------- + url : str + URL to a page of documentation that the agent will have access to in order to interact with users. + + name : typing.Optional[str] + A custom, human-readable name for the document. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AddKnowledgeBaseResponseModel + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.conversational_ai.knowledge_base.documents.create_from_url( + url="url", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.create_from_url(url=url, name=name, request_options=request_options) + return _response.data + + async def create_from_file( + self, + *, + file: core.File, + name: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AddKnowledgeBaseResponseModel: + """ + Create a knowledge base document generated form the uploaded file. + + Parameters + ---------- + file : core.File + See core.File for more documentation + + name : typing.Optional[str] + A custom, human-readable name for the document. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AddKnowledgeBaseResponseModel + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.conversational_ai.knowledge_base.documents.create_from_file() + + + asyncio.run(main()) + """ + _response = await self._raw_client.create_from_file(file=file, name=name, request_options=request_options) + return _response.data + + async def create_from_text( + self, *, text: str, name: typing.Optional[str] = OMIT, request_options: typing.Optional[RequestOptions] = None + ) -> AddKnowledgeBaseResponseModel: + """ + Create a knowledge base document containing the provided text. + + Parameters + ---------- + text : str + Text content to be added to the knowledge base. + + name : typing.Optional[str] + A custom, human-readable name for the document. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AddKnowledgeBaseResponseModel + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.conversational_ai.knowledge_base.documents.create_from_text( + text="text", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.create_from_text(text=text, name=name, request_options=request_options) + return _response.data + + async def get( + self, documentation_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> DocumentsGetResponse: + """ + Get details about a specific documentation making up the agent's knowledge base + + Parameters + ---------- + documentation_id : str + The id of a document from the knowledge base. This is returned on document addition. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + DocumentsGetResponse + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.conversational_ai.knowledge_base.documents.get( + documentation_id="21m00Tcm4TlvDq8ikWAM", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.get(documentation_id, request_options=request_options) + return _response.data + + async def delete( + self, documentation_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> typing.Optional[typing.Any]: + """ + Delete a document from the knowledge base + + Parameters + ---------- + documentation_id : str + The id of a document from the knowledge base. This is returned on document addition. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + typing.Optional[typing.Any] + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.conversational_ai.knowledge_base.documents.delete( + documentation_id="21m00Tcm4TlvDq8ikWAM", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.delete(documentation_id, request_options=request_options) + return _response.data + + async def update( + self, documentation_id: str, *, name: str, request_options: typing.Optional[RequestOptions] = None + ) -> DocumentsUpdateResponse: + """ + Update the name of a document + + Parameters + ---------- + documentation_id : str + The id of a document from the knowledge base. This is returned on document addition. + + name : str + A custom, human-readable name for the document. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + DocumentsUpdateResponse + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.conversational_ai.knowledge_base.documents.update( + documentation_id="21m00Tcm4TlvDq8ikWAM", + name="name", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.update(documentation_id, name=name, request_options=request_options) + return _response.data + + async def get_agents( + self, + documentation_id: str, + *, + cursor: typing.Optional[str] = None, + page_size: typing.Optional[int] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> GetKnowledgeBaseDependentAgentsResponseModel: + """ + Get a list of agents depending on this knowledge base document + + Parameters + ---------- + documentation_id : str + The id of a document from the knowledge base. This is returned on document addition. + + cursor : typing.Optional[str] + Used for fetching next page. Cursor is returned in the response. + + page_size : typing.Optional[int] + How many documents to return at maximum. Can not exceed 100, defaults to 30. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + GetKnowledgeBaseDependentAgentsResponseModel + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.conversational_ai.knowledge_base.documents.get_agents( + documentation_id="21m00Tcm4TlvDq8ikWAM", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.get_agents( + documentation_id, cursor=cursor, page_size=page_size, request_options=request_options + ) + return _response.data + + async def get_content( + self, documentation_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> None: + """ + Get the entire content of a document from the knowledge base + + Parameters + ---------- + documentation_id : str + The id of a document from the knowledge base. This is returned on document addition. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + None + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.conversational_ai.knowledge_base.documents.get_content( + documentation_id="21m00Tcm4TlvDq8ikWAM", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.get_content(documentation_id, request_options=request_options) + return _response.data diff --git a/src/elevenlabs/conversational_ai/knowledge_base/documents/raw_client.py b/src/elevenlabs/conversational_ai/knowledge_base/documents/raw_client.py new file mode 100644 index 00000000..da16f5db --- /dev/null +++ b/src/elevenlabs/conversational_ai/knowledge_base/documents/raw_client.py @@ -0,0 +1,955 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from .... import core +from ....core.api_error import ApiError +from ....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ....core.http_response import AsyncHttpResponse, HttpResponse +from ....core.jsonable_encoder import jsonable_encoder +from ....core.request_options import RequestOptions +from ....core.unchecked_base_model import construct_type +from ....errors.unprocessable_entity_error import UnprocessableEntityError +from ....types.add_knowledge_base_response_model import AddKnowledgeBaseResponseModel +from ....types.get_knowledge_base_dependent_agents_response_model import GetKnowledgeBaseDependentAgentsResponseModel +from ....types.http_validation_error import HttpValidationError +from .types.documents_get_response import DocumentsGetResponse +from .types.documents_update_response import DocumentsUpdateResponse + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RawDocumentsClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def create_from_url( + self, *, url: str, name: typing.Optional[str] = OMIT, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[AddKnowledgeBaseResponseModel]: + """ + Create a knowledge base document generated by scraping the given webpage. + + Parameters + ---------- + url : str + URL to a page of documentation that the agent will have access to in order to interact with users. + + name : typing.Optional[str] + A custom, human-readable name for the document. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[AddKnowledgeBaseResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + "v1/convai/knowledge-base/url", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "url": url, + "name": name, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + AddKnowledgeBaseResponseModel, + construct_type( + type_=AddKnowledgeBaseResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def create_from_file( + self, + *, + file: core.File, + name: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[AddKnowledgeBaseResponseModel]: + """ + Create a knowledge base document generated form the uploaded file. + + Parameters + ---------- + file : core.File + See core.File for more documentation + + name : typing.Optional[str] + A custom, human-readable name for the document. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[AddKnowledgeBaseResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + "v1/convai/knowledge-base/file", + base_url=self._client_wrapper.get_environment().base, + method="POST", + data={ + "name": name, + }, + files={ + "file": file, + }, + request_options=request_options, + omit=OMIT, + force_multipart=True, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + AddKnowledgeBaseResponseModel, + construct_type( + type_=AddKnowledgeBaseResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def create_from_text( + self, *, text: str, name: typing.Optional[str] = OMIT, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[AddKnowledgeBaseResponseModel]: + """ + Create a knowledge base document containing the provided text. + + Parameters + ---------- + text : str + Text content to be added to the knowledge base. + + name : typing.Optional[str] + A custom, human-readable name for the document. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[AddKnowledgeBaseResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + "v1/convai/knowledge-base/text", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "text": text, + "name": name, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + AddKnowledgeBaseResponseModel, + construct_type( + type_=AddKnowledgeBaseResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def get( + self, documentation_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[DocumentsGetResponse]: + """ + Get details about a specific documentation making up the agent's knowledge base + + Parameters + ---------- + documentation_id : str + The id of a document from the knowledge base. This is returned on document addition. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[DocumentsGetResponse] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/convai/knowledge-base/{jsonable_encoder(documentation_id)}", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + DocumentsGetResponse, + construct_type( + type_=DocumentsGetResponse, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def delete( + self, documentation_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[typing.Optional[typing.Any]]: + """ + Delete a document from the knowledge base + + Parameters + ---------- + documentation_id : str + The id of a document from the knowledge base. This is returned on document addition. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[typing.Optional[typing.Any]] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/convai/knowledge-base/{jsonable_encoder(documentation_id)}", + base_url=self._client_wrapper.get_environment().base, + method="DELETE", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + typing.Optional[typing.Any], + construct_type( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def update( + self, documentation_id: str, *, name: str, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[DocumentsUpdateResponse]: + """ + Update the name of a document + + Parameters + ---------- + documentation_id : str + The id of a document from the knowledge base. This is returned on document addition. + + name : str + A custom, human-readable name for the document. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[DocumentsUpdateResponse] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/convai/knowledge-base/{jsonable_encoder(documentation_id)}", + base_url=self._client_wrapper.get_environment().base, + method="PATCH", + json={ + "name": name, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + DocumentsUpdateResponse, + construct_type( + type_=DocumentsUpdateResponse, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def get_agents( + self, + documentation_id: str, + *, + cursor: typing.Optional[str] = None, + page_size: typing.Optional[int] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[GetKnowledgeBaseDependentAgentsResponseModel]: + """ + Get a list of agents depending on this knowledge base document + + Parameters + ---------- + documentation_id : str + The id of a document from the knowledge base. This is returned on document addition. + + cursor : typing.Optional[str] + Used for fetching next page. Cursor is returned in the response. + + page_size : typing.Optional[int] + How many documents to return at maximum. Can not exceed 100, defaults to 30. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[GetKnowledgeBaseDependentAgentsResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/convai/knowledge-base/{jsonable_encoder(documentation_id)}/dependent-agents", + base_url=self._client_wrapper.get_environment().base, + method="GET", + params={ + "cursor": cursor, + "page_size": page_size, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetKnowledgeBaseDependentAgentsResponseModel, + construct_type( + type_=GetKnowledgeBaseDependentAgentsResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def get_content( + self, documentation_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[None]: + """ + Get the entire content of a document from the knowledge base + + Parameters + ---------- + documentation_id : str + The id of a document from the knowledge base. This is returned on document addition. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[None] + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/convai/knowledge-base/{jsonable_encoder(documentation_id)}/content", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return HttpResponse(response=_response, data=None) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + +class AsyncRawDocumentsClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def create_from_url( + self, *, url: str, name: typing.Optional[str] = OMIT, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[AddKnowledgeBaseResponseModel]: + """ + Create a knowledge base document generated by scraping the given webpage. + + Parameters + ---------- + url : str + URL to a page of documentation that the agent will have access to in order to interact with users. + + name : typing.Optional[str] + A custom, human-readable name for the document. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[AddKnowledgeBaseResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + "v1/convai/knowledge-base/url", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "url": url, + "name": name, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + AddKnowledgeBaseResponseModel, + construct_type( + type_=AddKnowledgeBaseResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def create_from_file( + self, + *, + file: core.File, + name: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[AddKnowledgeBaseResponseModel]: + """ + Create a knowledge base document generated form the uploaded file. + + Parameters + ---------- + file : core.File + See core.File for more documentation + + name : typing.Optional[str] + A custom, human-readable name for the document. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[AddKnowledgeBaseResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + "v1/convai/knowledge-base/file", + base_url=self._client_wrapper.get_environment().base, + method="POST", + data={ + "name": name, + }, + files={ + "file": file, + }, + request_options=request_options, + omit=OMIT, + force_multipart=True, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + AddKnowledgeBaseResponseModel, + construct_type( + type_=AddKnowledgeBaseResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def create_from_text( + self, *, text: str, name: typing.Optional[str] = OMIT, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[AddKnowledgeBaseResponseModel]: + """ + Create a knowledge base document containing the provided text. + + Parameters + ---------- + text : str + Text content to be added to the knowledge base. + + name : typing.Optional[str] + A custom, human-readable name for the document. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[AddKnowledgeBaseResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + "v1/convai/knowledge-base/text", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "text": text, + "name": name, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + AddKnowledgeBaseResponseModel, + construct_type( + type_=AddKnowledgeBaseResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def get( + self, documentation_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[DocumentsGetResponse]: + """ + Get details about a specific documentation making up the agent's knowledge base + + Parameters + ---------- + documentation_id : str + The id of a document from the knowledge base. This is returned on document addition. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[DocumentsGetResponse] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/convai/knowledge-base/{jsonable_encoder(documentation_id)}", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + DocumentsGetResponse, + construct_type( + type_=DocumentsGetResponse, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def delete( + self, documentation_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[typing.Optional[typing.Any]]: + """ + Delete a document from the knowledge base + + Parameters + ---------- + documentation_id : str + The id of a document from the knowledge base. This is returned on document addition. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[typing.Optional[typing.Any]] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/convai/knowledge-base/{jsonable_encoder(documentation_id)}", + base_url=self._client_wrapper.get_environment().base, + method="DELETE", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + typing.Optional[typing.Any], + construct_type( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def update( + self, documentation_id: str, *, name: str, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[DocumentsUpdateResponse]: + """ + Update the name of a document + + Parameters + ---------- + documentation_id : str + The id of a document from the knowledge base. This is returned on document addition. + + name : str + A custom, human-readable name for the document. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[DocumentsUpdateResponse] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/convai/knowledge-base/{jsonable_encoder(documentation_id)}", + base_url=self._client_wrapper.get_environment().base, + method="PATCH", + json={ + "name": name, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + DocumentsUpdateResponse, + construct_type( + type_=DocumentsUpdateResponse, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def get_agents( + self, + documentation_id: str, + *, + cursor: typing.Optional[str] = None, + page_size: typing.Optional[int] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[GetKnowledgeBaseDependentAgentsResponseModel]: + """ + Get a list of agents depending on this knowledge base document + + Parameters + ---------- + documentation_id : str + The id of a document from the knowledge base. This is returned on document addition. + + cursor : typing.Optional[str] + Used for fetching next page. Cursor is returned in the response. + + page_size : typing.Optional[int] + How many documents to return at maximum. Can not exceed 100, defaults to 30. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[GetKnowledgeBaseDependentAgentsResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/convai/knowledge-base/{jsonable_encoder(documentation_id)}/dependent-agents", + base_url=self._client_wrapper.get_environment().base, + method="GET", + params={ + "cursor": cursor, + "page_size": page_size, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetKnowledgeBaseDependentAgentsResponseModel, + construct_type( + type_=GetKnowledgeBaseDependentAgentsResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def get_content( + self, documentation_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[None]: + """ + Get the entire content of a document from the knowledge base + + Parameters + ---------- + documentation_id : str + The id of a document from the knowledge base. This is returned on document addition. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[None] + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/convai/knowledge-base/{jsonable_encoder(documentation_id)}/content", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return AsyncHttpResponse(response=_response, data=None) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/elevenlabs/conversational_ai/knowledge_base/documents/types/__init__.py b/src/elevenlabs/conversational_ai/knowledge_base/documents/types/__init__.py new file mode 100644 index 00000000..0211b65c --- /dev/null +++ b/src/elevenlabs/conversational_ai/knowledge_base/documents/types/__init__.py @@ -0,0 +1,27 @@ +# This file was auto-generated by Fern from our API Definition. + +# isort: skip_file + +from .documents_get_response import ( + DocumentsGetResponse, + DocumentsGetResponse_File, + DocumentsGetResponse_Text, + DocumentsGetResponse_Url, +) +from .documents_update_response import ( + DocumentsUpdateResponse, + DocumentsUpdateResponse_File, + DocumentsUpdateResponse_Text, + DocumentsUpdateResponse_Url, +) + +__all__ = [ + "DocumentsGetResponse", + "DocumentsGetResponse_File", + "DocumentsGetResponse_Text", + "DocumentsGetResponse_Url", + "DocumentsUpdateResponse", + "DocumentsUpdateResponse_File", + "DocumentsUpdateResponse_Text", + "DocumentsUpdateResponse_Url", +] diff --git a/src/elevenlabs/conversational_ai/types/conversational_ai_update_knowledge_base_document_response.py b/src/elevenlabs/conversational_ai/knowledge_base/documents/types/documents_get_response.py similarity index 65% rename from src/elevenlabs/conversational_ai/types/conversational_ai_update_knowledge_base_document_response.py rename to src/elevenlabs/conversational_ai/knowledge_base/documents/types/documents_get_response.py index 8f1e0a55..2428ec50 100644 --- a/src/elevenlabs/conversational_ai/types/conversational_ai_update_knowledge_base_document_response.py +++ b/src/elevenlabs/conversational_ai/knowledge_base/documents/types/documents_get_response.py @@ -1,19 +1,18 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -from ...core.unchecked_base_model import UncheckedBaseModel + import typing -from ...types.knowledge_base_document_metadata_response_model import ( - KnowledgeBaseDocumentMetadataResponseModel, -) -from ...types.resource_access_info import ResourceAccessInfo -from ...core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic import typing_extensions -from ...core.unchecked_base_model import UnionMetadata +from .....core.pydantic_utilities import IS_PYDANTIC_V2 +from .....core.unchecked_base_model import UncheckedBaseModel, UnionMetadata +from .....types.knowledge_base_document_metadata_response_model import KnowledgeBaseDocumentMetadataResponseModel +from .....types.resource_access_info import ResourceAccessInfo -class ConversationalAiUpdateKnowledgeBaseDocumentResponse_Url(UncheckedBaseModel): +class DocumentsGetResponse_Url(UncheckedBaseModel): type: typing.Literal["url"] = "url" id: str name: str @@ -33,7 +32,7 @@ class Config: extra = pydantic.Extra.allow -class ConversationalAiUpdateKnowledgeBaseDocumentResponse_File(UncheckedBaseModel): +class DocumentsGetResponse_File(UncheckedBaseModel): type: typing.Literal["file"] = "file" id: str name: str @@ -52,7 +51,7 @@ class Config: extra = pydantic.Extra.allow -class ConversationalAiUpdateKnowledgeBaseDocumentResponse_Text(UncheckedBaseModel): +class DocumentsGetResponse_Text(UncheckedBaseModel): type: typing.Literal["text"] = "text" id: str name: str @@ -71,11 +70,7 @@ class Config: extra = pydantic.Extra.allow -ConversationalAiUpdateKnowledgeBaseDocumentResponse = typing_extensions.Annotated[ - typing.Union[ - ConversationalAiUpdateKnowledgeBaseDocumentResponse_Url, - ConversationalAiUpdateKnowledgeBaseDocumentResponse_File, - ConversationalAiUpdateKnowledgeBaseDocumentResponse_Text, - ], +DocumentsGetResponse = typing_extensions.Annotated[ + typing.Union[DocumentsGetResponse_Url, DocumentsGetResponse_File, DocumentsGetResponse_Text], UnionMetadata(discriminant="type"), ] diff --git a/src/elevenlabs/conversational_ai/types/conversational_ai_get_knowledge_base_document_by_id_response.py b/src/elevenlabs/conversational_ai/knowledge_base/documents/types/documents_update_response.py similarity index 65% rename from src/elevenlabs/conversational_ai/types/conversational_ai_get_knowledge_base_document_by_id_response.py rename to src/elevenlabs/conversational_ai/knowledge_base/documents/types/documents_update_response.py index 960d1155..563f8783 100644 --- a/src/elevenlabs/conversational_ai/types/conversational_ai_get_knowledge_base_document_by_id_response.py +++ b/src/elevenlabs/conversational_ai/knowledge_base/documents/types/documents_update_response.py @@ -1,19 +1,18 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -from ...core.unchecked_base_model import UncheckedBaseModel + import typing -from ...types.knowledge_base_document_metadata_response_model import ( - KnowledgeBaseDocumentMetadataResponseModel, -) -from ...types.resource_access_info import ResourceAccessInfo -from ...core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic import typing_extensions -from ...core.unchecked_base_model import UnionMetadata +from .....core.pydantic_utilities import IS_PYDANTIC_V2 +from .....core.unchecked_base_model import UncheckedBaseModel, UnionMetadata +from .....types.knowledge_base_document_metadata_response_model import KnowledgeBaseDocumentMetadataResponseModel +from .....types.resource_access_info import ResourceAccessInfo -class ConversationalAiGetKnowledgeBaseDocumentByIdResponse_Url(UncheckedBaseModel): +class DocumentsUpdateResponse_Url(UncheckedBaseModel): type: typing.Literal["url"] = "url" id: str name: str @@ -33,7 +32,7 @@ class Config: extra = pydantic.Extra.allow -class ConversationalAiGetKnowledgeBaseDocumentByIdResponse_File(UncheckedBaseModel): +class DocumentsUpdateResponse_File(UncheckedBaseModel): type: typing.Literal["file"] = "file" id: str name: str @@ -52,7 +51,7 @@ class Config: extra = pydantic.Extra.allow -class ConversationalAiGetKnowledgeBaseDocumentByIdResponse_Text(UncheckedBaseModel): +class DocumentsUpdateResponse_Text(UncheckedBaseModel): type: typing.Literal["text"] = "text" id: str name: str @@ -71,11 +70,7 @@ class Config: extra = pydantic.Extra.allow -ConversationalAiGetKnowledgeBaseDocumentByIdResponse = typing_extensions.Annotated[ - typing.Union[ - ConversationalAiGetKnowledgeBaseDocumentByIdResponse_Url, - ConversationalAiGetKnowledgeBaseDocumentByIdResponse_File, - ConversationalAiGetKnowledgeBaseDocumentByIdResponse_Text, - ], +DocumentsUpdateResponse = typing_extensions.Annotated[ + typing.Union[DocumentsUpdateResponse_Url, DocumentsUpdateResponse_File, DocumentsUpdateResponse_Text], UnionMetadata(discriminant="type"), ] diff --git a/src/elevenlabs/conversational_ai/knowledge_base/raw_client.py b/src/elevenlabs/conversational_ai/knowledge_base/raw_client.py new file mode 100644 index 00000000..1466c984 --- /dev/null +++ b/src/elevenlabs/conversational_ai/knowledge_base/raw_client.py @@ -0,0 +1,192 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ...core.api_error import ApiError +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ...core.http_response import AsyncHttpResponse, HttpResponse +from ...core.request_options import RequestOptions +from ...core.unchecked_base_model import construct_type +from ...errors.unprocessable_entity_error import UnprocessableEntityError +from ...types.get_knowledge_base_list_response_model import GetKnowledgeBaseListResponseModel +from ...types.http_validation_error import HttpValidationError +from ...types.knowledge_base_document_type import KnowledgeBaseDocumentType + + +class RawKnowledgeBaseClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def list( + self, + *, + cursor: typing.Optional[str] = None, + page_size: typing.Optional[int] = None, + search: typing.Optional[str] = None, + show_only_owned_documents: typing.Optional[bool] = None, + types: typing.Optional[ + typing.Union[KnowledgeBaseDocumentType, typing.Sequence[KnowledgeBaseDocumentType]] + ] = None, + use_typesense: typing.Optional[bool] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[GetKnowledgeBaseListResponseModel]: + """ + Get a list of available knowledge base documents + + Parameters + ---------- + cursor : typing.Optional[str] + Used for fetching next page. Cursor is returned in the response. + + page_size : typing.Optional[int] + How many documents to return at maximum. Can not exceed 100, defaults to 30. + + search : typing.Optional[str] + If specified, the endpoint returns only such knowledge base documents whose names start with this string. + + show_only_owned_documents : typing.Optional[bool] + If set to true, the endpoint will return only documents owned by you (and not shared from somebody else). + + types : typing.Optional[typing.Union[KnowledgeBaseDocumentType, typing.Sequence[KnowledgeBaseDocumentType]]] + If present, the endpoint will return only documents of the given types. + + use_typesense : typing.Optional[bool] + If set to true, the endpoint will use typesense DB to search for the documents). + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[GetKnowledgeBaseListResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + "v1/convai/knowledge-base", + base_url=self._client_wrapper.get_environment().base, + method="GET", + params={ + "cursor": cursor, + "page_size": page_size, + "search": search, + "show_only_owned_documents": show_only_owned_documents, + "types": types, + "use_typesense": use_typesense, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetKnowledgeBaseListResponseModel, + construct_type( + type_=GetKnowledgeBaseListResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + +class AsyncRawKnowledgeBaseClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def list( + self, + *, + cursor: typing.Optional[str] = None, + page_size: typing.Optional[int] = None, + search: typing.Optional[str] = None, + show_only_owned_documents: typing.Optional[bool] = None, + types: typing.Optional[ + typing.Union[KnowledgeBaseDocumentType, typing.Sequence[KnowledgeBaseDocumentType]] + ] = None, + use_typesense: typing.Optional[bool] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[GetKnowledgeBaseListResponseModel]: + """ + Get a list of available knowledge base documents + + Parameters + ---------- + cursor : typing.Optional[str] + Used for fetching next page. Cursor is returned in the response. + + page_size : typing.Optional[int] + How many documents to return at maximum. Can not exceed 100, defaults to 30. + + search : typing.Optional[str] + If specified, the endpoint returns only such knowledge base documents whose names start with this string. + + show_only_owned_documents : typing.Optional[bool] + If set to true, the endpoint will return only documents owned by you (and not shared from somebody else). + + types : typing.Optional[typing.Union[KnowledgeBaseDocumentType, typing.Sequence[KnowledgeBaseDocumentType]]] + If present, the endpoint will return only documents of the given types. + + use_typesense : typing.Optional[bool] + If set to true, the endpoint will use typesense DB to search for the documents). + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[GetKnowledgeBaseListResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + "v1/convai/knowledge-base", + base_url=self._client_wrapper.get_environment().base, + method="GET", + params={ + "cursor": cursor, + "page_size": page_size, + "search": search, + "show_only_owned_documents": show_only_owned_documents, + "types": types, + "use_typesense": use_typesense, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetKnowledgeBaseListResponseModel, + construct_type( + type_=GetKnowledgeBaseListResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/elevenlabs/conversational_ai/phone_numbers/__init__.py b/src/elevenlabs/conversational_ai/phone_numbers/__init__.py new file mode 100644 index 00000000..04b7908f --- /dev/null +++ b/src/elevenlabs/conversational_ai/phone_numbers/__init__.py @@ -0,0 +1,33 @@ +# This file was auto-generated by Fern from our API Definition. + +# isort: skip_file + +from .types import ( + PhoneNumbersCreateRequestBody, + PhoneNumbersCreateRequestBody_SipTrunk, + PhoneNumbersCreateRequestBody_Twilio, + PhoneNumbersGetResponse, + PhoneNumbersGetResponse_SipTrunk, + PhoneNumbersGetResponse_Twilio, + PhoneNumbersListResponseItem, + PhoneNumbersListResponseItem_SipTrunk, + PhoneNumbersListResponseItem_Twilio, + PhoneNumbersUpdateResponse, + PhoneNumbersUpdateResponse_SipTrunk, + PhoneNumbersUpdateResponse_Twilio, +) + +__all__ = [ + "PhoneNumbersCreateRequestBody", + "PhoneNumbersCreateRequestBody_SipTrunk", + "PhoneNumbersCreateRequestBody_Twilio", + "PhoneNumbersGetResponse", + "PhoneNumbersGetResponse_SipTrunk", + "PhoneNumbersGetResponse_Twilio", + "PhoneNumbersListResponseItem", + "PhoneNumbersListResponseItem_SipTrunk", + "PhoneNumbersListResponseItem_Twilio", + "PhoneNumbersUpdateResponse", + "PhoneNumbersUpdateResponse_SipTrunk", + "PhoneNumbersUpdateResponse_Twilio", +] diff --git a/src/elevenlabs/conversational_ai/phone_numbers/client.py b/src/elevenlabs/conversational_ai/phone_numbers/client.py new file mode 100644 index 00000000..96b50bbc --- /dev/null +++ b/src/elevenlabs/conversational_ai/phone_numbers/client.py @@ -0,0 +1,433 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ...core.request_options import RequestOptions +from ...types.create_phone_number_response_model import CreatePhoneNumberResponseModel +from .raw_client import AsyncRawPhoneNumbersClient, RawPhoneNumbersClient +from .types.phone_numbers_create_request_body import PhoneNumbersCreateRequestBody +from .types.phone_numbers_get_response import PhoneNumbersGetResponse +from .types.phone_numbers_list_response_item import PhoneNumbersListResponseItem +from .types.phone_numbers_update_response import PhoneNumbersUpdateResponse + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class PhoneNumbersClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._raw_client = RawPhoneNumbersClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawPhoneNumbersClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawPhoneNumbersClient + """ + return self._raw_client + + def create( + self, *, request: PhoneNumbersCreateRequestBody, request_options: typing.Optional[RequestOptions] = None + ) -> CreatePhoneNumberResponseModel: + """ + Import Phone Number from provider configuration (Twilio or SIP trunk) + + Parameters + ---------- + request : PhoneNumbersCreateRequestBody + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + CreatePhoneNumberResponseModel + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + from elevenlabs.conversational_ai.phone_numbers import ( + PhoneNumbersCreateRequestBody_Twilio, + ) + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.conversational_ai.phone_numbers.create( + request=PhoneNumbersCreateRequestBody_Twilio( + phone_number="phone_number", + label="label", + sid="sid", + token="token", + ), + ) + """ + _response = self._raw_client.create(request=request, request_options=request_options) + return _response.data + + def get( + self, phone_number_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> PhoneNumbersGetResponse: + """ + Retrieve Phone Number details by ID + + Parameters + ---------- + phone_number_id : str + The id of an agent. This is returned on agent creation. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + PhoneNumbersGetResponse + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.conversational_ai.phone_numbers.get( + phone_number_id="TeaqRRdTcIfIu2i7BYfT", + ) + """ + _response = self._raw_client.get(phone_number_id, request_options=request_options) + return _response.data + + def delete( + self, phone_number_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> typing.Optional[typing.Any]: + """ + Delete Phone Number by ID + + Parameters + ---------- + phone_number_id : str + The id of an agent. This is returned on agent creation. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + typing.Optional[typing.Any] + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.conversational_ai.phone_numbers.delete( + phone_number_id="TeaqRRdTcIfIu2i7BYfT", + ) + """ + _response = self._raw_client.delete(phone_number_id, request_options=request_options) + return _response.data + + def update( + self, + phone_number_id: str, + *, + agent_id: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> PhoneNumbersUpdateResponse: + """ + Update Phone Number details by ID + + Parameters + ---------- + phone_number_id : str + The id of an agent. This is returned on agent creation. + + agent_id : typing.Optional[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + PhoneNumbersUpdateResponse + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.conversational_ai.phone_numbers.update( + phone_number_id="TeaqRRdTcIfIu2i7BYfT", + ) + """ + _response = self._raw_client.update(phone_number_id, agent_id=agent_id, request_options=request_options) + return _response.data + + def list( + self, *, request_options: typing.Optional[RequestOptions] = None + ) -> typing.List[PhoneNumbersListResponseItem]: + """ + Retrieve all Phone Numbers + + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + typing.List[PhoneNumbersListResponseItem] + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.conversational_ai.phone_numbers.list() + """ + _response = self._raw_client.list(request_options=request_options) + return _response.data + + +class AsyncPhoneNumbersClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawPhoneNumbersClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawPhoneNumbersClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawPhoneNumbersClient + """ + return self._raw_client + + async def create( + self, *, request: PhoneNumbersCreateRequestBody, request_options: typing.Optional[RequestOptions] = None + ) -> CreatePhoneNumberResponseModel: + """ + Import Phone Number from provider configuration (Twilio or SIP trunk) + + Parameters + ---------- + request : PhoneNumbersCreateRequestBody + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + CreatePhoneNumberResponseModel + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + from elevenlabs.conversational_ai.phone_numbers import ( + PhoneNumbersCreateRequestBody_Twilio, + ) + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.conversational_ai.phone_numbers.create( + request=PhoneNumbersCreateRequestBody_Twilio( + phone_number="phone_number", + label="label", + sid="sid", + token="token", + ), + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.create(request=request, request_options=request_options) + return _response.data + + async def get( + self, phone_number_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> PhoneNumbersGetResponse: + """ + Retrieve Phone Number details by ID + + Parameters + ---------- + phone_number_id : str + The id of an agent. This is returned on agent creation. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + PhoneNumbersGetResponse + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.conversational_ai.phone_numbers.get( + phone_number_id="TeaqRRdTcIfIu2i7BYfT", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.get(phone_number_id, request_options=request_options) + return _response.data + + async def delete( + self, phone_number_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> typing.Optional[typing.Any]: + """ + Delete Phone Number by ID + + Parameters + ---------- + phone_number_id : str + The id of an agent. This is returned on agent creation. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + typing.Optional[typing.Any] + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.conversational_ai.phone_numbers.delete( + phone_number_id="TeaqRRdTcIfIu2i7BYfT", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.delete(phone_number_id, request_options=request_options) + return _response.data + + async def update( + self, + phone_number_id: str, + *, + agent_id: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> PhoneNumbersUpdateResponse: + """ + Update Phone Number details by ID + + Parameters + ---------- + phone_number_id : str + The id of an agent. This is returned on agent creation. + + agent_id : typing.Optional[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + PhoneNumbersUpdateResponse + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.conversational_ai.phone_numbers.update( + phone_number_id="TeaqRRdTcIfIu2i7BYfT", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.update(phone_number_id, agent_id=agent_id, request_options=request_options) + return _response.data + + async def list( + self, *, request_options: typing.Optional[RequestOptions] = None + ) -> typing.List[PhoneNumbersListResponseItem]: + """ + Retrieve all Phone Numbers + + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + typing.List[PhoneNumbersListResponseItem] + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.conversational_ai.phone_numbers.list() + + + asyncio.run(main()) + """ + _response = await self._raw_client.list(request_options=request_options) + return _response.data diff --git a/src/elevenlabs/conversational_ai/phone_numbers/raw_client.py b/src/elevenlabs/conversational_ai/phone_numbers/raw_client.py new file mode 100644 index 00000000..7f3c8187 --- /dev/null +++ b/src/elevenlabs/conversational_ai/phone_numbers/raw_client.py @@ -0,0 +1,574 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ...core.api_error import ApiError +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ...core.http_response import AsyncHttpResponse, HttpResponse +from ...core.jsonable_encoder import jsonable_encoder +from ...core.request_options import RequestOptions +from ...core.serialization import convert_and_respect_annotation_metadata +from ...core.unchecked_base_model import construct_type +from ...errors.unprocessable_entity_error import UnprocessableEntityError +from ...types.create_phone_number_response_model import CreatePhoneNumberResponseModel +from ...types.http_validation_error import HttpValidationError +from .types.phone_numbers_create_request_body import PhoneNumbersCreateRequestBody +from .types.phone_numbers_get_response import PhoneNumbersGetResponse +from .types.phone_numbers_list_response_item import PhoneNumbersListResponseItem +from .types.phone_numbers_update_response import PhoneNumbersUpdateResponse + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RawPhoneNumbersClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def create( + self, *, request: PhoneNumbersCreateRequestBody, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[CreatePhoneNumberResponseModel]: + """ + Import Phone Number from provider configuration (Twilio or SIP trunk) + + Parameters + ---------- + request : PhoneNumbersCreateRequestBody + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[CreatePhoneNumberResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + "v1/convai/phone-numbers/create", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json=convert_and_respect_annotation_metadata( + object_=request, annotation=PhoneNumbersCreateRequestBody, direction="write" + ), + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + CreatePhoneNumberResponseModel, + construct_type( + type_=CreatePhoneNumberResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def get( + self, phone_number_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[PhoneNumbersGetResponse]: + """ + Retrieve Phone Number details by ID + + Parameters + ---------- + phone_number_id : str + The id of an agent. This is returned on agent creation. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[PhoneNumbersGetResponse] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/convai/phone-numbers/{jsonable_encoder(phone_number_id)}", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + PhoneNumbersGetResponse, + construct_type( + type_=PhoneNumbersGetResponse, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def delete( + self, phone_number_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[typing.Optional[typing.Any]]: + """ + Delete Phone Number by ID + + Parameters + ---------- + phone_number_id : str + The id of an agent. This is returned on agent creation. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[typing.Optional[typing.Any]] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/convai/phone-numbers/{jsonable_encoder(phone_number_id)}", + base_url=self._client_wrapper.get_environment().base, + method="DELETE", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + typing.Optional[typing.Any], + construct_type( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def update( + self, + phone_number_id: str, + *, + agent_id: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[PhoneNumbersUpdateResponse]: + """ + Update Phone Number details by ID + + Parameters + ---------- + phone_number_id : str + The id of an agent. This is returned on agent creation. + + agent_id : typing.Optional[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[PhoneNumbersUpdateResponse] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/convai/phone-numbers/{jsonable_encoder(phone_number_id)}", + base_url=self._client_wrapper.get_environment().base, + method="PATCH", + json={ + "agent_id": agent_id, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + PhoneNumbersUpdateResponse, + construct_type( + type_=PhoneNumbersUpdateResponse, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def list( + self, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[typing.List[PhoneNumbersListResponseItem]]: + """ + Retrieve all Phone Numbers + + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[typing.List[PhoneNumbersListResponseItem]] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + "v1/convai/phone-numbers/", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + typing.List[PhoneNumbersListResponseItem], + construct_type( + type_=typing.List[PhoneNumbersListResponseItem], # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + +class AsyncRawPhoneNumbersClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def create( + self, *, request: PhoneNumbersCreateRequestBody, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[CreatePhoneNumberResponseModel]: + """ + Import Phone Number from provider configuration (Twilio or SIP trunk) + + Parameters + ---------- + request : PhoneNumbersCreateRequestBody + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[CreatePhoneNumberResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + "v1/convai/phone-numbers/create", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json=convert_and_respect_annotation_metadata( + object_=request, annotation=PhoneNumbersCreateRequestBody, direction="write" + ), + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + CreatePhoneNumberResponseModel, + construct_type( + type_=CreatePhoneNumberResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def get( + self, phone_number_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[PhoneNumbersGetResponse]: + """ + Retrieve Phone Number details by ID + + Parameters + ---------- + phone_number_id : str + The id of an agent. This is returned on agent creation. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[PhoneNumbersGetResponse] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/convai/phone-numbers/{jsonable_encoder(phone_number_id)}", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + PhoneNumbersGetResponse, + construct_type( + type_=PhoneNumbersGetResponse, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def delete( + self, phone_number_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[typing.Optional[typing.Any]]: + """ + Delete Phone Number by ID + + Parameters + ---------- + phone_number_id : str + The id of an agent. This is returned on agent creation. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[typing.Optional[typing.Any]] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/convai/phone-numbers/{jsonable_encoder(phone_number_id)}", + base_url=self._client_wrapper.get_environment().base, + method="DELETE", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + typing.Optional[typing.Any], + construct_type( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def update( + self, + phone_number_id: str, + *, + agent_id: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[PhoneNumbersUpdateResponse]: + """ + Update Phone Number details by ID + + Parameters + ---------- + phone_number_id : str + The id of an agent. This is returned on agent creation. + + agent_id : typing.Optional[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[PhoneNumbersUpdateResponse] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/convai/phone-numbers/{jsonable_encoder(phone_number_id)}", + base_url=self._client_wrapper.get_environment().base, + method="PATCH", + json={ + "agent_id": agent_id, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + PhoneNumbersUpdateResponse, + construct_type( + type_=PhoneNumbersUpdateResponse, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def list( + self, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[typing.List[PhoneNumbersListResponseItem]]: + """ + Retrieve all Phone Numbers + + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[typing.List[PhoneNumbersListResponseItem]] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + "v1/convai/phone-numbers/", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + typing.List[PhoneNumbersListResponseItem], + construct_type( + type_=typing.List[PhoneNumbersListResponseItem], # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/elevenlabs/conversational_ai/phone_numbers/types/__init__.py b/src/elevenlabs/conversational_ai/phone_numbers/types/__init__.py new file mode 100644 index 00000000..88a11dcb --- /dev/null +++ b/src/elevenlabs/conversational_ai/phone_numbers/types/__init__.py @@ -0,0 +1,39 @@ +# This file was auto-generated by Fern from our API Definition. + +# isort: skip_file + +from .phone_numbers_create_request_body import ( + PhoneNumbersCreateRequestBody, + PhoneNumbersCreateRequestBody_SipTrunk, + PhoneNumbersCreateRequestBody_Twilio, +) +from .phone_numbers_get_response import ( + PhoneNumbersGetResponse, + PhoneNumbersGetResponse_SipTrunk, + PhoneNumbersGetResponse_Twilio, +) +from .phone_numbers_list_response_item import ( + PhoneNumbersListResponseItem, + PhoneNumbersListResponseItem_SipTrunk, + PhoneNumbersListResponseItem_Twilio, +) +from .phone_numbers_update_response import ( + PhoneNumbersUpdateResponse, + PhoneNumbersUpdateResponse_SipTrunk, + PhoneNumbersUpdateResponse_Twilio, +) + +__all__ = [ + "PhoneNumbersCreateRequestBody", + "PhoneNumbersCreateRequestBody_SipTrunk", + "PhoneNumbersCreateRequestBody_Twilio", + "PhoneNumbersGetResponse", + "PhoneNumbersGetResponse_SipTrunk", + "PhoneNumbersGetResponse_Twilio", + "PhoneNumbersListResponseItem", + "PhoneNumbersListResponseItem_SipTrunk", + "PhoneNumbersListResponseItem_Twilio", + "PhoneNumbersUpdateResponse", + "PhoneNumbersUpdateResponse_SipTrunk", + "PhoneNumbersUpdateResponse_Twilio", +] diff --git a/src/elevenlabs/conversational_ai/types/conversational_ai_create_phone_number_request_body.py b/src/elevenlabs/conversational_ai/phone_numbers/types/phone_numbers_create_request_body.py similarity index 65% rename from src/elevenlabs/conversational_ai/types/conversational_ai_create_phone_number_request_body.py rename to src/elevenlabs/conversational_ai/phone_numbers/types/phone_numbers_create_request_body.py index 55000873..00580048 100644 --- a/src/elevenlabs/conversational_ai/types/conversational_ai_create_phone_number_request_body.py +++ b/src/elevenlabs/conversational_ai/phone_numbers/types/phone_numbers_create_request_body.py @@ -1,18 +1,19 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -from ...core.unchecked_base_model import UncheckedBaseModel + import typing -from ...core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic -from ...types.sip_trunk_transport_enum import SipTrunkTransportEnum -from ...types.sip_media_encryption_enum import SipMediaEncryptionEnum -from ...types.sip_trunk_credentials import SipTrunkCredentials import typing_extensions -from ...core.unchecked_base_model import UnionMetadata +from ....core.pydantic_utilities import IS_PYDANTIC_V2 +from ....core.unchecked_base_model import UncheckedBaseModel, UnionMetadata +from ....types.sip_media_encryption_enum import SipMediaEncryptionEnum +from ....types.sip_trunk_credentials import SipTrunkCredentials +from ....types.sip_trunk_transport_enum import SipTrunkTransportEnum -class ConversationalAiCreatePhoneNumberRequestBody_Twilio(UncheckedBaseModel): +class PhoneNumbersCreateRequestBody_Twilio(UncheckedBaseModel): """ Create Phone Request Information """ @@ -33,7 +34,7 @@ class Config: extra = pydantic.Extra.allow -class ConversationalAiCreatePhoneNumberRequestBody_SipTrunk(UncheckedBaseModel): +class PhoneNumbersCreateRequestBody_SipTrunk(UncheckedBaseModel): """ Create Phone Request Information """ @@ -58,10 +59,7 @@ class Config: extra = pydantic.Extra.allow -ConversationalAiCreatePhoneNumberRequestBody = typing_extensions.Annotated[ - typing.Union[ - ConversationalAiCreatePhoneNumberRequestBody_Twilio, - ConversationalAiCreatePhoneNumberRequestBody_SipTrunk, - ], +PhoneNumbersCreateRequestBody = typing_extensions.Annotated[ + typing.Union[PhoneNumbersCreateRequestBody_Twilio, PhoneNumbersCreateRequestBody_SipTrunk], UnionMetadata(discriminant="provider"), ] diff --git a/src/elevenlabs/conversational_ai/types/conversational_ai_get_phone_number_response.py b/src/elevenlabs/conversational_ai/phone_numbers/types/phone_numbers_get_response.py similarity index 64% rename from src/elevenlabs/conversational_ai/types/conversational_ai_get_phone_number_response.py rename to src/elevenlabs/conversational_ai/phone_numbers/types/phone_numbers_get_response.py index c4e43591..18c84731 100644 --- a/src/elevenlabs/conversational_ai/types/conversational_ai_get_phone_number_response.py +++ b/src/elevenlabs/conversational_ai/phone_numbers/types/phone_numbers_get_response.py @@ -1,17 +1,18 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -from ...core.unchecked_base_model import UncheckedBaseModel + import typing -from ...types.phone_number_agent_info import PhoneNumberAgentInfo -from ...core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic -from ...types.sip_trunk_config_response_model import SipTrunkConfigResponseModel import typing_extensions -from ...core.unchecked_base_model import UnionMetadata +from ....core.pydantic_utilities import IS_PYDANTIC_V2 +from ....core.unchecked_base_model import UncheckedBaseModel, UnionMetadata +from ....types.phone_number_agent_info import PhoneNumberAgentInfo +from ....types.sip_trunk_config_response_model import SipTrunkConfigResponseModel -class ConversationalAiGetPhoneNumberResponse_Twilio(UncheckedBaseModel): +class PhoneNumbersGetResponse_Twilio(UncheckedBaseModel): provider: typing.Literal["twilio"] = "twilio" phone_number: str label: str @@ -28,7 +29,7 @@ class Config: extra = pydantic.Extra.allow -class ConversationalAiGetPhoneNumberResponse_SipTrunk(UncheckedBaseModel): +class PhoneNumbersGetResponse_SipTrunk(UncheckedBaseModel): provider: typing.Literal["sip_trunk"] = "sip_trunk" phone_number: str label: str @@ -46,10 +47,7 @@ class Config: extra = pydantic.Extra.allow -ConversationalAiGetPhoneNumberResponse = typing_extensions.Annotated[ - typing.Union[ - ConversationalAiGetPhoneNumberResponse_Twilio, - ConversationalAiGetPhoneNumberResponse_SipTrunk, - ], +PhoneNumbersGetResponse = typing_extensions.Annotated[ + typing.Union[PhoneNumbersGetResponse_Twilio, PhoneNumbersGetResponse_SipTrunk], UnionMetadata(discriminant="provider"), ] diff --git a/src/elevenlabs/conversational_ai/types/conversational_ai_update_phone_number_response.py b/src/elevenlabs/conversational_ai/phone_numbers/types/phone_numbers_list_response_item.py similarity index 64% rename from src/elevenlabs/conversational_ai/types/conversational_ai_update_phone_number_response.py rename to src/elevenlabs/conversational_ai/phone_numbers/types/phone_numbers_list_response_item.py index 7354cddd..78dce652 100644 --- a/src/elevenlabs/conversational_ai/types/conversational_ai_update_phone_number_response.py +++ b/src/elevenlabs/conversational_ai/phone_numbers/types/phone_numbers_list_response_item.py @@ -1,17 +1,18 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -from ...core.unchecked_base_model import UncheckedBaseModel + import typing -from ...types.phone_number_agent_info import PhoneNumberAgentInfo -from ...core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic -from ...types.sip_trunk_config_response_model import SipTrunkConfigResponseModel import typing_extensions -from ...core.unchecked_base_model import UnionMetadata +from ....core.pydantic_utilities import IS_PYDANTIC_V2 +from ....core.unchecked_base_model import UncheckedBaseModel, UnionMetadata +from ....types.phone_number_agent_info import PhoneNumberAgentInfo +from ....types.sip_trunk_config_response_model import SipTrunkConfigResponseModel -class ConversationalAiUpdatePhoneNumberResponse_Twilio(UncheckedBaseModel): +class PhoneNumbersListResponseItem_Twilio(UncheckedBaseModel): provider: typing.Literal["twilio"] = "twilio" phone_number: str label: str @@ -28,7 +29,7 @@ class Config: extra = pydantic.Extra.allow -class ConversationalAiUpdatePhoneNumberResponse_SipTrunk(UncheckedBaseModel): +class PhoneNumbersListResponseItem_SipTrunk(UncheckedBaseModel): provider: typing.Literal["sip_trunk"] = "sip_trunk" phone_number: str label: str @@ -46,10 +47,7 @@ class Config: extra = pydantic.Extra.allow -ConversationalAiUpdatePhoneNumberResponse = typing_extensions.Annotated[ - typing.Union[ - ConversationalAiUpdatePhoneNumberResponse_Twilio, - ConversationalAiUpdatePhoneNumberResponse_SipTrunk, - ], +PhoneNumbersListResponseItem = typing_extensions.Annotated[ + typing.Union[PhoneNumbersListResponseItem_Twilio, PhoneNumbersListResponseItem_SipTrunk], UnionMetadata(discriminant="provider"), ] diff --git a/src/elevenlabs/conversational_ai/types/conversational_ai_get_phone_numbers_response_item.py b/src/elevenlabs/conversational_ai/phone_numbers/types/phone_numbers_update_response.py similarity index 63% rename from src/elevenlabs/conversational_ai/types/conversational_ai_get_phone_numbers_response_item.py rename to src/elevenlabs/conversational_ai/phone_numbers/types/phone_numbers_update_response.py index 95133628..bd57ad95 100644 --- a/src/elevenlabs/conversational_ai/types/conversational_ai_get_phone_numbers_response_item.py +++ b/src/elevenlabs/conversational_ai/phone_numbers/types/phone_numbers_update_response.py @@ -1,17 +1,18 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -from ...core.unchecked_base_model import UncheckedBaseModel + import typing -from ...types.phone_number_agent_info import PhoneNumberAgentInfo -from ...core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic -from ...types.sip_trunk_config_response_model import SipTrunkConfigResponseModel import typing_extensions -from ...core.unchecked_base_model import UnionMetadata +from ....core.pydantic_utilities import IS_PYDANTIC_V2 +from ....core.unchecked_base_model import UncheckedBaseModel, UnionMetadata +from ....types.phone_number_agent_info import PhoneNumberAgentInfo +from ....types.sip_trunk_config_response_model import SipTrunkConfigResponseModel -class ConversationalAiGetPhoneNumbersResponseItem_Twilio(UncheckedBaseModel): +class PhoneNumbersUpdateResponse_Twilio(UncheckedBaseModel): provider: typing.Literal["twilio"] = "twilio" phone_number: str label: str @@ -28,7 +29,7 @@ class Config: extra = pydantic.Extra.allow -class ConversationalAiGetPhoneNumbersResponseItem_SipTrunk(UncheckedBaseModel): +class PhoneNumbersUpdateResponse_SipTrunk(UncheckedBaseModel): provider: typing.Literal["sip_trunk"] = "sip_trunk" phone_number: str label: str @@ -46,10 +47,7 @@ class Config: extra = pydantic.Extra.allow -ConversationalAiGetPhoneNumbersResponseItem = typing_extensions.Annotated[ - typing.Union[ - ConversationalAiGetPhoneNumbersResponseItem_Twilio, - ConversationalAiGetPhoneNumbersResponseItem_SipTrunk, - ], +PhoneNumbersUpdateResponse = typing_extensions.Annotated[ + typing.Union[PhoneNumbersUpdateResponse_Twilio, PhoneNumbersUpdateResponse_SipTrunk], UnionMetadata(discriminant="provider"), ] diff --git a/src/elevenlabs/conversational_ai/raw_client.py b/src/elevenlabs/conversational_ai/raw_client.py new file mode 100644 index 00000000..ec243cb0 --- /dev/null +++ b/src/elevenlabs/conversational_ai/raw_client.py @@ -0,0 +1,297 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from .. import core +from ..core.api_error import ApiError +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ..core.http_response import AsyncHttpResponse, HttpResponse +from ..core.jsonable_encoder import jsonable_encoder +from ..core.request_options import RequestOptions +from ..core.unchecked_base_model import construct_type +from ..errors.unprocessable_entity_error import UnprocessableEntityError +from ..types.add_knowledge_base_response_model import AddKnowledgeBaseResponseModel +from ..types.http_validation_error import HttpValidationError +from ..types.post_workspace_secret_response_model import PostWorkspaceSecretResponseModel + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RawConversationalAiClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def add_to_knowledge_base( + self, + *, + name: typing.Optional[str] = OMIT, + url: typing.Optional[str] = OMIT, + file: typing.Optional[core.File] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[AddKnowledgeBaseResponseModel]: + """ + Upload a file or webpage URL to create a knowledge base document.
After creating the document, update the agent's knowledge base by calling [Update agent](/docs/conversational-ai/api-reference/agents/update-agent). + + Parameters + ---------- + name : typing.Optional[str] + A custom, human-readable name for the document. + + url : typing.Optional[str] + URL to a page of documentation that the agent will have access to in order to interact with users. + + file : typing.Optional[core.File] + See core.File for more documentation + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[AddKnowledgeBaseResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + "v1/convai/knowledge-base", + base_url=self._client_wrapper.get_environment().base, + method="POST", + data={ + "name": name, + "url": url, + }, + files={ + **({"file": file} if file is not None else {}), + }, + request_options=request_options, + omit=OMIT, + force_multipart=True, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + AddKnowledgeBaseResponseModel, + construct_type( + type_=AddKnowledgeBaseResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def update_secret( + self, secret_id: str, *, name: str, value: str, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[PostWorkspaceSecretResponseModel]: + """ + Update an existing secret for the workspace + + Parameters + ---------- + secret_id : str + + name : str + + value : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[PostWorkspaceSecretResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/convai/secrets/{jsonable_encoder(secret_id)}", + base_url=self._client_wrapper.get_environment().base, + method="PATCH", + json={ + "name": name, + "value": value, + "type": "update", + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + PostWorkspaceSecretResponseModel, + construct_type( + type_=PostWorkspaceSecretResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + +class AsyncRawConversationalAiClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def add_to_knowledge_base( + self, + *, + name: typing.Optional[str] = OMIT, + url: typing.Optional[str] = OMIT, + file: typing.Optional[core.File] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[AddKnowledgeBaseResponseModel]: + """ + Upload a file or webpage URL to create a knowledge base document.
After creating the document, update the agent's knowledge base by calling [Update agent](/docs/conversational-ai/api-reference/agents/update-agent). + + Parameters + ---------- + name : typing.Optional[str] + A custom, human-readable name for the document. + + url : typing.Optional[str] + URL to a page of documentation that the agent will have access to in order to interact with users. + + file : typing.Optional[core.File] + See core.File for more documentation + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[AddKnowledgeBaseResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + "v1/convai/knowledge-base", + base_url=self._client_wrapper.get_environment().base, + method="POST", + data={ + "name": name, + "url": url, + }, + files={ + **({"file": file} if file is not None else {}), + }, + request_options=request_options, + omit=OMIT, + force_multipart=True, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + AddKnowledgeBaseResponseModel, + construct_type( + type_=AddKnowledgeBaseResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def update_secret( + self, secret_id: str, *, name: str, value: str, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[PostWorkspaceSecretResponseModel]: + """ + Update an existing secret for the workspace + + Parameters + ---------- + secret_id : str + + name : str + + value : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[PostWorkspaceSecretResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/convai/secrets/{jsonable_encoder(secret_id)}", + base_url=self._client_wrapper.get_environment().base, + method="PATCH", + json={ + "name": name, + "value": value, + "type": "update", + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + PostWorkspaceSecretResponseModel, + construct_type( + type_=PostWorkspaceSecretResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/elevenlabs/conversational_ai/secrets/__init__.py b/src/elevenlabs/conversational_ai/secrets/__init__.py new file mode 100644 index 00000000..5cde0202 --- /dev/null +++ b/src/elevenlabs/conversational_ai/secrets/__init__.py @@ -0,0 +1,4 @@ +# This file was auto-generated by Fern from our API Definition. + +# isort: skip_file + diff --git a/src/elevenlabs/conversational_ai/secrets/client.py b/src/elevenlabs/conversational_ai/secrets/client.py new file mode 100644 index 00000000..69aff87c --- /dev/null +++ b/src/elevenlabs/conversational_ai/secrets/client.py @@ -0,0 +1,250 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ...core.request_options import RequestOptions +from ...types.get_workspace_secrets_response_model import GetWorkspaceSecretsResponseModel +from ...types.post_workspace_secret_response_model import PostWorkspaceSecretResponseModel +from .raw_client import AsyncRawSecretsClient, RawSecretsClient + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class SecretsClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._raw_client = RawSecretsClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawSecretsClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawSecretsClient + """ + return self._raw_client + + def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> GetWorkspaceSecretsResponseModel: + """ + Get all workspace secrets for the user + + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + GetWorkspaceSecretsResponseModel + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.conversational_ai.secrets.list() + """ + _response = self._raw_client.list(request_options=request_options) + return _response.data + + def create( + self, *, name: str, value: str, request_options: typing.Optional[RequestOptions] = None + ) -> PostWorkspaceSecretResponseModel: + """ + Create a new secret for the workspace + + Parameters + ---------- + name : str + + value : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + PostWorkspaceSecretResponseModel + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.conversational_ai.secrets.create( + name="name", + value="value", + ) + """ + _response = self._raw_client.create(name=name, value=value, request_options=request_options) + return _response.data + + def delete(self, secret_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None: + """ + Delete a workspace secret if it's not in use + + Parameters + ---------- + secret_id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + None + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.conversational_ai.secrets.delete( + secret_id="secret_id", + ) + """ + _response = self._raw_client.delete(secret_id, request_options=request_options) + return _response.data + + +class AsyncSecretsClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawSecretsClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawSecretsClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawSecretsClient + """ + return self._raw_client + + async def list( + self, *, request_options: typing.Optional[RequestOptions] = None + ) -> GetWorkspaceSecretsResponseModel: + """ + Get all workspace secrets for the user + + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + GetWorkspaceSecretsResponseModel + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.conversational_ai.secrets.list() + + + asyncio.run(main()) + """ + _response = await self._raw_client.list(request_options=request_options) + return _response.data + + async def create( + self, *, name: str, value: str, request_options: typing.Optional[RequestOptions] = None + ) -> PostWorkspaceSecretResponseModel: + """ + Create a new secret for the workspace + + Parameters + ---------- + name : str + + value : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + PostWorkspaceSecretResponseModel + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.conversational_ai.secrets.create( + name="name", + value="value", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.create(name=name, value=value, request_options=request_options) + return _response.data + + async def delete(self, secret_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None: + """ + Delete a workspace secret if it's not in use + + Parameters + ---------- + secret_id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + None + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.conversational_ai.secrets.delete( + secret_id="secret_id", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.delete(secret_id, request_options=request_options) + return _response.data diff --git a/src/elevenlabs/conversational_ai/secrets/raw_client.py b/src/elevenlabs/conversational_ai/secrets/raw_client.py new file mode 100644 index 00000000..c2967fe6 --- /dev/null +++ b/src/elevenlabs/conversational_ai/secrets/raw_client.py @@ -0,0 +1,328 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ...core.api_error import ApiError +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ...core.http_response import AsyncHttpResponse, HttpResponse +from ...core.jsonable_encoder import jsonable_encoder +from ...core.request_options import RequestOptions +from ...core.unchecked_base_model import construct_type +from ...errors.unprocessable_entity_error import UnprocessableEntityError +from ...types.get_workspace_secrets_response_model import GetWorkspaceSecretsResponseModel +from ...types.http_validation_error import HttpValidationError +from ...types.post_workspace_secret_response_model import PostWorkspaceSecretResponseModel + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RawSecretsClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def list( + self, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[GetWorkspaceSecretsResponseModel]: + """ + Get all workspace secrets for the user + + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[GetWorkspaceSecretsResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + "v1/convai/secrets", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetWorkspaceSecretsResponseModel, + construct_type( + type_=GetWorkspaceSecretsResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def create( + self, *, name: str, value: str, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[PostWorkspaceSecretResponseModel]: + """ + Create a new secret for the workspace + + Parameters + ---------- + name : str + + value : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[PostWorkspaceSecretResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + "v1/convai/secrets", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "name": name, + "value": value, + "type": "new", + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + PostWorkspaceSecretResponseModel, + construct_type( + type_=PostWorkspaceSecretResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def delete(self, secret_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> HttpResponse[None]: + """ + Delete a workspace secret if it's not in use + + Parameters + ---------- + secret_id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[None] + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/convai/secrets/{jsonable_encoder(secret_id)}", + base_url=self._client_wrapper.get_environment().base, + method="DELETE", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return HttpResponse(response=_response, data=None) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + +class AsyncRawSecretsClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def list( + self, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[GetWorkspaceSecretsResponseModel]: + """ + Get all workspace secrets for the user + + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[GetWorkspaceSecretsResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + "v1/convai/secrets", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetWorkspaceSecretsResponseModel, + construct_type( + type_=GetWorkspaceSecretsResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def create( + self, *, name: str, value: str, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[PostWorkspaceSecretResponseModel]: + """ + Create a new secret for the workspace + + Parameters + ---------- + name : str + + value : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[PostWorkspaceSecretResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + "v1/convai/secrets", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "name": name, + "value": value, + "type": "new", + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + PostWorkspaceSecretResponseModel, + construct_type( + type_=PostWorkspaceSecretResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def delete( + self, secret_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[None]: + """ + Delete a workspace secret if it's not in use + + Parameters + ---------- + secret_id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[None] + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/convai/secrets/{jsonable_encoder(secret_id)}", + base_url=self._client_wrapper.get_environment().base, + method="DELETE", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return AsyncHttpResponse(response=_response, data=None) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/elevenlabs/conversational_ai/settings/__init__.py b/src/elevenlabs/conversational_ai/settings/__init__.py new file mode 100644 index 00000000..5cde0202 --- /dev/null +++ b/src/elevenlabs/conversational_ai/settings/__init__.py @@ -0,0 +1,4 @@ +# This file was auto-generated by Fern from our API Definition. + +# isort: skip_file + diff --git a/src/elevenlabs/conversational_ai/settings/client.py b/src/elevenlabs/conversational_ai/settings/client.py new file mode 100644 index 00000000..f0d65ae6 --- /dev/null +++ b/src/elevenlabs/conversational_ai/settings/client.py @@ -0,0 +1,211 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ...core.request_options import RequestOptions +from ...types.conv_ai_webhooks import ConvAiWebhooks +from ...types.conversation_initiation_client_data_webhook import ConversationInitiationClientDataWebhook +from ...types.get_conv_ai_settings_response_model import GetConvAiSettingsResponseModel +from .raw_client import AsyncRawSettingsClient, RawSettingsClient + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class SettingsClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._raw_client = RawSettingsClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawSettingsClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawSettingsClient + """ + return self._raw_client + + def get(self, *, request_options: typing.Optional[RequestOptions] = None) -> GetConvAiSettingsResponseModel: + """ + Retrieve Convai settings for the workspace + + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + GetConvAiSettingsResponseModel + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.conversational_ai.settings.get() + """ + _response = self._raw_client.get(request_options=request_options) + return _response.data + + def update( + self, + *, + conversation_initiation_client_data_webhook: typing.Optional[ConversationInitiationClientDataWebhook] = OMIT, + webhooks: typing.Optional[ConvAiWebhooks] = OMIT, + can_use_mcp_servers: typing.Optional[bool] = OMIT, + rag_retention_period_days: typing.Optional[int] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> GetConvAiSettingsResponseModel: + """ + Update Convai settings for the workspace + + Parameters + ---------- + conversation_initiation_client_data_webhook : typing.Optional[ConversationInitiationClientDataWebhook] + + webhooks : typing.Optional[ConvAiWebhooks] + + can_use_mcp_servers : typing.Optional[bool] + Whether the workspace can use MCP servers + + rag_retention_period_days : typing.Optional[int] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + GetConvAiSettingsResponseModel + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.conversational_ai.settings.update() + """ + _response = self._raw_client.update( + conversation_initiation_client_data_webhook=conversation_initiation_client_data_webhook, + webhooks=webhooks, + can_use_mcp_servers=can_use_mcp_servers, + rag_retention_period_days=rag_retention_period_days, + request_options=request_options, + ) + return _response.data + + +class AsyncSettingsClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawSettingsClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawSettingsClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawSettingsClient + """ + return self._raw_client + + async def get(self, *, request_options: typing.Optional[RequestOptions] = None) -> GetConvAiSettingsResponseModel: + """ + Retrieve Convai settings for the workspace + + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + GetConvAiSettingsResponseModel + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.conversational_ai.settings.get() + + + asyncio.run(main()) + """ + _response = await self._raw_client.get(request_options=request_options) + return _response.data + + async def update( + self, + *, + conversation_initiation_client_data_webhook: typing.Optional[ConversationInitiationClientDataWebhook] = OMIT, + webhooks: typing.Optional[ConvAiWebhooks] = OMIT, + can_use_mcp_servers: typing.Optional[bool] = OMIT, + rag_retention_period_days: typing.Optional[int] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> GetConvAiSettingsResponseModel: + """ + Update Convai settings for the workspace + + Parameters + ---------- + conversation_initiation_client_data_webhook : typing.Optional[ConversationInitiationClientDataWebhook] + + webhooks : typing.Optional[ConvAiWebhooks] + + can_use_mcp_servers : typing.Optional[bool] + Whether the workspace can use MCP servers + + rag_retention_period_days : typing.Optional[int] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + GetConvAiSettingsResponseModel + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.conversational_ai.settings.update() + + + asyncio.run(main()) + """ + _response = await self._raw_client.update( + conversation_initiation_client_data_webhook=conversation_initiation_client_data_webhook, + webhooks=webhooks, + can_use_mcp_servers=can_use_mcp_servers, + rag_retention_period_days=rag_retention_period_days, + request_options=request_options, + ) + return _response.data diff --git a/src/elevenlabs/conversational_ai/settings/raw_client.py b/src/elevenlabs/conversational_ai/settings/raw_client.py new file mode 100644 index 00000000..c3df89e0 --- /dev/null +++ b/src/elevenlabs/conversational_ai/settings/raw_client.py @@ -0,0 +1,283 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ...core.api_error import ApiError +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ...core.http_response import AsyncHttpResponse, HttpResponse +from ...core.request_options import RequestOptions +from ...core.serialization import convert_and_respect_annotation_metadata +from ...core.unchecked_base_model import construct_type +from ...errors.unprocessable_entity_error import UnprocessableEntityError +from ...types.conv_ai_webhooks import ConvAiWebhooks +from ...types.conversation_initiation_client_data_webhook import ConversationInitiationClientDataWebhook +from ...types.get_conv_ai_settings_response_model import GetConvAiSettingsResponseModel +from ...types.http_validation_error import HttpValidationError + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RawSettingsClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def get( + self, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[GetConvAiSettingsResponseModel]: + """ + Retrieve Convai settings for the workspace + + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[GetConvAiSettingsResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + "v1/convai/settings", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetConvAiSettingsResponseModel, + construct_type( + type_=GetConvAiSettingsResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def update( + self, + *, + conversation_initiation_client_data_webhook: typing.Optional[ConversationInitiationClientDataWebhook] = OMIT, + webhooks: typing.Optional[ConvAiWebhooks] = OMIT, + can_use_mcp_servers: typing.Optional[bool] = OMIT, + rag_retention_period_days: typing.Optional[int] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[GetConvAiSettingsResponseModel]: + """ + Update Convai settings for the workspace + + Parameters + ---------- + conversation_initiation_client_data_webhook : typing.Optional[ConversationInitiationClientDataWebhook] + + webhooks : typing.Optional[ConvAiWebhooks] + + can_use_mcp_servers : typing.Optional[bool] + Whether the workspace can use MCP servers + + rag_retention_period_days : typing.Optional[int] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[GetConvAiSettingsResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + "v1/convai/settings", + base_url=self._client_wrapper.get_environment().base, + method="PATCH", + json={ + "conversation_initiation_client_data_webhook": convert_and_respect_annotation_metadata( + object_=conversation_initiation_client_data_webhook, + annotation=ConversationInitiationClientDataWebhook, + direction="write", + ), + "webhooks": convert_and_respect_annotation_metadata( + object_=webhooks, annotation=ConvAiWebhooks, direction="write" + ), + "can_use_mcp_servers": can_use_mcp_servers, + "rag_retention_period_days": rag_retention_period_days, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetConvAiSettingsResponseModel, + construct_type( + type_=GetConvAiSettingsResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + +class AsyncRawSettingsClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def get( + self, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[GetConvAiSettingsResponseModel]: + """ + Retrieve Convai settings for the workspace + + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[GetConvAiSettingsResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + "v1/convai/settings", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetConvAiSettingsResponseModel, + construct_type( + type_=GetConvAiSettingsResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def update( + self, + *, + conversation_initiation_client_data_webhook: typing.Optional[ConversationInitiationClientDataWebhook] = OMIT, + webhooks: typing.Optional[ConvAiWebhooks] = OMIT, + can_use_mcp_servers: typing.Optional[bool] = OMIT, + rag_retention_period_days: typing.Optional[int] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[GetConvAiSettingsResponseModel]: + """ + Update Convai settings for the workspace + + Parameters + ---------- + conversation_initiation_client_data_webhook : typing.Optional[ConversationInitiationClientDataWebhook] + + webhooks : typing.Optional[ConvAiWebhooks] + + can_use_mcp_servers : typing.Optional[bool] + Whether the workspace can use MCP servers + + rag_retention_period_days : typing.Optional[int] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[GetConvAiSettingsResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + "v1/convai/settings", + base_url=self._client_wrapper.get_environment().base, + method="PATCH", + json={ + "conversation_initiation_client_data_webhook": convert_and_respect_annotation_metadata( + object_=conversation_initiation_client_data_webhook, + annotation=ConversationInitiationClientDataWebhook, + direction="write", + ), + "webhooks": convert_and_respect_annotation_metadata( + object_=webhooks, annotation=ConvAiWebhooks, direction="write" + ), + "can_use_mcp_servers": can_use_mcp_servers, + "rag_retention_period_days": rag_retention_period_days, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetConvAiSettingsResponseModel, + construct_type( + type_=GetConvAiSettingsResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/elevenlabs/conversational_ai/sip_trunk/__init__.py b/src/elevenlabs/conversational_ai/sip_trunk/__init__.py index f3ea2659..5cde0202 100644 --- a/src/elevenlabs/conversational_ai/sip_trunk/__init__.py +++ b/src/elevenlabs/conversational_ai/sip_trunk/__init__.py @@ -1,2 +1,4 @@ # This file was auto-generated by Fern from our API Definition. +# isort: skip_file + diff --git a/src/elevenlabs/conversational_ai/sip_trunk/client.py b/src/elevenlabs/conversational_ai/sip_trunk/client.py index 7d3172d2..210a00d1 100644 --- a/src/elevenlabs/conversational_ai/sip_trunk/client.py +++ b/src/elevenlabs/conversational_ai/sip_trunk/client.py @@ -1,19 +1,12 @@ # This file was auto-generated by Fern from our API Definition. import typing -from ...core.client_wrapper import SyncClientWrapper -from ...types.conversation_initiation_client_data_request_input import ( - ConversationInitiationClientDataRequestInput, -) + +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ...core.request_options import RequestOptions +from ...types.conversation_initiation_client_data_request_input import ConversationInitiationClientDataRequestInput from ...types.sip_trunk_outbound_call_response import SipTrunkOutboundCallResponse -from ...core.serialization import convert_and_respect_annotation_metadata -from ...core.unchecked_base_model import construct_type -from ...errors.unprocessable_entity_error import UnprocessableEntityError -from ...types.http_validation_error import HttpValidationError -from json.decoder import JSONDecodeError -from ...core.api_error import ApiError -from ...core.client_wrapper import AsyncClientWrapper +from .raw_client import AsyncRawSipTrunkClient, RawSipTrunkClient # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -21,7 +14,18 @@ class SipTrunkClient: def __init__(self, *, client_wrapper: SyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = RawSipTrunkClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawSipTrunkClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawSipTrunkClient + """ + return self._raw_client def outbound_call( self, @@ -66,54 +70,30 @@ def outbound_call( to_number="to_number", ) """ - _response = self._client_wrapper.httpx_client.request( - "v1/convai/sip-trunk/outbound-call", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "agent_id": agent_id, - "agent_phone_number_id": agent_phone_number_id, - "to_number": to_number, - "conversation_initiation_client_data": convert_and_respect_annotation_metadata( - object_=conversation_initiation_client_data, - annotation=ConversationInitiationClientDataRequestInput, - direction="write", - ), - }, - headers={ - "content-type": "application/json", - }, + _response = self._raw_client.outbound_call( + agent_id=agent_id, + agent_phone_number_id=agent_phone_number_id, + to_number=to_number, + conversation_initiation_client_data=conversation_initiation_client_data, request_options=request_options, - omit=OMIT, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - SipTrunkOutboundCallResponse, - construct_type( - type_=SipTrunkOutboundCallResponse, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + return _response.data class AsyncSipTrunkClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = AsyncRawSipTrunkClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawSipTrunkClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawSipTrunkClient + """ + return self._raw_client async def outbound_call( self, @@ -166,46 +146,11 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - "v1/convai/sip-trunk/outbound-call", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "agent_id": agent_id, - "agent_phone_number_id": agent_phone_number_id, - "to_number": to_number, - "conversation_initiation_client_data": convert_and_respect_annotation_metadata( - object_=conversation_initiation_client_data, - annotation=ConversationInitiationClientDataRequestInput, - direction="write", - ), - }, - headers={ - "content-type": "application/json", - }, + _response = await self._raw_client.outbound_call( + agent_id=agent_id, + agent_phone_number_id=agent_phone_number_id, + to_number=to_number, + conversation_initiation_client_data=conversation_initiation_client_data, request_options=request_options, - omit=OMIT, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - SipTrunkOutboundCallResponse, - construct_type( - type_=SipTrunkOutboundCallResponse, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + return _response.data diff --git a/src/elevenlabs/conversational_ai/sip_trunk/raw_client.py b/src/elevenlabs/conversational_ai/sip_trunk/raw_client.py new file mode 100644 index 00000000..70dfc208 --- /dev/null +++ b/src/elevenlabs/conversational_ai/sip_trunk/raw_client.py @@ -0,0 +1,180 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ...core.api_error import ApiError +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ...core.http_response import AsyncHttpResponse, HttpResponse +from ...core.request_options import RequestOptions +from ...core.serialization import convert_and_respect_annotation_metadata +from ...core.unchecked_base_model import construct_type +from ...errors.unprocessable_entity_error import UnprocessableEntityError +from ...types.conversation_initiation_client_data_request_input import ConversationInitiationClientDataRequestInput +from ...types.http_validation_error import HttpValidationError +from ...types.sip_trunk_outbound_call_response import SipTrunkOutboundCallResponse + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RawSipTrunkClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def outbound_call( + self, + *, + agent_id: str, + agent_phone_number_id: str, + to_number: str, + conversation_initiation_client_data: typing.Optional[ConversationInitiationClientDataRequestInput] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[SipTrunkOutboundCallResponse]: + """ + Handle an outbound call via SIP trunk + + Parameters + ---------- + agent_id : str + + agent_phone_number_id : str + + to_number : str + + conversation_initiation_client_data : typing.Optional[ConversationInitiationClientDataRequestInput] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[SipTrunkOutboundCallResponse] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + "v1/convai/sip-trunk/outbound-call", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "agent_id": agent_id, + "agent_phone_number_id": agent_phone_number_id, + "to_number": to_number, + "conversation_initiation_client_data": convert_and_respect_annotation_metadata( + object_=conversation_initiation_client_data, + annotation=ConversationInitiationClientDataRequestInput, + direction="write", + ), + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + SipTrunkOutboundCallResponse, + construct_type( + type_=SipTrunkOutboundCallResponse, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + +class AsyncRawSipTrunkClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def outbound_call( + self, + *, + agent_id: str, + agent_phone_number_id: str, + to_number: str, + conversation_initiation_client_data: typing.Optional[ConversationInitiationClientDataRequestInput] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[SipTrunkOutboundCallResponse]: + """ + Handle an outbound call via SIP trunk + + Parameters + ---------- + agent_id : str + + agent_phone_number_id : str + + to_number : str + + conversation_initiation_client_data : typing.Optional[ConversationInitiationClientDataRequestInput] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[SipTrunkOutboundCallResponse] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + "v1/convai/sip-trunk/outbound-call", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "agent_id": agent_id, + "agent_phone_number_id": agent_phone_number_id, + "to_number": to_number, + "conversation_initiation_client_data": convert_and_respect_annotation_metadata( + object_=conversation_initiation_client_data, + annotation=ConversationInitiationClientDataRequestInput, + direction="write", + ), + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + SipTrunkOutboundCallResponse, + construct_type( + type_=SipTrunkOutboundCallResponse, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/elevenlabs/conversational_ai/twilio/__init__.py b/src/elevenlabs/conversational_ai/twilio/__init__.py new file mode 100644 index 00000000..5cde0202 --- /dev/null +++ b/src/elevenlabs/conversational_ai/twilio/__init__.py @@ -0,0 +1,4 @@ +# This file was auto-generated by Fern from our API Definition. + +# isort: skip_file + diff --git a/src/elevenlabs/conversational_ai/twilio/client.py b/src/elevenlabs/conversational_ai/twilio/client.py new file mode 100644 index 00000000..c858bb26 --- /dev/null +++ b/src/elevenlabs/conversational_ai/twilio/client.py @@ -0,0 +1,156 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ...core.request_options import RequestOptions +from ...types.conversation_initiation_client_data_request_input import ConversationInitiationClientDataRequestInput +from ...types.twilio_outbound_call_response import TwilioOutboundCallResponse +from .raw_client import AsyncRawTwilioClient, RawTwilioClient + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class TwilioClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._raw_client = RawTwilioClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawTwilioClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawTwilioClient + """ + return self._raw_client + + def outbound_call( + self, + *, + agent_id: str, + agent_phone_number_id: str, + to_number: str, + conversation_initiation_client_data: typing.Optional[ConversationInitiationClientDataRequestInput] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> TwilioOutboundCallResponse: + """ + Handle an outbound call via Twilio + + Parameters + ---------- + agent_id : str + + agent_phone_number_id : str + + to_number : str + + conversation_initiation_client_data : typing.Optional[ConversationInitiationClientDataRequestInput] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + TwilioOutboundCallResponse + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.conversational_ai.twilio.outbound_call( + agent_id="agent_id", + agent_phone_number_id="agent_phone_number_id", + to_number="to_number", + ) + """ + _response = self._raw_client.outbound_call( + agent_id=agent_id, + agent_phone_number_id=agent_phone_number_id, + to_number=to_number, + conversation_initiation_client_data=conversation_initiation_client_data, + request_options=request_options, + ) + return _response.data + + +class AsyncTwilioClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawTwilioClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawTwilioClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawTwilioClient + """ + return self._raw_client + + async def outbound_call( + self, + *, + agent_id: str, + agent_phone_number_id: str, + to_number: str, + conversation_initiation_client_data: typing.Optional[ConversationInitiationClientDataRequestInput] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> TwilioOutboundCallResponse: + """ + Handle an outbound call via Twilio + + Parameters + ---------- + agent_id : str + + agent_phone_number_id : str + + to_number : str + + conversation_initiation_client_data : typing.Optional[ConversationInitiationClientDataRequestInput] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + TwilioOutboundCallResponse + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.conversational_ai.twilio.outbound_call( + agent_id="agent_id", + agent_phone_number_id="agent_phone_number_id", + to_number="to_number", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.outbound_call( + agent_id=agent_id, + agent_phone_number_id=agent_phone_number_id, + to_number=to_number, + conversation_initiation_client_data=conversation_initiation_client_data, + request_options=request_options, + ) + return _response.data diff --git a/src/elevenlabs/conversational_ai/twilio/raw_client.py b/src/elevenlabs/conversational_ai/twilio/raw_client.py new file mode 100644 index 00000000..fdbd56d6 --- /dev/null +++ b/src/elevenlabs/conversational_ai/twilio/raw_client.py @@ -0,0 +1,180 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ...core.api_error import ApiError +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ...core.http_response import AsyncHttpResponse, HttpResponse +from ...core.request_options import RequestOptions +from ...core.serialization import convert_and_respect_annotation_metadata +from ...core.unchecked_base_model import construct_type +from ...errors.unprocessable_entity_error import UnprocessableEntityError +from ...types.conversation_initiation_client_data_request_input import ConversationInitiationClientDataRequestInput +from ...types.http_validation_error import HttpValidationError +from ...types.twilio_outbound_call_response import TwilioOutboundCallResponse + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RawTwilioClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def outbound_call( + self, + *, + agent_id: str, + agent_phone_number_id: str, + to_number: str, + conversation_initiation_client_data: typing.Optional[ConversationInitiationClientDataRequestInput] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[TwilioOutboundCallResponse]: + """ + Handle an outbound call via Twilio + + Parameters + ---------- + agent_id : str + + agent_phone_number_id : str + + to_number : str + + conversation_initiation_client_data : typing.Optional[ConversationInitiationClientDataRequestInput] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[TwilioOutboundCallResponse] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + "v1/convai/twilio/outbound-call", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "agent_id": agent_id, + "agent_phone_number_id": agent_phone_number_id, + "to_number": to_number, + "conversation_initiation_client_data": convert_and_respect_annotation_metadata( + object_=conversation_initiation_client_data, + annotation=ConversationInitiationClientDataRequestInput, + direction="write", + ), + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + TwilioOutboundCallResponse, + construct_type( + type_=TwilioOutboundCallResponse, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + +class AsyncRawTwilioClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def outbound_call( + self, + *, + agent_id: str, + agent_phone_number_id: str, + to_number: str, + conversation_initiation_client_data: typing.Optional[ConversationInitiationClientDataRequestInput] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[TwilioOutboundCallResponse]: + """ + Handle an outbound call via Twilio + + Parameters + ---------- + agent_id : str + + agent_phone_number_id : str + + to_number : str + + conversation_initiation_client_data : typing.Optional[ConversationInitiationClientDataRequestInput] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[TwilioOutboundCallResponse] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + "v1/convai/twilio/outbound-call", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "agent_id": agent_id, + "agent_phone_number_id": agent_phone_number_id, + "to_number": to_number, + "conversation_initiation_client_data": convert_and_respect_annotation_metadata( + object_=conversation_initiation_client_data, + annotation=ConversationInitiationClientDataRequestInput, + direction="write", + ), + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + TwilioOutboundCallResponse, + construct_type( + type_=TwilioOutboundCallResponse, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/elevenlabs/conversational_ai/types/__init__.py b/src/elevenlabs/conversational_ai/types/__init__.py deleted file mode 100644 index 82e3bb60..00000000 --- a/src/elevenlabs/conversational_ai/types/__init__.py +++ /dev/null @@ -1,67 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -from .conversational_ai_create_phone_number_request_body import ( - ConversationalAiCreatePhoneNumberRequestBody, - ConversationalAiCreatePhoneNumberRequestBody_SipTrunk, - ConversationalAiCreatePhoneNumberRequestBody_Twilio, -) -from .conversational_ai_get_knowledge_base_document_by_id_response import ( - ConversationalAiGetKnowledgeBaseDocumentByIdResponse, - ConversationalAiGetKnowledgeBaseDocumentByIdResponse_File, - ConversationalAiGetKnowledgeBaseDocumentByIdResponse_Text, - ConversationalAiGetKnowledgeBaseDocumentByIdResponse_Url, -) -from .conversational_ai_get_phone_number_response import ( - ConversationalAiGetPhoneNumberResponse, - ConversationalAiGetPhoneNumberResponse_SipTrunk, - ConversationalAiGetPhoneNumberResponse_Twilio, -) -from .conversational_ai_get_phone_numbers_response_item import ( - ConversationalAiGetPhoneNumbersResponseItem, - ConversationalAiGetPhoneNumbersResponseItem_SipTrunk, - ConversationalAiGetPhoneNumbersResponseItem_Twilio, -) -from .conversational_ai_update_knowledge_base_document_response import ( - ConversationalAiUpdateKnowledgeBaseDocumentResponse, - ConversationalAiUpdateKnowledgeBaseDocumentResponse_File, - ConversationalAiUpdateKnowledgeBaseDocumentResponse_Text, - ConversationalAiUpdateKnowledgeBaseDocumentResponse_Url, -) -from .conversational_ai_update_phone_number_response import ( - ConversationalAiUpdatePhoneNumberResponse, - ConversationalAiUpdatePhoneNumberResponse_SipTrunk, - ConversationalAiUpdatePhoneNumberResponse_Twilio, -) -from .patch_conv_ai_dashboard_settings_request_charts_item import ( - PatchConvAiDashboardSettingsRequestChartsItem, - PatchConvAiDashboardSettingsRequestChartsItem_CallSuccess, - PatchConvAiDashboardSettingsRequestChartsItem_Criteria, - PatchConvAiDashboardSettingsRequestChartsItem_DataCollection, -) - -__all__ = [ - "ConversationalAiCreatePhoneNumberRequestBody", - "ConversationalAiCreatePhoneNumberRequestBody_SipTrunk", - "ConversationalAiCreatePhoneNumberRequestBody_Twilio", - "ConversationalAiGetKnowledgeBaseDocumentByIdResponse", - "ConversationalAiGetKnowledgeBaseDocumentByIdResponse_File", - "ConversationalAiGetKnowledgeBaseDocumentByIdResponse_Text", - "ConversationalAiGetKnowledgeBaseDocumentByIdResponse_Url", - "ConversationalAiGetPhoneNumberResponse", - "ConversationalAiGetPhoneNumberResponse_SipTrunk", - "ConversationalAiGetPhoneNumberResponse_Twilio", - "ConversationalAiGetPhoneNumbersResponseItem", - "ConversationalAiGetPhoneNumbersResponseItem_SipTrunk", - "ConversationalAiGetPhoneNumbersResponseItem_Twilio", - "ConversationalAiUpdateKnowledgeBaseDocumentResponse", - "ConversationalAiUpdateKnowledgeBaseDocumentResponse_File", - "ConversationalAiUpdateKnowledgeBaseDocumentResponse_Text", - "ConversationalAiUpdateKnowledgeBaseDocumentResponse_Url", - "ConversationalAiUpdatePhoneNumberResponse", - "ConversationalAiUpdatePhoneNumberResponse_SipTrunk", - "ConversationalAiUpdatePhoneNumberResponse_Twilio", - "PatchConvAiDashboardSettingsRequestChartsItem", - "PatchConvAiDashboardSettingsRequestChartsItem_CallSuccess", - "PatchConvAiDashboardSettingsRequestChartsItem_Criteria", - "PatchConvAiDashboardSettingsRequestChartsItem_DataCollection", -] diff --git a/src/elevenlabs/core/__init__.py b/src/elevenlabs/core/__init__.py index 04b9a4e7..869898d7 100644 --- a/src/elevenlabs/core/__init__.py +++ b/src/elevenlabs/core/__init__.py @@ -1,10 +1,13 @@ # This file was auto-generated by Fern from our API Definition. +# isort: skip_file + from .api_error import ApiError from .client_wrapper import AsyncClientWrapper, BaseClientWrapper, SyncClientWrapper from .datetime_utils import serialize_datetime from .file import File, convert_file_dict_to_httpx_tuples, with_content_type from .http_client import AsyncHttpClient, HttpClient +from .http_response import AsyncHttpResponse, HttpResponse from .jsonable_encoder import jsonable_encoder from .pydantic_utilities import ( IS_PYDANTIC_V2, @@ -25,10 +28,12 @@ "ApiError", "AsyncClientWrapper", "AsyncHttpClient", + "AsyncHttpResponse", "BaseClientWrapper", "FieldMetadata", "File", "HttpClient", + "HttpResponse", "IS_PYDANTIC_V2", "RequestOptions", "SyncClientWrapper", diff --git a/src/elevenlabs/core/api_error.py b/src/elevenlabs/core/api_error.py index 2e9fc543..6f850a60 100644 --- a/src/elevenlabs/core/api_error.py +++ b/src/elevenlabs/core/api_error.py @@ -1,15 +1,23 @@ # This file was auto-generated by Fern from our API Definition. -import typing +from typing import Any, Dict, Optional class ApiError(Exception): - status_code: typing.Optional[int] - body: typing.Any + headers: Optional[Dict[str, str]] + status_code: Optional[int] + body: Any - def __init__(self, *, status_code: typing.Optional[int] = None, body: typing.Any = None): + def __init__( + self, + *, + headers: Optional[Dict[str, str]] = None, + status_code: Optional[int] = None, + body: Any = None, + ) -> None: + self.headers = headers self.status_code = status_code self.body = body def __str__(self) -> str: - return f"status_code: {self.status_code}, body: {self.body}" + return f"headers: {self.headers}, status_code: {self.status_code}, body: {self.body}" diff --git a/src/elevenlabs/core/client_wrapper.py b/src/elevenlabs/core/client_wrapper.py index b02638fe..3ae4fc22 100644 --- a/src/elevenlabs/core/client_wrapper.py +++ b/src/elevenlabs/core/client_wrapper.py @@ -1,10 +1,10 @@ # This file was auto-generated by Fern from our API Definition. import typing -from ..environment import ElevenLabsEnvironment + import httpx -from .http_client import HttpClient -from .http_client import AsyncHttpClient +from ..environment import ElevenLabsEnvironment +from .http_client import AsyncHttpClient, HttpClient class BaseClientWrapper: @@ -21,9 +21,10 @@ def __init__( def get_headers(self) -> typing.Dict[str, str]: headers: typing.Dict[str, str] = { + "User-Agent": "elevenlabs/v2.0.0", "X-Fern-Language": "Python", "X-Fern-SDK-Name": "elevenlabs", - "X-Fern-SDK-Version": "v1.59.0", + "X-Fern-SDK-Version": "v2.0.0", } if self._api_key is not None: headers["xi-api-key"] = self._api_key @@ -47,9 +48,7 @@ def __init__( ): super().__init__(api_key=api_key, environment=environment, timeout=timeout) self.httpx_client = HttpClient( - httpx_client=httpx_client, - base_headers=self.get_headers, - base_timeout=self.get_timeout, + httpx_client=httpx_client, base_headers=self.get_headers, base_timeout=self.get_timeout ) @@ -64,7 +63,5 @@ def __init__( ): super().__init__(api_key=api_key, environment=environment, timeout=timeout) self.httpx_client = AsyncHttpClient( - httpx_client=httpx_client, - base_headers=self.get_headers, - base_timeout=self.get_timeout, + httpx_client=httpx_client, base_headers=self.get_headers, base_timeout=self.get_timeout ) diff --git a/src/elevenlabs/core/file.py b/src/elevenlabs/core/file.py index c6d11fc7..44b0d27c 100644 --- a/src/elevenlabs/core/file.py +++ b/src/elevenlabs/core/file.py @@ -58,8 +58,7 @@ def with_content_type(*, file: File, default_content_type: str) -> File: return (filename, content, out_content_type) elif len(file) == 4: filename, content, file_content_type, headers = cast( # type: ignore - Tuple[Optional[str], FileContent, Optional[str], Mapping[str, str]], - file, + Tuple[Optional[str], FileContent, Optional[str], Mapping[str, str]], file ) out_content_type = file_content_type or default_content_type return (filename, content, out_content_type, headers) diff --git a/src/elevenlabs/core/force_multipart.py b/src/elevenlabs/core/force_multipart.py new file mode 100644 index 00000000..ae24ccff --- /dev/null +++ b/src/elevenlabs/core/force_multipart.py @@ -0,0 +1,16 @@ +# This file was auto-generated by Fern from our API Definition. + + +class ForceMultipartDict(dict): + """ + A dictionary subclass that always evaluates to True in boolean contexts. + + This is used to force multipart/form-data encoding in HTTP requests even when + the dictionary is empty, which would normally evaluate to False. + """ + + def __bool__(self): + return True + + +FORCE_MULTIPART = ForceMultipartDict() diff --git a/src/elevenlabs/core/http_client.py b/src/elevenlabs/core/http_client.py index 275a54cc..e4173f99 100644 --- a/src/elevenlabs/core/http_client.py +++ b/src/elevenlabs/core/http_client.py @@ -2,7 +2,6 @@ import asyncio import email.utils -import json import re import time import typing @@ -11,12 +10,13 @@ from random import random import httpx - from .file import File, convert_file_dict_to_httpx_tuples +from .force_multipart import FORCE_MULTIPART from .jsonable_encoder import jsonable_encoder from .query_encoder import encode_query from .remove_none_from_dict import remove_none_from_dict from .request_options import RequestOptions +from httpx._types import RequestFiles INITIAL_RETRY_DELAY_SECONDS = 0.5 MAX_RETRY_DELAY_SECONDS = 10 @@ -180,11 +180,17 @@ def request( json: typing.Optional[typing.Any] = None, data: typing.Optional[typing.Any] = None, content: typing.Optional[typing.Union[bytes, typing.Iterator[bytes], typing.AsyncIterator[bytes]]] = None, - files: typing.Optional[typing.Dict[str, typing.Optional[typing.Union[File, typing.List[File]]]]] = None, + files: typing.Optional[ + typing.Union[ + typing.Dict[str, typing.Optional[typing.Union[File, typing.List[File]]]], + typing.List[typing.Tuple[str, File]], + ] + ] = None, headers: typing.Optional[typing.Dict[str, typing.Any]] = None, request_options: typing.Optional[RequestOptions] = None, retries: int = 2, omit: typing.Optional[typing.Any] = None, + force_multipart: typing.Optional[bool] = None, ) -> httpx.Response: base_url = self.get_base_url(base_url) timeout = ( @@ -195,6 +201,15 @@ def request( json_body, data_body = get_request_body(json=json, data=data, request_options=request_options, omit=omit) + request_files: typing.Optional[RequestFiles] = ( + convert_file_dict_to_httpx_tuples(remove_omit_from_dict(remove_none_from_dict(files), omit)) + if (files is not None and files is not omit and isinstance(files, dict)) + else None + ) + + if (request_files is None or len(request_files) == 0) and force_multipart: + request_files = FORCE_MULTIPART + response = self.httpx_client.request( method=method, url=urllib.parse.urljoin(f"{base_url}/", path), @@ -227,11 +242,7 @@ def request( json=json_body, data=data_body, content=content, - files=( - convert_file_dict_to_httpx_tuples(remove_omit_from_dict(remove_none_from_dict(files), omit)) - if (files is not None and files is not omit) - else None - ), + files=request_files, timeout=timeout, ) @@ -266,11 +277,17 @@ def stream( json: typing.Optional[typing.Any] = None, data: typing.Optional[typing.Any] = None, content: typing.Optional[typing.Union[bytes, typing.Iterator[bytes], typing.AsyncIterator[bytes]]] = None, - files: typing.Optional[typing.Dict[str, typing.Optional[typing.Union[File, typing.List[File]]]]] = None, + files: typing.Optional[ + typing.Union[ + typing.Dict[str, typing.Optional[typing.Union[File, typing.List[File]]]], + typing.List[typing.Tuple[str, File]], + ] + ] = None, headers: typing.Optional[typing.Dict[str, typing.Any]] = None, request_options: typing.Optional[RequestOptions] = None, retries: int = 2, omit: typing.Optional[typing.Any] = None, + force_multipart: typing.Optional[bool] = None, ) -> typing.Iterator[httpx.Response]: base_url = self.get_base_url(base_url) timeout = ( @@ -279,6 +296,15 @@ def stream( else self.base_timeout() ) + request_files: typing.Optional[RequestFiles] = ( + convert_file_dict_to_httpx_tuples(remove_omit_from_dict(remove_none_from_dict(files), omit)) + if (files is not None and files is not omit and isinstance(files, dict)) + else None + ) + + if (request_files is None or len(request_files) == 0) and force_multipart: + request_files = FORCE_MULTIPART + json_body, data_body = get_request_body(json=json, data=data, request_options=request_options, omit=omit) with self.httpx_client.stream( @@ -313,11 +339,7 @@ def stream( json=json_body, data=data_body, content=content, - files=( - convert_file_dict_to_httpx_tuples(remove_omit_from_dict(remove_none_from_dict(files), omit)) - if (files is not None and files is not omit) - else None - ), + files=request_files, timeout=timeout, ) as stream: yield stream @@ -356,11 +378,17 @@ async def request( json: typing.Optional[typing.Any] = None, data: typing.Optional[typing.Any] = None, content: typing.Optional[typing.Union[bytes, typing.Iterator[bytes], typing.AsyncIterator[bytes]]] = None, - files: typing.Optional[typing.Dict[str, typing.Optional[typing.Union[File, typing.List[File]]]]] = None, + files: typing.Optional[ + typing.Union[ + typing.Dict[str, typing.Optional[typing.Union[File, typing.List[File]]]], + typing.List[typing.Tuple[str, File]], + ] + ] = None, headers: typing.Optional[typing.Dict[str, typing.Any]] = None, request_options: typing.Optional[RequestOptions] = None, retries: int = 2, omit: typing.Optional[typing.Any] = None, + force_multipart: typing.Optional[bool] = None, ) -> httpx.Response: base_url = self.get_base_url(base_url) timeout = ( @@ -369,6 +397,15 @@ async def request( else self.base_timeout() ) + request_files: typing.Optional[RequestFiles] = ( + convert_file_dict_to_httpx_tuples(remove_omit_from_dict(remove_none_from_dict(files), omit)) + if (files is not None and files is not omit and isinstance(files, dict)) + else None + ) + + if (request_files is None or len(request_files) == 0) and force_multipart: + request_files = FORCE_MULTIPART + json_body, data_body = get_request_body(json=json, data=data, request_options=request_options, omit=omit) # Add the input to each of these and do None-safety checks @@ -404,11 +441,7 @@ async def request( json=json_body, data=data_body, content=content, - files=( - convert_file_dict_to_httpx_tuples(remove_omit_from_dict(remove_none_from_dict(files), omit)) - if files is not None - else None - ), + files=request_files, timeout=timeout, ) @@ -442,11 +475,17 @@ async def stream( json: typing.Optional[typing.Any] = None, data: typing.Optional[typing.Any] = None, content: typing.Optional[typing.Union[bytes, typing.Iterator[bytes], typing.AsyncIterator[bytes]]] = None, - files: typing.Optional[typing.Dict[str, typing.Optional[typing.Union[File, typing.List[File]]]]] = None, + files: typing.Optional[ + typing.Union[ + typing.Dict[str, typing.Optional[typing.Union[File, typing.List[File]]]], + typing.List[typing.Tuple[str, File]], + ] + ] = None, headers: typing.Optional[typing.Dict[str, typing.Any]] = None, request_options: typing.Optional[RequestOptions] = None, retries: int = 2, omit: typing.Optional[typing.Any] = None, + force_multipart: typing.Optional[bool] = None, ) -> typing.AsyncIterator[httpx.Response]: base_url = self.get_base_url(base_url) timeout = ( @@ -455,6 +494,15 @@ async def stream( else self.base_timeout() ) + request_files: typing.Optional[RequestFiles] = ( + convert_file_dict_to_httpx_tuples(remove_omit_from_dict(remove_none_from_dict(files), omit)) + if (files is not None and files is not omit and isinstance(files, dict)) + else None + ) + + if (request_files is None or len(request_files) == 0) and force_multipart: + request_files = FORCE_MULTIPART + json_body, data_body = get_request_body(json=json, data=data, request_options=request_options, omit=omit) async with self.httpx_client.stream( @@ -489,11 +537,7 @@ async def stream( json=json_body, data=data_body, content=content, - files=( - convert_file_dict_to_httpx_tuples(remove_omit_from_dict(remove_none_from_dict(files), omit)) - if files is not None - else None - ), + files=request_files, timeout=timeout, ) as stream: yield stream diff --git a/src/elevenlabs/core/http_response.py b/src/elevenlabs/core/http_response.py new file mode 100644 index 00000000..48a1798a --- /dev/null +++ b/src/elevenlabs/core/http_response.py @@ -0,0 +1,55 @@ +# This file was auto-generated by Fern from our API Definition. + +from typing import Dict, Generic, TypeVar + +import httpx + +T = TypeVar("T") +"""Generic to represent the underlying type of the data wrapped by the HTTP response.""" + + +class BaseHttpResponse: + """Minimalist HTTP response wrapper that exposes response headers.""" + + _response: httpx.Response + + def __init__(self, response: httpx.Response): + self._response = response + + @property + def headers(self) -> Dict[str, str]: + return dict(self._response.headers) + + +class HttpResponse(Generic[T], BaseHttpResponse): + """HTTP response wrapper that exposes response headers and data.""" + + _data: T + + def __init__(self, response: httpx.Response, data: T): + super().__init__(response) + self._data = data + + @property + def data(self) -> T: + return self._data + + def close(self) -> None: + self._response.close() + + +class AsyncHttpResponse(Generic[T], BaseHttpResponse): + """HTTP response wrapper that exposes response headers and data.""" + + _data: T + + def __init__(self, response: httpx.Response, data: T): + super().__init__(response) + self._data = data + + @property + def data(self) -> T: + return self._data + + async def close(self) -> None: + await self._response.aclose() diff --git a/src/elevenlabs/core/jsonable_encoder.py b/src/elevenlabs/core/jsonable_encoder.py index 1b631e90..afee3662 100644 --- a/src/elevenlabs/core/jsonable_encoder.py +++ b/src/elevenlabs/core/jsonable_encoder.py @@ -17,7 +17,6 @@ from typing import Any, Callable, Dict, List, Optional, Set, Union import pydantic - from .datetime_utils import serialize_datetime from .pydantic_utilities import ( IS_PYDANTIC_V2, diff --git a/src/elevenlabs/core/pydantic_utilities.py b/src/elevenlabs/core/pydantic_utilities.py index 93a9d786..0360ef49 100644 --- a/src/elevenlabs/core/pydantic_utilities.py +++ b/src/elevenlabs/core/pydantic_utilities.py @@ -2,89 +2,65 @@ # nopycln: file import datetime as dt -import typing from collections import defaultdict - -import typing_extensions +from typing import Any, Callable, ClassVar, Dict, List, Mapping, Optional, Set, Tuple, Type, TypeVar, Union, cast import pydantic -from .datetime_utils import serialize_datetime -from .serialization import convert_and_respect_annotation_metadata - IS_PYDANTIC_V2 = pydantic.VERSION.startswith("2.") if IS_PYDANTIC_V2: - # isort will try to reformat the comments on these imports, which breaks mypy - # isort: off - from pydantic.v1.datetime_parse import ( # type: ignore # pyright: ignore[reportMissingImports] # Pydantic v2 - parse_date as parse_date, - ) - from pydantic.v1.datetime_parse import ( # pyright: ignore[reportMissingImports] # Pydantic v2 - parse_datetime as parse_datetime, - ) - from pydantic.v1.json import ( # type: ignore # pyright: ignore[reportMissingImports] # Pydantic v2 - ENCODERS_BY_TYPE as encoders_by_type, - ) - from pydantic.v1.typing import ( # type: ignore # pyright: ignore[reportMissingImports] # Pydantic v2 - get_args as get_args, - ) - from pydantic.v1.typing import ( # pyright: ignore[reportMissingImports] # Pydantic v2 - get_origin as get_origin, - ) - from pydantic.v1.typing import ( # pyright: ignore[reportMissingImports] # Pydantic v2 - is_literal_type as is_literal_type, - ) - from pydantic.v1.typing import ( # pyright: ignore[reportMissingImports] # Pydantic v2 - is_union as is_union, - ) - from pydantic.v1.fields import ModelField as ModelField # type: ignore # pyright: ignore[reportMissingImports] # Pydantic v2 + from pydantic.v1.datetime_parse import parse_date as parse_date + from pydantic.v1.datetime_parse import parse_datetime as parse_datetime + from pydantic.v1.fields import ModelField as ModelField + from pydantic.v1.json import ENCODERS_BY_TYPE as encoders_by_type # type: ignore[attr-defined] + from pydantic.v1.typing import get_args as get_args + from pydantic.v1.typing import get_origin as get_origin + from pydantic.v1.typing import is_literal_type as is_literal_type + from pydantic.v1.typing import is_union as is_union else: - from pydantic.datetime_parse import parse_date as parse_date # type: ignore # Pydantic v1 - from pydantic.datetime_parse import parse_datetime as parse_datetime # type: ignore # Pydantic v1 - from pydantic.fields import ModelField as ModelField # type: ignore # Pydantic v1 - from pydantic.json import ENCODERS_BY_TYPE as encoders_by_type # type: ignore # Pydantic v1 - from pydantic.typing import get_args as get_args # type: ignore # Pydantic v1 - from pydantic.typing import get_origin as get_origin # type: ignore # Pydantic v1 - from pydantic.typing import is_literal_type as is_literal_type # type: ignore # Pydantic v1 - from pydantic.typing import is_union as is_union # type: ignore # Pydantic v1 - - # isort: on + from pydantic.datetime_parse import parse_date as parse_date # type: ignore[no-redef] + from pydantic.datetime_parse import parse_datetime as parse_datetime # type: ignore[no-redef] + from pydantic.fields import ModelField as ModelField # type: ignore[attr-defined, no-redef] + from pydantic.json import ENCODERS_BY_TYPE as encoders_by_type # type: ignore[no-redef] + from pydantic.typing import get_args as get_args # type: ignore[no-redef] + from pydantic.typing import get_origin as get_origin # type: ignore[no-redef] + from pydantic.typing import is_literal_type as is_literal_type # type: ignore[no-redef] + from pydantic.typing import is_union as is_union # type: ignore[no-redef] +from .datetime_utils import serialize_datetime +from .serialization import convert_and_respect_annotation_metadata +from typing_extensions import TypeAlias -T = typing.TypeVar("T") -Model = typing.TypeVar("Model", bound=pydantic.BaseModel) +T = TypeVar("T") +Model = TypeVar("Model", bound=pydantic.BaseModel) -def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: +def parse_obj_as(type_: Type[T], object_: Any) -> T: dealiased_object = convert_and_respect_annotation_metadata(object_=object_, annotation=type_, direction="read") if IS_PYDANTIC_V2: - adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 + adapter = pydantic.TypeAdapter(type_) # type: ignore[attr-defined] return adapter.validate_python(dealiased_object) - else: - return pydantic.parse_obj_as(type_, dealiased_object) + return pydantic.parse_obj_as(type_, dealiased_object) -def to_jsonable_with_fallback( - obj: typing.Any, fallback_serializer: typing.Callable[[typing.Any], typing.Any] -) -> typing.Any: +def to_jsonable_with_fallback(obj: Any, fallback_serializer: Callable[[Any], Any]) -> Any: if IS_PYDANTIC_V2: from pydantic_core import to_jsonable_python return to_jsonable_python(obj, fallback=fallback_serializer) - else: - return fallback_serializer(obj) + return fallback_serializer(obj) class UniversalBaseModel(pydantic.BaseModel): if IS_PYDANTIC_V2: - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( + model_config: ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( # type: ignore[typeddict-unknown-key] # Allow fields beginning with `model_` to be used in the model protected_namespaces=(), - ) # type: ignore # Pydantic v2 + ) - @pydantic.model_serializer(mode="wrap", when_used="json") # type: ignore # Pydantic v2 - def serialize_model(self, handler: pydantic.SerializerFunctionWrapHandler) -> typing.Any: # type: ignore # Pydantic v2 + @pydantic.model_serializer(mode="wrap", when_used="json") # type: ignore[attr-defined] + def serialize_model(self, handler: pydantic.SerializerFunctionWrapHandler) -> Any: # type: ignore[name-defined] serialized = handler(self) data = {k: serialize_datetime(v) if isinstance(v, dt.datetime) else v for k, v in serialized.items()} return data @@ -96,38 +72,28 @@ class Config: json_encoders = {dt.datetime: serialize_datetime} @classmethod - def model_construct( - cls: typing.Type["Model"], - _fields_set: typing.Optional[typing.Set[str]] = None, - **values: typing.Any, - ) -> "Model": + def model_construct(cls: Type["Model"], _fields_set: Optional[Set[str]] = None, **values: Any) -> "Model": dealiased_object = convert_and_respect_annotation_metadata(object_=values, annotation=cls, direction="read") return cls.construct(_fields_set, **dealiased_object) @classmethod - def construct( - cls: typing.Type["Model"], - _fields_set: typing.Optional[typing.Set[str]] = None, - **values: typing.Any, - ) -> "Model": + def construct(cls: Type["Model"], _fields_set: Optional[Set[str]] = None, **values: Any) -> "Model": dealiased_object = convert_and_respect_annotation_metadata(object_=values, annotation=cls, direction="read") if IS_PYDANTIC_V2: - return super().model_construct(_fields_set, **dealiased_object) # type: ignore # Pydantic v2 - else: - return super().construct(_fields_set, **dealiased_object) + return super().model_construct(_fields_set, **dealiased_object) # type: ignore[misc] + return super().construct(_fields_set, **dealiased_object) - def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = { + def json(self, **kwargs: Any) -> str: + kwargs_with_defaults = { "by_alias": True, "exclude_unset": True, **kwargs, } if IS_PYDANTIC_V2: - return super().model_dump_json(**kwargs_with_defaults) # type: ignore # Pydantic v2 - else: - return super().json(**kwargs_with_defaults) + return super().model_dump_json(**kwargs_with_defaults) # type: ignore[misc] + return super().json(**kwargs_with_defaults) - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + def dict(self, **kwargs: Any) -> Dict[str, Any]: """ Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. @@ -138,21 +104,21 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset = { **kwargs, "by_alias": True, "exclude_unset": True, "exclude_none": False, } - kwargs_with_defaults_exclude_none: typing.Any = { + kwargs_with_defaults_exclude_none = { **kwargs, "by_alias": True, "exclude_none": True, "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore[misc] + super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore[misc] ) else: @@ -172,7 +138,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default is not None: self.__fields_set__.add(name) - kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields = { "by_alias": True, "exclude_unset": True, "include": _fields_set, @@ -184,12 +150,10 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") -def _union_list_of_pydantic_dicts( - source: typing.List[typing.Any], destination: typing.List[typing.Any] -) -> typing.List[typing.Any]: - converted_list: typing.List[typing.Any] = [] +def _union_list_of_pydantic_dicts(source: List[Any], destination: List[Any]) -> List[Any]: + converted_list: List[Any] = [] for i, item in enumerate(source): - destination_value = destination[i] # type: ignore + destination_value = destination[i] if isinstance(item, dict): converted_list.append(deep_union_pydantic_dicts(item, destination_value)) elif isinstance(item, list): @@ -199,9 +163,7 @@ def _union_list_of_pydantic_dicts( return converted_list -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: +def deep_union_pydantic_dicts(source: Dict[str, Any], destination: Dict[str, Any]) -> Dict[str, Any]: for key, value in source.items(): node = destination.setdefault(key, {}) if isinstance(value, dict): @@ -219,18 +181,16 @@ def deep_union_pydantic_dicts( if IS_PYDANTIC_V2: - class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2 + class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore[misc, name-defined, type-arg] pass - UniversalRootModel: typing_extensions.TypeAlias = V2RootModel # type: ignore + UniversalRootModel: TypeAlias = V2RootModel # type: ignore[misc] else: - UniversalRootModel: typing_extensions.TypeAlias = UniversalBaseModel # type: ignore + UniversalRootModel: TypeAlias = UniversalBaseModel # type: ignore[misc, no-redef] -def encode_by_type(o: typing.Any) -> typing.Any: - encoders_by_class_tuples: typing.Dict[typing.Callable[[typing.Any], typing.Any], typing.Tuple[typing.Any, ...]] = ( - defaultdict(tuple) - ) +def encode_by_type(o: Any) -> Any: + encoders_by_class_tuples: Dict[Callable[[Any], Any], Tuple[Any, ...]] = defaultdict(tuple) for type_, encoder in encoders_by_type.items(): encoders_by_class_tuples[encoder] += (type_,) @@ -241,54 +201,49 @@ def encode_by_type(o: typing.Any) -> typing.Any: return encoder(o) -def update_forward_refs(model: typing.Type["Model"], **localns: typing.Any) -> None: +def update_forward_refs(model: Type["Model"], **localns: Any) -> None: if IS_PYDANTIC_V2: - model.model_rebuild(raise_errors=False) # type: ignore # Pydantic v2 + model.model_rebuild(raise_errors=False) # type: ignore[attr-defined] else: model.update_forward_refs(**localns) # Mirrors Pydantic's internal typing -AnyCallable = typing.Callable[..., typing.Any] +AnyCallable = Callable[..., Any] def universal_root_validator( pre: bool = False, -) -> typing.Callable[[AnyCallable], AnyCallable]: +) -> Callable[[AnyCallable], AnyCallable]: def decorator(func: AnyCallable) -> AnyCallable: if IS_PYDANTIC_V2: - return pydantic.model_validator(mode="before" if pre else "after")(func) # type: ignore # Pydantic v2 - else: - return pydantic.root_validator(pre=pre)(func) # type: ignore # Pydantic v1 + return cast(AnyCallable, pydantic.model_validator(mode="before" if pre else "after")(func)) # type: ignore[attr-defined] + return cast(AnyCallable, pydantic.root_validator(pre=pre)(func)) # type: ignore[call-overload] return decorator -def universal_field_validator(field_name: str, pre: bool = False) -> typing.Callable[[AnyCallable], AnyCallable]: +def universal_field_validator(field_name: str, pre: bool = False) -> Callable[[AnyCallable], AnyCallable]: def decorator(func: AnyCallable) -> AnyCallable: if IS_PYDANTIC_V2: - return pydantic.field_validator(field_name, mode="before" if pre else "after")(func) # type: ignore # Pydantic v2 - else: - return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 + return cast(AnyCallable, pydantic.field_validator(field_name, mode="before" if pre else "after")(func)) # type: ignore[attr-defined] + return cast(AnyCallable, pydantic.validator(field_name, pre=pre)(func)) return decorator -PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] +PydanticField = Union[ModelField, pydantic.fields.FieldInfo] -def _get_model_fields( - model: typing.Type["Model"], -) -> typing.Mapping[str, PydanticField]: +def _get_model_fields(model: Type["Model"]) -> Mapping[str, PydanticField]: if IS_PYDANTIC_V2: - return model.model_fields # type: ignore # Pydantic v2 - else: - return model.__fields__ # type: ignore # Pydantic v1 + return cast(Mapping[str, PydanticField], model.model_fields) # type: ignore[attr-defined] + return cast(Mapping[str, PydanticField], model.__fields__) -def _get_field_default(field: PydanticField) -> typing.Any: +def _get_field_default(field: PydanticField) -> Any: try: - value = field.get_default() # type: ignore # Pydantic < v1.10.15 + value = field.get_default() # type: ignore[union-attr] except: value = field.default if IS_PYDANTIC_V2: diff --git a/src/elevenlabs/core/serialization.py b/src/elevenlabs/core/serialization.py index cb5dcbf9..c36e865c 100644 --- a/src/elevenlabs/core/serialization.py +++ b/src/elevenlabs/core/serialization.py @@ -4,9 +4,8 @@ import inspect import typing -import typing_extensions - import pydantic +import typing_extensions class FieldMetadata: @@ -161,7 +160,12 @@ def _convert_mapping( direction: typing.Literal["read", "write"], ) -> typing.Mapping[str, object]: converted_object: typing.Dict[str, object] = {} - annotations = typing_extensions.get_type_hints(expected_type, include_extras=True) + try: + annotations = typing_extensions.get_type_hints(expected_type, include_extras=True) + except NameError: + # The TypedDict contains a circular reference, so + # we use the __annotations__ attribute directly. + annotations = getattr(expected_type, "__annotations__", {}) aliases_to_field_names = _get_alias_to_field_name(annotations) for key, value in object_.items(): if direction == "read" and key in aliases_to_field_names: diff --git a/src/elevenlabs/core/unchecked_base_model.py b/src/elevenlabs/core/unchecked_base_model.py index d111b06d..2c2d92a7 100644 --- a/src/elevenlabs/core/unchecked_base_model.py +++ b/src/elevenlabs/core/unchecked_base_model.py @@ -5,11 +5,8 @@ import typing import uuid -import typing_extensions -from pydantic_core import PydanticUndefined - import pydantic - +import typing_extensions from .pydantic_utilities import ( IS_PYDANTIC_V2, ModelField, @@ -23,6 +20,7 @@ parse_obj_as, ) from .serialization import get_field_to_alias_mapping +from pydantic_core import PydanticUndefined class UnionMetadata: diff --git a/src/elevenlabs/dubbing/__init__.py b/src/elevenlabs/dubbing/__init__.py index 08f84ed0..9ce91100 100644 --- a/src/elevenlabs/dubbing/__init__.py +++ b/src/elevenlabs/dubbing/__init__.py @@ -1,6 +1,8 @@ # This file was auto-generated by Fern from our API Definition. -from .types import DubbingGetTranscriptForDubRequestFormatType -from . import speaker +# isort: skip_file -__all__ = ["DubbingGetTranscriptForDubRequestFormatType", "speaker"] +from . import audio, resource, transcript +from .transcript import TranscriptGetTranscriptForDubRequestFormatType + +__all__ = ["TranscriptGetTranscriptForDubRequestFormatType", "audio", "resource", "transcript"] diff --git a/src/elevenlabs/dubbing/audio/__init__.py b/src/elevenlabs/dubbing/audio/__init__.py new file mode 100644 index 00000000..5cde0202 --- /dev/null +++ b/src/elevenlabs/dubbing/audio/__init__.py @@ -0,0 +1,4 @@ +# This file was auto-generated by Fern from our API Definition. + +# isort: skip_file + diff --git a/src/elevenlabs/dubbing/audio/client.py b/src/elevenlabs/dubbing/audio/client.py new file mode 100644 index 00000000..7b7f803f --- /dev/null +++ b/src/elevenlabs/dubbing/audio/client.py @@ -0,0 +1,90 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ...core.request_options import RequestOptions +from .raw_client import AsyncRawAudioClient, RawAudioClient + + +class AudioClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._raw_client = RawAudioClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawAudioClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawAudioClient + """ + return self._raw_client + + def get( + self, dubbing_id: str, language_code: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> typing.Iterator[bytes]: + """ + Returns dub as a streamed MP3 or MP4 file. If this dub has been edited using Dubbing Studio you need to use the resource render endpoint as this endpoint only returns the original automatic dub result. + + Parameters + ---------- + dubbing_id : str + ID of the dubbing project. + + language_code : str + ID of the language. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. + + Returns + ------- + typing.Iterator[bytes] + The dubbed audio or video file + """ + with self._raw_client.get(dubbing_id, language_code, request_options=request_options) as r: + yield from r.data + + +class AsyncAudioClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawAudioClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawAudioClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawAudioClient + """ + return self._raw_client + + async def get( + self, dubbing_id: str, language_code: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> typing.AsyncIterator[bytes]: + """ + Returns dub as a streamed MP3 or MP4 file. If this dub has been edited using Dubbing Studio you need to use the resource render endpoint as this endpoint only returns the original automatic dub result. + + Parameters + ---------- + dubbing_id : str + ID of the dubbing project. + + language_code : str + ID of the language. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. + + Returns + ------- + typing.AsyncIterator[bytes] + The dubbed audio or video file + """ + async with self._raw_client.get(dubbing_id, language_code, request_options=request_options) as r: + async for _chunk in r.data: + yield _chunk diff --git a/src/elevenlabs/dubbing/audio/raw_client.py b/src/elevenlabs/dubbing/audio/raw_client.py new file mode 100644 index 00000000..50b86832 --- /dev/null +++ b/src/elevenlabs/dubbing/audio/raw_client.py @@ -0,0 +1,210 @@ +# This file was auto-generated by Fern from our API Definition. + +import contextlib +import typing +from json.decoder import JSONDecodeError + +from ...core.api_error import ApiError +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ...core.http_response import AsyncHttpResponse, HttpResponse +from ...core.jsonable_encoder import jsonable_encoder +from ...core.request_options import RequestOptions +from ...core.unchecked_base_model import construct_type +from ...errors.forbidden_error import ForbiddenError +from ...errors.not_found_error import NotFoundError +from ...errors.too_early_error import TooEarlyError +from ...errors.unprocessable_entity_error import UnprocessableEntityError +from ...types.http_validation_error import HttpValidationError + + +class RawAudioClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + @contextlib.contextmanager + def get( + self, dubbing_id: str, language_code: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> typing.Iterator[HttpResponse[typing.Iterator[bytes]]]: + """ + Returns dub as a streamed MP3 or MP4 file. If this dub has been edited using Dubbing Studio you need to use the resource render endpoint as this endpoint only returns the original automatic dub result. + + Parameters + ---------- + dubbing_id : str + ID of the dubbing project. + + language_code : str + ID of the language. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. + + Returns + ------- + typing.Iterator[HttpResponse[typing.Iterator[bytes]]] + The dubbed audio or video file + """ + with self._client_wrapper.httpx_client.stream( + f"v1/dubbing/{jsonable_encoder(dubbing_id)}/audio/{jsonable_encoder(language_code)}", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) as _response: + + def _stream() -> HttpResponse[typing.Iterator[bytes]]: + try: + if 200 <= _response.status_code < 300: + _chunk_size = request_options.get("chunk_size", 1024) if request_options is not None else 1024 + return HttpResponse( + response=_response, data=(_chunk for _chunk in _response.iter_bytes(chunk_size=_chunk_size)) + ) + _response.read() + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + construct_type( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + construct_type( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 425: + raise TooEarlyError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + construct_type( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + yield _stream() + + +class AsyncRawAudioClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + @contextlib.asynccontextmanager + async def get( + self, dubbing_id: str, language_code: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> typing.AsyncIterator[AsyncHttpResponse[typing.AsyncIterator[bytes]]]: + """ + Returns dub as a streamed MP3 or MP4 file. If this dub has been edited using Dubbing Studio you need to use the resource render endpoint as this endpoint only returns the original automatic dub result. + + Parameters + ---------- + dubbing_id : str + ID of the dubbing project. + + language_code : str + ID of the language. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. + + Returns + ------- + typing.AsyncIterator[AsyncHttpResponse[typing.AsyncIterator[bytes]]] + The dubbed audio or video file + """ + async with self._client_wrapper.httpx_client.stream( + f"v1/dubbing/{jsonable_encoder(dubbing_id)}/audio/{jsonable_encoder(language_code)}", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) as _response: + + async def _stream() -> AsyncHttpResponse[typing.AsyncIterator[bytes]]: + try: + if 200 <= _response.status_code < 300: + _chunk_size = request_options.get("chunk_size", 1024) if request_options is not None else 1024 + return AsyncHttpResponse( + response=_response, + data=(_chunk async for _chunk in _response.aiter_bytes(chunk_size=_chunk_size)), + ) + await _response.aread() + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + construct_type( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + construct_type( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 425: + raise TooEarlyError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + construct_type( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + yield await _stream() diff --git a/src/elevenlabs/dubbing/client.py b/src/elevenlabs/dubbing/client.py index 8ac3bfb5..380739c6 100644 --- a/src/elevenlabs/dubbing/client.py +++ b/src/elevenlabs/dubbing/client.py @@ -1,1800 +1,252 @@ # This file was auto-generated by Fern from our API Definition. import typing -from ..core.client_wrapper import SyncClientWrapper -from .speaker.client import SpeakerClient -from ..core.request_options import RequestOptions -from ..types.dubbing_resource import DubbingResource -from ..core.jsonable_encoder import jsonable_encoder -from ..core.unchecked_base_model import construct_type -from ..errors.unprocessable_entity_error import UnprocessableEntityError -from ..types.http_validation_error import HttpValidationError -from json.decoder import JSONDecodeError -from ..core.api_error import ApiError -from ..types.language_added_response import LanguageAddedResponse -from ..types.segment_update_response import SegmentUpdateResponse -from ..types.segment_delete_response import SegmentDeleteResponse -from ..types.segment_transcription_response import SegmentTranscriptionResponse -from ..types.segment_translation_response import SegmentTranslationResponse -from ..types.segment_dub_response import SegmentDubResponse -from ..types.render_type import RenderType -from ..types.dubbing_render_response_model import DubbingRenderResponseModel -from .. import core -from ..types.do_dubbing_response import DoDubbingResponse -from ..types.dubbing_metadata_response import DubbingMetadataResponse -from ..types.delete_dubbing_response_model import DeleteDubbingResponseModel -from ..errors.forbidden_error import ForbiddenError -from ..errors.not_found_error import NotFoundError -from ..errors.too_early_error import TooEarlyError -from .types.dubbing_get_transcript_for_dub_request_format_type import ( - DubbingGetTranscriptForDubRequestFormatType, -) -from ..core.client_wrapper import AsyncClientWrapper -from .speaker.client import AsyncSpeakerClient - -# this is used as the default value for optional parameters -OMIT = typing.cast(typing.Any, ...) - - -class DubbingClient: - def __init__(self, *, client_wrapper: SyncClientWrapper): - self._client_wrapper = client_wrapper - self.speaker = SpeakerClient(client_wrapper=self._client_wrapper) - - def get_dubbing_resource( - self, - dubbing_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, - ) -> DubbingResource: - """ - Given a dubbing ID generated from the '/v1/dubbing' endpoint with studio enabled, returns the dubbing resource. - - Parameters - ---------- - dubbing_id : str - ID of the dubbing project. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - DubbingResource - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.dubbing.get_dubbing_resource( - dubbing_id="dubbing_id", - ) - """ - _response = self._client_wrapper.httpx_client.request( - f"v1/dubbing/resource/{jsonable_encoder(dubbing_id)}", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - DubbingResource, - construct_type( - type_=DubbingResource, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def add_language_to_resource( - self, - dubbing_id: str, - *, - language: typing.Optional[str] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> LanguageAddedResponse: - """ - Adds the given ElevenLab Turbo V2/V2.5 language code to the resource. Does not automatically generate transcripts/translations/audio. - - Parameters - ---------- - dubbing_id : str - ID of the dubbing project. - - language : typing.Optional[str] - The Target language. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - LanguageAddedResponse - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.dubbing.add_language_to_resource( - dubbing_id="dubbing_id", - ) - """ - _response = self._client_wrapper.httpx_client.request( - f"v1/dubbing/resource/{jsonable_encoder(dubbing_id)}/language", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "language": language, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - LanguageAddedResponse, - construct_type( - type_=LanguageAddedResponse, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def update_segment_language( - self, - dubbing_id: str, - segment_id: str, - language: str, - *, - start_time: typing.Optional[float] = OMIT, - end_time: typing.Optional[float] = OMIT, - text: typing.Optional[str] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> SegmentUpdateResponse: - """ - Modifies a single segment with new text and/or start/end times. Will update the values for only a specific language of a segment. Does not automatically regenerate the dub. - - Parameters - ---------- - dubbing_id : str - ID of the dubbing project. - - segment_id : str - ID of the segment - - language : str - ID of the language. - - start_time : typing.Optional[float] - - end_time : typing.Optional[float] - - text : typing.Optional[str] - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - SegmentUpdateResponse - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.dubbing.update_segment_language( - dubbing_id="dubbing_id", - segment_id="segment_id", - language="language", - ) - """ - _response = self._client_wrapper.httpx_client.request( - f"v1/dubbing/resource/{jsonable_encoder(dubbing_id)}/segment/{jsonable_encoder(segment_id)}/{jsonable_encoder(language)}", - base_url=self._client_wrapper.get_environment().base, - method="PATCH", - json={ - "start_time": start_time, - "end_time": end_time, - "text": text, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - SegmentUpdateResponse, - construct_type( - type_=SegmentUpdateResponse, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def delete_segment( - self, - dubbing_id: str, - segment_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, - ) -> SegmentDeleteResponse: - """ - Deletes a single segment from the dubbing. - - Parameters - ---------- - dubbing_id : str - ID of the dubbing project. - - segment_id : str - ID of the segment - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - SegmentDeleteResponse - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.dubbing.delete_segment( - dubbing_id="dubbing_id", - segment_id="segment_id", - ) - """ - _response = self._client_wrapper.httpx_client.request( - f"v1/dubbing/resource/{jsonable_encoder(dubbing_id)}/segment/{jsonable_encoder(segment_id)}", - base_url=self._client_wrapper.get_environment().base, - method="DELETE", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - SegmentDeleteResponse, - construct_type( - type_=SegmentDeleteResponse, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def transcribe_segments( - self, - dubbing_id: str, - *, - segments: typing.Sequence[str], - request_options: typing.Optional[RequestOptions] = None, - ) -> SegmentTranscriptionResponse: - """ - Regenerate the transcriptions for the specified segments. Does not automatically regenerate translations or dubs. - - Parameters - ---------- - dubbing_id : str - ID of the dubbing project. - - segments : typing.Sequence[str] - Transcribe this specific list of segments. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - SegmentTranscriptionResponse - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.dubbing.transcribe_segments( - dubbing_id="dubbing_id", - segments=["segments"], - ) - """ - _response = self._client_wrapper.httpx_client.request( - f"v1/dubbing/resource/{jsonable_encoder(dubbing_id)}/transcribe", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "segments": segments, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - SegmentTranscriptionResponse, - construct_type( - type_=SegmentTranscriptionResponse, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def translate_segments( - self, - dubbing_id: str, - *, - segments: typing.Sequence[str], - languages: typing.Optional[typing.Sequence[str]] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> SegmentTranslationResponse: - """ - Regenerate the translations for either the entire resource or the specified segments/languages. Will automatically transcribe missing transcriptions. Will not automatically regenerate the dubs. - - Parameters - ---------- - dubbing_id : str - ID of the dubbing project. - - segments : typing.Sequence[str] - Translate only this list of segments. - - languages : typing.Optional[typing.Sequence[str]] - Translate only these languages for each segment. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - SegmentTranslationResponse - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.dubbing.translate_segments( - dubbing_id="dubbing_id", - segments=["segments"], - ) - """ - _response = self._client_wrapper.httpx_client.request( - f"v1/dubbing/resource/{jsonable_encoder(dubbing_id)}/translate", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "segments": segments, - "languages": languages, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - SegmentTranslationResponse, - construct_type( - type_=SegmentTranslationResponse, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def dub_segments( - self, - dubbing_id: str, - *, - segments: typing.Sequence[str], - languages: typing.Optional[typing.Sequence[str]] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> SegmentDubResponse: - """ - Regenerate the dubs for either the entire resource or the specified segments/languages. Will automatically transcribe and translate any missing transcriptions and translations. - - Parameters - ---------- - dubbing_id : str - ID of the dubbing project. - - segments : typing.Sequence[str] - Dub only this list of segments. - - languages : typing.Optional[typing.Sequence[str]] - Dub only these languages for each segment. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - SegmentDubResponse - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.dubbing.dub_segments( - dubbing_id="dubbing_id", - segments=["segments"], - ) - """ - _response = self._client_wrapper.httpx_client.request( - f"v1/dubbing/resource/{jsonable_encoder(dubbing_id)}/dub", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "segments": segments, - "languages": languages, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - SegmentDubResponse, - construct_type( - type_=SegmentDubResponse, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def render_dub( - self, - dubbing_id: str, - language: str, - *, - render_type: RenderType, - request_options: typing.Optional[RequestOptions] = None, - ) -> DubbingRenderResponseModel: - """ - Regenerate the dubs for either the entire resource or the specified segments/languages. Will automatically transcribe and translate any missing transcriptions and translations. - - Parameters - ---------- - dubbing_id : str - ID of the dubbing project. - - language : str - Render this language - - render_type : RenderType - The type of the render. One of ['mp4', 'aac', 'mp3', 'wav', 'aaf', 'tracks_zip', 'clips_zip'] - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - DubbingRenderResponseModel - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.dubbing.render_dub( - dubbing_id="dubbing_id", - language="language", - render_type="mp4", - ) - """ - _response = self._client_wrapper.httpx_client.request( - f"v1/dubbing/resource/{jsonable_encoder(dubbing_id)}/render/{jsonable_encoder(language)}", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "render_type": render_type, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - DubbingRenderResponseModel, - construct_type( - type_=DubbingRenderResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def dub_a_video_or_an_audio_file( - self, - *, - file: typing.Optional[core.File] = OMIT, - csv_file: typing.Optional[core.File] = OMIT, - foreground_audio_file: typing.Optional[core.File] = OMIT, - background_audio_file: typing.Optional[core.File] = OMIT, - name: typing.Optional[str] = OMIT, - source_url: typing.Optional[str] = OMIT, - source_lang: typing.Optional[str] = OMIT, - target_lang: typing.Optional[str] = OMIT, - num_speakers: typing.Optional[int] = OMIT, - watermark: typing.Optional[bool] = OMIT, - start_time: typing.Optional[int] = OMIT, - end_time: typing.Optional[int] = OMIT, - highest_resolution: typing.Optional[bool] = OMIT, - drop_background_audio: typing.Optional[bool] = OMIT, - use_profanity_filter: typing.Optional[bool] = OMIT, - dubbing_studio: typing.Optional[bool] = OMIT, - disable_voice_cloning: typing.Optional[bool] = OMIT, - mode: typing.Optional[str] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> DoDubbingResponse: - """ - Dubs a provided audio or video file into given language. - - Parameters - ---------- - file : typing.Optional[core.File] - See core.File for more documentation - - csv_file : typing.Optional[core.File] - See core.File for more documentation - - foreground_audio_file : typing.Optional[core.File] - See core.File for more documentation - - background_audio_file : typing.Optional[core.File] - See core.File for more documentation - - name : typing.Optional[str] - Name of the dubbing project. - - source_url : typing.Optional[str] - URL of the source video/audio file. - - source_lang : typing.Optional[str] - Source language. - - target_lang : typing.Optional[str] - The Target language to dub the content into. - - num_speakers : typing.Optional[int] - Number of speakers to use for the dubbing. Set to 0 to automatically detect the number of speakers - - watermark : typing.Optional[bool] - Whether to apply watermark to the output video. - - start_time : typing.Optional[int] - Start time of the source video/audio file. - - end_time : typing.Optional[int] - End time of the source video/audio file. - - highest_resolution : typing.Optional[bool] - Whether to use the highest resolution available. - - drop_background_audio : typing.Optional[bool] - An advanced setting. Whether to drop background audio from the final dub. This can improve dub quality where it's known that audio shouldn't have a background track such as for speeches or monologues. - - use_profanity_filter : typing.Optional[bool] - [BETA] Whether transcripts should have profanities censored with the words '[censored]' - - dubbing_studio : typing.Optional[bool] - Whether to prepare dub for edits in dubbing studio or edits as a dubbing resource. - - disable_voice_cloning : typing.Optional[bool] - [BETA] Instead of using a voice clone in dubbing, use a similar voice from the ElevenLabs Voice Library. - - mode : typing.Optional[str] - automatic or manual. Manual mode is only supported when creating a dubbing studio project - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - DoDubbingResponse - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.dubbing.dub_a_video_or_an_audio_file() - """ - _response = self._client_wrapper.httpx_client.request( - "v1/dubbing", - base_url=self._client_wrapper.get_environment().base, - method="POST", - data={ - "name": name, - "source_url": source_url, - "source_lang": source_lang, - "target_lang": target_lang, - "num_speakers": num_speakers, - "watermark": watermark, - "start_time": start_time, - "end_time": end_time, - "highest_resolution": highest_resolution, - "drop_background_audio": drop_background_audio, - "use_profanity_filter": use_profanity_filter, - "dubbing_studio": dubbing_studio, - "disable_voice_cloning": disable_voice_cloning, - "mode": mode, - }, - files={ - "file": file, - "csv_file": csv_file, - "foreground_audio_file": foreground_audio_file, - "background_audio_file": background_audio_file, - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - DoDubbingResponse, - construct_type( - type_=DoDubbingResponse, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def get_dubbing_project_metadata( - self, - dubbing_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, - ) -> DubbingMetadataResponse: - """ - Returns metadata about a dubbing project, including whether it's still in progress or not - - Parameters - ---------- - dubbing_id : str - ID of the dubbing project. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - DubbingMetadataResponse - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.dubbing.get_dubbing_project_metadata( - dubbing_id="dubbing_id", - ) - """ - _response = self._client_wrapper.httpx_client.request( - f"v1/dubbing/{jsonable_encoder(dubbing_id)}", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - DubbingMetadataResponse, - construct_type( - type_=DubbingMetadataResponse, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def delete_dubbing_project( - self, - dubbing_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, - ) -> DeleteDubbingResponseModel: - """ - Deletes a dubbing project. - - Parameters - ---------- - dubbing_id : str - ID of the dubbing project. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - DeleteDubbingResponseModel - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.dubbing.delete_dubbing_project( - dubbing_id="dubbing_id", - ) - """ - _response = self._client_wrapper.httpx_client.request( - f"v1/dubbing/{jsonable_encoder(dubbing_id)}", - base_url=self._client_wrapper.get_environment().base, - method="DELETE", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - DeleteDubbingResponseModel, - construct_type( - type_=DeleteDubbingResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def get_dubbed_file( - self, - dubbing_id: str, - language_code: str, - *, - request_options: typing.Optional[RequestOptions] = None, - ) -> typing.Iterator[bytes]: - """ - Returns dubbed file as a streamed file. Videos will be returned in MP4 format and audio only dubs will be returned in MP3. - - Parameters - ---------- - dubbing_id : str - ID of the dubbing project. - - language_code : str - ID of the language. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. - - Yields - ------ - typing.Iterator[bytes] - The dubbed audio or video file - """ - with self._client_wrapper.httpx_client.stream( - f"v1/dubbing/{jsonable_encoder(dubbing_id)}/audio/{jsonable_encoder(language_code)}", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) as _response: - try: - if 200 <= _response.status_code < 300: - _chunk_size = request_options.get("chunk_size", 1024) if request_options is not None else 1024 - for _chunk in _response.iter_bytes(chunk_size=_chunk_size): - yield _chunk - return - _response.read() - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 425: - raise TooEarlyError( - typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def get_transcript_for_dub( - self, - dubbing_id: str, - language_code: str, - *, - format_type: typing.Optional[DubbingGetTranscriptForDubRequestFormatType] = None, - request_options: typing.Optional[RequestOptions] = None, - ) -> str: - """ - Returns transcript for the dub as an SRT or WEBVTT file. - - Parameters - ---------- - dubbing_id : str - ID of the dubbing project. - - language_code : str - ID of the language. - - format_type : typing.Optional[DubbingGetTranscriptForDubRequestFormatType] - Format to use for the subtitle file, either 'srt' or 'webvtt' - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - str - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.dubbing.get_transcript_for_dub( - dubbing_id="dubbing_id", - language_code="language_code", - ) - """ - _response = self._client_wrapper.httpx_client.request( - f"v1/dubbing/{jsonable_encoder(dubbing_id)}/transcript/{jsonable_encoder(language_code)}", - base_url=self._client_wrapper.get_environment().base, - method="GET", - params={ - "format_type": format_type, - }, - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return _response.text # type: ignore - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 425: - raise TooEarlyError( - typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - -class AsyncDubbingClient: - def __init__(self, *, client_wrapper: AsyncClientWrapper): - self._client_wrapper = client_wrapper - self.speaker = AsyncSpeakerClient(client_wrapper=self._client_wrapper) - - async def get_dubbing_resource( - self, - dubbing_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, - ) -> DubbingResource: - """ - Given a dubbing ID generated from the '/v1/dubbing' endpoint with studio enabled, returns the dubbing resource. - - Parameters - ---------- - dubbing_id : str - ID of the dubbing project. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - DubbingResource - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.dubbing.get_dubbing_resource( - dubbing_id="dubbing_id", - ) - - - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/dubbing/resource/{jsonable_encoder(dubbing_id)}", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - DubbingResource, - construct_type( - type_=DubbingResource, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def add_language_to_resource( - self, - dubbing_id: str, - *, - language: typing.Optional[str] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> LanguageAddedResponse: - """ - Adds the given ElevenLab Turbo V2/V2.5 language code to the resource. Does not automatically generate transcripts/translations/audio. - - Parameters - ---------- - dubbing_id : str - ID of the dubbing project. - - language : typing.Optional[str] - The Target language. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - LanguageAddedResponse - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.dubbing.add_language_to_resource( - dubbing_id="dubbing_id", - ) +from .. import core +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ..core.request_options import RequestOptions +from ..types.delete_dubbing_response_model import DeleteDubbingResponseModel +from ..types.do_dubbing_response import DoDubbingResponse +from ..types.dubbing_metadata_response import DubbingMetadataResponse +from .audio.client import AsyncAudioClient, AudioClient +from .raw_client import AsyncRawDubbingClient, RawDubbingClient +from .resource.client import AsyncResourceClient, ResourceClient +from .transcript.client import AsyncTranscriptClient, TranscriptClient - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/dubbing/resource/{jsonable_encoder(dubbing_id)}/language", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "language": language, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - LanguageAddedResponse, - construct_type( - type_=LanguageAddedResponse, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def update_segment_language( - self, - dubbing_id: str, - segment_id: str, - language: str, - *, - start_time: typing.Optional[float] = OMIT, - end_time: typing.Optional[float] = OMIT, - text: typing.Optional[str] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> SegmentUpdateResponse: - """ - Modifies a single segment with new text and/or start/end times. Will update the values for only a specific language of a segment. Does not automatically regenerate the dub. - - Parameters - ---------- - dubbing_id : str - ID of the dubbing project. - - segment_id : str - ID of the segment - - language : str - ID of the language. - - start_time : typing.Optional[float] - - end_time : typing.Optional[float] - - text : typing.Optional[str] - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - SegmentUpdateResponse - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.dubbing.update_segment_language( - dubbing_id="dubbing_id", - segment_id="segment_id", - language="language", - ) - - - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/dubbing/resource/{jsonable_encoder(dubbing_id)}/segment/{jsonable_encoder(segment_id)}/{jsonable_encoder(language)}", - base_url=self._client_wrapper.get_environment().base, - method="PATCH", - json={ - "start_time": start_time, - "end_time": end_time, - "text": text, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - SegmentUpdateResponse, - construct_type( - type_=SegmentUpdateResponse, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def delete_segment( - self, - dubbing_id: str, - segment_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, - ) -> SegmentDeleteResponse: - """ - Deletes a single segment from the dubbing. - - Parameters - ---------- - dubbing_id : str - ID of the dubbing project. - - segment_id : str - ID of the segment - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - SegmentDeleteResponse - Successful Response - - Examples - -------- - import asyncio +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) - from elevenlabs import AsyncElevenLabs - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) +class DubbingClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._raw_client = RawDubbingClient(client_wrapper=client_wrapper) + self.resource = ResourceClient(client_wrapper=client_wrapper) + self.audio = AudioClient(client_wrapper=client_wrapper) - async def main() -> None: - await client.dubbing.delete_segment( - dubbing_id="dubbing_id", - segment_id="segment_id", - ) + self.transcript = TranscriptClient(client_wrapper=client_wrapper) + @property + def with_raw_response(self) -> RawDubbingClient: + """ + Retrieves a raw implementation of this client that returns raw responses. - asyncio.run(main()) + Returns + ------- + RawDubbingClient """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/dubbing/resource/{jsonable_encoder(dubbing_id)}/segment/{jsonable_encoder(segment_id)}", - base_url=self._client_wrapper.get_environment().base, - method="DELETE", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - SegmentDeleteResponse, - construct_type( - type_=SegmentDeleteResponse, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def transcribe_segments( + return self._raw_client + + def create( self, - dubbing_id: str, *, - segments: typing.Sequence[str], + file: typing.Optional[core.File] = OMIT, + csv_file: typing.Optional[core.File] = OMIT, + foreground_audio_file: typing.Optional[core.File] = OMIT, + background_audio_file: typing.Optional[core.File] = OMIT, + name: typing.Optional[str] = OMIT, + source_url: typing.Optional[str] = OMIT, + source_lang: typing.Optional[str] = OMIT, + target_lang: typing.Optional[str] = OMIT, + num_speakers: typing.Optional[int] = OMIT, + watermark: typing.Optional[bool] = OMIT, + start_time: typing.Optional[int] = OMIT, + end_time: typing.Optional[int] = OMIT, + highest_resolution: typing.Optional[bool] = OMIT, + drop_background_audio: typing.Optional[bool] = OMIT, + use_profanity_filter: typing.Optional[bool] = OMIT, + dubbing_studio: typing.Optional[bool] = OMIT, + disable_voice_cloning: typing.Optional[bool] = OMIT, + mode: typing.Optional[str] = OMIT, request_options: typing.Optional[RequestOptions] = None, - ) -> SegmentTranscriptionResponse: + ) -> DoDubbingResponse: """ - Regenerate the transcriptions for the specified segments. Does not automatically regenerate translations or dubs. + Dubs a provided audio or video file into given language. Parameters ---------- - dubbing_id : str - ID of the dubbing project. + file : typing.Optional[core.File] + See core.File for more documentation - segments : typing.Sequence[str] - Transcribe this specific list of segments. + csv_file : typing.Optional[core.File] + See core.File for more documentation - request_options : typing.Optional[RequestOptions] - Request-specific configuration. + foreground_audio_file : typing.Optional[core.File] + See core.File for more documentation - Returns - ------- - SegmentTranscriptionResponse - Successful Response + background_audio_file : typing.Optional[core.File] + See core.File for more documentation - Examples - -------- - import asyncio + name : typing.Optional[str] + Name of the dubbing project. - from elevenlabs import AsyncElevenLabs + source_url : typing.Optional[str] + URL of the source video/audio file. - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) + source_lang : typing.Optional[str] + Source language. + target_lang : typing.Optional[str] + The Target language to dub the content into. - async def main() -> None: - await client.dubbing.transcribe_segments( - dubbing_id="dubbing_id", - segments=["segments"], - ) + num_speakers : typing.Optional[int] + Number of speakers to use for the dubbing. Set to 0 to automatically detect the number of speakers + watermark : typing.Optional[bool] + Whether to apply watermark to the output video. - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/dubbing/resource/{jsonable_encoder(dubbing_id)}/transcribe", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "segments": segments, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - SegmentTranscriptionResponse, - construct_type( - type_=SegmentTranscriptionResponse, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def translate_segments( - self, - dubbing_id: str, - *, - segments: typing.Sequence[str], - languages: typing.Optional[typing.Sequence[str]] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> SegmentTranslationResponse: - """ - Regenerate the translations for either the entire resource or the specified segments/languages. Will automatically transcribe missing transcriptions. Will not automatically regenerate the dubs. + start_time : typing.Optional[int] + Start time of the source video/audio file. - Parameters - ---------- - dubbing_id : str - ID of the dubbing project. + end_time : typing.Optional[int] + End time of the source video/audio file. + + highest_resolution : typing.Optional[bool] + Whether to use the highest resolution available. + + drop_background_audio : typing.Optional[bool] + An advanced setting. Whether to drop background audio from the final dub. This can improve dub quality where it's known that audio shouldn't have a background track such as for speeches or monologues. + + use_profanity_filter : typing.Optional[bool] + [BETA] Whether transcripts should have profanities censored with the words '[censored]' - segments : typing.Sequence[str] - Translate only this list of segments. + dubbing_studio : typing.Optional[bool] + Whether to prepare dub for edits in dubbing studio or edits as a dubbing resource. + + disable_voice_cloning : typing.Optional[bool] + [BETA] Instead of using a voice clone in dubbing, use a similar voice from the ElevenLabs Voice Library. - languages : typing.Optional[typing.Sequence[str]] - Translate only these languages for each segment. + mode : typing.Optional[str] + automatic or manual. Manual mode is only supported when creating a dubbing studio project request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- - SegmentTranslationResponse + DoDubbingResponse Successful Response Examples -------- - import asyncio - - from elevenlabs import AsyncElevenLabs + from elevenlabs import ElevenLabs - client = AsyncElevenLabs( + client = ElevenLabs( api_key="YOUR_API_KEY", ) - - - async def main() -> None: - await client.dubbing.translate_segments( - dubbing_id="dubbing_id", - segments=["segments"], - ) - - - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/dubbing/resource/{jsonable_encoder(dubbing_id)}/translate", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "segments": segments, - "languages": languages, - }, - headers={ - "content-type": "application/json", - }, + client.dubbing.create() + """ + _response = self._raw_client.create( + file=file, + csv_file=csv_file, + foreground_audio_file=foreground_audio_file, + background_audio_file=background_audio_file, + name=name, + source_url=source_url, + source_lang=source_lang, + target_lang=target_lang, + num_speakers=num_speakers, + watermark=watermark, + start_time=start_time, + end_time=end_time, + highest_resolution=highest_resolution, + drop_background_audio=drop_background_audio, + use_profanity_filter=use_profanity_filter, + dubbing_studio=dubbing_studio, + disable_voice_cloning=disable_voice_cloning, + mode=mode, request_options=request_options, - omit=OMIT, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - SegmentTranslationResponse, - construct_type( - type_=SegmentTranslationResponse, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def dub_segments( - self, - dubbing_id: str, - *, - segments: typing.Sequence[str], - languages: typing.Optional[typing.Sequence[str]] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> SegmentDubResponse: + return _response.data + + def get( + self, dubbing_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> DubbingMetadataResponse: """ - Regenerate the dubs for either the entire resource or the specified segments/languages. Will automatically transcribe and translate any missing transcriptions and translations. + Returns metadata about a dubbing project, including whether it's still in progress or not Parameters ---------- dubbing_id : str ID of the dubbing project. - segments : typing.Sequence[str] - Dub only this list of segments. - - languages : typing.Optional[typing.Sequence[str]] - Dub only these languages for each segment. - request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- - SegmentDubResponse + DubbingMetadataResponse Successful Response Examples -------- - import asyncio - - from elevenlabs import AsyncElevenLabs + from elevenlabs import ElevenLabs - client = AsyncElevenLabs( + client = ElevenLabs( api_key="YOUR_API_KEY", ) - - - async def main() -> None: - await client.dubbing.dub_segments( - dubbing_id="dubbing_id", - segments=["segments"], - ) - - - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/dubbing/resource/{jsonable_encoder(dubbing_id)}/dub", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "segments": segments, - "languages": languages, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, + client.dubbing.get( + dubbing_id="dubbing_id", ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - SegmentDubResponse, - construct_type( - type_=SegmentDubResponse, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def render_dub( - self, - dubbing_id: str, - language: str, - *, - render_type: RenderType, - request_options: typing.Optional[RequestOptions] = None, - ) -> DubbingRenderResponseModel: """ - Regenerate the dubs for either the entire resource or the specified segments/languages. Will automatically transcribe and translate any missing transcriptions and translations. + _response = self._raw_client.get(dubbing_id, request_options=request_options) + return _response.data + + def delete( + self, dubbing_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> DeleteDubbingResponseModel: + """ + Deletes a dubbing project. Parameters ---------- dubbing_id : str ID of the dubbing project. - language : str - Render this language - - render_type : RenderType - The type of the render. One of ['mp4', 'aac', 'mp3', 'wav', 'aaf', 'tracks_zip', 'clips_zip'] - request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- - DubbingRenderResponseModel + DeleteDubbingResponseModel Successful Response Examples -------- - import asyncio - - from elevenlabs import AsyncElevenLabs + from elevenlabs import ElevenLabs - client = AsyncElevenLabs( + client = ElevenLabs( api_key="YOUR_API_KEY", ) + client.dubbing.delete( + dubbing_id="dubbing_id", + ) + """ + _response = self._raw_client.delete(dubbing_id, request_options=request_options) + return _response.data - async def main() -> None: - await client.dubbing.render_dub( - dubbing_id="dubbing_id", - language="language", - render_type="mp4", - ) +class AsyncDubbingClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawDubbingClient(client_wrapper=client_wrapper) + self.resource = AsyncResourceClient(client_wrapper=client_wrapper) + self.audio = AsyncAudioClient(client_wrapper=client_wrapper) - asyncio.run(main()) + self.transcript = AsyncTranscriptClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawDubbingClient: """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/dubbing/resource/{jsonable_encoder(dubbing_id)}/render/{jsonable_encoder(language)}", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "render_type": render_type, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - DubbingRenderResponseModel, - construct_type( - type_=DubbingRenderResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def dub_a_video_or_an_audio_file( + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawDubbingClient + """ + return self._raw_client + + async def create( self, *, file: typing.Optional[core.File] = OMIT, @@ -1896,69 +348,36 @@ async def dub_a_video_or_an_audio_file( async def main() -> None: - await client.dubbing.dub_a_video_or_an_audio_file() + await client.dubbing.create() asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - "v1/dubbing", - base_url=self._client_wrapper.get_environment().base, - method="POST", - data={ - "name": name, - "source_url": source_url, - "source_lang": source_lang, - "target_lang": target_lang, - "num_speakers": num_speakers, - "watermark": watermark, - "start_time": start_time, - "end_time": end_time, - "highest_resolution": highest_resolution, - "drop_background_audio": drop_background_audio, - "use_profanity_filter": use_profanity_filter, - "dubbing_studio": dubbing_studio, - "disable_voice_cloning": disable_voice_cloning, - "mode": mode, - }, - files={ - "file": file, - "csv_file": csv_file, - "foreground_audio_file": foreground_audio_file, - "background_audio_file": background_audio_file, - }, + _response = await self._raw_client.create( + file=file, + csv_file=csv_file, + foreground_audio_file=foreground_audio_file, + background_audio_file=background_audio_file, + name=name, + source_url=source_url, + source_lang=source_lang, + target_lang=target_lang, + num_speakers=num_speakers, + watermark=watermark, + start_time=start_time, + end_time=end_time, + highest_resolution=highest_resolution, + drop_background_audio=drop_background_audio, + use_profanity_filter=use_profanity_filter, + dubbing_studio=dubbing_studio, + disable_voice_cloning=disable_voice_cloning, + mode=mode, request_options=request_options, - omit=OMIT, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - DoDubbingResponse, - construct_type( - type_=DoDubbingResponse, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def get_dubbing_project_metadata( - self, - dubbing_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, + return _response.data + + async def get( + self, dubbing_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> DubbingMetadataResponse: """ Returns metadata about a dubbing project, including whether it's still in progress or not @@ -1988,48 +407,18 @@ async def get_dubbing_project_metadata( async def main() -> None: - await client.dubbing.get_dubbing_project_metadata( + await client.dubbing.get( dubbing_id="dubbing_id", ) asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/dubbing/{jsonable_encoder(dubbing_id)}", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - DubbingMetadataResponse, - construct_type( - type_=DubbingMetadataResponse, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def delete_dubbing_project( - self, - dubbing_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, + _response = await self._raw_client.get(dubbing_id, request_options=request_options) + return _response.data + + async def delete( + self, dubbing_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> DeleteDubbingResponseModel: """ Deletes a dubbing project. @@ -2059,230 +448,12 @@ async def delete_dubbing_project( async def main() -> None: - await client.dubbing.delete_dubbing_project( - dubbing_id="dubbing_id", - ) - - - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/dubbing/{jsonable_encoder(dubbing_id)}", - base_url=self._client_wrapper.get_environment().base, - method="DELETE", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - DeleteDubbingResponseModel, - construct_type( - type_=DeleteDubbingResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def get_dubbed_file( - self, - dubbing_id: str, - language_code: str, - *, - request_options: typing.Optional[RequestOptions] = None, - ) -> typing.AsyncIterator[bytes]: - """ - Returns dubbed file as a streamed file. Videos will be returned in MP4 format and audio only dubs will be returned in MP3. - - Parameters - ---------- - dubbing_id : str - ID of the dubbing project. - - language_code : str - ID of the language. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. - - Yields - ------ - typing.AsyncIterator[bytes] - The dubbed audio or video file - """ - async with self._client_wrapper.httpx_client.stream( - f"v1/dubbing/{jsonable_encoder(dubbing_id)}/audio/{jsonable_encoder(language_code)}", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) as _response: - try: - if 200 <= _response.status_code < 300: - _chunk_size = request_options.get("chunk_size", 1024) if request_options is not None else 1024 - async for _chunk in _response.aiter_bytes(chunk_size=_chunk_size): - yield _chunk - return - await _response.aread() - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 425: - raise TooEarlyError( - typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def get_transcript_for_dub( - self, - dubbing_id: str, - language_code: str, - *, - format_type: typing.Optional[DubbingGetTranscriptForDubRequestFormatType] = None, - request_options: typing.Optional[RequestOptions] = None, - ) -> str: - """ - Returns transcript for the dub as an SRT or WEBVTT file. - - Parameters - ---------- - dubbing_id : str - ID of the dubbing project. - - language_code : str - ID of the language. - - format_type : typing.Optional[DubbingGetTranscriptForDubRequestFormatType] - Format to use for the subtitle file, either 'srt' or 'webvtt' - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - str - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.dubbing.get_transcript_for_dub( + await client.dubbing.delete( dubbing_id="dubbing_id", - language_code="language_code", ) asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/dubbing/{jsonable_encoder(dubbing_id)}/transcript/{jsonable_encoder(language_code)}", - base_url=self._client_wrapper.get_environment().base, - method="GET", - params={ - "format_type": format_type, - }, - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return _response.text # type: ignore - if _response.status_code == 403: - raise ForbiddenError( - typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 404: - raise NotFoundError( - typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 425: - raise TooEarlyError( - typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.delete(dubbing_id, request_options=request_options) + return _response.data diff --git a/src/elevenlabs/dubbing/raw_client.py b/src/elevenlabs/dubbing/raw_client.py new file mode 100644 index 00000000..e8f09118 --- /dev/null +++ b/src/elevenlabs/dubbing/raw_client.py @@ -0,0 +1,526 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from .. import core +from ..core.api_error import ApiError +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ..core.http_response import AsyncHttpResponse, HttpResponse +from ..core.jsonable_encoder import jsonable_encoder +from ..core.request_options import RequestOptions +from ..core.unchecked_base_model import construct_type +from ..errors.unprocessable_entity_error import UnprocessableEntityError +from ..types.delete_dubbing_response_model import DeleteDubbingResponseModel +from ..types.do_dubbing_response import DoDubbingResponse +from ..types.dubbing_metadata_response import DubbingMetadataResponse +from ..types.http_validation_error import HttpValidationError + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RawDubbingClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def create( + self, + *, + file: typing.Optional[core.File] = OMIT, + csv_file: typing.Optional[core.File] = OMIT, + foreground_audio_file: typing.Optional[core.File] = OMIT, + background_audio_file: typing.Optional[core.File] = OMIT, + name: typing.Optional[str] = OMIT, + source_url: typing.Optional[str] = OMIT, + source_lang: typing.Optional[str] = OMIT, + target_lang: typing.Optional[str] = OMIT, + num_speakers: typing.Optional[int] = OMIT, + watermark: typing.Optional[bool] = OMIT, + start_time: typing.Optional[int] = OMIT, + end_time: typing.Optional[int] = OMIT, + highest_resolution: typing.Optional[bool] = OMIT, + drop_background_audio: typing.Optional[bool] = OMIT, + use_profanity_filter: typing.Optional[bool] = OMIT, + dubbing_studio: typing.Optional[bool] = OMIT, + disable_voice_cloning: typing.Optional[bool] = OMIT, + mode: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[DoDubbingResponse]: + """ + Dubs a provided audio or video file into given language. + + Parameters + ---------- + file : typing.Optional[core.File] + See core.File for more documentation + + csv_file : typing.Optional[core.File] + See core.File for more documentation + + foreground_audio_file : typing.Optional[core.File] + See core.File for more documentation + + background_audio_file : typing.Optional[core.File] + See core.File for more documentation + + name : typing.Optional[str] + Name of the dubbing project. + + source_url : typing.Optional[str] + URL of the source video/audio file. + + source_lang : typing.Optional[str] + Source language. + + target_lang : typing.Optional[str] + The Target language to dub the content into. + + num_speakers : typing.Optional[int] + Number of speakers to use for the dubbing. Set to 0 to automatically detect the number of speakers + + watermark : typing.Optional[bool] + Whether to apply watermark to the output video. + + start_time : typing.Optional[int] + Start time of the source video/audio file. + + end_time : typing.Optional[int] + End time of the source video/audio file. + + highest_resolution : typing.Optional[bool] + Whether to use the highest resolution available. + + drop_background_audio : typing.Optional[bool] + An advanced setting. Whether to drop background audio from the final dub. This can improve dub quality where it's known that audio shouldn't have a background track such as for speeches or monologues. + + use_profanity_filter : typing.Optional[bool] + [BETA] Whether transcripts should have profanities censored with the words '[censored]' + + dubbing_studio : typing.Optional[bool] + Whether to prepare dub for edits in dubbing studio or edits as a dubbing resource. + + disable_voice_cloning : typing.Optional[bool] + [BETA] Instead of using a voice clone in dubbing, use a similar voice from the ElevenLabs Voice Library. + + mode : typing.Optional[str] + automatic or manual. Manual mode is only supported when creating a dubbing studio project + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[DoDubbingResponse] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + "v1/dubbing", + base_url=self._client_wrapper.get_environment().base, + method="POST", + data={ + "name": name, + "source_url": source_url, + "source_lang": source_lang, + "target_lang": target_lang, + "num_speakers": num_speakers, + "watermark": watermark, + "start_time": start_time, + "end_time": end_time, + "highest_resolution": highest_resolution, + "drop_background_audio": drop_background_audio, + "use_profanity_filter": use_profanity_filter, + "dubbing_studio": dubbing_studio, + "disable_voice_cloning": disable_voice_cloning, + "mode": mode, + }, + files={ + **({"file": file} if file is not None else {}), + **({"csv_file": csv_file} if csv_file is not None else {}), + **({"foreground_audio_file": foreground_audio_file} if foreground_audio_file is not None else {}), + **({"background_audio_file": background_audio_file} if background_audio_file is not None else {}), + }, + request_options=request_options, + omit=OMIT, + force_multipart=True, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + DoDubbingResponse, + construct_type( + type_=DoDubbingResponse, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def get( + self, dubbing_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[DubbingMetadataResponse]: + """ + Returns metadata about a dubbing project, including whether it's still in progress or not + + Parameters + ---------- + dubbing_id : str + ID of the dubbing project. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[DubbingMetadataResponse] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/dubbing/{jsonable_encoder(dubbing_id)}", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + DubbingMetadataResponse, + construct_type( + type_=DubbingMetadataResponse, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def delete( + self, dubbing_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[DeleteDubbingResponseModel]: + """ + Deletes a dubbing project. + + Parameters + ---------- + dubbing_id : str + ID of the dubbing project. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[DeleteDubbingResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/dubbing/{jsonable_encoder(dubbing_id)}", + base_url=self._client_wrapper.get_environment().base, + method="DELETE", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + DeleteDubbingResponseModel, + construct_type( + type_=DeleteDubbingResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + +class AsyncRawDubbingClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def create( + self, + *, + file: typing.Optional[core.File] = OMIT, + csv_file: typing.Optional[core.File] = OMIT, + foreground_audio_file: typing.Optional[core.File] = OMIT, + background_audio_file: typing.Optional[core.File] = OMIT, + name: typing.Optional[str] = OMIT, + source_url: typing.Optional[str] = OMIT, + source_lang: typing.Optional[str] = OMIT, + target_lang: typing.Optional[str] = OMIT, + num_speakers: typing.Optional[int] = OMIT, + watermark: typing.Optional[bool] = OMIT, + start_time: typing.Optional[int] = OMIT, + end_time: typing.Optional[int] = OMIT, + highest_resolution: typing.Optional[bool] = OMIT, + drop_background_audio: typing.Optional[bool] = OMIT, + use_profanity_filter: typing.Optional[bool] = OMIT, + dubbing_studio: typing.Optional[bool] = OMIT, + disable_voice_cloning: typing.Optional[bool] = OMIT, + mode: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[DoDubbingResponse]: + """ + Dubs a provided audio or video file into given language. + + Parameters + ---------- + file : typing.Optional[core.File] + See core.File for more documentation + + csv_file : typing.Optional[core.File] + See core.File for more documentation + + foreground_audio_file : typing.Optional[core.File] + See core.File for more documentation + + background_audio_file : typing.Optional[core.File] + See core.File for more documentation + + name : typing.Optional[str] + Name of the dubbing project. + + source_url : typing.Optional[str] + URL of the source video/audio file. + + source_lang : typing.Optional[str] + Source language. + + target_lang : typing.Optional[str] + The Target language to dub the content into. + + num_speakers : typing.Optional[int] + Number of speakers to use for the dubbing. Set to 0 to automatically detect the number of speakers + + watermark : typing.Optional[bool] + Whether to apply watermark to the output video. + + start_time : typing.Optional[int] + Start time of the source video/audio file. + + end_time : typing.Optional[int] + End time of the source video/audio file. + + highest_resolution : typing.Optional[bool] + Whether to use the highest resolution available. + + drop_background_audio : typing.Optional[bool] + An advanced setting. Whether to drop background audio from the final dub. This can improve dub quality where it's known that audio shouldn't have a background track such as for speeches or monologues. + + use_profanity_filter : typing.Optional[bool] + [BETA] Whether transcripts should have profanities censored with the words '[censored]' + + dubbing_studio : typing.Optional[bool] + Whether to prepare dub for edits in dubbing studio or edits as a dubbing resource. + + disable_voice_cloning : typing.Optional[bool] + [BETA] Instead of using a voice clone in dubbing, use a similar voice from the ElevenLabs Voice Library. + + mode : typing.Optional[str] + automatic or manual. Manual mode is only supported when creating a dubbing studio project + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[DoDubbingResponse] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + "v1/dubbing", + base_url=self._client_wrapper.get_environment().base, + method="POST", + data={ + "name": name, + "source_url": source_url, + "source_lang": source_lang, + "target_lang": target_lang, + "num_speakers": num_speakers, + "watermark": watermark, + "start_time": start_time, + "end_time": end_time, + "highest_resolution": highest_resolution, + "drop_background_audio": drop_background_audio, + "use_profanity_filter": use_profanity_filter, + "dubbing_studio": dubbing_studio, + "disable_voice_cloning": disable_voice_cloning, + "mode": mode, + }, + files={ + **({"file": file} if file is not None else {}), + **({"csv_file": csv_file} if csv_file is not None else {}), + **({"foreground_audio_file": foreground_audio_file} if foreground_audio_file is not None else {}), + **({"background_audio_file": background_audio_file} if background_audio_file is not None else {}), + }, + request_options=request_options, + omit=OMIT, + force_multipart=True, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + DoDubbingResponse, + construct_type( + type_=DoDubbingResponse, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def get( + self, dubbing_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[DubbingMetadataResponse]: + """ + Returns metadata about a dubbing project, including whether it's still in progress or not + + Parameters + ---------- + dubbing_id : str + ID of the dubbing project. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[DubbingMetadataResponse] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/dubbing/{jsonable_encoder(dubbing_id)}", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + DubbingMetadataResponse, + construct_type( + type_=DubbingMetadataResponse, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def delete( + self, dubbing_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[DeleteDubbingResponseModel]: + """ + Deletes a dubbing project. + + Parameters + ---------- + dubbing_id : str + ID of the dubbing project. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[DeleteDubbingResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/dubbing/{jsonable_encoder(dubbing_id)}", + base_url=self._client_wrapper.get_environment().base, + method="DELETE", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + DeleteDubbingResponseModel, + construct_type( + type_=DeleteDubbingResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/elevenlabs/dubbing/resource/__init__.py b/src/elevenlabs/dubbing/resource/__init__.py new file mode 100644 index 00000000..80d5a1a4 --- /dev/null +++ b/src/elevenlabs/dubbing/resource/__init__.py @@ -0,0 +1,7 @@ +# This file was auto-generated by Fern from our API Definition. + +# isort: skip_file + +from . import language, segment, speaker + +__all__ = ["language", "segment", "speaker"] diff --git a/src/elevenlabs/dubbing/resource/client.py b/src/elevenlabs/dubbing/resource/client.py new file mode 100644 index 00000000..d9d99e18 --- /dev/null +++ b/src/elevenlabs/dubbing/resource/client.py @@ -0,0 +1,529 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ...core.request_options import RequestOptions +from ...types.dubbing_render_response_model import DubbingRenderResponseModel +from ...types.dubbing_resource import DubbingResource +from ...types.render_type import RenderType +from ...types.segment_dub_response import SegmentDubResponse +from ...types.segment_transcription_response import SegmentTranscriptionResponse +from ...types.segment_translation_response import SegmentTranslationResponse +from .language.client import AsyncLanguageClient, LanguageClient +from .raw_client import AsyncRawResourceClient, RawResourceClient +from .segment.client import AsyncSegmentClient, SegmentClient +from .speaker.client import AsyncSpeakerClient, SpeakerClient + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class ResourceClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._raw_client = RawResourceClient(client_wrapper=client_wrapper) + self.language = LanguageClient(client_wrapper=client_wrapper) + + self.segment = SegmentClient(client_wrapper=client_wrapper) + + self.speaker = SpeakerClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawResourceClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawResourceClient + """ + return self._raw_client + + def get(self, dubbing_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> DubbingResource: + """ + Given a dubbing ID generated from the '/v1/dubbing' endpoint with studio enabled, returns the dubbing resource. + + Parameters + ---------- + dubbing_id : str + ID of the dubbing project. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + DubbingResource + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.dubbing.resource.get( + dubbing_id="dubbing_id", + ) + """ + _response = self._raw_client.get(dubbing_id, request_options=request_options) + return _response.data + + def transcribe( + self, + dubbing_id: str, + *, + segments: typing.Sequence[str], + request_options: typing.Optional[RequestOptions] = None, + ) -> SegmentTranscriptionResponse: + """ + Regenerate the transcriptions for the specified segments. Does not automatically regenerate translations or dubs. + + Parameters + ---------- + dubbing_id : str + ID of the dubbing project. + + segments : typing.Sequence[str] + Transcribe this specific list of segments. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + SegmentTranscriptionResponse + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.dubbing.resource.transcribe( + dubbing_id="dubbing_id", + segments=["segments"], + ) + """ + _response = self._raw_client.transcribe(dubbing_id, segments=segments, request_options=request_options) + return _response.data + + def translate( + self, + dubbing_id: str, + *, + segments: typing.Sequence[str], + languages: typing.Optional[typing.Sequence[str]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> SegmentTranslationResponse: + """ + Regenerate the translations for either the entire resource or the specified segments/languages. Will automatically transcribe missing transcriptions. Will not automatically regenerate the dubs. + + Parameters + ---------- + dubbing_id : str + ID of the dubbing project. + + segments : typing.Sequence[str] + Translate only this list of segments. + + languages : typing.Optional[typing.Sequence[str]] + Translate only these languages for each segment. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + SegmentTranslationResponse + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.dubbing.resource.translate( + dubbing_id="dubbing_id", + segments=["segments"], + ) + """ + _response = self._raw_client.translate( + dubbing_id, segments=segments, languages=languages, request_options=request_options + ) + return _response.data + + def dub( + self, + dubbing_id: str, + *, + segments: typing.Sequence[str], + languages: typing.Optional[typing.Sequence[str]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> SegmentDubResponse: + """ + Regenerate the dubs for either the entire resource or the specified segments/languages. Will automatically transcribe and translate any missing transcriptions and translations. + + Parameters + ---------- + dubbing_id : str + ID of the dubbing project. + + segments : typing.Sequence[str] + Dub only this list of segments. + + languages : typing.Optional[typing.Sequence[str]] + Dub only these languages for each segment. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + SegmentDubResponse + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.dubbing.resource.dub( + dubbing_id="dubbing_id", + segments=["segments"], + ) + """ + _response = self._raw_client.dub( + dubbing_id, segments=segments, languages=languages, request_options=request_options + ) + return _response.data + + def render( + self, + dubbing_id: str, + language: str, + *, + render_type: RenderType, + request_options: typing.Optional[RequestOptions] = None, + ) -> DubbingRenderResponseModel: + """ + Regenerate the output media for a language using the latest Studio state. Please ensure all segments have been dubbed before rendering, otherwise they will be omitted. Renders are generated asynchronously, and to check the status of all renders please use the 'Get Dubbing Resource' endpoint. + + Parameters + ---------- + dubbing_id : str + ID of the dubbing project. + + language : str + Render this language + + render_type : RenderType + The type of the render. One of ['mp4', 'aac', 'mp3', 'wav', 'aaf', 'tracks_zip', 'clips_zip'] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + DubbingRenderResponseModel + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.dubbing.resource.render( + dubbing_id="dubbing_id", + language="language", + render_type="mp4", + ) + """ + _response = self._raw_client.render( + dubbing_id, language, render_type=render_type, request_options=request_options + ) + return _response.data + + +class AsyncResourceClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawResourceClient(client_wrapper=client_wrapper) + self.language = AsyncLanguageClient(client_wrapper=client_wrapper) + + self.segment = AsyncSegmentClient(client_wrapper=client_wrapper) + + self.speaker = AsyncSpeakerClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawResourceClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawResourceClient + """ + return self._raw_client + + async def get(self, dubbing_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> DubbingResource: + """ + Given a dubbing ID generated from the '/v1/dubbing' endpoint with studio enabled, returns the dubbing resource. + + Parameters + ---------- + dubbing_id : str + ID of the dubbing project. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + DubbingResource + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.dubbing.resource.get( + dubbing_id="dubbing_id", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.get(dubbing_id, request_options=request_options) + return _response.data + + async def transcribe( + self, + dubbing_id: str, + *, + segments: typing.Sequence[str], + request_options: typing.Optional[RequestOptions] = None, + ) -> SegmentTranscriptionResponse: + """ + Regenerate the transcriptions for the specified segments. Does not automatically regenerate translations or dubs. + + Parameters + ---------- + dubbing_id : str + ID of the dubbing project. + + segments : typing.Sequence[str] + Transcribe this specific list of segments. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + SegmentTranscriptionResponse + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.dubbing.resource.transcribe( + dubbing_id="dubbing_id", + segments=["segments"], + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.transcribe(dubbing_id, segments=segments, request_options=request_options) + return _response.data + + async def translate( + self, + dubbing_id: str, + *, + segments: typing.Sequence[str], + languages: typing.Optional[typing.Sequence[str]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> SegmentTranslationResponse: + """ + Regenerate the translations for either the entire resource or the specified segments/languages. Will automatically transcribe missing transcriptions. Will not automatically regenerate the dubs. + + Parameters + ---------- + dubbing_id : str + ID of the dubbing project. + + segments : typing.Sequence[str] + Translate only this list of segments. + + languages : typing.Optional[typing.Sequence[str]] + Translate only these languages for each segment. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + SegmentTranslationResponse + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.dubbing.resource.translate( + dubbing_id="dubbing_id", + segments=["segments"], + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.translate( + dubbing_id, segments=segments, languages=languages, request_options=request_options + ) + return _response.data + + async def dub( + self, + dubbing_id: str, + *, + segments: typing.Sequence[str], + languages: typing.Optional[typing.Sequence[str]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> SegmentDubResponse: + """ + Regenerate the dubs for either the entire resource or the specified segments/languages. Will automatically transcribe and translate any missing transcriptions and translations. + + Parameters + ---------- + dubbing_id : str + ID of the dubbing project. + + segments : typing.Sequence[str] + Dub only this list of segments. + + languages : typing.Optional[typing.Sequence[str]] + Dub only these languages for each segment. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + SegmentDubResponse + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.dubbing.resource.dub( + dubbing_id="dubbing_id", + segments=["segments"], + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.dub( + dubbing_id, segments=segments, languages=languages, request_options=request_options + ) + return _response.data + + async def render( + self, + dubbing_id: str, + language: str, + *, + render_type: RenderType, + request_options: typing.Optional[RequestOptions] = None, + ) -> DubbingRenderResponseModel: + """ + Regenerate the output media for a language using the latest Studio state. Please ensure all segments have been dubbed before rendering, otherwise they will be omitted. Renders are generated asynchronously, and to check the status of all renders please use the 'Get Dubbing Resource' endpoint. + + Parameters + ---------- + dubbing_id : str + ID of the dubbing project. + + language : str + Render this language + + render_type : RenderType + The type of the render. One of ['mp4', 'aac', 'mp3', 'wav', 'aaf', 'tracks_zip', 'clips_zip'] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + DubbingRenderResponseModel + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.dubbing.resource.render( + dubbing_id="dubbing_id", + language="language", + render_type="mp4", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.render( + dubbing_id, language, render_type=render_type, request_options=request_options + ) + return _response.data diff --git a/src/elevenlabs/dubbing/resource/language/__init__.py b/src/elevenlabs/dubbing/resource/language/__init__.py new file mode 100644 index 00000000..5cde0202 --- /dev/null +++ b/src/elevenlabs/dubbing/resource/language/__init__.py @@ -0,0 +1,4 @@ +# This file was auto-generated by Fern from our API Definition. + +# isort: skip_file + diff --git a/src/elevenlabs/dubbing/resource/language/client.py b/src/elevenlabs/dubbing/resource/language/client.py new file mode 100644 index 00000000..bbf2c129 --- /dev/null +++ b/src/elevenlabs/dubbing/resource/language/client.py @@ -0,0 +1,131 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +from ....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ....core.request_options import RequestOptions +from ....types.language_added_response import LanguageAddedResponse +from .raw_client import AsyncRawLanguageClient, RawLanguageClient + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class LanguageClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._raw_client = RawLanguageClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawLanguageClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawLanguageClient + """ + return self._raw_client + + def add( + self, + dubbing_id: str, + *, + language: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> LanguageAddedResponse: + """ + Adds the given ElevenLab Turbo V2/V2.5 language code to the resource. Does not automatically generate transcripts/translations/audio. + + Parameters + ---------- + dubbing_id : str + ID of the dubbing project. + + language : typing.Optional[str] + The Target language. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + LanguageAddedResponse + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.dubbing.resource.language.add( + dubbing_id="dubbing_id", + ) + """ + _response = self._raw_client.add(dubbing_id, language=language, request_options=request_options) + return _response.data + + +class AsyncLanguageClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawLanguageClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawLanguageClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawLanguageClient + """ + return self._raw_client + + async def add( + self, + dubbing_id: str, + *, + language: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> LanguageAddedResponse: + """ + Adds the given ElevenLab Turbo V2/V2.5 language code to the resource. Does not automatically generate transcripts/translations/audio. + + Parameters + ---------- + dubbing_id : str + ID of the dubbing project. + + language : typing.Optional[str] + The Target language. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + LanguageAddedResponse + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.dubbing.resource.language.add( + dubbing_id="dubbing_id", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.add(dubbing_id, language=language, request_options=request_options) + return _response.data diff --git a/src/elevenlabs/dubbing/resource/language/raw_client.py b/src/elevenlabs/dubbing/resource/language/raw_client.py new file mode 100644 index 00000000..2adb83e7 --- /dev/null +++ b/src/elevenlabs/dubbing/resource/language/raw_client.py @@ -0,0 +1,157 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ....core.api_error import ApiError +from ....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ....core.http_response import AsyncHttpResponse, HttpResponse +from ....core.jsonable_encoder import jsonable_encoder +from ....core.request_options import RequestOptions +from ....core.unchecked_base_model import construct_type +from ....errors.unprocessable_entity_error import UnprocessableEntityError +from ....types.http_validation_error import HttpValidationError +from ....types.language_added_response import LanguageAddedResponse + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RawLanguageClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def add( + self, + dubbing_id: str, + *, + language: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[LanguageAddedResponse]: + """ + Adds the given ElevenLab Turbo V2/V2.5 language code to the resource. Does not automatically generate transcripts/translations/audio. + + Parameters + ---------- + dubbing_id : str + ID of the dubbing project. + + language : typing.Optional[str] + The Target language. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[LanguageAddedResponse] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/dubbing/resource/{jsonable_encoder(dubbing_id)}/language", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "language": language, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + LanguageAddedResponse, + construct_type( + type_=LanguageAddedResponse, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + +class AsyncRawLanguageClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def add( + self, + dubbing_id: str, + *, + language: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[LanguageAddedResponse]: + """ + Adds the given ElevenLab Turbo V2/V2.5 language code to the resource. Does not automatically generate transcripts/translations/audio. + + Parameters + ---------- + dubbing_id : str + ID of the dubbing project. + + language : typing.Optional[str] + The Target language. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[LanguageAddedResponse] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/dubbing/resource/{jsonable_encoder(dubbing_id)}/language", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "language": language, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + LanguageAddedResponse, + construct_type( + type_=LanguageAddedResponse, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/elevenlabs/dubbing/resource/raw_client.py b/src/elevenlabs/dubbing/resource/raw_client.py new file mode 100644 index 00000000..28f446b1 --- /dev/null +++ b/src/elevenlabs/dubbing/resource/raw_client.py @@ -0,0 +1,682 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ...core.api_error import ApiError +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ...core.http_response import AsyncHttpResponse, HttpResponse +from ...core.jsonable_encoder import jsonable_encoder +from ...core.request_options import RequestOptions +from ...core.unchecked_base_model import construct_type +from ...errors.unprocessable_entity_error import UnprocessableEntityError +from ...types.dubbing_render_response_model import DubbingRenderResponseModel +from ...types.dubbing_resource import DubbingResource +from ...types.http_validation_error import HttpValidationError +from ...types.render_type import RenderType +from ...types.segment_dub_response import SegmentDubResponse +from ...types.segment_transcription_response import SegmentTranscriptionResponse +from ...types.segment_translation_response import SegmentTranslationResponse + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RawResourceClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def get( + self, dubbing_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[DubbingResource]: + """ + Given a dubbing ID generated from the '/v1/dubbing' endpoint with studio enabled, returns the dubbing resource. + + Parameters + ---------- + dubbing_id : str + ID of the dubbing project. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[DubbingResource] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/dubbing/resource/{jsonable_encoder(dubbing_id)}", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + DubbingResource, + construct_type( + type_=DubbingResource, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def transcribe( + self, + dubbing_id: str, + *, + segments: typing.Sequence[str], + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[SegmentTranscriptionResponse]: + """ + Regenerate the transcriptions for the specified segments. Does not automatically regenerate translations or dubs. + + Parameters + ---------- + dubbing_id : str + ID of the dubbing project. + + segments : typing.Sequence[str] + Transcribe this specific list of segments. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[SegmentTranscriptionResponse] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/dubbing/resource/{jsonable_encoder(dubbing_id)}/transcribe", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "segments": segments, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + SegmentTranscriptionResponse, + construct_type( + type_=SegmentTranscriptionResponse, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def translate( + self, + dubbing_id: str, + *, + segments: typing.Sequence[str], + languages: typing.Optional[typing.Sequence[str]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[SegmentTranslationResponse]: + """ + Regenerate the translations for either the entire resource or the specified segments/languages. Will automatically transcribe missing transcriptions. Will not automatically regenerate the dubs. + + Parameters + ---------- + dubbing_id : str + ID of the dubbing project. + + segments : typing.Sequence[str] + Translate only this list of segments. + + languages : typing.Optional[typing.Sequence[str]] + Translate only these languages for each segment. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[SegmentTranslationResponse] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/dubbing/resource/{jsonable_encoder(dubbing_id)}/translate", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "segments": segments, + "languages": languages, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + SegmentTranslationResponse, + construct_type( + type_=SegmentTranslationResponse, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def dub( + self, + dubbing_id: str, + *, + segments: typing.Sequence[str], + languages: typing.Optional[typing.Sequence[str]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[SegmentDubResponse]: + """ + Regenerate the dubs for either the entire resource or the specified segments/languages. Will automatically transcribe and translate any missing transcriptions and translations. + + Parameters + ---------- + dubbing_id : str + ID of the dubbing project. + + segments : typing.Sequence[str] + Dub only this list of segments. + + languages : typing.Optional[typing.Sequence[str]] + Dub only these languages for each segment. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[SegmentDubResponse] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/dubbing/resource/{jsonable_encoder(dubbing_id)}/dub", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "segments": segments, + "languages": languages, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + SegmentDubResponse, + construct_type( + type_=SegmentDubResponse, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def render( + self, + dubbing_id: str, + language: str, + *, + render_type: RenderType, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[DubbingRenderResponseModel]: + """ + Regenerate the output media for a language using the latest Studio state. Please ensure all segments have been dubbed before rendering, otherwise they will be omitted. Renders are generated asynchronously, and to check the status of all renders please use the 'Get Dubbing Resource' endpoint. + + Parameters + ---------- + dubbing_id : str + ID of the dubbing project. + + language : str + Render this language + + render_type : RenderType + The type of the render. One of ['mp4', 'aac', 'mp3', 'wav', 'aaf', 'tracks_zip', 'clips_zip'] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[DubbingRenderResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/dubbing/resource/{jsonable_encoder(dubbing_id)}/render/{jsonable_encoder(language)}", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "render_type": render_type, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + DubbingRenderResponseModel, + construct_type( + type_=DubbingRenderResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + +class AsyncRawResourceClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def get( + self, dubbing_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[DubbingResource]: + """ + Given a dubbing ID generated from the '/v1/dubbing' endpoint with studio enabled, returns the dubbing resource. + + Parameters + ---------- + dubbing_id : str + ID of the dubbing project. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[DubbingResource] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/dubbing/resource/{jsonable_encoder(dubbing_id)}", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + DubbingResource, + construct_type( + type_=DubbingResource, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def transcribe( + self, + dubbing_id: str, + *, + segments: typing.Sequence[str], + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[SegmentTranscriptionResponse]: + """ + Regenerate the transcriptions for the specified segments. Does not automatically regenerate translations or dubs. + + Parameters + ---------- + dubbing_id : str + ID of the dubbing project. + + segments : typing.Sequence[str] + Transcribe this specific list of segments. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[SegmentTranscriptionResponse] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/dubbing/resource/{jsonable_encoder(dubbing_id)}/transcribe", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "segments": segments, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + SegmentTranscriptionResponse, + construct_type( + type_=SegmentTranscriptionResponse, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def translate( + self, + dubbing_id: str, + *, + segments: typing.Sequence[str], + languages: typing.Optional[typing.Sequence[str]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[SegmentTranslationResponse]: + """ + Regenerate the translations for either the entire resource or the specified segments/languages. Will automatically transcribe missing transcriptions. Will not automatically regenerate the dubs. + + Parameters + ---------- + dubbing_id : str + ID of the dubbing project. + + segments : typing.Sequence[str] + Translate only this list of segments. + + languages : typing.Optional[typing.Sequence[str]] + Translate only these languages for each segment. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[SegmentTranslationResponse] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/dubbing/resource/{jsonable_encoder(dubbing_id)}/translate", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "segments": segments, + "languages": languages, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + SegmentTranslationResponse, + construct_type( + type_=SegmentTranslationResponse, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def dub( + self, + dubbing_id: str, + *, + segments: typing.Sequence[str], + languages: typing.Optional[typing.Sequence[str]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[SegmentDubResponse]: + """ + Regenerate the dubs for either the entire resource or the specified segments/languages. Will automatically transcribe and translate any missing transcriptions and translations. + + Parameters + ---------- + dubbing_id : str + ID of the dubbing project. + + segments : typing.Sequence[str] + Dub only this list of segments. + + languages : typing.Optional[typing.Sequence[str]] + Dub only these languages for each segment. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[SegmentDubResponse] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/dubbing/resource/{jsonable_encoder(dubbing_id)}/dub", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "segments": segments, + "languages": languages, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + SegmentDubResponse, + construct_type( + type_=SegmentDubResponse, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def render( + self, + dubbing_id: str, + language: str, + *, + render_type: RenderType, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[DubbingRenderResponseModel]: + """ + Regenerate the output media for a language using the latest Studio state. Please ensure all segments have been dubbed before rendering, otherwise they will be omitted. Renders are generated asynchronously, and to check the status of all renders please use the 'Get Dubbing Resource' endpoint. + + Parameters + ---------- + dubbing_id : str + ID of the dubbing project. + + language : str + Render this language + + render_type : RenderType + The type of the render. One of ['mp4', 'aac', 'mp3', 'wav', 'aaf', 'tracks_zip', 'clips_zip'] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[DubbingRenderResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/dubbing/resource/{jsonable_encoder(dubbing_id)}/render/{jsonable_encoder(language)}", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "render_type": render_type, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + DubbingRenderResponseModel, + construct_type( + type_=DubbingRenderResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/elevenlabs/dubbing/resource/segment/__init__.py b/src/elevenlabs/dubbing/resource/segment/__init__.py new file mode 100644 index 00000000..5cde0202 --- /dev/null +++ b/src/elevenlabs/dubbing/resource/segment/__init__.py @@ -0,0 +1,4 @@ +# This file was auto-generated by Fern from our API Definition. + +# isort: skip_file + diff --git a/src/elevenlabs/dubbing/resource/segment/client.py b/src/elevenlabs/dubbing/resource/segment/client.py new file mode 100644 index 00000000..a6fcda05 --- /dev/null +++ b/src/elevenlabs/dubbing/resource/segment/client.py @@ -0,0 +1,260 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +from ....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ....core.request_options import RequestOptions +from ....types.segment_delete_response import SegmentDeleteResponse +from ....types.segment_update_response import SegmentUpdateResponse +from .raw_client import AsyncRawSegmentClient, RawSegmentClient + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class SegmentClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._raw_client = RawSegmentClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawSegmentClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawSegmentClient + """ + return self._raw_client + + def update( + self, + dubbing_id: str, + segment_id: str, + language: str, + *, + start_time: typing.Optional[float] = OMIT, + end_time: typing.Optional[float] = OMIT, + text: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> SegmentUpdateResponse: + """ + Modifies a single segment with new text and/or start/end times. Will update the values for only a specific language of a segment. Does not automatically regenerate the dub. + + Parameters + ---------- + dubbing_id : str + ID of the dubbing project. + + segment_id : str + ID of the segment + + language : str + ID of the language. + + start_time : typing.Optional[float] + + end_time : typing.Optional[float] + + text : typing.Optional[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + SegmentUpdateResponse + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.dubbing.resource.segment.update( + dubbing_id="dubbing_id", + segment_id="segment_id", + language="language", + ) + """ + _response = self._raw_client.update( + dubbing_id, + segment_id, + language, + start_time=start_time, + end_time=end_time, + text=text, + request_options=request_options, + ) + return _response.data + + def delete( + self, dubbing_id: str, segment_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> SegmentDeleteResponse: + """ + Deletes a single segment from the dubbing. + + Parameters + ---------- + dubbing_id : str + ID of the dubbing project. + + segment_id : str + ID of the segment + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + SegmentDeleteResponse + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.dubbing.resource.segment.delete( + dubbing_id="dubbing_id", + segment_id="segment_id", + ) + """ + _response = self._raw_client.delete(dubbing_id, segment_id, request_options=request_options) + return _response.data + + +class AsyncSegmentClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawSegmentClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawSegmentClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawSegmentClient + """ + return self._raw_client + + async def update( + self, + dubbing_id: str, + segment_id: str, + language: str, + *, + start_time: typing.Optional[float] = OMIT, + end_time: typing.Optional[float] = OMIT, + text: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> SegmentUpdateResponse: + """ + Modifies a single segment with new text and/or start/end times. Will update the values for only a specific language of a segment. Does not automatically regenerate the dub. + + Parameters + ---------- + dubbing_id : str + ID of the dubbing project. + + segment_id : str + ID of the segment + + language : str + ID of the language. + + start_time : typing.Optional[float] + + end_time : typing.Optional[float] + + text : typing.Optional[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + SegmentUpdateResponse + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.dubbing.resource.segment.update( + dubbing_id="dubbing_id", + segment_id="segment_id", + language="language", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.update( + dubbing_id, + segment_id, + language, + start_time=start_time, + end_time=end_time, + text=text, + request_options=request_options, + ) + return _response.data + + async def delete( + self, dubbing_id: str, segment_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> SegmentDeleteResponse: + """ + Deletes a single segment from the dubbing. + + Parameters + ---------- + dubbing_id : str + ID of the dubbing project. + + segment_id : str + ID of the segment + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + SegmentDeleteResponse + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.dubbing.resource.segment.delete( + dubbing_id="dubbing_id", + segment_id="segment_id", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.delete(dubbing_id, segment_id, request_options=request_options) + return _response.data diff --git a/src/elevenlabs/dubbing/resource/segment/raw_client.py b/src/elevenlabs/dubbing/resource/segment/raw_client.py new file mode 100644 index 00000000..97c67631 --- /dev/null +++ b/src/elevenlabs/dubbing/resource/segment/raw_client.py @@ -0,0 +1,296 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ....core.api_error import ApiError +from ....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ....core.http_response import AsyncHttpResponse, HttpResponse +from ....core.jsonable_encoder import jsonable_encoder +from ....core.request_options import RequestOptions +from ....core.unchecked_base_model import construct_type +from ....errors.unprocessable_entity_error import UnprocessableEntityError +from ....types.http_validation_error import HttpValidationError +from ....types.segment_delete_response import SegmentDeleteResponse +from ....types.segment_update_response import SegmentUpdateResponse + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RawSegmentClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def update( + self, + dubbing_id: str, + segment_id: str, + language: str, + *, + start_time: typing.Optional[float] = OMIT, + end_time: typing.Optional[float] = OMIT, + text: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[SegmentUpdateResponse]: + """ + Modifies a single segment with new text and/or start/end times. Will update the values for only a specific language of a segment. Does not automatically regenerate the dub. + + Parameters + ---------- + dubbing_id : str + ID of the dubbing project. + + segment_id : str + ID of the segment + + language : str + ID of the language. + + start_time : typing.Optional[float] + + end_time : typing.Optional[float] + + text : typing.Optional[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[SegmentUpdateResponse] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/dubbing/resource/{jsonable_encoder(dubbing_id)}/segment/{jsonable_encoder(segment_id)}/{jsonable_encoder(language)}", + base_url=self._client_wrapper.get_environment().base, + method="PATCH", + json={ + "start_time": start_time, + "end_time": end_time, + "text": text, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + SegmentUpdateResponse, + construct_type( + type_=SegmentUpdateResponse, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def delete( + self, dubbing_id: str, segment_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[SegmentDeleteResponse]: + """ + Deletes a single segment from the dubbing. + + Parameters + ---------- + dubbing_id : str + ID of the dubbing project. + + segment_id : str + ID of the segment + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[SegmentDeleteResponse] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/dubbing/resource/{jsonable_encoder(dubbing_id)}/segment/{jsonable_encoder(segment_id)}", + base_url=self._client_wrapper.get_environment().base, + method="DELETE", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + SegmentDeleteResponse, + construct_type( + type_=SegmentDeleteResponse, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + +class AsyncRawSegmentClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def update( + self, + dubbing_id: str, + segment_id: str, + language: str, + *, + start_time: typing.Optional[float] = OMIT, + end_time: typing.Optional[float] = OMIT, + text: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[SegmentUpdateResponse]: + """ + Modifies a single segment with new text and/or start/end times. Will update the values for only a specific language of a segment. Does not automatically regenerate the dub. + + Parameters + ---------- + dubbing_id : str + ID of the dubbing project. + + segment_id : str + ID of the segment + + language : str + ID of the language. + + start_time : typing.Optional[float] + + end_time : typing.Optional[float] + + text : typing.Optional[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[SegmentUpdateResponse] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/dubbing/resource/{jsonable_encoder(dubbing_id)}/segment/{jsonable_encoder(segment_id)}/{jsonable_encoder(language)}", + base_url=self._client_wrapper.get_environment().base, + method="PATCH", + json={ + "start_time": start_time, + "end_time": end_time, + "text": text, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + SegmentUpdateResponse, + construct_type( + type_=SegmentUpdateResponse, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def delete( + self, dubbing_id: str, segment_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[SegmentDeleteResponse]: + """ + Deletes a single segment from the dubbing. + + Parameters + ---------- + dubbing_id : str + ID of the dubbing project. + + segment_id : str + ID of the segment + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[SegmentDeleteResponse] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/dubbing/resource/{jsonable_encoder(dubbing_id)}/segment/{jsonable_encoder(segment_id)}", + base_url=self._client_wrapper.get_environment().base, + method="DELETE", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + SegmentDeleteResponse, + construct_type( + type_=SegmentDeleteResponse, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/elevenlabs/dubbing/speaker/__init__.py b/src/elevenlabs/dubbing/resource/speaker/__init__.py similarity index 84% rename from src/elevenlabs/dubbing/speaker/__init__.py rename to src/elevenlabs/dubbing/resource/speaker/__init__.py index c2182255..c9422df9 100644 --- a/src/elevenlabs/dubbing/speaker/__init__.py +++ b/src/elevenlabs/dubbing/resource/speaker/__init__.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# isort: skip_file + from . import segment __all__ = ["segment"] diff --git a/src/elevenlabs/dubbing/resource/speaker/client.py b/src/elevenlabs/dubbing/resource/speaker/client.py new file mode 100644 index 00000000..5f1fcae6 --- /dev/null +++ b/src/elevenlabs/dubbing/resource/speaker/client.py @@ -0,0 +1,239 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +from ....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ....core.request_options import RequestOptions +from ....types.similar_voices_for_speaker_response import SimilarVoicesForSpeakerResponse +from ....types.speaker_updated_response import SpeakerUpdatedResponse +from .raw_client import AsyncRawSpeakerClient, RawSpeakerClient +from .segment.client import AsyncSegmentClient, SegmentClient + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class SpeakerClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._raw_client = RawSpeakerClient(client_wrapper=client_wrapper) + self.segment = SegmentClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawSpeakerClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawSpeakerClient + """ + return self._raw_client + + def update( + self, + dubbing_id: str, + speaker_id: str, + *, + voice_id: typing.Optional[str] = OMIT, + languages: typing.Optional[typing.Sequence[str]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> SpeakerUpdatedResponse: + """ + Amend the metadata associated with a speaker, such as their voice. Both voice cloning and using voices from the ElevenLabs library are supported. + + Parameters + ---------- + dubbing_id : str + ID of the dubbing project. + + speaker_id : str + ID of the speaker. + + voice_id : typing.Optional[str] + Either the identifier of a voice from the ElevenLabs voice library, or one of ['track-clone', 'clip-clone']. + + languages : typing.Optional[typing.Sequence[str]] + Languages to apply these changes to. If empty, will apply to all languages. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + SpeakerUpdatedResponse + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.dubbing.resource.speaker.update( + dubbing_id="dubbing_id", + speaker_id="speaker_id", + ) + """ + _response = self._raw_client.update( + dubbing_id, speaker_id, voice_id=voice_id, languages=languages, request_options=request_options + ) + return _response.data + + def find_similar_voices( + self, dubbing_id: str, speaker_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> SimilarVoicesForSpeakerResponse: + """ + Fetch the top 10 similar voices to a speaker, including the voice IDs, names, descriptions, and, where possible, a sample audio recording. + + Parameters + ---------- + dubbing_id : str + ID of the dubbing project. + + speaker_id : str + ID of the speaker. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + SimilarVoicesForSpeakerResponse + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.dubbing.resource.speaker.find_similar_voices( + dubbing_id="dubbing_id", + speaker_id="speaker_id", + ) + """ + _response = self._raw_client.find_similar_voices(dubbing_id, speaker_id, request_options=request_options) + return _response.data + + +class AsyncSpeakerClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawSpeakerClient(client_wrapper=client_wrapper) + self.segment = AsyncSegmentClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawSpeakerClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawSpeakerClient + """ + return self._raw_client + + async def update( + self, + dubbing_id: str, + speaker_id: str, + *, + voice_id: typing.Optional[str] = OMIT, + languages: typing.Optional[typing.Sequence[str]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> SpeakerUpdatedResponse: + """ + Amend the metadata associated with a speaker, such as their voice. Both voice cloning and using voices from the ElevenLabs library are supported. + + Parameters + ---------- + dubbing_id : str + ID of the dubbing project. + + speaker_id : str + ID of the speaker. + + voice_id : typing.Optional[str] + Either the identifier of a voice from the ElevenLabs voice library, or one of ['track-clone', 'clip-clone']. + + languages : typing.Optional[typing.Sequence[str]] + Languages to apply these changes to. If empty, will apply to all languages. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + SpeakerUpdatedResponse + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.dubbing.resource.speaker.update( + dubbing_id="dubbing_id", + speaker_id="speaker_id", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.update( + dubbing_id, speaker_id, voice_id=voice_id, languages=languages, request_options=request_options + ) + return _response.data + + async def find_similar_voices( + self, dubbing_id: str, speaker_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> SimilarVoicesForSpeakerResponse: + """ + Fetch the top 10 similar voices to a speaker, including the voice IDs, names, descriptions, and, where possible, a sample audio recording. + + Parameters + ---------- + dubbing_id : str + ID of the dubbing project. + + speaker_id : str + ID of the speaker. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + SimilarVoicesForSpeakerResponse + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.dubbing.resource.speaker.find_similar_voices( + dubbing_id="dubbing_id", + speaker_id="speaker_id", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.find_similar_voices(dubbing_id, speaker_id, request_options=request_options) + return _response.data diff --git a/src/elevenlabs/dubbing/speaker/client.py b/src/elevenlabs/dubbing/resource/speaker/raw_client.py similarity index 68% rename from src/elevenlabs/dubbing/speaker/client.py rename to src/elevenlabs/dubbing/resource/speaker/raw_client.py index 0cbd680b..a1626e20 100644 --- a/src/elevenlabs/dubbing/speaker/client.py +++ b/src/elevenlabs/dubbing/resource/speaker/raw_client.py @@ -1,28 +1,26 @@ # This file was auto-generated by Fern from our API Definition. import typing -from ...core.client_wrapper import SyncClientWrapper -from .segment.client import SegmentClient -from ...core.request_options import RequestOptions -from ...types.speaker_updated_response import SpeakerUpdatedResponse -from ...core.jsonable_encoder import jsonable_encoder -from ...core.unchecked_base_model import construct_type -from ...errors.unprocessable_entity_error import UnprocessableEntityError -from ...types.http_validation_error import HttpValidationError from json.decoder import JSONDecodeError -from ...core.api_error import ApiError -from ...types.similar_voices_for_speaker_response import SimilarVoicesForSpeakerResponse -from ...core.client_wrapper import AsyncClientWrapper -from .segment.client import AsyncSegmentClient + +from ....core.api_error import ApiError +from ....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ....core.http_response import AsyncHttpResponse, HttpResponse +from ....core.jsonable_encoder import jsonable_encoder +from ....core.request_options import RequestOptions +from ....core.unchecked_base_model import construct_type +from ....errors.unprocessable_entity_error import UnprocessableEntityError +from ....types.http_validation_error import HttpValidationError +from ....types.similar_voices_for_speaker_response import SimilarVoicesForSpeakerResponse +from ....types.speaker_updated_response import SpeakerUpdatedResponse # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) -class SpeakerClient: +class RawSpeakerClient: def __init__(self, *, client_wrapper: SyncClientWrapper): self._client_wrapper = client_wrapper - self.segment = SegmentClient(client_wrapper=self._client_wrapper) def update( self, @@ -32,7 +30,7 @@ def update( voice_id: typing.Optional[str] = OMIT, languages: typing.Optional[typing.Sequence[str]] = OMIT, request_options: typing.Optional[RequestOptions] = None, - ) -> SpeakerUpdatedResponse: + ) -> HttpResponse[SpeakerUpdatedResponse]: """ Amend the metadata associated with a speaker, such as their voice. Both voice cloning and using voices from the ElevenLabs library are supported. @@ -55,20 +53,8 @@ def update( Returns ------- - SpeakerUpdatedResponse + HttpResponse[SpeakerUpdatedResponse] Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.dubbing.speaker.update( - dubbing_id="dubbing_id", - speaker_id="speaker_id", - ) """ _response = self._client_wrapper.httpx_client.request( f"v1/dubbing/resource/{jsonable_encoder(dubbing_id)}/speaker/{jsonable_encoder(speaker_id)}", @@ -86,35 +72,33 @@ def update( ) try: if 200 <= _response.status_code < 300: - return typing.cast( + _data = typing.cast( SpeakerUpdatedResponse, construct_type( type_=SpeakerUpdatedResponse, # type: ignore object_=_response.json(), ), ) + return HttpResponse(response=_response, data=_data) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast( + headers=dict(_response.headers), + body=typing.cast( HttpValidationError, construct_type( type_=HttpValidationError, # type: ignore object_=_response.json(), ), - ) + ), ) _response_json = _response.json() except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) - def similar_voices( - self, - dubbing_id: str, - speaker_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, - ) -> SimilarVoicesForSpeakerResponse: + def find_similar_voices( + self, dubbing_id: str, speaker_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[SimilarVoicesForSpeakerResponse]: """ Fetch the top 10 similar voices to a speaker, including the voice IDs, names, descriptions, and, where possible, a sample audio recording. @@ -131,20 +115,8 @@ def similar_voices( Returns ------- - SimilarVoicesForSpeakerResponse + HttpResponse[SimilarVoicesForSpeakerResponse] Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.dubbing.speaker.similar_voices( - dubbing_id="dubbing_id", - speaker_id="speaker_id", - ) """ _response = self._client_wrapper.httpx_client.request( f"v1/dubbing/resource/{jsonable_encoder(dubbing_id)}/speaker/{jsonable_encoder(speaker_id)}/similar-voices", @@ -154,33 +126,34 @@ def similar_voices( ) try: if 200 <= _response.status_code < 300: - return typing.cast( + _data = typing.cast( SimilarVoicesForSpeakerResponse, construct_type( type_=SimilarVoicesForSpeakerResponse, # type: ignore object_=_response.json(), ), ) + return HttpResponse(response=_response, data=_data) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast( + headers=dict(_response.headers), + body=typing.cast( HttpValidationError, construct_type( type_=HttpValidationError, # type: ignore object_=_response.json(), ), - ) + ), ) _response_json = _response.json() except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) -class AsyncSpeakerClient: +class AsyncRawSpeakerClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): self._client_wrapper = client_wrapper - self.segment = AsyncSegmentClient(client_wrapper=self._client_wrapper) async def update( self, @@ -190,7 +163,7 @@ async def update( voice_id: typing.Optional[str] = OMIT, languages: typing.Optional[typing.Sequence[str]] = OMIT, request_options: typing.Optional[RequestOptions] = None, - ) -> SpeakerUpdatedResponse: + ) -> AsyncHttpResponse[SpeakerUpdatedResponse]: """ Amend the metadata associated with a speaker, such as their voice. Both voice cloning and using voices from the ElevenLabs library are supported. @@ -213,28 +186,8 @@ async def update( Returns ------- - SpeakerUpdatedResponse + AsyncHttpResponse[SpeakerUpdatedResponse] Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.dubbing.speaker.update( - dubbing_id="dubbing_id", - speaker_id="speaker_id", - ) - - - asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"v1/dubbing/resource/{jsonable_encoder(dubbing_id)}/speaker/{jsonable_encoder(speaker_id)}", @@ -252,35 +205,33 @@ async def main() -> None: ) try: if 200 <= _response.status_code < 300: - return typing.cast( + _data = typing.cast( SpeakerUpdatedResponse, construct_type( type_=SpeakerUpdatedResponse, # type: ignore object_=_response.json(), ), ) + return AsyncHttpResponse(response=_response, data=_data) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast( + headers=dict(_response.headers), + body=typing.cast( HttpValidationError, construct_type( type_=HttpValidationError, # type: ignore object_=_response.json(), ), - ) + ), ) _response_json = _response.json() except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) - async def similar_voices( - self, - dubbing_id: str, - speaker_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, - ) -> SimilarVoicesForSpeakerResponse: + async def find_similar_voices( + self, dubbing_id: str, speaker_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[SimilarVoicesForSpeakerResponse]: """ Fetch the top 10 similar voices to a speaker, including the voice IDs, names, descriptions, and, where possible, a sample audio recording. @@ -297,28 +248,8 @@ async def similar_voices( Returns ------- - SimilarVoicesForSpeakerResponse + AsyncHttpResponse[SimilarVoicesForSpeakerResponse] Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.dubbing.speaker.similar_voices( - dubbing_id="dubbing_id", - speaker_id="speaker_id", - ) - - - asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"v1/dubbing/resource/{jsonable_encoder(dubbing_id)}/speaker/{jsonable_encoder(speaker_id)}/similar-voices", @@ -328,24 +259,26 @@ async def main() -> None: ) try: if 200 <= _response.status_code < 300: - return typing.cast( + _data = typing.cast( SimilarVoicesForSpeakerResponse, construct_type( type_=SimilarVoicesForSpeakerResponse, # type: ignore object_=_response.json(), ), ) + return AsyncHttpResponse(response=_response, data=_data) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast( + headers=dict(_response.headers), + body=typing.cast( HttpValidationError, construct_type( type_=HttpValidationError, # type: ignore object_=_response.json(), ), - ) + ), ) _response_json = _response.json() except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/elevenlabs/dubbing/resource/speaker/segment/__init__.py b/src/elevenlabs/dubbing/resource/speaker/segment/__init__.py new file mode 100644 index 00000000..5cde0202 --- /dev/null +++ b/src/elevenlabs/dubbing/resource/speaker/segment/__init__.py @@ -0,0 +1,4 @@ +# This file was auto-generated by Fern from our API Definition. + +# isort: skip_file + diff --git a/src/elevenlabs/dubbing/resource/speaker/segment/client.py b/src/elevenlabs/dubbing/resource/speaker/segment/client.py new file mode 100644 index 00000000..5996fec9 --- /dev/null +++ b/src/elevenlabs/dubbing/resource/speaker/segment/client.py @@ -0,0 +1,177 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +from .....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from .....core.request_options import RequestOptions +from .....types.segment_create_response import SegmentCreateResponse +from .raw_client import AsyncRawSegmentClient, RawSegmentClient + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class SegmentClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._raw_client = RawSegmentClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawSegmentClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawSegmentClient + """ + return self._raw_client + + def create( + self, + dubbing_id: str, + speaker_id: str, + *, + start_time: float, + end_time: float, + text: typing.Optional[str] = OMIT, + translations: typing.Optional[typing.Dict[str, typing.Optional[str]]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> SegmentCreateResponse: + """ + Creates a new segment in dubbing resource with a start and end time for the speaker in every available language. Does not automatically generate transcripts/translations/audio. + + Parameters + ---------- + dubbing_id : str + ID of the dubbing project. + + speaker_id : str + ID of the speaker. + + start_time : float + + end_time : float + + text : typing.Optional[str] + + translations : typing.Optional[typing.Dict[str, typing.Optional[str]]] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + SegmentCreateResponse + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.dubbing.resource.speaker.segment.create( + dubbing_id="dubbing_id", + speaker_id="speaker_id", + start_time=1.1, + end_time=1.1, + ) + """ + _response = self._raw_client.create( + dubbing_id, + speaker_id, + start_time=start_time, + end_time=end_time, + text=text, + translations=translations, + request_options=request_options, + ) + return _response.data + + +class AsyncSegmentClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawSegmentClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawSegmentClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawSegmentClient + """ + return self._raw_client + + async def create( + self, + dubbing_id: str, + speaker_id: str, + *, + start_time: float, + end_time: float, + text: typing.Optional[str] = OMIT, + translations: typing.Optional[typing.Dict[str, typing.Optional[str]]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> SegmentCreateResponse: + """ + Creates a new segment in dubbing resource with a start and end time for the speaker in every available language. Does not automatically generate transcripts/translations/audio. + + Parameters + ---------- + dubbing_id : str + ID of the dubbing project. + + speaker_id : str + ID of the speaker. + + start_time : float + + end_time : float + + text : typing.Optional[str] + + translations : typing.Optional[typing.Dict[str, typing.Optional[str]]] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + SegmentCreateResponse + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.dubbing.resource.speaker.segment.create( + dubbing_id="dubbing_id", + speaker_id="speaker_id", + start_time=1.1, + end_time=1.1, + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.create( + dubbing_id, + speaker_id, + start_time=start_time, + end_time=end_time, + text=text, + translations=translations, + request_options=request_options, + ) + return _response.data diff --git a/src/elevenlabs/dubbing/speaker/segment/client.py b/src/elevenlabs/dubbing/resource/speaker/segment/raw_client.py similarity index 72% rename from src/elevenlabs/dubbing/speaker/segment/client.py rename to src/elevenlabs/dubbing/resource/speaker/segment/raw_client.py index 6f07af59..fbb205de 100644 --- a/src/elevenlabs/dubbing/speaker/segment/client.py +++ b/src/elevenlabs/dubbing/resource/speaker/segment/raw_client.py @@ -1,22 +1,23 @@ # This file was auto-generated by Fern from our API Definition. import typing -from ....core.client_wrapper import SyncClientWrapper -from ....core.request_options import RequestOptions -from ....types.segment_create_response import SegmentCreateResponse -from ....core.jsonable_encoder import jsonable_encoder -from ....core.unchecked_base_model import construct_type -from ....errors.unprocessable_entity_error import UnprocessableEntityError -from ....types.http_validation_error import HttpValidationError from json.decoder import JSONDecodeError -from ....core.api_error import ApiError -from ....core.client_wrapper import AsyncClientWrapper + +from .....core.api_error import ApiError +from .....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from .....core.http_response import AsyncHttpResponse, HttpResponse +from .....core.jsonable_encoder import jsonable_encoder +from .....core.request_options import RequestOptions +from .....core.unchecked_base_model import construct_type +from .....errors.unprocessable_entity_error import UnprocessableEntityError +from .....types.http_validation_error import HttpValidationError +from .....types.segment_create_response import SegmentCreateResponse # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) -class SegmentClient: +class RawSegmentClient: def __init__(self, *, client_wrapper: SyncClientWrapper): self._client_wrapper = client_wrapper @@ -30,7 +31,7 @@ def create( text: typing.Optional[str] = OMIT, translations: typing.Optional[typing.Dict[str, typing.Optional[str]]] = OMIT, request_options: typing.Optional[RequestOptions] = None, - ) -> SegmentCreateResponse: + ) -> HttpResponse[SegmentCreateResponse]: """ Creates a new segment in dubbing resource with a start and end time for the speaker in every available language. Does not automatically generate transcripts/translations/audio. @@ -55,22 +56,8 @@ def create( Returns ------- - SegmentCreateResponse + HttpResponse[SegmentCreateResponse] Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.dubbing.speaker.segment.create( - dubbing_id="dubbing_id", - speaker_id="speaker_id", - start_time=1.1, - end_time=1.1, - ) """ _response = self._client_wrapper.httpx_client.request( f"v1/dubbing/resource/{jsonable_encoder(dubbing_id)}/speaker/{jsonable_encoder(speaker_id)}/segment", @@ -90,30 +77,32 @@ def create( ) try: if 200 <= _response.status_code < 300: - return typing.cast( + _data = typing.cast( SegmentCreateResponse, construct_type( type_=SegmentCreateResponse, # type: ignore object_=_response.json(), ), ) + return HttpResponse(response=_response, data=_data) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast( + headers=dict(_response.headers), + body=typing.cast( HttpValidationError, construct_type( type_=HttpValidationError, # type: ignore object_=_response.json(), ), - ) + ), ) _response_json = _response.json() except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) -class AsyncSegmentClient: +class AsyncRawSegmentClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): self._client_wrapper = client_wrapper @@ -127,7 +116,7 @@ async def create( text: typing.Optional[str] = OMIT, translations: typing.Optional[typing.Dict[str, typing.Optional[str]]] = OMIT, request_options: typing.Optional[RequestOptions] = None, - ) -> SegmentCreateResponse: + ) -> AsyncHttpResponse[SegmentCreateResponse]: """ Creates a new segment in dubbing resource with a start and end time for the speaker in every available language. Does not automatically generate transcripts/translations/audio. @@ -152,30 +141,8 @@ async def create( Returns ------- - SegmentCreateResponse + AsyncHttpResponse[SegmentCreateResponse] Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.dubbing.speaker.segment.create( - dubbing_id="dubbing_id", - speaker_id="speaker_id", - start_time=1.1, - end_time=1.1, - ) - - - asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"v1/dubbing/resource/{jsonable_encoder(dubbing_id)}/speaker/{jsonable_encoder(speaker_id)}/segment", @@ -195,24 +162,26 @@ async def main() -> None: ) try: if 200 <= _response.status_code < 300: - return typing.cast( + _data = typing.cast( SegmentCreateResponse, construct_type( type_=SegmentCreateResponse, # type: ignore object_=_response.json(), ), ) + return AsyncHttpResponse(response=_response, data=_data) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast( + headers=dict(_response.headers), + body=typing.cast( HttpValidationError, construct_type( type_=HttpValidationError, # type: ignore object_=_response.json(), ), - ) + ), ) _response_json = _response.json() except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/elevenlabs/dubbing/transcript/__init__.py b/src/elevenlabs/dubbing/transcript/__init__.py new file mode 100644 index 00000000..2f9b180a --- /dev/null +++ b/src/elevenlabs/dubbing/transcript/__init__.py @@ -0,0 +1,7 @@ +# This file was auto-generated by Fern from our API Definition. + +# isort: skip_file + +from .types import TranscriptGetTranscriptForDubRequestFormatType + +__all__ = ["TranscriptGetTranscriptForDubRequestFormatType"] diff --git a/src/elevenlabs/dubbing/transcript/client.py b/src/elevenlabs/dubbing/transcript/client.py new file mode 100644 index 00000000..d3c651a8 --- /dev/null +++ b/src/elevenlabs/dubbing/transcript/client.py @@ -0,0 +1,142 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ...core.request_options import RequestOptions +from .raw_client import AsyncRawTranscriptClient, RawTranscriptClient +from .types.transcript_get_transcript_for_dub_request_format_type import TranscriptGetTranscriptForDubRequestFormatType + + +class TranscriptClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._raw_client = RawTranscriptClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawTranscriptClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawTranscriptClient + """ + return self._raw_client + + def get_transcript_for_dub( + self, + dubbing_id: str, + language_code: str, + *, + format_type: typing.Optional[TranscriptGetTranscriptForDubRequestFormatType] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> str: + """ + Returns transcript for the dub as an SRT or WEBVTT file. + + Parameters + ---------- + dubbing_id : str + ID of the dubbing project. + + language_code : str + ID of the language. + + format_type : typing.Optional[TranscriptGetTranscriptForDubRequestFormatType] + Format to use for the subtitle file, either 'srt' or 'webvtt' + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + str + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.dubbing.transcript.get_transcript_for_dub( + dubbing_id="dubbing_id", + language_code="language_code", + ) + """ + _response = self._raw_client.get_transcript_for_dub( + dubbing_id, language_code, format_type=format_type, request_options=request_options + ) + return _response.data + + +class AsyncTranscriptClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawTranscriptClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawTranscriptClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawTranscriptClient + """ + return self._raw_client + + async def get_transcript_for_dub( + self, + dubbing_id: str, + language_code: str, + *, + format_type: typing.Optional[TranscriptGetTranscriptForDubRequestFormatType] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> str: + """ + Returns transcript for the dub as an SRT or WEBVTT file. + + Parameters + ---------- + dubbing_id : str + ID of the dubbing project. + + language_code : str + ID of the language. + + format_type : typing.Optional[TranscriptGetTranscriptForDubRequestFormatType] + Format to use for the subtitle file, either 'srt' or 'webvtt' + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + str + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.dubbing.transcript.get_transcript_for_dub( + dubbing_id="dubbing_id", + language_code="language_code", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.get_transcript_for_dub( + dubbing_id, language_code, format_type=format_type, request_options=request_options + ) + return _response.data diff --git a/src/elevenlabs/dubbing/transcript/raw_client.py b/src/elevenlabs/dubbing/transcript/raw_client.py new file mode 100644 index 00000000..2a12d372 --- /dev/null +++ b/src/elevenlabs/dubbing/transcript/raw_client.py @@ -0,0 +1,209 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ...core.api_error import ApiError +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ...core.http_response import AsyncHttpResponse, HttpResponse +from ...core.jsonable_encoder import jsonable_encoder +from ...core.request_options import RequestOptions +from ...core.unchecked_base_model import construct_type +from ...errors.forbidden_error import ForbiddenError +from ...errors.not_found_error import NotFoundError +from ...errors.too_early_error import TooEarlyError +from ...errors.unprocessable_entity_error import UnprocessableEntityError +from ...types.http_validation_error import HttpValidationError +from .types.transcript_get_transcript_for_dub_request_format_type import TranscriptGetTranscriptForDubRequestFormatType + + +class RawTranscriptClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def get_transcript_for_dub( + self, + dubbing_id: str, + language_code: str, + *, + format_type: typing.Optional[TranscriptGetTranscriptForDubRequestFormatType] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[str]: + """ + Returns transcript for the dub as an SRT or WEBVTT file. + + Parameters + ---------- + dubbing_id : str + ID of the dubbing project. + + language_code : str + ID of the language. + + format_type : typing.Optional[TranscriptGetTranscriptForDubRequestFormatType] + Format to use for the subtitle file, either 'srt' or 'webvtt' + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[str] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/dubbing/{jsonable_encoder(dubbing_id)}/transcript/{jsonable_encoder(language_code)}", + base_url=self._client_wrapper.get_environment().base, + method="GET", + params={ + "format_type": format_type, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return HttpResponse(response=_response, data=_response.text) # type: ignore + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + construct_type( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + construct_type( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 425: + raise TooEarlyError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + construct_type( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + +class AsyncRawTranscriptClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def get_transcript_for_dub( + self, + dubbing_id: str, + language_code: str, + *, + format_type: typing.Optional[TranscriptGetTranscriptForDubRequestFormatType] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[str]: + """ + Returns transcript for the dub as an SRT or WEBVTT file. + + Parameters + ---------- + dubbing_id : str + ID of the dubbing project. + + language_code : str + ID of the language. + + format_type : typing.Optional[TranscriptGetTranscriptForDubRequestFormatType] + Format to use for the subtitle file, either 'srt' or 'webvtt' + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[str] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/dubbing/{jsonable_encoder(dubbing_id)}/transcript/{jsonable_encoder(language_code)}", + base_url=self._client_wrapper.get_environment().base, + method="GET", + params={ + "format_type": format_type, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return AsyncHttpResponse(response=_response, data=_response.text) # type: ignore + if _response.status_code == 403: + raise ForbiddenError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + construct_type( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + construct_type( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 425: + raise TooEarlyError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + construct_type( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/elevenlabs/dubbing/transcript/types/__init__.py b/src/elevenlabs/dubbing/transcript/types/__init__.py new file mode 100644 index 00000000..35f6bdfe --- /dev/null +++ b/src/elevenlabs/dubbing/transcript/types/__init__.py @@ -0,0 +1,7 @@ +# This file was auto-generated by Fern from our API Definition. + +# isort: skip_file + +from .transcript_get_transcript_for_dub_request_format_type import TranscriptGetTranscriptForDubRequestFormatType + +__all__ = ["TranscriptGetTranscriptForDubRequestFormatType"] diff --git a/src/elevenlabs/dubbing/transcript/types/transcript_get_transcript_for_dub_request_format_type.py b/src/elevenlabs/dubbing/transcript/types/transcript_get_transcript_for_dub_request_format_type.py new file mode 100644 index 00000000..2d2f5dbb --- /dev/null +++ b/src/elevenlabs/dubbing/transcript/types/transcript_get_transcript_for_dub_request_format_type.py @@ -0,0 +1,5 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +TranscriptGetTranscriptForDubRequestFormatType = typing.Union[typing.Literal["srt", "webvtt"], typing.Any] diff --git a/src/elevenlabs/dubbing/types/__init__.py b/src/elevenlabs/dubbing/types/__init__.py deleted file mode 100644 index 0c667fb2..00000000 --- a/src/elevenlabs/dubbing/types/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -from .dubbing_get_transcript_for_dub_request_format_type import DubbingGetTranscriptForDubRequestFormatType - -__all__ = ["DubbingGetTranscriptForDubRequestFormatType"] diff --git a/src/elevenlabs/dubbing/types/dubbing_get_transcript_for_dub_request_format_type.py b/src/elevenlabs/dubbing/types/dubbing_get_transcript_for_dub_request_format_type.py deleted file mode 100644 index ed4d2ea2..00000000 --- a/src/elevenlabs/dubbing/types/dubbing_get_transcript_for_dub_request_format_type.py +++ /dev/null @@ -1,5 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import typing - -DubbingGetTranscriptForDubRequestFormatType = typing.Union[typing.Literal["srt", "webvtt"], typing.Any] diff --git a/src/elevenlabs/errors/__init__.py b/src/elevenlabs/errors/__init__.py index cc9497e5..f744d3fb 100644 --- a/src/elevenlabs/errors/__init__.py +++ b/src/elevenlabs/errors/__init__.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# isort: skip_file + from .bad_request_error import BadRequestError from .forbidden_error import ForbiddenError from .not_found_error import NotFoundError diff --git a/src/elevenlabs/errors/bad_request_error.py b/src/elevenlabs/errors/bad_request_error.py index 9c13c61f..baf5be4f 100644 --- a/src/elevenlabs/errors/bad_request_error.py +++ b/src/elevenlabs/errors/bad_request_error.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.api_error import ApiError import typing +from ..core.api_error import ApiError + class BadRequestError(ApiError): - def __init__(self, body: typing.Optional[typing.Any]): - super().__init__(status_code=400, body=body) + def __init__(self, body: typing.Optional[typing.Any], headers: typing.Optional[typing.Dict[str, str]] = None): + super().__init__(status_code=400, headers=headers, body=body) diff --git a/src/elevenlabs/errors/forbidden_error.py b/src/elevenlabs/errors/forbidden_error.py index d17eb4b9..3e390b0d 100644 --- a/src/elevenlabs/errors/forbidden_error.py +++ b/src/elevenlabs/errors/forbidden_error.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.api_error import ApiError import typing +from ..core.api_error import ApiError + class ForbiddenError(ApiError): - def __init__(self, body: typing.Optional[typing.Any]): - super().__init__(status_code=403, body=body) + def __init__(self, body: typing.Optional[typing.Any], headers: typing.Optional[typing.Dict[str, str]] = None): + super().__init__(status_code=403, headers=headers, body=body) diff --git a/src/elevenlabs/errors/not_found_error.py b/src/elevenlabs/errors/not_found_error.py index a1235b87..dcd60e38 100644 --- a/src/elevenlabs/errors/not_found_error.py +++ b/src/elevenlabs/errors/not_found_error.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.api_error import ApiError import typing +from ..core.api_error import ApiError + class NotFoundError(ApiError): - def __init__(self, body: typing.Optional[typing.Any]): - super().__init__(status_code=404, body=body) + def __init__(self, body: typing.Optional[typing.Any], headers: typing.Optional[typing.Dict[str, str]] = None): + super().__init__(status_code=404, headers=headers, body=body) diff --git a/src/elevenlabs/errors/too_early_error.py b/src/elevenlabs/errors/too_early_error.py index 33796003..422acaaa 100644 --- a/src/elevenlabs/errors/too_early_error.py +++ b/src/elevenlabs/errors/too_early_error.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.api_error import ApiError import typing +from ..core.api_error import ApiError + class TooEarlyError(ApiError): - def __init__(self, body: typing.Optional[typing.Any]): - super().__init__(status_code=425, body=body) + def __init__(self, body: typing.Optional[typing.Any], headers: typing.Optional[typing.Dict[str, str]] = None): + super().__init__(status_code=425, headers=headers, body=body) diff --git a/src/elevenlabs/errors/unprocessable_entity_error.py b/src/elevenlabs/errors/unprocessable_entity_error.py index 47470a70..d3f9c5d8 100644 --- a/src/elevenlabs/errors/unprocessable_entity_error.py +++ b/src/elevenlabs/errors/unprocessable_entity_error.py @@ -1,9 +1,11 @@ # This file was auto-generated by Fern from our API Definition. +import typing + from ..core.api_error import ApiError from ..types.http_validation_error import HttpValidationError class UnprocessableEntityError(ApiError): - def __init__(self, body: HttpValidationError): - super().__init__(status_code=422, body=body) + def __init__(self, body: HttpValidationError, headers: typing.Optional[typing.Dict[str, str]] = None): + super().__init__(status_code=422, headers=headers, body=body) diff --git a/src/elevenlabs/forced_alignment/__init__.py b/src/elevenlabs/forced_alignment/__init__.py index f3ea2659..5cde0202 100644 --- a/src/elevenlabs/forced_alignment/__init__.py +++ b/src/elevenlabs/forced_alignment/__init__.py @@ -1,2 +1,4 @@ # This file was auto-generated by Fern from our API Definition. +# isort: skip_file + diff --git a/src/elevenlabs/forced_alignment/client.py b/src/elevenlabs/forced_alignment/client.py index 6d995e95..011a6b34 100644 --- a/src/elevenlabs/forced_alignment/client.py +++ b/src/elevenlabs/forced_alignment/client.py @@ -1,16 +1,12 @@ # This file was auto-generated by Fern from our API Definition. import typing -from ..core.client_wrapper import SyncClientWrapper + from .. import core +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ..core.request_options import RequestOptions from ..types.forced_alignment_response_model import ForcedAlignmentResponseModel -from ..core.unchecked_base_model import construct_type -from ..errors.unprocessable_entity_error import UnprocessableEntityError -from ..types.http_validation_error import HttpValidationError -from json.decoder import JSONDecodeError -from ..core.api_error import ApiError -from ..core.client_wrapper import AsyncClientWrapper +from .raw_client import AsyncRawForcedAlignmentClient, RawForcedAlignmentClient # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -18,7 +14,18 @@ class ForcedAlignmentClient: def __init__(self, *, client_wrapper: SyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = RawForcedAlignmentClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawForcedAlignmentClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawForcedAlignmentClient + """ + return self._raw_client def create( self, @@ -61,48 +68,26 @@ def create( text="text", ) """ - _response = self._client_wrapper.httpx_client.request( - "v1/forced-alignment", - base_url=self._client_wrapper.get_environment().base, - method="POST", - data={ - "text": text, - "enabled_spooled_file": enabled_spooled_file, - }, - files={ - "file": file, - }, - request_options=request_options, - omit=OMIT, + _response = self._raw_client.create( + file=file, text=text, enabled_spooled_file=enabled_spooled_file, request_options=request_options ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ForcedAlignmentResponseModel, - construct_type( - type_=ForcedAlignmentResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + return _response.data class AsyncForcedAlignmentClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = AsyncRawForcedAlignmentClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawForcedAlignmentClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawForcedAlignmentClient + """ + return self._raw_client async def create( self, @@ -153,40 +138,7 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - "v1/forced-alignment", - base_url=self._client_wrapper.get_environment().base, - method="POST", - data={ - "text": text, - "enabled_spooled_file": enabled_spooled_file, - }, - files={ - "file": file, - }, - request_options=request_options, - omit=OMIT, + _response = await self._raw_client.create( + file=file, text=text, enabled_spooled_file=enabled_spooled_file, request_options=request_options ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ForcedAlignmentResponseModel, - construct_type( - type_=ForcedAlignmentResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + return _response.data diff --git a/src/elevenlabs/forced_alignment/raw_client.py b/src/elevenlabs/forced_alignment/raw_client.py new file mode 100644 index 00000000..83a931c1 --- /dev/null +++ b/src/elevenlabs/forced_alignment/raw_client.py @@ -0,0 +1,169 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from .. import core +from ..core.api_error import ApiError +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ..core.http_response import AsyncHttpResponse, HttpResponse +from ..core.request_options import RequestOptions +from ..core.unchecked_base_model import construct_type +from ..errors.unprocessable_entity_error import UnprocessableEntityError +from ..types.forced_alignment_response_model import ForcedAlignmentResponseModel +from ..types.http_validation_error import HttpValidationError + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RawForcedAlignmentClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def create( + self, + *, + file: core.File, + text: str, + enabled_spooled_file: typing.Optional[bool] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[ForcedAlignmentResponseModel]: + """ + Force align an audio file to text. Use this endpoint to get the timing information for each character and word in an audio file based on a provided text transcript. + + Parameters + ---------- + file : core.File + See core.File for more documentation + + text : str + The text to align with the audio. The input text can be in any format, however diarization is not supported at this time. + + enabled_spooled_file : typing.Optional[bool] + If true, the file will be streamed to the server and processed in chunks. This is useful for large files that cannot be loaded into memory. The default is false. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[ForcedAlignmentResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + "v1/forced-alignment", + base_url=self._client_wrapper.get_environment().base, + method="POST", + data={ + "text": text, + "enabled_spooled_file": enabled_spooled_file, + }, + files={ + "file": file, + }, + request_options=request_options, + omit=OMIT, + force_multipart=True, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ForcedAlignmentResponseModel, + construct_type( + type_=ForcedAlignmentResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + +class AsyncRawForcedAlignmentClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def create( + self, + *, + file: core.File, + text: str, + enabled_spooled_file: typing.Optional[bool] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[ForcedAlignmentResponseModel]: + """ + Force align an audio file to text. Use this endpoint to get the timing information for each character and word in an audio file based on a provided text transcript. + + Parameters + ---------- + file : core.File + See core.File for more documentation + + text : str + The text to align with the audio. The input text can be in any format, however diarization is not supported at this time. + + enabled_spooled_file : typing.Optional[bool] + If true, the file will be streamed to the server and processed in chunks. This is useful for large files that cannot be loaded into memory. The default is false. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[ForcedAlignmentResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + "v1/forced-alignment", + base_url=self._client_wrapper.get_environment().base, + method="POST", + data={ + "text": text, + "enabled_spooled_file": enabled_spooled_file, + }, + files={ + "file": file, + }, + request_options=request_options, + omit=OMIT, + force_multipart=True, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ForcedAlignmentResponseModel, + construct_type( + type_=ForcedAlignmentResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/elevenlabs/history/__init__.py b/src/elevenlabs/history/__init__.py index 5c94f169..7233ea43 100644 --- a/src/elevenlabs/history/__init__.py +++ b/src/elevenlabs/history/__init__.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. -from .types import HistoryGetAllRequestSource +# isort: skip_file -__all__ = ["HistoryGetAllRequestSource"] +from .types import HistoryListRequestSource + +__all__ = ["HistoryListRequestSource"] diff --git a/src/elevenlabs/history/client.py b/src/elevenlabs/history/client.py index 3a739a50..ad7764f1 100644 --- a/src/elevenlabs/history/client.py +++ b/src/elevenlabs/history/client.py @@ -1,20 +1,14 @@ # This file was auto-generated by Fern from our API Definition. import typing -from ..core.client_wrapper import SyncClientWrapper -from .types.history_get_all_request_source import HistoryGetAllRequestSource + +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ..core.request_options import RequestOptions +from ..types.delete_history_item_response import DeleteHistoryItemResponse from ..types.get_speech_history_response import GetSpeechHistoryResponse -from ..core.unchecked_base_model import construct_type -from ..errors.unprocessable_entity_error import UnprocessableEntityError -from ..types.http_validation_error import HttpValidationError -from json.decoder import JSONDecodeError -from ..core.api_error import ApiError from ..types.speech_history_item_response import SpeechHistoryItemResponse -from ..core.jsonable_encoder import jsonable_encoder -from ..types.delete_history_item_response import DeleteHistoryItemResponse -from ..errors.bad_request_error import BadRequestError -from ..core.client_wrapper import AsyncClientWrapper +from .raw_client import AsyncRawHistoryClient, RawHistoryClient +from .types.history_list_request_source import HistoryListRequestSource # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -22,16 +16,27 @@ class HistoryClient: def __init__(self, *, client_wrapper: SyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = RawHistoryClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawHistoryClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawHistoryClient + """ + return self._raw_client - def get_all( + def list( self, *, page_size: typing.Optional[int] = None, start_after_history_item_id: typing.Optional[str] = None, voice_id: typing.Optional[str] = None, search: typing.Optional[str] = None, - source: typing.Optional[HistoryGetAllRequestSource] = None, + source: typing.Optional[HistoryListRequestSource] = None, request_options: typing.Optional[RequestOptions] = None, ) -> GetSpeechHistoryResponse: """ @@ -51,7 +56,7 @@ def get_all( search : typing.Optional[str] Search term used for filtering history items. If provided, source becomes required. - source : typing.Optional[HistoryGetAllRequestSource] + source : typing.Optional[HistoryListRequestSource] Source of the generated history item request_options : typing.Optional[RequestOptions] @@ -69,50 +74,20 @@ def get_all( client = ElevenLabs( api_key="YOUR_API_KEY", ) - client.history.get_all() + client.history.list() """ - _response = self._client_wrapper.httpx_client.request( - "v1/history", - base_url=self._client_wrapper.get_environment().base, - method="GET", - params={ - "page_size": page_size, - "start_after_history_item_id": start_after_history_item_id, - "voice_id": voice_id, - "search": search, - "source": source, - }, + _response = self._raw_client.list( + page_size=page_size, + start_after_history_item_id=start_after_history_item_id, + voice_id=voice_id, + search=search, + source=source, request_options=request_options, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - GetSpeechHistoryResponse, - construct_type( - type_=GetSpeechHistoryResponse, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + return _response.data def get( - self, - history_item_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, + self, history_item_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> SpeechHistoryItemResponse: """ Retrieves a history item. @@ -141,41 +116,11 @@ def get( history_item_id="VW7YKqPnjY4h39yTbx2L", ) """ - _response = self._client_wrapper.httpx_client.request( - f"v1/history/{jsonable_encoder(history_item_id)}", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - SpeechHistoryItemResponse, - construct_type( - type_=SpeechHistoryItemResponse, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.get(history_item_id, request_options=request_options) + return _response.data def delete( - self, - history_item_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, + self, history_item_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> DeleteHistoryItemResponse: """ Delete a history item by its ID @@ -204,41 +149,11 @@ def delete( history_item_id="VW7YKqPnjY4h39yTbx2L", ) """ - _response = self._client_wrapper.httpx_client.request( - f"v1/history/{jsonable_encoder(history_item_id)}", - base_url=self._client_wrapper.get_environment().base, - method="DELETE", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - DeleteHistoryItemResponse, - construct_type( - type_=DeleteHistoryItemResponse, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.delete(history_item_id, request_options=request_options) + return _response.data def get_audio( - self, - history_item_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, + self, history_item_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> typing.Iterator[bytes]: """ Returns the audio of an history item. @@ -251,38 +166,13 @@ def get_audio( request_options : typing.Optional[RequestOptions] Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. - Yields - ------ + Returns + ------- typing.Iterator[bytes] The audio file of the history item. """ - with self._client_wrapper.httpx_client.stream( - f"v1/history/{jsonable_encoder(history_item_id)}/audio", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) as _response: - try: - if 200 <= _response.status_code < 300: - _chunk_size = request_options.get("chunk_size", 1024) if request_options is not None else 1024 - for _chunk in _response.iter_bytes(chunk_size=_chunk_size): - yield _chunk - return - _response.read() - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + with self._raw_client.get_audio(history_item_id, request_options=request_options) as r: + yield from r.data def download( self, @@ -305,70 +195,40 @@ def download( request_options : typing.Optional[RequestOptions] Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. - Yields - ------ + Returns + ------- typing.Iterator[bytes] The requested audio file, or a zip file containing multiple audio files when multiple history items are requested. """ - with self._client_wrapper.httpx_client.stream( - "v1/history/download", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "history_item_ids": history_item_ids, - "output_format": output_format, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) as _response: - try: - if 200 <= _response.status_code < 300: - _chunk_size = request_options.get("chunk_size", 1024) if request_options is not None else 1024 - for _chunk in _response.iter_bytes(chunk_size=_chunk_size): - yield _chunk - return - _response.read() - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + with self._raw_client.download( + history_item_ids=history_item_ids, output_format=output_format, request_options=request_options + ) as r: + yield from r.data class AsyncHistoryClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = AsyncRawHistoryClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawHistoryClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawHistoryClient + """ + return self._raw_client - async def get_all( + async def list( self, *, page_size: typing.Optional[int] = None, start_after_history_item_id: typing.Optional[str] = None, voice_id: typing.Optional[str] = None, search: typing.Optional[str] = None, - source: typing.Optional[HistoryGetAllRequestSource] = None, + source: typing.Optional[HistoryListRequestSource] = None, request_options: typing.Optional[RequestOptions] = None, ) -> GetSpeechHistoryResponse: """ @@ -388,7 +248,7 @@ async def get_all( search : typing.Optional[str] Search term used for filtering history items. If provided, source becomes required. - source : typing.Optional[HistoryGetAllRequestSource] + source : typing.Optional[HistoryListRequestSource] Source of the generated history item request_options : typing.Optional[RequestOptions] @@ -411,53 +271,23 @@ async def get_all( async def main() -> None: - await client.history.get_all() + await client.history.list() asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - "v1/history", - base_url=self._client_wrapper.get_environment().base, - method="GET", - params={ - "page_size": page_size, - "start_after_history_item_id": start_after_history_item_id, - "voice_id": voice_id, - "search": search, - "source": source, - }, + _response = await self._raw_client.list( + page_size=page_size, + start_after_history_item_id=start_after_history_item_id, + voice_id=voice_id, + search=search, + source=source, request_options=request_options, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - GetSpeechHistoryResponse, - construct_type( - type_=GetSpeechHistoryResponse, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + return _response.data async def get( - self, - history_item_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, + self, history_item_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> SpeechHistoryItemResponse: """ Retrieves a history item. @@ -494,41 +324,11 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/history/{jsonable_encoder(history_item_id)}", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - SpeechHistoryItemResponse, - construct_type( - type_=SpeechHistoryItemResponse, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.get(history_item_id, request_options=request_options) + return _response.data async def delete( - self, - history_item_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, + self, history_item_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> DeleteHistoryItemResponse: """ Delete a history item by its ID @@ -565,41 +365,11 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/history/{jsonable_encoder(history_item_id)}", - base_url=self._client_wrapper.get_environment().base, - method="DELETE", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - DeleteHistoryItemResponse, - construct_type( - type_=DeleteHistoryItemResponse, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.delete(history_item_id, request_options=request_options) + return _response.data async def get_audio( - self, - history_item_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, + self, history_item_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> typing.AsyncIterator[bytes]: """ Returns the audio of an history item. @@ -612,38 +382,14 @@ async def get_audio( request_options : typing.Optional[RequestOptions] Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. - Yields - ------ + Returns + ------- typing.AsyncIterator[bytes] The audio file of the history item. """ - async with self._client_wrapper.httpx_client.stream( - f"v1/history/{jsonable_encoder(history_item_id)}/audio", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) as _response: - try: - if 200 <= _response.status_code < 300: - _chunk_size = request_options.get("chunk_size", 1024) if request_options is not None else 1024 - async for _chunk in _response.aiter_bytes(chunk_size=_chunk_size): - yield _chunk - return - await _response.aread() - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + async with self._raw_client.get_audio(history_item_id, request_options=request_options) as r: + async for _chunk in r.data: + yield _chunk async def download( self, @@ -666,53 +412,13 @@ async def download( request_options : typing.Optional[RequestOptions] Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. - Yields - ------ + Returns + ------- typing.AsyncIterator[bytes] The requested audio file, or a zip file containing multiple audio files when multiple history items are requested. """ - async with self._client_wrapper.httpx_client.stream( - "v1/history/download", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "history_item_ids": history_item_ids, - "output_format": output_format, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) as _response: - try: - if 200 <= _response.status_code < 300: - _chunk_size = request_options.get("chunk_size", 1024) if request_options is not None else 1024 - async for _chunk in _response.aiter_bytes(chunk_size=_chunk_size): - yield _chunk - return - await _response.aread() - if _response.status_code == 400: - raise BadRequestError( - typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + async with self._raw_client.download( + history_item_ids=history_item_ids, output_format=output_format, request_options=request_options + ) as r: + async for _chunk in r.data: + yield _chunk diff --git a/src/elevenlabs/history/raw_client.py b/src/elevenlabs/history/raw_client.py new file mode 100644 index 00000000..266f4cf0 --- /dev/null +++ b/src/elevenlabs/history/raw_client.py @@ -0,0 +1,664 @@ +# This file was auto-generated by Fern from our API Definition. + +import contextlib +import typing +from json.decoder import JSONDecodeError + +from ..core.api_error import ApiError +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ..core.http_response import AsyncHttpResponse, HttpResponse +from ..core.jsonable_encoder import jsonable_encoder +from ..core.request_options import RequestOptions +from ..core.unchecked_base_model import construct_type +from ..errors.bad_request_error import BadRequestError +from ..errors.unprocessable_entity_error import UnprocessableEntityError +from ..types.delete_history_item_response import DeleteHistoryItemResponse +from ..types.get_speech_history_response import GetSpeechHistoryResponse +from ..types.http_validation_error import HttpValidationError +from ..types.speech_history_item_response import SpeechHistoryItemResponse +from .types.history_list_request_source import HistoryListRequestSource + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RawHistoryClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def list( + self, + *, + page_size: typing.Optional[int] = None, + start_after_history_item_id: typing.Optional[str] = None, + voice_id: typing.Optional[str] = None, + search: typing.Optional[str] = None, + source: typing.Optional[HistoryListRequestSource] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[GetSpeechHistoryResponse]: + """ + Returns a list of your generated audio. + + Parameters + ---------- + page_size : typing.Optional[int] + How many history items to return at maximum. Can not exceed 1000, defaults to 100. + + start_after_history_item_id : typing.Optional[str] + After which ID to start fetching, use this parameter to paginate across a large collection of history items. In case this parameter is not provided history items will be fetched starting from the most recently created one ordered descending by their creation date. + + voice_id : typing.Optional[str] + ID of the voice to be filtered for. You can use the [Get voices](/docs/api-reference/voices/search) endpoint list all the available voices. + + search : typing.Optional[str] + Search term used for filtering history items. If provided, source becomes required. + + source : typing.Optional[HistoryListRequestSource] + Source of the generated history item + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[GetSpeechHistoryResponse] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + "v1/history", + base_url=self._client_wrapper.get_environment().base, + method="GET", + params={ + "page_size": page_size, + "start_after_history_item_id": start_after_history_item_id, + "voice_id": voice_id, + "search": search, + "source": source, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetSpeechHistoryResponse, + construct_type( + type_=GetSpeechHistoryResponse, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def get( + self, history_item_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[SpeechHistoryItemResponse]: + """ + Retrieves a history item. + + Parameters + ---------- + history_item_id : str + ID of the history item to be used. You can use the [Get generated items](/docs/api-reference/history/get-all) endpoint to retrieve a list of history items. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[SpeechHistoryItemResponse] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/history/{jsonable_encoder(history_item_id)}", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + SpeechHistoryItemResponse, + construct_type( + type_=SpeechHistoryItemResponse, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def delete( + self, history_item_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[DeleteHistoryItemResponse]: + """ + Delete a history item by its ID + + Parameters + ---------- + history_item_id : str + ID of the history item to be used. You can use the [Get generated items](/docs/api-reference/history/get-all) endpoint to retrieve a list of history items. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[DeleteHistoryItemResponse] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/history/{jsonable_encoder(history_item_id)}", + base_url=self._client_wrapper.get_environment().base, + method="DELETE", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + DeleteHistoryItemResponse, + construct_type( + type_=DeleteHistoryItemResponse, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + @contextlib.contextmanager + def get_audio( + self, history_item_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> typing.Iterator[HttpResponse[typing.Iterator[bytes]]]: + """ + Returns the audio of an history item. + + Parameters + ---------- + history_item_id : str + ID of the history item to be used. You can use the [Get generated items](/docs/api-reference/history/get-all) endpoint to retrieve a list of history items. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. + + Returns + ------- + typing.Iterator[HttpResponse[typing.Iterator[bytes]]] + The audio file of the history item. + """ + with self._client_wrapper.httpx_client.stream( + f"v1/history/{jsonable_encoder(history_item_id)}/audio", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) as _response: + + def _stream() -> HttpResponse[typing.Iterator[bytes]]: + try: + if 200 <= _response.status_code < 300: + _chunk_size = request_options.get("chunk_size", 1024) if request_options is not None else 1024 + return HttpResponse( + response=_response, data=(_chunk for _chunk in _response.iter_bytes(chunk_size=_chunk_size)) + ) + _response.read() + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + yield _stream() + + @contextlib.contextmanager + def download( + self, + *, + history_item_ids: typing.Sequence[str], + output_format: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> typing.Iterator[HttpResponse[typing.Iterator[bytes]]]: + """ + Download one or more history items. If one history item ID is provided, we will return a single audio file. If more than one history item IDs are provided, we will provide the history items packed into a .zip file. + + Parameters + ---------- + history_item_ids : typing.Sequence[str] + A list of history items to download, you can get IDs of history items and other metadata using the GET https://api.elevenlabs.io/v1/history endpoint. + + output_format : typing.Optional[str] + Output format to transcode the audio file, can be wav or default. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. + + Returns + ------- + typing.Iterator[HttpResponse[typing.Iterator[bytes]]] + The requested audio file, or a zip file containing multiple audio files when multiple history items are requested. + """ + with self._client_wrapper.httpx_client.stream( + "v1/history/download", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "history_item_ids": history_item_ids, + "output_format": output_format, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) as _response: + + def _stream() -> HttpResponse[typing.Iterator[bytes]]: + try: + if 200 <= _response.status_code < 300: + _chunk_size = request_options.get("chunk_size", 1024) if request_options is not None else 1024 + return HttpResponse( + response=_response, data=(_chunk for _chunk in _response.iter_bytes(chunk_size=_chunk_size)) + ) + _response.read() + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + construct_type( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + yield _stream() + + +class AsyncRawHistoryClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def list( + self, + *, + page_size: typing.Optional[int] = None, + start_after_history_item_id: typing.Optional[str] = None, + voice_id: typing.Optional[str] = None, + search: typing.Optional[str] = None, + source: typing.Optional[HistoryListRequestSource] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[GetSpeechHistoryResponse]: + """ + Returns a list of your generated audio. + + Parameters + ---------- + page_size : typing.Optional[int] + How many history items to return at maximum. Can not exceed 1000, defaults to 100. + + start_after_history_item_id : typing.Optional[str] + After which ID to start fetching, use this parameter to paginate across a large collection of history items. In case this parameter is not provided history items will be fetched starting from the most recently created one ordered descending by their creation date. + + voice_id : typing.Optional[str] + ID of the voice to be filtered for. You can use the [Get voices](/docs/api-reference/voices/search) endpoint list all the available voices. + + search : typing.Optional[str] + Search term used for filtering history items. If provided, source becomes required. + + source : typing.Optional[HistoryListRequestSource] + Source of the generated history item + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[GetSpeechHistoryResponse] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + "v1/history", + base_url=self._client_wrapper.get_environment().base, + method="GET", + params={ + "page_size": page_size, + "start_after_history_item_id": start_after_history_item_id, + "voice_id": voice_id, + "search": search, + "source": source, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetSpeechHistoryResponse, + construct_type( + type_=GetSpeechHistoryResponse, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def get( + self, history_item_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[SpeechHistoryItemResponse]: + """ + Retrieves a history item. + + Parameters + ---------- + history_item_id : str + ID of the history item to be used. You can use the [Get generated items](/docs/api-reference/history/get-all) endpoint to retrieve a list of history items. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[SpeechHistoryItemResponse] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/history/{jsonable_encoder(history_item_id)}", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + SpeechHistoryItemResponse, + construct_type( + type_=SpeechHistoryItemResponse, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def delete( + self, history_item_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[DeleteHistoryItemResponse]: + """ + Delete a history item by its ID + + Parameters + ---------- + history_item_id : str + ID of the history item to be used. You can use the [Get generated items](/docs/api-reference/history/get-all) endpoint to retrieve a list of history items. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[DeleteHistoryItemResponse] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/history/{jsonable_encoder(history_item_id)}", + base_url=self._client_wrapper.get_environment().base, + method="DELETE", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + DeleteHistoryItemResponse, + construct_type( + type_=DeleteHistoryItemResponse, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + @contextlib.asynccontextmanager + async def get_audio( + self, history_item_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> typing.AsyncIterator[AsyncHttpResponse[typing.AsyncIterator[bytes]]]: + """ + Returns the audio of an history item. + + Parameters + ---------- + history_item_id : str + ID of the history item to be used. You can use the [Get generated items](/docs/api-reference/history/get-all) endpoint to retrieve a list of history items. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. + + Returns + ------- + typing.AsyncIterator[AsyncHttpResponse[typing.AsyncIterator[bytes]]] + The audio file of the history item. + """ + async with self._client_wrapper.httpx_client.stream( + f"v1/history/{jsonable_encoder(history_item_id)}/audio", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) as _response: + + async def _stream() -> AsyncHttpResponse[typing.AsyncIterator[bytes]]: + try: + if 200 <= _response.status_code < 300: + _chunk_size = request_options.get("chunk_size", 1024) if request_options is not None else 1024 + return AsyncHttpResponse( + response=_response, + data=(_chunk async for _chunk in _response.aiter_bytes(chunk_size=_chunk_size)), + ) + await _response.aread() + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + yield await _stream() + + @contextlib.asynccontextmanager + async def download( + self, + *, + history_item_ids: typing.Sequence[str], + output_format: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> typing.AsyncIterator[AsyncHttpResponse[typing.AsyncIterator[bytes]]]: + """ + Download one or more history items. If one history item ID is provided, we will return a single audio file. If more than one history item IDs are provided, we will provide the history items packed into a .zip file. + + Parameters + ---------- + history_item_ids : typing.Sequence[str] + A list of history items to download, you can get IDs of history items and other metadata using the GET https://api.elevenlabs.io/v1/history endpoint. + + output_format : typing.Optional[str] + Output format to transcode the audio file, can be wav or default. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. + + Returns + ------- + typing.AsyncIterator[AsyncHttpResponse[typing.AsyncIterator[bytes]]] + The requested audio file, or a zip file containing multiple audio files when multiple history items are requested. + """ + async with self._client_wrapper.httpx_client.stream( + "v1/history/download", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "history_item_ids": history_item_ids, + "output_format": output_format, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) as _response: + + async def _stream() -> AsyncHttpResponse[typing.AsyncIterator[bytes]]: + try: + if 200 <= _response.status_code < 300: + _chunk_size = request_options.get("chunk_size", 1024) if request_options is not None else 1024 + return AsyncHttpResponse( + response=_response, + data=(_chunk async for _chunk in _response.aiter_bytes(chunk_size=_chunk_size)), + ) + await _response.aread() + if _response.status_code == 400: + raise BadRequestError( + headers=dict(_response.headers), + body=typing.cast( + typing.Optional[typing.Any], + construct_type( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + yield await _stream() diff --git a/src/elevenlabs/history/types/__init__.py b/src/elevenlabs/history/types/__init__.py index c1e50696..74f623fc 100644 --- a/src/elevenlabs/history/types/__init__.py +++ b/src/elevenlabs/history/types/__init__.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. -from .history_get_all_request_source import HistoryGetAllRequestSource +# isort: skip_file -__all__ = ["HistoryGetAllRequestSource"] +from .history_list_request_source import HistoryListRequestSource + +__all__ = ["HistoryListRequestSource"] diff --git a/src/elevenlabs/history/types/history_get_all_request_source.py b/src/elevenlabs/history/types/history_get_all_request_source.py deleted file mode 100644 index fc4371db..00000000 --- a/src/elevenlabs/history/types/history_get_all_request_source.py +++ /dev/null @@ -1,5 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import typing - -HistoryGetAllRequestSource = typing.Union[typing.Literal["TTS", "STS"], typing.Any] diff --git a/src/elevenlabs/history/types/history_list_request_source.py b/src/elevenlabs/history/types/history_list_request_source.py new file mode 100644 index 00000000..ce066139 --- /dev/null +++ b/src/elevenlabs/history/types/history_list_request_source.py @@ -0,0 +1,5 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +HistoryListRequestSource = typing.Union[typing.Literal["TTS", "STS"], typing.Any] diff --git a/src/elevenlabs/models/__init__.py b/src/elevenlabs/models/__init__.py index f3ea2659..5cde0202 100644 --- a/src/elevenlabs/models/__init__.py +++ b/src/elevenlabs/models/__init__.py @@ -1,2 +1,4 @@ # This file was auto-generated by Fern from our API Definition. +# isort: skip_file + diff --git a/src/elevenlabs/models/client.py b/src/elevenlabs/models/client.py index d0da9b00..1ac846ae 100644 --- a/src/elevenlabs/models/client.py +++ b/src/elevenlabs/models/client.py @@ -1,22 +1,29 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.client_wrapper import SyncClientWrapper import typing + +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ..core.request_options import RequestOptions from ..types.model import Model -from ..core.unchecked_base_model import construct_type -from ..errors.unprocessable_entity_error import UnprocessableEntityError -from ..types.http_validation_error import HttpValidationError -from json.decoder import JSONDecodeError -from ..core.api_error import ApiError -from ..core.client_wrapper import AsyncClientWrapper +from .raw_client import AsyncRawModelsClient, RawModelsClient class ModelsClient: def __init__(self, *, client_wrapper: SyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = RawModelsClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawModelsClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawModelsClient + """ + return self._raw_client - def get_all(self, *, request_options: typing.Optional[RequestOptions] = None) -> typing.List[Model]: + def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> typing.List[Model]: """ Gets a list of available models. @@ -37,44 +44,28 @@ def get_all(self, *, request_options: typing.Optional[RequestOptions] = None) -> client = ElevenLabs( api_key="YOUR_API_KEY", ) - client.models.get_all() + client.models.list() """ - _response = self._client_wrapper.httpx_client.request( - "v1/models", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - typing.List[Model], - construct_type( - type_=typing.List[Model], # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.list(request_options=request_options) + return _response.data class AsyncModelsClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = AsyncRawModelsClient(client_wrapper=client_wrapper) - async def get_all(self, *, request_options: typing.Optional[RequestOptions] = None) -> typing.List[Model]: + @property + def with_raw_response(self) -> AsyncRawModelsClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawModelsClient + """ + return self._raw_client + + async def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> typing.List[Model]: """ Gets a list of available models. @@ -100,37 +91,10 @@ async def get_all(self, *, request_options: typing.Optional[RequestOptions] = No async def main() -> None: - await client.models.get_all() + await client.models.list() asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - "v1/models", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - typing.List[Model], - construct_type( - type_=typing.List[Model], # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.list(request_options=request_options) + return _response.data diff --git a/src/elevenlabs/models/raw_client.py b/src/elevenlabs/models/raw_client.py new file mode 100644 index 00000000..2686c32c --- /dev/null +++ b/src/elevenlabs/models/raw_client.py @@ -0,0 +1,117 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ..core.api_error import ApiError +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ..core.http_response import AsyncHttpResponse, HttpResponse +from ..core.request_options import RequestOptions +from ..core.unchecked_base_model import construct_type +from ..errors.unprocessable_entity_error import UnprocessableEntityError +from ..types.http_validation_error import HttpValidationError +from ..types.model import Model + + +class RawModelsClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> HttpResponse[typing.List[Model]]: + """ + Gets a list of available models. + + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[typing.List[Model]] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + "v1/models", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + typing.List[Model], + construct_type( + type_=typing.List[Model], # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + +class AsyncRawModelsClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def list( + self, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[typing.List[Model]]: + """ + Gets a list of available models. + + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[typing.List[Model]] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + "v1/models", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + typing.List[Model], + construct_type( + type_=typing.List[Model], # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/elevenlabs/pronunciation_dictionary/__init__.py b/src/elevenlabs/pronunciation_dictionaries/__init__.py similarity index 70% rename from src/elevenlabs/pronunciation_dictionary/__init__.py rename to src/elevenlabs/pronunciation_dictionaries/__init__.py index 257375ec..9418f247 100644 --- a/src/elevenlabs/pronunciation_dictionary/__init__.py +++ b/src/elevenlabs/pronunciation_dictionaries/__init__.py @@ -1,25 +1,27 @@ # This file was auto-generated by Fern from our API Definition. +# isort: skip_file + from .types import ( BodyAddAPronunciationDictionaryV1PronunciationDictionariesAddFromRulesPostRulesItem, BodyAddAPronunciationDictionaryV1PronunciationDictionariesAddFromRulesPostRulesItem_Alias, BodyAddAPronunciationDictionaryV1PronunciationDictionariesAddFromRulesPostRulesItem_Phoneme, BodyAddAPronunciationDictionaryV1PronunciationDictionariesAddFromRulesPostWorkspaceAccess, - PronunciationDictionaryAddFromFileRequestWorkspaceAccess, - PronunciationDictionaryGetAllRequestSort, - PronunciationDictionaryRule, - PronunciationDictionaryRule_Alias, - PronunciationDictionaryRule_Phoneme, + PronunciationDictionariesCreateFromFileRequestWorkspaceAccess, + PronunciationDictionariesListRequestSort, ) +from . import rules +from .rules import PronunciationDictionaryRule, PronunciationDictionaryRule_Alias, PronunciationDictionaryRule_Phoneme __all__ = [ "BodyAddAPronunciationDictionaryV1PronunciationDictionariesAddFromRulesPostRulesItem", "BodyAddAPronunciationDictionaryV1PronunciationDictionariesAddFromRulesPostRulesItem_Alias", "BodyAddAPronunciationDictionaryV1PronunciationDictionariesAddFromRulesPostRulesItem_Phoneme", "BodyAddAPronunciationDictionaryV1PronunciationDictionariesAddFromRulesPostWorkspaceAccess", - "PronunciationDictionaryAddFromFileRequestWorkspaceAccess", - "PronunciationDictionaryGetAllRequestSort", + "PronunciationDictionariesCreateFromFileRequestWorkspaceAccess", + "PronunciationDictionariesListRequestSort", "PronunciationDictionaryRule", "PronunciationDictionaryRule_Alias", "PronunciationDictionaryRule_Phoneme", + "rules", ] diff --git a/src/elevenlabs/pronunciation_dictionaries/client.py b/src/elevenlabs/pronunciation_dictionaries/client.py new file mode 100644 index 00000000..c4e56a11 --- /dev/null +++ b/src/elevenlabs/pronunciation_dictionaries/client.py @@ -0,0 +1,556 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +from .. import core +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ..core.request_options import RequestOptions +from ..types.add_pronunciation_dictionary_response_model import AddPronunciationDictionaryResponseModel +from ..types.get_pronunciation_dictionaries_metadata_response_model import ( + GetPronunciationDictionariesMetadataResponseModel, +) +from ..types.get_pronunciation_dictionary_metadata_response import GetPronunciationDictionaryMetadataResponse +from .raw_client import AsyncRawPronunciationDictionariesClient, RawPronunciationDictionariesClient +from .rules.client import AsyncRulesClient, RulesClient +from .types.body_add_a_pronunciation_dictionary_v_1_pronunciation_dictionaries_add_from_rules_post_rules_item import ( + BodyAddAPronunciationDictionaryV1PronunciationDictionariesAddFromRulesPostRulesItem, +) +from .types.body_add_a_pronunciation_dictionary_v_1_pronunciation_dictionaries_add_from_rules_post_workspace_access import ( + BodyAddAPronunciationDictionaryV1PronunciationDictionariesAddFromRulesPostWorkspaceAccess, +) +from .types.pronunciation_dictionaries_create_from_file_request_workspace_access import ( + PronunciationDictionariesCreateFromFileRequestWorkspaceAccess, +) +from .types.pronunciation_dictionaries_list_request_sort import PronunciationDictionariesListRequestSort + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class PronunciationDictionariesClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._raw_client = RawPronunciationDictionariesClient(client_wrapper=client_wrapper) + self.rules = RulesClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawPronunciationDictionariesClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawPronunciationDictionariesClient + """ + return self._raw_client + + def create_from_file( + self, + *, + name: str, + file: typing.Optional[core.File] = OMIT, + description: typing.Optional[str] = OMIT, + workspace_access: typing.Optional[PronunciationDictionariesCreateFromFileRequestWorkspaceAccess] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AddPronunciationDictionaryResponseModel: + """ + Creates a new pronunciation dictionary from a lexicon .PLS file + + Parameters + ---------- + name : str + The name of the pronunciation dictionary, used for identification only. + + file : typing.Optional[core.File] + See core.File for more documentation + + description : typing.Optional[str] + A description of the pronunciation dictionary, used for identification only. + + workspace_access : typing.Optional[PronunciationDictionariesCreateFromFileRequestWorkspaceAccess] + Should be one of 'admin', 'editor' or 'viewer'. If not provided, defaults to no access. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AddPronunciationDictionaryResponseModel + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.pronunciation_dictionaries.create_from_file( + name="name", + ) + """ + _response = self._raw_client.create_from_file( + name=name, + file=file, + description=description, + workspace_access=workspace_access, + request_options=request_options, + ) + return _response.data + + def create_from_rules( + self, + *, + rules: typing.Sequence[BodyAddAPronunciationDictionaryV1PronunciationDictionariesAddFromRulesPostRulesItem], + name: str, + description: typing.Optional[str] = OMIT, + workspace_access: typing.Optional[ + BodyAddAPronunciationDictionaryV1PronunciationDictionariesAddFromRulesPostWorkspaceAccess + ] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AddPronunciationDictionaryResponseModel: + """ + Creates a new pronunciation dictionary from provided rules. + + Parameters + ---------- + rules : typing.Sequence[BodyAddAPronunciationDictionaryV1PronunciationDictionariesAddFromRulesPostRulesItem] + List of pronunciation rules. Rule can be either: + an alias rule: {'string_to_replace': 'a', 'type': 'alias', 'alias': 'b', } + or a phoneme rule: {'string_to_replace': 'a', 'type': 'phoneme', 'phoneme': 'b', 'alphabet': 'ipa' } + + name : str + The name of the pronunciation dictionary, used for identification only. + + description : typing.Optional[str] + A description of the pronunciation dictionary, used for identification only. + + workspace_access : typing.Optional[BodyAddAPronunciationDictionaryV1PronunciationDictionariesAddFromRulesPostWorkspaceAccess] + Should be one of 'admin', 'editor' or 'viewer'. If not provided, defaults to no access. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AddPronunciationDictionaryResponseModel + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + from elevenlabs.pronunciation_dictionaries import ( + BodyAddAPronunciationDictionaryV1PronunciationDictionariesAddFromRulesPostRulesItem_Alias, + ) + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.pronunciation_dictionaries.create_from_rules( + rules=[ + BodyAddAPronunciationDictionaryV1PronunciationDictionariesAddFromRulesPostRulesItem_Alias( + string_to_replace="Thailand", + alias="tie-land", + ) + ], + name="My Dictionary", + ) + """ + _response = self._raw_client.create_from_rules( + rules=rules, + name=name, + description=description, + workspace_access=workspace_access, + request_options=request_options, + ) + return _response.data + + def download( + self, dictionary_id: str, version_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> typing.Iterator[bytes]: + """ + Get a PLS file with a pronunciation dictionary version rules + + Parameters + ---------- + dictionary_id : str + The id of the pronunciation dictionary + + version_id : str + The id of the version of the pronunciation dictionary + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. + + Returns + ------- + typing.Iterator[bytes] + The PLS file containing pronunciation dictionary rules + """ + with self._raw_client.download(dictionary_id, version_id, request_options=request_options) as r: + yield from r.data + + def get( + self, pronunciation_dictionary_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> GetPronunciationDictionaryMetadataResponse: + """ + Get metadata for a pronunciation dictionary + + Parameters + ---------- + pronunciation_dictionary_id : str + The id of the pronunciation dictionary + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + GetPronunciationDictionaryMetadataResponse + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.pronunciation_dictionaries.get( + pronunciation_dictionary_id="21m00Tcm4TlvDq8ikWAM", + ) + """ + _response = self._raw_client.get(pronunciation_dictionary_id, request_options=request_options) + return _response.data + + def list( + self, + *, + cursor: typing.Optional[str] = None, + page_size: typing.Optional[int] = None, + sort: typing.Optional[PronunciationDictionariesListRequestSort] = None, + sort_direction: typing.Optional[str] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> GetPronunciationDictionariesMetadataResponseModel: + """ + Get a list of the pronunciation dictionaries you have access to and their metadata + + Parameters + ---------- + cursor : typing.Optional[str] + Used for fetching next page. Cursor is returned in the response. + + page_size : typing.Optional[int] + How many pronunciation dictionaries to return at maximum. Can not exceed 100, defaults to 30. + + sort : typing.Optional[PronunciationDictionariesListRequestSort] + Which field to sort by, one of 'created_at_unix' or 'name'. + + sort_direction : typing.Optional[str] + Which direction to sort the voices in. 'ascending' or 'descending'. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + GetPronunciationDictionariesMetadataResponseModel + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.pronunciation_dictionaries.list() + """ + _response = self._raw_client.list( + cursor=cursor, + page_size=page_size, + sort=sort, + sort_direction=sort_direction, + request_options=request_options, + ) + return _response.data + + +class AsyncPronunciationDictionariesClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawPronunciationDictionariesClient(client_wrapper=client_wrapper) + self.rules = AsyncRulesClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawPronunciationDictionariesClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawPronunciationDictionariesClient + """ + return self._raw_client + + async def create_from_file( + self, + *, + name: str, + file: typing.Optional[core.File] = OMIT, + description: typing.Optional[str] = OMIT, + workspace_access: typing.Optional[PronunciationDictionariesCreateFromFileRequestWorkspaceAccess] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AddPronunciationDictionaryResponseModel: + """ + Creates a new pronunciation dictionary from a lexicon .PLS file + + Parameters + ---------- + name : str + The name of the pronunciation dictionary, used for identification only. + + file : typing.Optional[core.File] + See core.File for more documentation + + description : typing.Optional[str] + A description of the pronunciation dictionary, used for identification only. + + workspace_access : typing.Optional[PronunciationDictionariesCreateFromFileRequestWorkspaceAccess] + Should be one of 'admin', 'editor' or 'viewer'. If not provided, defaults to no access. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AddPronunciationDictionaryResponseModel + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.pronunciation_dictionaries.create_from_file( + name="name", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.create_from_file( + name=name, + file=file, + description=description, + workspace_access=workspace_access, + request_options=request_options, + ) + return _response.data + + async def create_from_rules( + self, + *, + rules: typing.Sequence[BodyAddAPronunciationDictionaryV1PronunciationDictionariesAddFromRulesPostRulesItem], + name: str, + description: typing.Optional[str] = OMIT, + workspace_access: typing.Optional[ + BodyAddAPronunciationDictionaryV1PronunciationDictionariesAddFromRulesPostWorkspaceAccess + ] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AddPronunciationDictionaryResponseModel: + """ + Creates a new pronunciation dictionary from provided rules. + + Parameters + ---------- + rules : typing.Sequence[BodyAddAPronunciationDictionaryV1PronunciationDictionariesAddFromRulesPostRulesItem] + List of pronunciation rules. Rule can be either: + an alias rule: {'string_to_replace': 'a', 'type': 'alias', 'alias': 'b', } + or a phoneme rule: {'string_to_replace': 'a', 'type': 'phoneme', 'phoneme': 'b', 'alphabet': 'ipa' } + + name : str + The name of the pronunciation dictionary, used for identification only. + + description : typing.Optional[str] + A description of the pronunciation dictionary, used for identification only. + + workspace_access : typing.Optional[BodyAddAPronunciationDictionaryV1PronunciationDictionariesAddFromRulesPostWorkspaceAccess] + Should be one of 'admin', 'editor' or 'viewer'. If not provided, defaults to no access. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AddPronunciationDictionaryResponseModel + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + from elevenlabs.pronunciation_dictionaries import ( + BodyAddAPronunciationDictionaryV1PronunciationDictionariesAddFromRulesPostRulesItem_Alias, + ) + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.pronunciation_dictionaries.create_from_rules( + rules=[ + BodyAddAPronunciationDictionaryV1PronunciationDictionariesAddFromRulesPostRulesItem_Alias( + string_to_replace="Thailand", + alias="tie-land", + ) + ], + name="My Dictionary", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.create_from_rules( + rules=rules, + name=name, + description=description, + workspace_access=workspace_access, + request_options=request_options, + ) + return _response.data + + async def download( + self, dictionary_id: str, version_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> typing.AsyncIterator[bytes]: + """ + Get a PLS file with a pronunciation dictionary version rules + + Parameters + ---------- + dictionary_id : str + The id of the pronunciation dictionary + + version_id : str + The id of the version of the pronunciation dictionary + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. + + Returns + ------- + typing.AsyncIterator[bytes] + The PLS file containing pronunciation dictionary rules + """ + async with self._raw_client.download(dictionary_id, version_id, request_options=request_options) as r: + async for _chunk in r.data: + yield _chunk + + async def get( + self, pronunciation_dictionary_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> GetPronunciationDictionaryMetadataResponse: + """ + Get metadata for a pronunciation dictionary + + Parameters + ---------- + pronunciation_dictionary_id : str + The id of the pronunciation dictionary + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + GetPronunciationDictionaryMetadataResponse + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.pronunciation_dictionaries.get( + pronunciation_dictionary_id="21m00Tcm4TlvDq8ikWAM", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.get(pronunciation_dictionary_id, request_options=request_options) + return _response.data + + async def list( + self, + *, + cursor: typing.Optional[str] = None, + page_size: typing.Optional[int] = None, + sort: typing.Optional[PronunciationDictionariesListRequestSort] = None, + sort_direction: typing.Optional[str] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> GetPronunciationDictionariesMetadataResponseModel: + """ + Get a list of the pronunciation dictionaries you have access to and their metadata + + Parameters + ---------- + cursor : typing.Optional[str] + Used for fetching next page. Cursor is returned in the response. + + page_size : typing.Optional[int] + How many pronunciation dictionaries to return at maximum. Can not exceed 100, defaults to 30. + + sort : typing.Optional[PronunciationDictionariesListRequestSort] + Which field to sort by, one of 'created_at_unix' or 'name'. + + sort_direction : typing.Optional[str] + Which direction to sort the voices in. 'ascending' or 'descending'. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + GetPronunciationDictionariesMetadataResponseModel + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.pronunciation_dictionaries.list() + + + asyncio.run(main()) + """ + _response = await self._raw_client.list( + cursor=cursor, + page_size=page_size, + sort=sort, + sort_direction=sort_direction, + request_options=request_options, + ) + return _response.data diff --git a/src/elevenlabs/pronunciation_dictionary/client.py b/src/elevenlabs/pronunciation_dictionaries/raw_client.py similarity index 50% rename from src/elevenlabs/pronunciation_dictionary/client.py rename to src/elevenlabs/pronunciation_dictionaries/raw_client.py index 8a333bfe..3ce1921d 100644 --- a/src/elevenlabs/pronunciation_dictionary/client.py +++ b/src/elevenlabs/pronunciation_dictionaries/raw_client.py @@ -1,60 +1,52 @@ # This file was auto-generated by Fern from our API Definition. +import contextlib import typing -from ..core.client_wrapper import SyncClientWrapper +from json.decoder import JSONDecodeError + from .. import core -from .types.pronunciation_dictionary_add_from_file_request_workspace_access import ( - PronunciationDictionaryAddFromFileRequestWorkspaceAccess, -) +from ..core.api_error import ApiError +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ..core.http_response import AsyncHttpResponse, HttpResponse +from ..core.jsonable_encoder import jsonable_encoder from ..core.request_options import RequestOptions -from ..types.add_pronunciation_dictionary_response_model import ( - AddPronunciationDictionaryResponseModel, -) +from ..core.serialization import convert_and_respect_annotation_metadata from ..core.unchecked_base_model import construct_type from ..errors.unprocessable_entity_error import UnprocessableEntityError +from ..types.add_pronunciation_dictionary_response_model import AddPronunciationDictionaryResponseModel +from ..types.get_pronunciation_dictionaries_metadata_response_model import ( + GetPronunciationDictionariesMetadataResponseModel, +) +from ..types.get_pronunciation_dictionary_metadata_response import GetPronunciationDictionaryMetadataResponse from ..types.http_validation_error import HttpValidationError -from json.decoder import JSONDecodeError -from ..core.api_error import ApiError from .types.body_add_a_pronunciation_dictionary_v_1_pronunciation_dictionaries_add_from_rules_post_rules_item import ( BodyAddAPronunciationDictionaryV1PronunciationDictionariesAddFromRulesPostRulesItem, ) from .types.body_add_a_pronunciation_dictionary_v_1_pronunciation_dictionaries_add_from_rules_post_workspace_access import ( BodyAddAPronunciationDictionaryV1PronunciationDictionariesAddFromRulesPostWorkspaceAccess, ) -from ..core.serialization import convert_and_respect_annotation_metadata -from .types.pronunciation_dictionary_rule import PronunciationDictionaryRule -from ..types.pronunciation_dictionary_rules_response_model import ( - PronunciationDictionaryRulesResponseModel, -) -from ..core.jsonable_encoder import jsonable_encoder -from ..types.get_pronunciation_dictionary_metadata_response import ( - GetPronunciationDictionaryMetadataResponse, -) -from .types.pronunciation_dictionary_get_all_request_sort import ( - PronunciationDictionaryGetAllRequestSort, +from .types.pronunciation_dictionaries_create_from_file_request_workspace_access import ( + PronunciationDictionariesCreateFromFileRequestWorkspaceAccess, ) -from ..types.get_pronunciation_dictionaries_metadata_response_model import ( - GetPronunciationDictionariesMetadataResponseModel, -) -from ..core.client_wrapper import AsyncClientWrapper +from .types.pronunciation_dictionaries_list_request_sort import PronunciationDictionariesListRequestSort # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) -class PronunciationDictionaryClient: +class RawPronunciationDictionariesClient: def __init__(self, *, client_wrapper: SyncClientWrapper): self._client_wrapper = client_wrapper - def add_from_file( + def create_from_file( self, *, name: str, file: typing.Optional[core.File] = OMIT, description: typing.Optional[str] = OMIT, - workspace_access: typing.Optional[PronunciationDictionaryAddFromFileRequestWorkspaceAccess] = OMIT, + workspace_access: typing.Optional[PronunciationDictionariesCreateFromFileRequestWorkspaceAccess] = OMIT, request_options: typing.Optional[RequestOptions] = None, - ) -> AddPronunciationDictionaryResponseModel: + ) -> HttpResponse[AddPronunciationDictionaryResponseModel]: """ Creates a new pronunciation dictionary from a lexicon .PLS file @@ -69,7 +61,7 @@ def add_from_file( description : typing.Optional[str] A description of the pronunciation dictionary, used for identification only. - workspace_access : typing.Optional[PronunciationDictionaryAddFromFileRequestWorkspaceAccess] + workspace_access : typing.Optional[PronunciationDictionariesCreateFromFileRequestWorkspaceAccess] Should be one of 'admin', 'editor' or 'viewer'. If not provided, defaults to no access. request_options : typing.Optional[RequestOptions] @@ -77,19 +69,8 @@ def add_from_file( Returns ------- - AddPronunciationDictionaryResponseModel + HttpResponse[AddPronunciationDictionaryResponseModel] Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.pronunciation_dictionary.add_from_file( - name="name", - ) """ _response = self._client_wrapper.httpx_client.request( "v1/pronunciation-dictionaries/add-from-file", @@ -101,36 +82,39 @@ def add_from_file( "workspace_access": workspace_access, }, files={ - "file": file, + **({"file": file} if file is not None else {}), }, request_options=request_options, omit=OMIT, + force_multipart=True, ) try: if 200 <= _response.status_code < 300: - return typing.cast( + _data = typing.cast( AddPronunciationDictionaryResponseModel, construct_type( type_=AddPronunciationDictionaryResponseModel, # type: ignore object_=_response.json(), ), ) + return HttpResponse(response=_response, data=_data) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast( + headers=dict(_response.headers), + body=typing.cast( HttpValidationError, construct_type( type_=HttpValidationError, # type: ignore object_=_response.json(), ), - ) + ), ) _response_json = _response.json() except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) - def add_from_rules( + def create_from_rules( self, *, rules: typing.Sequence[BodyAddAPronunciationDictionaryV1PronunciationDictionariesAddFromRulesPostRulesItem], @@ -140,7 +124,7 @@ def add_from_rules( BodyAddAPronunciationDictionaryV1PronunciationDictionariesAddFromRulesPostWorkspaceAccess ] = OMIT, request_options: typing.Optional[RequestOptions] = None, - ) -> AddPronunciationDictionaryResponseModel: + ) -> HttpResponse[AddPronunciationDictionaryResponseModel]: """ Creates a new pronunciation dictionary from provided rules. @@ -165,28 +149,8 @@ def add_from_rules( Returns ------- - AddPronunciationDictionaryResponseModel + HttpResponse[AddPronunciationDictionaryResponseModel] Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - from elevenlabs.pronunciation_dictionary import ( - BodyAddAPronunciationDictionaryV1PronunciationDictionariesAddFromRulesPostRulesItem_Alias, - ) - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.pronunciation_dictionary.add_from_rules( - rules=[ - BodyAddAPronunciationDictionaryV1PronunciationDictionariesAddFromRulesPostRulesItem_Alias( - string_to_replace="Thailand", - alias="tie-land", - ) - ], - name="My Dictionary", - ) """ _response = self._client_wrapper.httpx_client.request( "v1/pronunciation-dictionaries/add-from-rules", @@ -212,199 +176,34 @@ def add_from_rules( ) try: if 200 <= _response.status_code < 300: - return typing.cast( + _data = typing.cast( AddPronunciationDictionaryResponseModel, construct_type( type_=AddPronunciationDictionaryResponseModel, # type: ignore object_=_response.json(), ), ) + return HttpResponse(response=_response, data=_data) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast( + headers=dict(_response.headers), + body=typing.cast( HttpValidationError, construct_type( type_=HttpValidationError, # type: ignore object_=_response.json(), ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def add_rules( - self, - pronunciation_dictionary_id: str, - *, - rules: typing.Sequence[PronunciationDictionaryRule], - request_options: typing.Optional[RequestOptions] = None, - ) -> PronunciationDictionaryRulesResponseModel: - """ - Add rules to the pronunciation dictionary - - Parameters - ---------- - pronunciation_dictionary_id : str - The id of the pronunciation dictionary - - rules : typing.Sequence[PronunciationDictionaryRule] - List of pronunciation rules. Rule can be either: - an alias rule: {'string_to_replace': 'a', 'type': 'alias', 'alias': 'b', } - or a phoneme rule: {'string_to_replace': 'a', 'type': 'phoneme', 'phoneme': 'b', 'alphabet': 'ipa' } - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - PronunciationDictionaryRulesResponseModel - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - from elevenlabs.pronunciation_dictionary import ( - PronunciationDictionaryRule_Alias, - ) - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.pronunciation_dictionary.add_rules( - pronunciation_dictionary_id="21m00Tcm4TlvDq8ikWAM", - rules=[ - PronunciationDictionaryRule_Alias( - string_to_replace="Thailand", - alias="tie-land", - ) - ], - ) - """ - _response = self._client_wrapper.httpx_client.request( - f"v1/pronunciation-dictionaries/{jsonable_encoder(pronunciation_dictionary_id)}/add-rules", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "rules": convert_and_respect_annotation_metadata( - object_=rules, - annotation=typing.Sequence[PronunciationDictionaryRule], - direction="write", - ), - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - PronunciationDictionaryRulesResponseModel, - construct_type( - type_=PronunciationDictionaryRulesResponseModel, # type: ignore - object_=_response.json(), ), ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) _response_json = _response.json() except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def remove_rules( - self, - pronunciation_dictionary_id: str, - *, - rule_strings: typing.Sequence[str], - request_options: typing.Optional[RequestOptions] = None, - ) -> PronunciationDictionaryRulesResponseModel: - """ - Remove rules from the pronunciation dictionary - - Parameters - ---------- - pronunciation_dictionary_id : str - The id of the pronunciation dictionary - - rule_strings : typing.Sequence[str] - List of strings to remove from the pronunciation dictionary. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - PronunciationDictionaryRulesResponseModel - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.pronunciation_dictionary.remove_rules( - pronunciation_dictionary_id="21m00Tcm4TlvDq8ikWAM", - rule_strings=["rule_strings"], - ) - """ - _response = self._client_wrapper.httpx_client.request( - f"v1/pronunciation-dictionaries/{jsonable_encoder(pronunciation_dictionary_id)}/remove-rules", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "rule_strings": rule_strings, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - PronunciationDictionaryRulesResponseModel, - construct_type( - type_=PronunciationDictionaryRulesResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + @contextlib.contextmanager def download( - self, - dictionary_id: str, - version_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, - ) -> typing.Iterator[bytes]: + self, dictionary_id: str, version_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> typing.Iterator[HttpResponse[typing.Iterator[bytes]]]: """ Get a PLS file with a pronunciation dictionary version rules @@ -419,9 +218,9 @@ def download( request_options : typing.Optional[RequestOptions] Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. - Yields - ------ - typing.Iterator[bytes] + Returns + ------- + typing.Iterator[HttpResponse[typing.Iterator[bytes]]] The PLS file containing pronunciation dictionary rules """ with self._client_wrapper.httpx_client.stream( @@ -430,34 +229,38 @@ def download( method="GET", request_options=request_options, ) as _response: - try: - if 200 <= _response.status_code < 300: - _chunk_size = request_options.get("chunk_size", 1024) if request_options is not None else 1024 - for _chunk in _response.iter_bytes(chunk_size=_chunk_size): - yield _chunk - return - _response.read() - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), + + def _stream() -> HttpResponse[typing.Iterator[bytes]]: + try: + if 200 <= _response.status_code < 300: + _chunk_size = request_options.get("chunk_size", 1024) if request_options is not None else 1024 + return HttpResponse( + response=_response, data=(_chunk for _chunk in _response.iter_bytes(chunk_size=_chunk_size)) + ) + _response.read() + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), ), ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + yield _stream() def get( - self, - pronunciation_dictionary_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, - ) -> GetPronunciationDictionaryMetadataResponse: + self, pronunciation_dictionary_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[GetPronunciationDictionaryMetadataResponse]: """ Get metadata for a pronunciation dictionary @@ -471,19 +274,8 @@ def get( Returns ------- - GetPronunciationDictionaryMetadataResponse + HttpResponse[GetPronunciationDictionaryMetadataResponse] Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.pronunciation_dictionary.get( - pronunciation_dictionary_id="21m00Tcm4TlvDq8ikWAM", - ) """ _response = self._client_wrapper.httpx_client.request( f"v1/pronunciation-dictionaries/{jsonable_encoder(pronunciation_dictionary_id)}/", @@ -493,37 +285,39 @@ def get( ) try: if 200 <= _response.status_code < 300: - return typing.cast( + _data = typing.cast( GetPronunciationDictionaryMetadataResponse, construct_type( type_=GetPronunciationDictionaryMetadataResponse, # type: ignore object_=_response.json(), ), ) + return HttpResponse(response=_response, data=_data) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast( + headers=dict(_response.headers), + body=typing.cast( HttpValidationError, construct_type( type_=HttpValidationError, # type: ignore object_=_response.json(), ), - ) + ), ) _response_json = _response.json() except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) - def get_all( + def list( self, *, cursor: typing.Optional[str] = None, page_size: typing.Optional[int] = None, - sort: typing.Optional[PronunciationDictionaryGetAllRequestSort] = None, + sort: typing.Optional[PronunciationDictionariesListRequestSort] = None, sort_direction: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None, - ) -> GetPronunciationDictionariesMetadataResponseModel: + ) -> HttpResponse[GetPronunciationDictionariesMetadataResponseModel]: """ Get a list of the pronunciation dictionaries you have access to and their metadata @@ -535,7 +329,7 @@ def get_all( page_size : typing.Optional[int] How many pronunciation dictionaries to return at maximum. Can not exceed 100, defaults to 30. - sort : typing.Optional[PronunciationDictionaryGetAllRequestSort] + sort : typing.Optional[PronunciationDictionariesListRequestSort] Which field to sort by, one of 'created_at_unix' or 'name'. sort_direction : typing.Optional[str] @@ -546,17 +340,8 @@ def get_all( Returns ------- - GetPronunciationDictionariesMetadataResponseModel + HttpResponse[GetPronunciationDictionariesMetadataResponseModel] Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.pronunciation_dictionary.get_all() """ _response = self._client_wrapper.httpx_client.request( "v1/pronunciation-dictionaries/", @@ -572,42 +357,44 @@ def get_all( ) try: if 200 <= _response.status_code < 300: - return typing.cast( + _data = typing.cast( GetPronunciationDictionariesMetadataResponseModel, construct_type( type_=GetPronunciationDictionariesMetadataResponseModel, # type: ignore object_=_response.json(), ), ) + return HttpResponse(response=_response, data=_data) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast( + headers=dict(_response.headers), + body=typing.cast( HttpValidationError, construct_type( type_=HttpValidationError, # type: ignore object_=_response.json(), ), - ) + ), ) _response_json = _response.json() except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) -class AsyncPronunciationDictionaryClient: +class AsyncRawPronunciationDictionariesClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): self._client_wrapper = client_wrapper - async def add_from_file( + async def create_from_file( self, *, name: str, file: typing.Optional[core.File] = OMIT, description: typing.Optional[str] = OMIT, - workspace_access: typing.Optional[PronunciationDictionaryAddFromFileRequestWorkspaceAccess] = OMIT, + workspace_access: typing.Optional[PronunciationDictionariesCreateFromFileRequestWorkspaceAccess] = OMIT, request_options: typing.Optional[RequestOptions] = None, - ) -> AddPronunciationDictionaryResponseModel: + ) -> AsyncHttpResponse[AddPronunciationDictionaryResponseModel]: """ Creates a new pronunciation dictionary from a lexicon .PLS file @@ -622,7 +409,7 @@ async def add_from_file( description : typing.Optional[str] A description of the pronunciation dictionary, used for identification only. - workspace_access : typing.Optional[PronunciationDictionaryAddFromFileRequestWorkspaceAccess] + workspace_access : typing.Optional[PronunciationDictionariesCreateFromFileRequestWorkspaceAccess] Should be one of 'admin', 'editor' or 'viewer'. If not provided, defaults to no access. request_options : typing.Optional[RequestOptions] @@ -630,27 +417,8 @@ async def add_from_file( Returns ------- - AddPronunciationDictionaryResponseModel + AsyncHttpResponse[AddPronunciationDictionaryResponseModel] Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.pronunciation_dictionary.add_from_file( - name="name", - ) - - - asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( "v1/pronunciation-dictionaries/add-from-file", @@ -662,36 +430,39 @@ async def main() -> None: "workspace_access": workspace_access, }, files={ - "file": file, + **({"file": file} if file is not None else {}), }, request_options=request_options, omit=OMIT, + force_multipart=True, ) try: if 200 <= _response.status_code < 300: - return typing.cast( + _data = typing.cast( AddPronunciationDictionaryResponseModel, construct_type( type_=AddPronunciationDictionaryResponseModel, # type: ignore object_=_response.json(), ), ) + return AsyncHttpResponse(response=_response, data=_data) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast( + headers=dict(_response.headers), + body=typing.cast( HttpValidationError, construct_type( type_=HttpValidationError, # type: ignore object_=_response.json(), ), - ) + ), ) _response_json = _response.json() except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) - async def add_from_rules( + async def create_from_rules( self, *, rules: typing.Sequence[BodyAddAPronunciationDictionaryV1PronunciationDictionariesAddFromRulesPostRulesItem], @@ -701,7 +472,7 @@ async def add_from_rules( BodyAddAPronunciationDictionaryV1PronunciationDictionariesAddFromRulesPostWorkspaceAccess ] = OMIT, request_options: typing.Optional[RequestOptions] = None, - ) -> AddPronunciationDictionaryResponseModel: + ) -> AsyncHttpResponse[AddPronunciationDictionaryResponseModel]: """ Creates a new pronunciation dictionary from provided rules. @@ -726,36 +497,8 @@ async def add_from_rules( Returns ------- - AddPronunciationDictionaryResponseModel + AsyncHttpResponse[AddPronunciationDictionaryResponseModel] Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - from elevenlabs.pronunciation_dictionary import ( - BodyAddAPronunciationDictionaryV1PronunciationDictionariesAddFromRulesPostRulesItem_Alias, - ) - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.pronunciation_dictionary.add_from_rules( - rules=[ - BodyAddAPronunciationDictionaryV1PronunciationDictionariesAddFromRulesPostRulesItem_Alias( - string_to_replace="Thailand", - alias="tie-land", - ) - ], - name="My Dictionary", - ) - - - asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( "v1/pronunciation-dictionaries/add-from-rules", @@ -781,215 +524,34 @@ async def main() -> None: ) try: if 200 <= _response.status_code < 300: - return typing.cast( + _data = typing.cast( AddPronunciationDictionaryResponseModel, construct_type( type_=AddPronunciationDictionaryResponseModel, # type: ignore object_=_response.json(), ), ) + return AsyncHttpResponse(response=_response, data=_data) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast( + headers=dict(_response.headers), + body=typing.cast( HttpValidationError, construct_type( type_=HttpValidationError, # type: ignore object_=_response.json(), ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def add_rules( - self, - pronunciation_dictionary_id: str, - *, - rules: typing.Sequence[PronunciationDictionaryRule], - request_options: typing.Optional[RequestOptions] = None, - ) -> PronunciationDictionaryRulesResponseModel: - """ - Add rules to the pronunciation dictionary - - Parameters - ---------- - pronunciation_dictionary_id : str - The id of the pronunciation dictionary - - rules : typing.Sequence[PronunciationDictionaryRule] - List of pronunciation rules. Rule can be either: - an alias rule: {'string_to_replace': 'a', 'type': 'alias', 'alias': 'b', } - or a phoneme rule: {'string_to_replace': 'a', 'type': 'phoneme', 'phoneme': 'b', 'alphabet': 'ipa' } - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - PronunciationDictionaryRulesResponseModel - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - from elevenlabs.pronunciation_dictionary import ( - PronunciationDictionaryRule_Alias, - ) - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.pronunciation_dictionary.add_rules( - pronunciation_dictionary_id="21m00Tcm4TlvDq8ikWAM", - rules=[ - PronunciationDictionaryRule_Alias( - string_to_replace="Thailand", - alias="tie-land", - ) - ], - ) - - - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/pronunciation-dictionaries/{jsonable_encoder(pronunciation_dictionary_id)}/add-rules", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "rules": convert_and_respect_annotation_metadata( - object_=rules, - annotation=typing.Sequence[PronunciationDictionaryRule], - direction="write", - ), - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - PronunciationDictionaryRulesResponseModel, - construct_type( - type_=PronunciationDictionaryRulesResponseModel, # type: ignore - object_=_response.json(), ), ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) _response_json = _response.json() except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def remove_rules( - self, - pronunciation_dictionary_id: str, - *, - rule_strings: typing.Sequence[str], - request_options: typing.Optional[RequestOptions] = None, - ) -> PronunciationDictionaryRulesResponseModel: - """ - Remove rules from the pronunciation dictionary - - Parameters - ---------- - pronunciation_dictionary_id : str - The id of the pronunciation dictionary - - rule_strings : typing.Sequence[str] - List of strings to remove from the pronunciation dictionary. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - PronunciationDictionaryRulesResponseModel - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.pronunciation_dictionary.remove_rules( - pronunciation_dictionary_id="21m00Tcm4TlvDq8ikWAM", - rule_strings=["rule_strings"], - ) - - - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/pronunciation-dictionaries/{jsonable_encoder(pronunciation_dictionary_id)}/remove-rules", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "rule_strings": rule_strings, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - PronunciationDictionaryRulesResponseModel, - construct_type( - type_=PronunciationDictionaryRulesResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + @contextlib.asynccontextmanager async def download( - self, - dictionary_id: str, - version_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, - ) -> typing.AsyncIterator[bytes]: + self, dictionary_id: str, version_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> typing.AsyncIterator[AsyncHttpResponse[typing.AsyncIterator[bytes]]]: """ Get a PLS file with a pronunciation dictionary version rules @@ -1004,9 +566,9 @@ async def download( request_options : typing.Optional[RequestOptions] Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. - Yields - ------ - typing.AsyncIterator[bytes] + Returns + ------- + typing.AsyncIterator[AsyncHttpResponse[typing.AsyncIterator[bytes]]] The PLS file containing pronunciation dictionary rules """ async with self._client_wrapper.httpx_client.stream( @@ -1015,34 +577,39 @@ async def download( method="GET", request_options=request_options, ) as _response: - try: - if 200 <= _response.status_code < 300: - _chunk_size = request_options.get("chunk_size", 1024) if request_options is not None else 1024 - async for _chunk in _response.aiter_bytes(chunk_size=_chunk_size): - yield _chunk - return - await _response.aread() - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), + + async def _stream() -> AsyncHttpResponse[typing.AsyncIterator[bytes]]: + try: + if 200 <= _response.status_code < 300: + _chunk_size = request_options.get("chunk_size", 1024) if request_options is not None else 1024 + return AsyncHttpResponse( + response=_response, + data=(_chunk async for _chunk in _response.aiter_bytes(chunk_size=_chunk_size)), + ) + await _response.aread() + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), ), ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + yield await _stream() async def get( - self, - pronunciation_dictionary_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, - ) -> GetPronunciationDictionaryMetadataResponse: + self, pronunciation_dictionary_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[GetPronunciationDictionaryMetadataResponse]: """ Get metadata for a pronunciation dictionary @@ -1056,27 +623,8 @@ async def get( Returns ------- - GetPronunciationDictionaryMetadataResponse + AsyncHttpResponse[GetPronunciationDictionaryMetadataResponse] Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.pronunciation_dictionary.get( - pronunciation_dictionary_id="21m00Tcm4TlvDq8ikWAM", - ) - - - asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( f"v1/pronunciation-dictionaries/{jsonable_encoder(pronunciation_dictionary_id)}/", @@ -1086,37 +634,39 @@ async def main() -> None: ) try: if 200 <= _response.status_code < 300: - return typing.cast( + _data = typing.cast( GetPronunciationDictionaryMetadataResponse, construct_type( type_=GetPronunciationDictionaryMetadataResponse, # type: ignore object_=_response.json(), ), ) + return AsyncHttpResponse(response=_response, data=_data) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast( + headers=dict(_response.headers), + body=typing.cast( HttpValidationError, construct_type( type_=HttpValidationError, # type: ignore object_=_response.json(), ), - ) + ), ) _response_json = _response.json() except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) - async def get_all( + async def list( self, *, cursor: typing.Optional[str] = None, page_size: typing.Optional[int] = None, - sort: typing.Optional[PronunciationDictionaryGetAllRequestSort] = None, + sort: typing.Optional[PronunciationDictionariesListRequestSort] = None, sort_direction: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None, - ) -> GetPronunciationDictionariesMetadataResponseModel: + ) -> AsyncHttpResponse[GetPronunciationDictionariesMetadataResponseModel]: """ Get a list of the pronunciation dictionaries you have access to and their metadata @@ -1128,7 +678,7 @@ async def get_all( page_size : typing.Optional[int] How many pronunciation dictionaries to return at maximum. Can not exceed 100, defaults to 30. - sort : typing.Optional[PronunciationDictionaryGetAllRequestSort] + sort : typing.Optional[PronunciationDictionariesListRequestSort] Which field to sort by, one of 'created_at_unix' or 'name'. sort_direction : typing.Optional[str] @@ -1139,25 +689,8 @@ async def get_all( Returns ------- - GetPronunciationDictionariesMetadataResponseModel + AsyncHttpResponse[GetPronunciationDictionariesMetadataResponseModel] Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.pronunciation_dictionary.get_all() - - - asyncio.run(main()) """ _response = await self._client_wrapper.httpx_client.request( "v1/pronunciation-dictionaries/", @@ -1173,24 +706,26 @@ async def main() -> None: ) try: if 200 <= _response.status_code < 300: - return typing.cast( + _data = typing.cast( GetPronunciationDictionariesMetadataResponseModel, construct_type( type_=GetPronunciationDictionariesMetadataResponseModel, # type: ignore object_=_response.json(), ), ) + return AsyncHttpResponse(response=_response, data=_data) if _response.status_code == 422: raise UnprocessableEntityError( - typing.cast( + headers=dict(_response.headers), + body=typing.cast( HttpValidationError, construct_type( type_=HttpValidationError, # type: ignore object_=_response.json(), ), - ) + ), ) _response_json = _response.json() except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/elevenlabs/pronunciation_dictionaries/rules/__init__.py b/src/elevenlabs/pronunciation_dictionaries/rules/__init__.py new file mode 100644 index 00000000..8522724b --- /dev/null +++ b/src/elevenlabs/pronunciation_dictionaries/rules/__init__.py @@ -0,0 +1,7 @@ +# This file was auto-generated by Fern from our API Definition. + +# isort: skip_file + +from .types import PronunciationDictionaryRule, PronunciationDictionaryRule_Alias, PronunciationDictionaryRule_Phoneme + +__all__ = ["PronunciationDictionaryRule", "PronunciationDictionaryRule_Alias", "PronunciationDictionaryRule_Phoneme"] diff --git a/src/elevenlabs/pronunciation_dictionaries/rules/client.py b/src/elevenlabs/pronunciation_dictionaries/rules/client.py new file mode 100644 index 00000000..2a2bfef0 --- /dev/null +++ b/src/elevenlabs/pronunciation_dictionaries/rules/client.py @@ -0,0 +1,250 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ...core.request_options import RequestOptions +from ...types.pronunciation_dictionary_rules_response_model import PronunciationDictionaryRulesResponseModel +from .raw_client import AsyncRawRulesClient, RawRulesClient +from .types.pronunciation_dictionary_rule import PronunciationDictionaryRule + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RulesClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._raw_client = RawRulesClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawRulesClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawRulesClient + """ + return self._raw_client + + def add( + self, + pronunciation_dictionary_id: str, + *, + rules: typing.Sequence[PronunciationDictionaryRule], + request_options: typing.Optional[RequestOptions] = None, + ) -> PronunciationDictionaryRulesResponseModel: + """ + Add rules to the pronunciation dictionary + + Parameters + ---------- + pronunciation_dictionary_id : str + The id of the pronunciation dictionary + + rules : typing.Sequence[PronunciationDictionaryRule] + List of pronunciation rules. Rule can be either: + an alias rule: {'string_to_replace': 'a', 'type': 'alias', 'alias': 'b', } + or a phoneme rule: {'string_to_replace': 'a', 'type': 'phoneme', 'phoneme': 'b', 'alphabet': 'ipa' } + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + PronunciationDictionaryRulesResponseModel + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + from elevenlabs.pronunciation_dictionaries.rules import ( + PronunciationDictionaryRule_Alias, + ) + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.pronunciation_dictionaries.rules.add( + pronunciation_dictionary_id="21m00Tcm4TlvDq8ikWAM", + rules=[ + PronunciationDictionaryRule_Alias( + string_to_replace="Thailand", + alias="tie-land", + ) + ], + ) + """ + _response = self._raw_client.add(pronunciation_dictionary_id, rules=rules, request_options=request_options) + return _response.data + + def remove( + self, + pronunciation_dictionary_id: str, + *, + rule_strings: typing.Sequence[str], + request_options: typing.Optional[RequestOptions] = None, + ) -> PronunciationDictionaryRulesResponseModel: + """ + Remove rules from the pronunciation dictionary + + Parameters + ---------- + pronunciation_dictionary_id : str + The id of the pronunciation dictionary + + rule_strings : typing.Sequence[str] + List of strings to remove from the pronunciation dictionary. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + PronunciationDictionaryRulesResponseModel + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.pronunciation_dictionaries.rules.remove( + pronunciation_dictionary_id="21m00Tcm4TlvDq8ikWAM", + rule_strings=["rule_strings"], + ) + """ + _response = self._raw_client.remove( + pronunciation_dictionary_id, rule_strings=rule_strings, request_options=request_options + ) + return _response.data + + +class AsyncRulesClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawRulesClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawRulesClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawRulesClient + """ + return self._raw_client + + async def add( + self, + pronunciation_dictionary_id: str, + *, + rules: typing.Sequence[PronunciationDictionaryRule], + request_options: typing.Optional[RequestOptions] = None, + ) -> PronunciationDictionaryRulesResponseModel: + """ + Add rules to the pronunciation dictionary + + Parameters + ---------- + pronunciation_dictionary_id : str + The id of the pronunciation dictionary + + rules : typing.Sequence[PronunciationDictionaryRule] + List of pronunciation rules. Rule can be either: + an alias rule: {'string_to_replace': 'a', 'type': 'alias', 'alias': 'b', } + or a phoneme rule: {'string_to_replace': 'a', 'type': 'phoneme', 'phoneme': 'b', 'alphabet': 'ipa' } + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + PronunciationDictionaryRulesResponseModel + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + from elevenlabs.pronunciation_dictionaries.rules import ( + PronunciationDictionaryRule_Alias, + ) + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.pronunciation_dictionaries.rules.add( + pronunciation_dictionary_id="21m00Tcm4TlvDq8ikWAM", + rules=[ + PronunciationDictionaryRule_Alias( + string_to_replace="Thailand", + alias="tie-land", + ) + ], + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.add( + pronunciation_dictionary_id, rules=rules, request_options=request_options + ) + return _response.data + + async def remove( + self, + pronunciation_dictionary_id: str, + *, + rule_strings: typing.Sequence[str], + request_options: typing.Optional[RequestOptions] = None, + ) -> PronunciationDictionaryRulesResponseModel: + """ + Remove rules from the pronunciation dictionary + + Parameters + ---------- + pronunciation_dictionary_id : str + The id of the pronunciation dictionary + + rule_strings : typing.Sequence[str] + List of strings to remove from the pronunciation dictionary. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + PronunciationDictionaryRulesResponseModel + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.pronunciation_dictionaries.rules.remove( + pronunciation_dictionary_id="21m00Tcm4TlvDq8ikWAM", + rule_strings=["rule_strings"], + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.remove( + pronunciation_dictionary_id, rule_strings=rule_strings, request_options=request_options + ) + return _response.data diff --git a/src/elevenlabs/pronunciation_dictionaries/rules/raw_client.py b/src/elevenlabs/pronunciation_dictionaries/rules/raw_client.py new file mode 100644 index 00000000..649162bf --- /dev/null +++ b/src/elevenlabs/pronunciation_dictionaries/rules/raw_client.py @@ -0,0 +1,297 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ...core.api_error import ApiError +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ...core.http_response import AsyncHttpResponse, HttpResponse +from ...core.jsonable_encoder import jsonable_encoder +from ...core.request_options import RequestOptions +from ...core.serialization import convert_and_respect_annotation_metadata +from ...core.unchecked_base_model import construct_type +from ...errors.unprocessable_entity_error import UnprocessableEntityError +from ...types.http_validation_error import HttpValidationError +from ...types.pronunciation_dictionary_rules_response_model import PronunciationDictionaryRulesResponseModel +from .types.pronunciation_dictionary_rule import PronunciationDictionaryRule + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RawRulesClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def add( + self, + pronunciation_dictionary_id: str, + *, + rules: typing.Sequence[PronunciationDictionaryRule], + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[PronunciationDictionaryRulesResponseModel]: + """ + Add rules to the pronunciation dictionary + + Parameters + ---------- + pronunciation_dictionary_id : str + The id of the pronunciation dictionary + + rules : typing.Sequence[PronunciationDictionaryRule] + List of pronunciation rules. Rule can be either: + an alias rule: {'string_to_replace': 'a', 'type': 'alias', 'alias': 'b', } + or a phoneme rule: {'string_to_replace': 'a', 'type': 'phoneme', 'phoneme': 'b', 'alphabet': 'ipa' } + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[PronunciationDictionaryRulesResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/pronunciation-dictionaries/{jsonable_encoder(pronunciation_dictionary_id)}/add-rules", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "rules": convert_and_respect_annotation_metadata( + object_=rules, annotation=typing.Sequence[PronunciationDictionaryRule], direction="write" + ), + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + PronunciationDictionaryRulesResponseModel, + construct_type( + type_=PronunciationDictionaryRulesResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def remove( + self, + pronunciation_dictionary_id: str, + *, + rule_strings: typing.Sequence[str], + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[PronunciationDictionaryRulesResponseModel]: + """ + Remove rules from the pronunciation dictionary + + Parameters + ---------- + pronunciation_dictionary_id : str + The id of the pronunciation dictionary + + rule_strings : typing.Sequence[str] + List of strings to remove from the pronunciation dictionary. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[PronunciationDictionaryRulesResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/pronunciation-dictionaries/{jsonable_encoder(pronunciation_dictionary_id)}/remove-rules", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "rule_strings": rule_strings, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + PronunciationDictionaryRulesResponseModel, + construct_type( + type_=PronunciationDictionaryRulesResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + +class AsyncRawRulesClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def add( + self, + pronunciation_dictionary_id: str, + *, + rules: typing.Sequence[PronunciationDictionaryRule], + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[PronunciationDictionaryRulesResponseModel]: + """ + Add rules to the pronunciation dictionary + + Parameters + ---------- + pronunciation_dictionary_id : str + The id of the pronunciation dictionary + + rules : typing.Sequence[PronunciationDictionaryRule] + List of pronunciation rules. Rule can be either: + an alias rule: {'string_to_replace': 'a', 'type': 'alias', 'alias': 'b', } + or a phoneme rule: {'string_to_replace': 'a', 'type': 'phoneme', 'phoneme': 'b', 'alphabet': 'ipa' } + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[PronunciationDictionaryRulesResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/pronunciation-dictionaries/{jsonable_encoder(pronunciation_dictionary_id)}/add-rules", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "rules": convert_and_respect_annotation_metadata( + object_=rules, annotation=typing.Sequence[PronunciationDictionaryRule], direction="write" + ), + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + PronunciationDictionaryRulesResponseModel, + construct_type( + type_=PronunciationDictionaryRulesResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def remove( + self, + pronunciation_dictionary_id: str, + *, + rule_strings: typing.Sequence[str], + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[PronunciationDictionaryRulesResponseModel]: + """ + Remove rules from the pronunciation dictionary + + Parameters + ---------- + pronunciation_dictionary_id : str + The id of the pronunciation dictionary + + rule_strings : typing.Sequence[str] + List of strings to remove from the pronunciation dictionary. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[PronunciationDictionaryRulesResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/pronunciation-dictionaries/{jsonable_encoder(pronunciation_dictionary_id)}/remove-rules", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "rule_strings": rule_strings, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + PronunciationDictionaryRulesResponseModel, + construct_type( + type_=PronunciationDictionaryRulesResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/elevenlabs/pronunciation_dictionaries/rules/types/__init__.py b/src/elevenlabs/pronunciation_dictionaries/rules/types/__init__.py new file mode 100644 index 00000000..7838edb1 --- /dev/null +++ b/src/elevenlabs/pronunciation_dictionaries/rules/types/__init__.py @@ -0,0 +1,11 @@ +# This file was auto-generated by Fern from our API Definition. + +# isort: skip_file + +from .pronunciation_dictionary_rule import ( + PronunciationDictionaryRule, + PronunciationDictionaryRule_Alias, + PronunciationDictionaryRule_Phoneme, +) + +__all__ = ["PronunciationDictionaryRule", "PronunciationDictionaryRule_Alias", "PronunciationDictionaryRule_Phoneme"] diff --git a/src/elevenlabs/pronunciation_dictionary/types/pronunciation_dictionary_rule.py b/src/elevenlabs/pronunciation_dictionaries/rules/types/pronunciation_dictionary_rule.py similarity index 88% rename from src/elevenlabs/pronunciation_dictionary/types/pronunciation_dictionary_rule.py rename to src/elevenlabs/pronunciation_dictionaries/rules/types/pronunciation_dictionary_rule.py index 7d78ebff..bb76a51b 100644 --- a/src/elevenlabs/pronunciation_dictionary/types/pronunciation_dictionary_rule.py +++ b/src/elevenlabs/pronunciation_dictionaries/rules/types/pronunciation_dictionary_rule.py @@ -1,12 +1,13 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -from ...core.unchecked_base_model import UncheckedBaseModel + import typing -from ...core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic import typing_extensions -from ...core.unchecked_base_model import UnionMetadata +from ....core.pydantic_utilities import IS_PYDANTIC_V2 +from ....core.unchecked_base_model import UncheckedBaseModel, UnionMetadata class PronunciationDictionaryRule_Alias(UncheckedBaseModel): diff --git a/src/elevenlabs/pronunciation_dictionary/types/__init__.py b/src/elevenlabs/pronunciation_dictionaries/types/__init__.py similarity index 63% rename from src/elevenlabs/pronunciation_dictionary/types/__init__.py rename to src/elevenlabs/pronunciation_dictionaries/types/__init__.py index 8e59609b..abe93e76 100644 --- a/src/elevenlabs/pronunciation_dictionary/types/__init__.py +++ b/src/elevenlabs/pronunciation_dictionaries/types/__init__.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# isort: skip_file + from .body_add_a_pronunciation_dictionary_v_1_pronunciation_dictionaries_add_from_rules_post_rules_item import ( BodyAddAPronunciationDictionaryV1PronunciationDictionariesAddFromRulesPostRulesItem, BodyAddAPronunciationDictionaryV1PronunciationDictionariesAddFromRulesPostRulesItem_Alias, @@ -8,24 +10,16 @@ from .body_add_a_pronunciation_dictionary_v_1_pronunciation_dictionaries_add_from_rules_post_workspace_access import ( BodyAddAPronunciationDictionaryV1PronunciationDictionariesAddFromRulesPostWorkspaceAccess, ) -from .pronunciation_dictionary_add_from_file_request_workspace_access import ( - PronunciationDictionaryAddFromFileRequestWorkspaceAccess, -) -from .pronunciation_dictionary_get_all_request_sort import PronunciationDictionaryGetAllRequestSort -from .pronunciation_dictionary_rule import ( - PronunciationDictionaryRule, - PronunciationDictionaryRule_Alias, - PronunciationDictionaryRule_Phoneme, +from .pronunciation_dictionaries_create_from_file_request_workspace_access import ( + PronunciationDictionariesCreateFromFileRequestWorkspaceAccess, ) +from .pronunciation_dictionaries_list_request_sort import PronunciationDictionariesListRequestSort __all__ = [ "BodyAddAPronunciationDictionaryV1PronunciationDictionariesAddFromRulesPostRulesItem", "BodyAddAPronunciationDictionaryV1PronunciationDictionariesAddFromRulesPostRulesItem_Alias", "BodyAddAPronunciationDictionaryV1PronunciationDictionariesAddFromRulesPostRulesItem_Phoneme", "BodyAddAPronunciationDictionaryV1PronunciationDictionariesAddFromRulesPostWorkspaceAccess", - "PronunciationDictionaryAddFromFileRequestWorkspaceAccess", - "PronunciationDictionaryGetAllRequestSort", - "PronunciationDictionaryRule", - "PronunciationDictionaryRule_Alias", - "PronunciationDictionaryRule_Phoneme", + "PronunciationDictionariesCreateFromFileRequestWorkspaceAccess", + "PronunciationDictionariesListRequestSort", ] diff --git a/src/elevenlabs/pronunciation_dictionary/types/body_add_a_pronunciation_dictionary_v_1_pronunciation_dictionaries_add_from_rules_post_rules_item.py b/src/elevenlabs/pronunciation_dictionaries/types/body_add_a_pronunciation_dictionary_v_1_pronunciation_dictionaries_add_from_rules_post_rules_item.py similarity index 93% rename from src/elevenlabs/pronunciation_dictionary/types/body_add_a_pronunciation_dictionary_v_1_pronunciation_dictionaries_add_from_rules_post_rules_item.py rename to src/elevenlabs/pronunciation_dictionaries/types/body_add_a_pronunciation_dictionary_v_1_pronunciation_dictionaries_add_from_rules_post_rules_item.py index cf8e3ff5..fc13007b 100644 --- a/src/elevenlabs/pronunciation_dictionary/types/body_add_a_pronunciation_dictionary_v_1_pronunciation_dictionaries_add_from_rules_post_rules_item.py +++ b/src/elevenlabs/pronunciation_dictionaries/types/body_add_a_pronunciation_dictionary_v_1_pronunciation_dictionaries_add_from_rules_post_rules_item.py @@ -1,12 +1,13 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -from ...core.unchecked_base_model import UncheckedBaseModel + import typing -from ...core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic import typing_extensions -from ...core.unchecked_base_model import UnionMetadata +from ...core.pydantic_utilities import IS_PYDANTIC_V2 +from ...core.unchecked_base_model import UncheckedBaseModel, UnionMetadata class BodyAddAPronunciationDictionaryV1PronunciationDictionariesAddFromRulesPostRulesItem_Alias(UncheckedBaseModel): diff --git a/src/elevenlabs/pronunciation_dictionary/types/body_add_a_pronunciation_dictionary_v_1_pronunciation_dictionaries_add_from_rules_post_workspace_access.py b/src/elevenlabs/pronunciation_dictionaries/types/body_add_a_pronunciation_dictionary_v_1_pronunciation_dictionaries_add_from_rules_post_workspace_access.py similarity index 100% rename from src/elevenlabs/pronunciation_dictionary/types/body_add_a_pronunciation_dictionary_v_1_pronunciation_dictionaries_add_from_rules_post_workspace_access.py rename to src/elevenlabs/pronunciation_dictionaries/types/body_add_a_pronunciation_dictionary_v_1_pronunciation_dictionaries_add_from_rules_post_workspace_access.py diff --git a/src/elevenlabs/pronunciation_dictionary/types/pronunciation_dictionary_add_from_file_request_workspace_access.py b/src/elevenlabs/pronunciation_dictionaries/types/pronunciation_dictionaries_create_from_file_request_workspace_access.py similarity index 64% rename from src/elevenlabs/pronunciation_dictionary/types/pronunciation_dictionary_add_from_file_request_workspace_access.py rename to src/elevenlabs/pronunciation_dictionaries/types/pronunciation_dictionaries_create_from_file_request_workspace_access.py index 076acb8d..adf01cac 100644 --- a/src/elevenlabs/pronunciation_dictionary/types/pronunciation_dictionary_add_from_file_request_workspace_access.py +++ b/src/elevenlabs/pronunciation_dictionaries/types/pronunciation_dictionaries_create_from_file_request_workspace_access.py @@ -2,6 +2,6 @@ import typing -PronunciationDictionaryAddFromFileRequestWorkspaceAccess = typing.Union[ +PronunciationDictionariesCreateFromFileRequestWorkspaceAccess = typing.Union[ typing.Literal["admin", "editor", "viewer"], typing.Any ] diff --git a/src/elevenlabs/pronunciation_dictionary/types/pronunciation_dictionary_get_all_request_sort.py b/src/elevenlabs/pronunciation_dictionaries/types/pronunciation_dictionaries_list_request_sort.py similarity index 67% rename from src/elevenlabs/pronunciation_dictionary/types/pronunciation_dictionary_get_all_request_sort.py rename to src/elevenlabs/pronunciation_dictionaries/types/pronunciation_dictionaries_list_request_sort.py index 57e33e04..41d39079 100644 --- a/src/elevenlabs/pronunciation_dictionary/types/pronunciation_dictionary_get_all_request_sort.py +++ b/src/elevenlabs/pronunciation_dictionaries/types/pronunciation_dictionaries_list_request_sort.py @@ -2,4 +2,4 @@ import typing -PronunciationDictionaryGetAllRequestSort = typing.Union[typing.Literal["creation_time_unix", "name"], typing.Any] +PronunciationDictionariesListRequestSort = typing.Union[typing.Literal["creation_time_unix", "name"], typing.Any] diff --git a/src/elevenlabs/realtime_tts.py b/src/elevenlabs/realtime_tts.py deleted file mode 100644 index ca2c168f..00000000 --- a/src/elevenlabs/realtime_tts.py +++ /dev/null @@ -1,143 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import typing -import urllib.parse -import json -import base64 -import websockets - -from websockets.sync.client import connect - -from .core.api_error import ApiError -from .core.client_wrapper import SyncClientWrapper -from .core.jsonable_encoder import jsonable_encoder -from .core.remove_none_from_dict import remove_none_from_dict -from .core.request_options import RequestOptions -from .types.voice_settings import VoiceSettings -from .text_to_speech.client import TextToSpeechClient -from .types import OutputFormat - -# this is used as the default value for optional parameters -OMIT = typing.cast(typing.Any, ...) - - -def text_chunker(chunks: typing.Iterator[str]) -> typing.Iterator[str]: - """Used during input streaming to chunk text blocks and set last char to space""" - splitters = (".", ",", "?", "!", ";", ":", "—", "-", "(", ")", "[", "]", "}", " ") - buffer = "" - for text in chunks: - if buffer.endswith(splitters): - yield buffer if buffer.endswith(" ") else buffer + " " - buffer = text - elif text.startswith(splitters): - output = buffer + text[0] - yield output if output.endswith(" ") else output + " " - buffer = text[1:] - else: - buffer += text - if buffer != "": - yield buffer + " " - - -class RealtimeTextToSpeechClient(TextToSpeechClient): - def __init__(self, *, client_wrapper: SyncClientWrapper): - super().__init__(client_wrapper=client_wrapper) - self._ws_base_url = urllib.parse.urlparse(self._client_wrapper.get_environment().base)._replace(scheme="wss").geturl() - - def convert_realtime( - self, - voice_id: str, - *, - text: typing.Iterator[str], - model_id: typing.Optional[str] = OMIT, - output_format: typing.Optional[OutputFormat] = "mp3_44100_128", - voice_settings: typing.Optional[VoiceSettings] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> typing.Iterator[bytes]: - """ - Converts text into speech using a voice of your choice and returns audio. - - Parameters: - - voice_id: str. Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices. - - - text: typing.Iterator[str]. The text that will get converted into speech. - - - model_id: typing.Optional[str]. Identifier of the model that will be used, you can query them using GET /v1/models. The model needs to have support for text to speech, you can check this using the can_do_text_to_speech property. - - - voice_settings: typing.Optional[VoiceSettings]. Voice settings overriding stored setttings for the given voice. They are applied only on the given request. - - - request_options: typing.Optional[RequestOptions]. Request-specific configuration. - --- - from elevenlabs import PronunciationDictionaryVersionLocator, VoiceSettings - from elevenlabs.client import ElevenLabs - - def get_text() -> typing.Iterator[str]: - yield "Hello, how are you?" - yield "I am fine, thank you." - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.text_to_speech.convert_realtime( - voice_id="string", - text=get_text(), - model_id="string", - voice_settings=VoiceSettings( - stability=1.1, - similarity_boost=1.1, - style=1.1, - use_speaker_boost=True, - ), - ) - """ - with connect( - urllib.parse.urljoin( - self._ws_base_url, - f"v1/text-to-speech/{jsonable_encoder(voice_id)}/stream-input?model_id={model_id}&output_format={output_format}" - ), - additional_headers=jsonable_encoder( - remove_none_from_dict( - { - **self._client_wrapper.get_headers(), - **(request_options.get("additional_headers", {}) if request_options is not None else {}), - } - ) - ) - ) as socket: - try: - socket.send(json.dumps( - dict( - text=" ", - try_trigger_generation=True, - voice_settings=voice_settings.dict() if voice_settings else None, - generation_config=dict( - chunk_length_schedule=[50], - ), - ) - )) - except websockets.exceptions.ConnectionClosedError as ce: - raise ApiError(body=ce.reason, status_code=ce.code) - - try: - for text_chunk in text_chunker(text): - data = dict(text=text_chunk, try_trigger_generation=True) - socket.send(json.dumps(data)) - try: - data = json.loads(socket.recv(1e-2)) - if "audio" in data and data["audio"]: - yield base64.b64decode(data["audio"]) # type: ignore - except TimeoutError: - pass - - socket.send(json.dumps(dict(text=""))) - - while True: - - data = json.loads(socket.recv()) - if "audio" in data and data["audio"]: - yield base64.b64decode(data["audio"]) # type: ignore - except websockets.exceptions.ConnectionClosed as ce: - if "message" in data: - raise ApiError(body=data, status_code=ce.code) - elif ce.code != 1000: - raise ApiError(body=ce.reason, status_code=ce.code) diff --git a/src/elevenlabs/samples/__init__.py b/src/elevenlabs/samples/__init__.py index f3ea2659..5cde0202 100644 --- a/src/elevenlabs/samples/__init__.py +++ b/src/elevenlabs/samples/__init__.py @@ -1,2 +1,4 @@ # This file was auto-generated by Fern from our API Definition. +# isort: skip_file + diff --git a/src/elevenlabs/samples/client.py b/src/elevenlabs/samples/client.py index 09665f55..c20083e1 100644 --- a/src/elevenlabs/samples/client.py +++ b/src/elevenlabs/samples/client.py @@ -1,28 +1,30 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.client_wrapper import SyncClientWrapper import typing + +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ..core.request_options import RequestOptions from ..types.delete_sample_response import DeleteSampleResponse -from ..core.jsonable_encoder import jsonable_encoder -from ..core.unchecked_base_model import construct_type -from ..errors.unprocessable_entity_error import UnprocessableEntityError -from ..types.http_validation_error import HttpValidationError -from json.decoder import JSONDecodeError -from ..core.api_error import ApiError -from ..core.client_wrapper import AsyncClientWrapper +from .raw_client import AsyncRawSamplesClient, RawSamplesClient class SamplesClient: def __init__(self, *, client_wrapper: SyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = RawSamplesClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawSamplesClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawSamplesClient + """ + return self._raw_client def delete( - self, - voice_id: str, - sample_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, + self, voice_id: str, sample_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> DeleteSampleResponse: """ Removes a sample by its ID. @@ -55,101 +57,27 @@ def delete( sample_id="VW7YKqPnjY4h39yTbx2L", ) """ - _response = self._client_wrapper.httpx_client.request( - f"v1/voices/{jsonable_encoder(voice_id)}/samples/{jsonable_encoder(sample_id)}", - base_url=self._client_wrapper.get_environment().base, - method="DELETE", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - DeleteSampleResponse, - construct_type( - type_=DeleteSampleResponse, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def get_audio( - self, - voice_id: str, - sample_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, - ) -> typing.Iterator[bytes]: - """ - Returns the audio corresponding to a sample attached to a voice. - - Parameters - ---------- - voice_id : str - ID of the voice to be used. You can use the [Get voices](/docs/api-reference/voices/search) endpoint list all the available voices. + _response = self._raw_client.delete(voice_id, sample_id, request_options=request_options) + return _response.data - sample_id : str - ID of the sample to be used. You can use the [Get voices](/docs/api-reference/voices/get) endpoint list all the available samples for a voice. - request_options : typing.Optional[RequestOptions] - Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. +class AsyncSamplesClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawSamplesClient(client_wrapper=client_wrapper) - Yields - ------ - typing.Iterator[bytes] - Successful Response + @property + def with_raw_response(self) -> AsyncRawSamplesClient: """ - with self._client_wrapper.httpx_client.stream( - f"v1/voices/{jsonable_encoder(voice_id)}/samples/{jsonable_encoder(sample_id)}/audio", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) as _response: - try: - if 200 <= _response.status_code < 300: - _chunk_size = request_options.get("chunk_size", 1024) if request_options is not None else 1024 - for _chunk in _response.iter_bytes(chunk_size=_chunk_size): - yield _chunk - return - _response.read() - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - + Retrieves a raw implementation of this client that returns raw responses. -class AsyncSamplesClient: - def __init__(self, *, client_wrapper: AsyncClientWrapper): - self._client_wrapper = client_wrapper + Returns + ------- + AsyncRawSamplesClient + """ + return self._raw_client async def delete( - self, - voice_id: str, - sample_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, + self, voice_id: str, sample_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> DeleteSampleResponse: """ Removes a sample by its ID. @@ -190,86 +118,5 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/voices/{jsonable_encoder(voice_id)}/samples/{jsonable_encoder(sample_id)}", - base_url=self._client_wrapper.get_environment().base, - method="DELETE", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - DeleteSampleResponse, - construct_type( - type_=DeleteSampleResponse, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def get_audio( - self, - voice_id: str, - sample_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, - ) -> typing.AsyncIterator[bytes]: - """ - Returns the audio corresponding to a sample attached to a voice. - - Parameters - ---------- - voice_id : str - ID of the voice to be used. You can use the [Get voices](/docs/api-reference/voices/search) endpoint list all the available voices. - - sample_id : str - ID of the sample to be used. You can use the [Get voices](/docs/api-reference/voices/get) endpoint list all the available samples for a voice. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. - - Yields - ------ - typing.AsyncIterator[bytes] - Successful Response - """ - async with self._client_wrapper.httpx_client.stream( - f"v1/voices/{jsonable_encoder(voice_id)}/samples/{jsonable_encoder(sample_id)}/audio", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) as _response: - try: - if 200 <= _response.status_code < 300: - _chunk_size = request_options.get("chunk_size", 1024) if request_options is not None else 1024 - async for _chunk in _response.aiter_bytes(chunk_size=_chunk_size): - yield _chunk - return - await _response.aread() - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.delete(voice_id, sample_id, request_options=request_options) + return _response.data diff --git a/src/elevenlabs/samples/raw_client.py b/src/elevenlabs/samples/raw_client.py new file mode 100644 index 00000000..16aca14f --- /dev/null +++ b/src/elevenlabs/samples/raw_client.py @@ -0,0 +1,132 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ..core.api_error import ApiError +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ..core.http_response import AsyncHttpResponse, HttpResponse +from ..core.jsonable_encoder import jsonable_encoder +from ..core.request_options import RequestOptions +from ..core.unchecked_base_model import construct_type +from ..errors.unprocessable_entity_error import UnprocessableEntityError +from ..types.delete_sample_response import DeleteSampleResponse +from ..types.http_validation_error import HttpValidationError + + +class RawSamplesClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def delete( + self, voice_id: str, sample_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[DeleteSampleResponse]: + """ + Removes a sample by its ID. + + Parameters + ---------- + voice_id : str + ID of the voice to be used. You can use the [Get voices](/docs/api-reference/voices/search) endpoint list all the available voices. + + sample_id : str + ID of the sample to be used. You can use the [Get voices](/docs/api-reference/voices/get) endpoint list all the available samples for a voice. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[DeleteSampleResponse] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/voices/{jsonable_encoder(voice_id)}/samples/{jsonable_encoder(sample_id)}", + base_url=self._client_wrapper.get_environment().base, + method="DELETE", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + DeleteSampleResponse, + construct_type( + type_=DeleteSampleResponse, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + +class AsyncRawSamplesClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def delete( + self, voice_id: str, sample_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[DeleteSampleResponse]: + """ + Removes a sample by its ID. + + Parameters + ---------- + voice_id : str + ID of the voice to be used. You can use the [Get voices](/docs/api-reference/voices/search) endpoint list all the available voices. + + sample_id : str + ID of the sample to be used. You can use the [Get voices](/docs/api-reference/voices/get) endpoint list all the available samples for a voice. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[DeleteSampleResponse] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/voices/{jsonable_encoder(voice_id)}/samples/{jsonable_encoder(sample_id)}", + base_url=self._client_wrapper.get_environment().base, + method="DELETE", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + DeleteSampleResponse, + construct_type( + type_=DeleteSampleResponse, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/elevenlabs/speech_to_speech/__init__.py b/src/elevenlabs/speech_to_speech/__init__.py index 9b6b14bb..4eec6092 100644 --- a/src/elevenlabs/speech_to_speech/__init__.py +++ b/src/elevenlabs/speech_to_speech/__init__.py @@ -1,15 +1,17 @@ # This file was auto-generated by Fern from our API Definition. +# isort: skip_file + from .types import ( - SpeechToSpeechConvertAsStreamRequestFileFormat, - SpeechToSpeechConvertAsStreamRequestOutputFormat, SpeechToSpeechConvertRequestFileFormat, SpeechToSpeechConvertRequestOutputFormat, + SpeechToSpeechStreamRequestFileFormat, + SpeechToSpeechStreamRequestOutputFormat, ) __all__ = [ - "SpeechToSpeechConvertAsStreamRequestFileFormat", - "SpeechToSpeechConvertAsStreamRequestOutputFormat", "SpeechToSpeechConvertRequestFileFormat", "SpeechToSpeechConvertRequestOutputFormat", + "SpeechToSpeechStreamRequestFileFormat", + "SpeechToSpeechStreamRequestOutputFormat", ] diff --git a/src/elevenlabs/speech_to_speech/client.py b/src/elevenlabs/speech_to_speech/client.py index fd89d523..7e9fc79d 100644 --- a/src/elevenlabs/speech_to_speech/client.py +++ b/src/elevenlabs/speech_to_speech/client.py @@ -1,28 +1,15 @@ # This file was auto-generated by Fern from our API Definition. import typing -from ..core.client_wrapper import SyncClientWrapper + from .. import core -from .types.speech_to_speech_convert_request_output_format import ( - SpeechToSpeechConvertRequestOutputFormat, -) -from .types.speech_to_speech_convert_request_file_format import ( - SpeechToSpeechConvertRequestFileFormat, -) +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ..core.request_options import RequestOptions -from ..core.jsonable_encoder import jsonable_encoder -from ..errors.unprocessable_entity_error import UnprocessableEntityError -from ..types.http_validation_error import HttpValidationError -from ..core.unchecked_base_model import construct_type -from json.decoder import JSONDecodeError -from ..core.api_error import ApiError -from .types.speech_to_speech_convert_as_stream_request_output_format import ( - SpeechToSpeechConvertAsStreamRequestOutputFormat, -) -from .types.speech_to_speech_convert_as_stream_request_file_format import ( - SpeechToSpeechConvertAsStreamRequestFileFormat, -) -from ..core.client_wrapper import AsyncClientWrapper +from .raw_client import AsyncRawSpeechToSpeechClient, RawSpeechToSpeechClient +from .types.speech_to_speech_convert_request_file_format import SpeechToSpeechConvertRequestFileFormat +from .types.speech_to_speech_convert_request_output_format import SpeechToSpeechConvertRequestOutputFormat +from .types.speech_to_speech_stream_request_file_format import SpeechToSpeechStreamRequestFileFormat +from .types.speech_to_speech_stream_request_output_format import SpeechToSpeechStreamRequestOutputFormat # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -30,7 +17,18 @@ class SpeechToSpeechClient: def __init__(self, *, client_wrapper: SyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = RawSpeechToSpeechClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawSpeechToSpeechClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawSpeechToSpeechClient + """ + return self._raw_client def convert( self, @@ -92,8 +90,8 @@ def convert( request_options : typing.Optional[RequestOptions] Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. - Yields - ------ + Returns + ------- typing.Iterator[bytes] The generated audio file @@ -110,63 +108,34 @@ def convert( model_id="eleven_multilingual_sts_v2", ) """ - with self._client_wrapper.httpx_client.stream( - f"v1/speech-to-speech/{jsonable_encoder(voice_id)}", - base_url=self._client_wrapper.get_environment().base, - method="POST", - params={ - "enable_logging": enable_logging, - "optimize_streaming_latency": optimize_streaming_latency, - "output_format": output_format, - }, - data={ - "model_id": model_id, - "voice_settings": voice_settings, - "seed": seed, - "remove_background_noise": remove_background_noise, - "file_format": file_format, - }, - files={ - "audio": audio, - }, + with self._raw_client.convert( + voice_id, + audio=audio, + enable_logging=enable_logging, + optimize_streaming_latency=optimize_streaming_latency, + output_format=output_format, + model_id=model_id, + voice_settings=voice_settings, + seed=seed, + remove_background_noise=remove_background_noise, + file_format=file_format, request_options=request_options, - omit=OMIT, - ) as _response: - try: - if 200 <= _response.status_code < 300: - _chunk_size = request_options.get("chunk_size", 1024) if request_options is not None else 1024 - for _chunk in _response.iter_bytes(chunk_size=_chunk_size): - yield _chunk - return - _response.read() - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def convert_as_stream( + ) as r: + yield from r.data + + def stream( self, voice_id: str, *, audio: core.File, enable_logging: typing.Optional[bool] = None, optimize_streaming_latency: typing.Optional[int] = None, - output_format: typing.Optional[SpeechToSpeechConvertAsStreamRequestOutputFormat] = None, + output_format: typing.Optional[SpeechToSpeechStreamRequestOutputFormat] = None, model_id: typing.Optional[str] = OMIT, voice_settings: typing.Optional[str] = OMIT, seed: typing.Optional[int] = OMIT, remove_background_noise: typing.Optional[bool] = OMIT, - file_format: typing.Optional[SpeechToSpeechConvertAsStreamRequestFileFormat] = OMIT, + file_format: typing.Optional[SpeechToSpeechStreamRequestFileFormat] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> typing.Iterator[bytes]: """ @@ -193,7 +162,7 @@ def convert_as_stream( Defaults to None. - output_format : typing.Optional[SpeechToSpeechConvertAsStreamRequestOutputFormat] + output_format : typing.Optional[SpeechToSpeechStreamRequestOutputFormat] Output format of the generated audio. Formatted as codec_sample_rate_bitrate. So an mp3 with 22.05kHz sample rate at 32kbs is represented as mp3_22050_32. MP3 with 192kbps bitrate requires you to be subscribed to Creator tier or above. PCM with 44.1kHz sample rate requires you to be subscribed to Pro tier or above. Note that the μ-law format (sometimes written mu-law, often approximated as u-law) is commonly used for Twilio audio inputs. model_id : typing.Optional[str] @@ -208,14 +177,14 @@ def convert_as_stream( remove_background_noise : typing.Optional[bool] If set, will remove the background noise from your audio input using our audio isolation model. Only applies to Voice Changer. - file_format : typing.Optional[SpeechToSpeechConvertAsStreamRequestFileFormat] + file_format : typing.Optional[SpeechToSpeechStreamRequestFileFormat] The format of input audio. Options are 'pcm_s16le_16' or 'other' For `pcm_s16le_16`, the input audio must be 16-bit PCM at a 16kHz sample rate, single channel (mono), and little-endian byte order. Latency will be lower than with passing an encoded waveform. request_options : typing.Optional[RequestOptions] Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. - Yields - ------ + Returns + ------- typing.Iterator[bytes] Streaming audio data @@ -226,60 +195,42 @@ def convert_as_stream( client = ElevenLabs( api_key="YOUR_API_KEY", ) - client.speech_to_speech.convert_as_stream( + client.speech_to_speech.stream( voice_id="JBFqnCBsd6RMkjVDRZzb", output_format="mp3_44100_128", model_id="eleven_multilingual_sts_v2", ) """ - with self._client_wrapper.httpx_client.stream( - f"v1/speech-to-speech/{jsonable_encoder(voice_id)}/stream", - base_url=self._client_wrapper.get_environment().base, - method="POST", - params={ - "enable_logging": enable_logging, - "optimize_streaming_latency": optimize_streaming_latency, - "output_format": output_format, - }, - data={ - "model_id": model_id, - "voice_settings": voice_settings, - "seed": seed, - "remove_background_noise": remove_background_noise, - "file_format": file_format, - }, - files={ - "audio": audio, - }, + with self._raw_client.stream( + voice_id, + audio=audio, + enable_logging=enable_logging, + optimize_streaming_latency=optimize_streaming_latency, + output_format=output_format, + model_id=model_id, + voice_settings=voice_settings, + seed=seed, + remove_background_noise=remove_background_noise, + file_format=file_format, request_options=request_options, - omit=OMIT, - ) as _response: - try: - if 200 <= _response.status_code < 300: - _chunk_size = request_options.get("chunk_size", 1024) if request_options is not None else 1024 - for _chunk in _response.iter_bytes(chunk_size=_chunk_size): - yield _chunk - return - _response.read() - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + ) as r: + yield from r.data class AsyncSpeechToSpeechClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = AsyncRawSpeechToSpeechClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawSpeechToSpeechClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawSpeechToSpeechClient + """ + return self._raw_client async def convert( self, @@ -341,8 +292,8 @@ async def convert( request_options : typing.Optional[RequestOptions] Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. - Yields - ------ + Returns + ------- typing.AsyncIterator[bytes] The generated audio file @@ -367,63 +318,35 @@ async def main() -> None: asyncio.run(main()) """ - async with self._client_wrapper.httpx_client.stream( - f"v1/speech-to-speech/{jsonable_encoder(voice_id)}", - base_url=self._client_wrapper.get_environment().base, - method="POST", - params={ - "enable_logging": enable_logging, - "optimize_streaming_latency": optimize_streaming_latency, - "output_format": output_format, - }, - data={ - "model_id": model_id, - "voice_settings": voice_settings, - "seed": seed, - "remove_background_noise": remove_background_noise, - "file_format": file_format, - }, - files={ - "audio": audio, - }, + async with self._raw_client.convert( + voice_id, + audio=audio, + enable_logging=enable_logging, + optimize_streaming_latency=optimize_streaming_latency, + output_format=output_format, + model_id=model_id, + voice_settings=voice_settings, + seed=seed, + remove_background_noise=remove_background_noise, + file_format=file_format, request_options=request_options, - omit=OMIT, - ) as _response: - try: - if 200 <= _response.status_code < 300: - _chunk_size = request_options.get("chunk_size", 1024) if request_options is not None else 1024 - async for _chunk in _response.aiter_bytes(chunk_size=_chunk_size): - yield _chunk - return - await _response.aread() - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def convert_as_stream( + ) as r: + async for _chunk in r.data: + yield _chunk + + async def stream( self, voice_id: str, *, audio: core.File, enable_logging: typing.Optional[bool] = None, optimize_streaming_latency: typing.Optional[int] = None, - output_format: typing.Optional[SpeechToSpeechConvertAsStreamRequestOutputFormat] = None, + output_format: typing.Optional[SpeechToSpeechStreamRequestOutputFormat] = None, model_id: typing.Optional[str] = OMIT, voice_settings: typing.Optional[str] = OMIT, seed: typing.Optional[int] = OMIT, remove_background_noise: typing.Optional[bool] = OMIT, - file_format: typing.Optional[SpeechToSpeechConvertAsStreamRequestFileFormat] = OMIT, + file_format: typing.Optional[SpeechToSpeechStreamRequestFileFormat] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> typing.AsyncIterator[bytes]: """ @@ -450,7 +373,7 @@ async def convert_as_stream( Defaults to None. - output_format : typing.Optional[SpeechToSpeechConvertAsStreamRequestOutputFormat] + output_format : typing.Optional[SpeechToSpeechStreamRequestOutputFormat] Output format of the generated audio. Formatted as codec_sample_rate_bitrate. So an mp3 with 22.05kHz sample rate at 32kbs is represented as mp3_22050_32. MP3 with 192kbps bitrate requires you to be subscribed to Creator tier or above. PCM with 44.1kHz sample rate requires you to be subscribed to Pro tier or above. Note that the μ-law format (sometimes written mu-law, often approximated as u-law) is commonly used for Twilio audio inputs. model_id : typing.Optional[str] @@ -465,14 +388,14 @@ async def convert_as_stream( remove_background_noise : typing.Optional[bool] If set, will remove the background noise from your audio input using our audio isolation model. Only applies to Voice Changer. - file_format : typing.Optional[SpeechToSpeechConvertAsStreamRequestFileFormat] + file_format : typing.Optional[SpeechToSpeechStreamRequestFileFormat] The format of input audio. Options are 'pcm_s16le_16' or 'other' For `pcm_s16le_16`, the input audio must be 16-bit PCM at a 16kHz sample rate, single channel (mono), and little-endian byte order. Latency will be lower than with passing an encoded waveform. request_options : typing.Optional[RequestOptions] Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. - Yields - ------ + Returns + ------- typing.AsyncIterator[bytes] Streaming audio data @@ -488,7 +411,7 @@ async def convert_as_stream( async def main() -> None: - await client.speech_to_speech.convert_as_stream( + await client.speech_to_speech.stream( voice_id="JBFqnCBsd6RMkjVDRZzb", output_format="mp3_44100_128", model_id="eleven_multilingual_sts_v2", @@ -497,46 +420,18 @@ async def main() -> None: asyncio.run(main()) """ - async with self._client_wrapper.httpx_client.stream( - f"v1/speech-to-speech/{jsonable_encoder(voice_id)}/stream", - base_url=self._client_wrapper.get_environment().base, - method="POST", - params={ - "enable_logging": enable_logging, - "optimize_streaming_latency": optimize_streaming_latency, - "output_format": output_format, - }, - data={ - "model_id": model_id, - "voice_settings": voice_settings, - "seed": seed, - "remove_background_noise": remove_background_noise, - "file_format": file_format, - }, - files={ - "audio": audio, - }, + async with self._raw_client.stream( + voice_id, + audio=audio, + enable_logging=enable_logging, + optimize_streaming_latency=optimize_streaming_latency, + output_format=output_format, + model_id=model_id, + voice_settings=voice_settings, + seed=seed, + remove_background_noise=remove_background_noise, + file_format=file_format, request_options=request_options, - omit=OMIT, - ) as _response: - try: - if 200 <= _response.status_code < 300: - _chunk_size = request_options.get("chunk_size", 1024) if request_options is not None else 1024 - async for _chunk in _response.aiter_bytes(chunk_size=_chunk_size): - yield _chunk - return - await _response.aread() - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + ) as r: + async for _chunk in r.data: + yield _chunk diff --git a/src/elevenlabs/speech_to_speech/raw_client.py b/src/elevenlabs/speech_to_speech/raw_client.py new file mode 100644 index 00000000..7c3bc428 --- /dev/null +++ b/src/elevenlabs/speech_to_speech/raw_client.py @@ -0,0 +1,506 @@ +# This file was auto-generated by Fern from our API Definition. + +import contextlib +import typing +from json.decoder import JSONDecodeError + +from .. import core +from ..core.api_error import ApiError +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ..core.http_response import AsyncHttpResponse, HttpResponse +from ..core.jsonable_encoder import jsonable_encoder +from ..core.request_options import RequestOptions +from ..core.unchecked_base_model import construct_type +from ..errors.unprocessable_entity_error import UnprocessableEntityError +from ..types.http_validation_error import HttpValidationError +from .types.speech_to_speech_convert_request_file_format import SpeechToSpeechConvertRequestFileFormat +from .types.speech_to_speech_convert_request_output_format import SpeechToSpeechConvertRequestOutputFormat +from .types.speech_to_speech_stream_request_file_format import SpeechToSpeechStreamRequestFileFormat +from .types.speech_to_speech_stream_request_output_format import SpeechToSpeechStreamRequestOutputFormat + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RawSpeechToSpeechClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + @contextlib.contextmanager + def convert( + self, + voice_id: str, + *, + audio: core.File, + enable_logging: typing.Optional[bool] = None, + optimize_streaming_latency: typing.Optional[int] = None, + output_format: typing.Optional[SpeechToSpeechConvertRequestOutputFormat] = None, + model_id: typing.Optional[str] = OMIT, + voice_settings: typing.Optional[str] = OMIT, + seed: typing.Optional[int] = OMIT, + remove_background_noise: typing.Optional[bool] = OMIT, + file_format: typing.Optional[SpeechToSpeechConvertRequestFileFormat] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> typing.Iterator[HttpResponse[typing.Iterator[bytes]]]: + """ + Transform audio from one voice to another. Maintain full control over emotion, timing and delivery. + + Parameters + ---------- + voice_id : str + ID of the voice to be used. Use the [Get voices](/docs/api-reference/voices/search) endpoint list all the available voices. + + audio : core.File + See core.File for more documentation + + enable_logging : typing.Optional[bool] + When enable_logging is set to false zero retention mode will be used for the request. This will mean history features are unavailable for this request, including request stitching. Zero retention mode may only be used by enterprise customers. + + optimize_streaming_latency : typing.Optional[int] + You can turn on latency optimizations at some cost of quality. The best possible final latency varies by model. Possible values: + 0 - default mode (no latency optimizations) + 1 - normal latency optimizations (about 50% of possible latency improvement of option 3) + 2 - strong latency optimizations (about 75% of possible latency improvement of option 3) + 3 - max latency optimizations + 4 - max latency optimizations, but also with text normalizer turned off for even more latency savings (best latency, but can mispronounce eg numbers and dates). + + Defaults to None. + + output_format : typing.Optional[SpeechToSpeechConvertRequestOutputFormat] + Output format of the generated audio. Formatted as codec_sample_rate_bitrate. So an mp3 with 22.05kHz sample rate at 32kbs is represented as mp3_22050_32. MP3 with 192kbps bitrate requires you to be subscribed to Creator tier or above. PCM with 44.1kHz sample rate requires you to be subscribed to Pro tier or above. Note that the μ-law format (sometimes written mu-law, often approximated as u-law) is commonly used for Twilio audio inputs. + + model_id : typing.Optional[str] + Identifier of the model that will be used, you can query them using GET /v1/models. The model needs to have support for speech to speech, you can check this using the can_do_voice_conversion property. + + voice_settings : typing.Optional[str] + Voice settings overriding stored settings for the given voice. They are applied only on the given request. Needs to be send as a JSON encoded string. + + seed : typing.Optional[int] + If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same seed and parameters should return the same result. Determinism is not guaranteed. Must be integer between 0 and 4294967295. + + remove_background_noise : typing.Optional[bool] + If set, will remove the background noise from your audio input using our audio isolation model. Only applies to Voice Changer. + + file_format : typing.Optional[SpeechToSpeechConvertRequestFileFormat] + The format of input audio. Options are 'pcm_s16le_16' or 'other' For `pcm_s16le_16`, the input audio must be 16-bit PCM at a 16kHz sample rate, single channel (mono), and little-endian byte order. Latency will be lower than with passing an encoded waveform. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. + + Returns + ------- + typing.Iterator[HttpResponse[typing.Iterator[bytes]]] + The generated audio file + """ + with self._client_wrapper.httpx_client.stream( + f"v1/speech-to-speech/{jsonable_encoder(voice_id)}", + base_url=self._client_wrapper.get_environment().base, + method="POST", + params={ + "enable_logging": enable_logging, + "optimize_streaming_latency": optimize_streaming_latency, + "output_format": output_format, + }, + data={ + "model_id": model_id, + "voice_settings": voice_settings, + "seed": seed, + "remove_background_noise": remove_background_noise, + "file_format": file_format, + }, + files={ + "audio": audio, + }, + request_options=request_options, + omit=OMIT, + force_multipart=True, + ) as _response: + + def _stream() -> HttpResponse[typing.Iterator[bytes]]: + try: + if 200 <= _response.status_code < 300: + _chunk_size = request_options.get("chunk_size", 1024) if request_options is not None else 1024 + return HttpResponse( + response=_response, data=(_chunk for _chunk in _response.iter_bytes(chunk_size=_chunk_size)) + ) + _response.read() + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + yield _stream() + + @contextlib.contextmanager + def stream( + self, + voice_id: str, + *, + audio: core.File, + enable_logging: typing.Optional[bool] = None, + optimize_streaming_latency: typing.Optional[int] = None, + output_format: typing.Optional[SpeechToSpeechStreamRequestOutputFormat] = None, + model_id: typing.Optional[str] = OMIT, + voice_settings: typing.Optional[str] = OMIT, + seed: typing.Optional[int] = OMIT, + remove_background_noise: typing.Optional[bool] = OMIT, + file_format: typing.Optional[SpeechToSpeechStreamRequestFileFormat] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> typing.Iterator[HttpResponse[typing.Iterator[bytes]]]: + """ + Stream audio from one voice to another. Maintain full control over emotion, timing and delivery. + + Parameters + ---------- + voice_id : str + ID of the voice to be used. Use the [Get voices](/docs/api-reference/voices/search) endpoint list all the available voices. + + audio : core.File + See core.File for more documentation + + enable_logging : typing.Optional[bool] + When enable_logging is set to false zero retention mode will be used for the request. This will mean history features are unavailable for this request, including request stitching. Zero retention mode may only be used by enterprise customers. + + optimize_streaming_latency : typing.Optional[int] + You can turn on latency optimizations at some cost of quality. The best possible final latency varies by model. Possible values: + 0 - default mode (no latency optimizations) + 1 - normal latency optimizations (about 50% of possible latency improvement of option 3) + 2 - strong latency optimizations (about 75% of possible latency improvement of option 3) + 3 - max latency optimizations + 4 - max latency optimizations, but also with text normalizer turned off for even more latency savings (best latency, but can mispronounce eg numbers and dates). + + Defaults to None. + + output_format : typing.Optional[SpeechToSpeechStreamRequestOutputFormat] + Output format of the generated audio. Formatted as codec_sample_rate_bitrate. So an mp3 with 22.05kHz sample rate at 32kbs is represented as mp3_22050_32. MP3 with 192kbps bitrate requires you to be subscribed to Creator tier or above. PCM with 44.1kHz sample rate requires you to be subscribed to Pro tier or above. Note that the μ-law format (sometimes written mu-law, often approximated as u-law) is commonly used for Twilio audio inputs. + + model_id : typing.Optional[str] + Identifier of the model that will be used, you can query them using GET /v1/models. The model needs to have support for speech to speech, you can check this using the can_do_voice_conversion property. + + voice_settings : typing.Optional[str] + Voice settings overriding stored settings for the given voice. They are applied only on the given request. Needs to be send as a JSON encoded string. + + seed : typing.Optional[int] + If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same seed and parameters should return the same result. Determinism is not guaranteed. Must be integer between 0 and 4294967295. + + remove_background_noise : typing.Optional[bool] + If set, will remove the background noise from your audio input using our audio isolation model. Only applies to Voice Changer. + + file_format : typing.Optional[SpeechToSpeechStreamRequestFileFormat] + The format of input audio. Options are 'pcm_s16le_16' or 'other' For `pcm_s16le_16`, the input audio must be 16-bit PCM at a 16kHz sample rate, single channel (mono), and little-endian byte order. Latency will be lower than with passing an encoded waveform. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. + + Returns + ------- + typing.Iterator[HttpResponse[typing.Iterator[bytes]]] + Streaming audio data + """ + with self._client_wrapper.httpx_client.stream( + f"v1/speech-to-speech/{jsonable_encoder(voice_id)}/stream", + base_url=self._client_wrapper.get_environment().base, + method="POST", + params={ + "enable_logging": enable_logging, + "optimize_streaming_latency": optimize_streaming_latency, + "output_format": output_format, + }, + data={ + "model_id": model_id, + "voice_settings": voice_settings, + "seed": seed, + "remove_background_noise": remove_background_noise, + "file_format": file_format, + }, + files={ + "audio": audio, + }, + request_options=request_options, + omit=OMIT, + force_multipart=True, + ) as _response: + + def _stream() -> HttpResponse[typing.Iterator[bytes]]: + try: + if 200 <= _response.status_code < 300: + _chunk_size = request_options.get("chunk_size", 1024) if request_options is not None else 1024 + return HttpResponse( + response=_response, data=(_chunk for _chunk in _response.iter_bytes(chunk_size=_chunk_size)) + ) + _response.read() + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + yield _stream() + + +class AsyncRawSpeechToSpeechClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + @contextlib.asynccontextmanager + async def convert( + self, + voice_id: str, + *, + audio: core.File, + enable_logging: typing.Optional[bool] = None, + optimize_streaming_latency: typing.Optional[int] = None, + output_format: typing.Optional[SpeechToSpeechConvertRequestOutputFormat] = None, + model_id: typing.Optional[str] = OMIT, + voice_settings: typing.Optional[str] = OMIT, + seed: typing.Optional[int] = OMIT, + remove_background_noise: typing.Optional[bool] = OMIT, + file_format: typing.Optional[SpeechToSpeechConvertRequestFileFormat] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> typing.AsyncIterator[AsyncHttpResponse[typing.AsyncIterator[bytes]]]: + """ + Transform audio from one voice to another. Maintain full control over emotion, timing and delivery. + + Parameters + ---------- + voice_id : str + ID of the voice to be used. Use the [Get voices](/docs/api-reference/voices/search) endpoint list all the available voices. + + audio : core.File + See core.File for more documentation + + enable_logging : typing.Optional[bool] + When enable_logging is set to false zero retention mode will be used for the request. This will mean history features are unavailable for this request, including request stitching. Zero retention mode may only be used by enterprise customers. + + optimize_streaming_latency : typing.Optional[int] + You can turn on latency optimizations at some cost of quality. The best possible final latency varies by model. Possible values: + 0 - default mode (no latency optimizations) + 1 - normal latency optimizations (about 50% of possible latency improvement of option 3) + 2 - strong latency optimizations (about 75% of possible latency improvement of option 3) + 3 - max latency optimizations + 4 - max latency optimizations, but also with text normalizer turned off for even more latency savings (best latency, but can mispronounce eg numbers and dates). + + Defaults to None. + + output_format : typing.Optional[SpeechToSpeechConvertRequestOutputFormat] + Output format of the generated audio. Formatted as codec_sample_rate_bitrate. So an mp3 with 22.05kHz sample rate at 32kbs is represented as mp3_22050_32. MP3 with 192kbps bitrate requires you to be subscribed to Creator tier or above. PCM with 44.1kHz sample rate requires you to be subscribed to Pro tier or above. Note that the μ-law format (sometimes written mu-law, often approximated as u-law) is commonly used for Twilio audio inputs. + + model_id : typing.Optional[str] + Identifier of the model that will be used, you can query them using GET /v1/models. The model needs to have support for speech to speech, you can check this using the can_do_voice_conversion property. + + voice_settings : typing.Optional[str] + Voice settings overriding stored settings for the given voice. They are applied only on the given request. Needs to be send as a JSON encoded string. + + seed : typing.Optional[int] + If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same seed and parameters should return the same result. Determinism is not guaranteed. Must be integer between 0 and 4294967295. + + remove_background_noise : typing.Optional[bool] + If set, will remove the background noise from your audio input using our audio isolation model. Only applies to Voice Changer. + + file_format : typing.Optional[SpeechToSpeechConvertRequestFileFormat] + The format of input audio. Options are 'pcm_s16le_16' or 'other' For `pcm_s16le_16`, the input audio must be 16-bit PCM at a 16kHz sample rate, single channel (mono), and little-endian byte order. Latency will be lower than with passing an encoded waveform. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. + + Returns + ------- + typing.AsyncIterator[AsyncHttpResponse[typing.AsyncIterator[bytes]]] + The generated audio file + """ + async with self._client_wrapper.httpx_client.stream( + f"v1/speech-to-speech/{jsonable_encoder(voice_id)}", + base_url=self._client_wrapper.get_environment().base, + method="POST", + params={ + "enable_logging": enable_logging, + "optimize_streaming_latency": optimize_streaming_latency, + "output_format": output_format, + }, + data={ + "model_id": model_id, + "voice_settings": voice_settings, + "seed": seed, + "remove_background_noise": remove_background_noise, + "file_format": file_format, + }, + files={ + "audio": audio, + }, + request_options=request_options, + omit=OMIT, + force_multipart=True, + ) as _response: + + async def _stream() -> AsyncHttpResponse[typing.AsyncIterator[bytes]]: + try: + if 200 <= _response.status_code < 300: + _chunk_size = request_options.get("chunk_size", 1024) if request_options is not None else 1024 + return AsyncHttpResponse( + response=_response, + data=(_chunk async for _chunk in _response.aiter_bytes(chunk_size=_chunk_size)), + ) + await _response.aread() + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + yield await _stream() + + @contextlib.asynccontextmanager + async def stream( + self, + voice_id: str, + *, + audio: core.File, + enable_logging: typing.Optional[bool] = None, + optimize_streaming_latency: typing.Optional[int] = None, + output_format: typing.Optional[SpeechToSpeechStreamRequestOutputFormat] = None, + model_id: typing.Optional[str] = OMIT, + voice_settings: typing.Optional[str] = OMIT, + seed: typing.Optional[int] = OMIT, + remove_background_noise: typing.Optional[bool] = OMIT, + file_format: typing.Optional[SpeechToSpeechStreamRequestFileFormat] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> typing.AsyncIterator[AsyncHttpResponse[typing.AsyncIterator[bytes]]]: + """ + Stream audio from one voice to another. Maintain full control over emotion, timing and delivery. + + Parameters + ---------- + voice_id : str + ID of the voice to be used. Use the [Get voices](/docs/api-reference/voices/search) endpoint list all the available voices. + + audio : core.File + See core.File for more documentation + + enable_logging : typing.Optional[bool] + When enable_logging is set to false zero retention mode will be used for the request. This will mean history features are unavailable for this request, including request stitching. Zero retention mode may only be used by enterprise customers. + + optimize_streaming_latency : typing.Optional[int] + You can turn on latency optimizations at some cost of quality. The best possible final latency varies by model. Possible values: + 0 - default mode (no latency optimizations) + 1 - normal latency optimizations (about 50% of possible latency improvement of option 3) + 2 - strong latency optimizations (about 75% of possible latency improvement of option 3) + 3 - max latency optimizations + 4 - max latency optimizations, but also with text normalizer turned off for even more latency savings (best latency, but can mispronounce eg numbers and dates). + + Defaults to None. + + output_format : typing.Optional[SpeechToSpeechStreamRequestOutputFormat] + Output format of the generated audio. Formatted as codec_sample_rate_bitrate. So an mp3 with 22.05kHz sample rate at 32kbs is represented as mp3_22050_32. MP3 with 192kbps bitrate requires you to be subscribed to Creator tier or above. PCM with 44.1kHz sample rate requires you to be subscribed to Pro tier or above. Note that the μ-law format (sometimes written mu-law, often approximated as u-law) is commonly used for Twilio audio inputs. + + model_id : typing.Optional[str] + Identifier of the model that will be used, you can query them using GET /v1/models. The model needs to have support for speech to speech, you can check this using the can_do_voice_conversion property. + + voice_settings : typing.Optional[str] + Voice settings overriding stored settings for the given voice. They are applied only on the given request. Needs to be send as a JSON encoded string. + + seed : typing.Optional[int] + If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same seed and parameters should return the same result. Determinism is not guaranteed. Must be integer between 0 and 4294967295. + + remove_background_noise : typing.Optional[bool] + If set, will remove the background noise from your audio input using our audio isolation model. Only applies to Voice Changer. + + file_format : typing.Optional[SpeechToSpeechStreamRequestFileFormat] + The format of input audio. Options are 'pcm_s16le_16' or 'other' For `pcm_s16le_16`, the input audio must be 16-bit PCM at a 16kHz sample rate, single channel (mono), and little-endian byte order. Latency will be lower than with passing an encoded waveform. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. + + Returns + ------- + typing.AsyncIterator[AsyncHttpResponse[typing.AsyncIterator[bytes]]] + Streaming audio data + """ + async with self._client_wrapper.httpx_client.stream( + f"v1/speech-to-speech/{jsonable_encoder(voice_id)}/stream", + base_url=self._client_wrapper.get_environment().base, + method="POST", + params={ + "enable_logging": enable_logging, + "optimize_streaming_latency": optimize_streaming_latency, + "output_format": output_format, + }, + data={ + "model_id": model_id, + "voice_settings": voice_settings, + "seed": seed, + "remove_background_noise": remove_background_noise, + "file_format": file_format, + }, + files={ + "audio": audio, + }, + request_options=request_options, + omit=OMIT, + force_multipart=True, + ) as _response: + + async def _stream() -> AsyncHttpResponse[typing.AsyncIterator[bytes]]: + try: + if 200 <= _response.status_code < 300: + _chunk_size = request_options.get("chunk_size", 1024) if request_options is not None else 1024 + return AsyncHttpResponse( + response=_response, + data=(_chunk async for _chunk in _response.aiter_bytes(chunk_size=_chunk_size)), + ) + await _response.aread() + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + yield await _stream() diff --git a/src/elevenlabs/speech_to_speech/types/__init__.py b/src/elevenlabs/speech_to_speech/types/__init__.py index 79e6d85b..ef522535 100644 --- a/src/elevenlabs/speech_to_speech/types/__init__.py +++ b/src/elevenlabs/speech_to_speech/types/__init__.py @@ -1,13 +1,15 @@ # This file was auto-generated by Fern from our API Definition. -from .speech_to_speech_convert_as_stream_request_file_format import SpeechToSpeechConvertAsStreamRequestFileFormat -from .speech_to_speech_convert_as_stream_request_output_format import SpeechToSpeechConvertAsStreamRequestOutputFormat +# isort: skip_file + from .speech_to_speech_convert_request_file_format import SpeechToSpeechConvertRequestFileFormat from .speech_to_speech_convert_request_output_format import SpeechToSpeechConvertRequestOutputFormat +from .speech_to_speech_stream_request_file_format import SpeechToSpeechStreamRequestFileFormat +from .speech_to_speech_stream_request_output_format import SpeechToSpeechStreamRequestOutputFormat __all__ = [ - "SpeechToSpeechConvertAsStreamRequestFileFormat", - "SpeechToSpeechConvertAsStreamRequestOutputFormat", "SpeechToSpeechConvertRequestFileFormat", "SpeechToSpeechConvertRequestOutputFormat", + "SpeechToSpeechStreamRequestFileFormat", + "SpeechToSpeechStreamRequestOutputFormat", ] diff --git a/src/elevenlabs/speech_to_speech/types/speech_to_speech_convert_as_stream_request_file_format.py b/src/elevenlabs/speech_to_speech/types/speech_to_speech_convert_as_stream_request_file_format.py deleted file mode 100644 index 7af219f2..00000000 --- a/src/elevenlabs/speech_to_speech/types/speech_to_speech_convert_as_stream_request_file_format.py +++ /dev/null @@ -1,5 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import typing - -SpeechToSpeechConvertAsStreamRequestFileFormat = typing.Union[typing.Literal["pcm_s16le_16", "other"], typing.Any] diff --git a/src/elevenlabs/speech_to_speech/types/speech_to_speech_stream_request_file_format.py b/src/elevenlabs/speech_to_speech/types/speech_to_speech_stream_request_file_format.py new file mode 100644 index 00000000..d10faa2d --- /dev/null +++ b/src/elevenlabs/speech_to_speech/types/speech_to_speech_stream_request_file_format.py @@ -0,0 +1,5 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +SpeechToSpeechStreamRequestFileFormat = typing.Union[typing.Literal["pcm_s16le_16", "other"], typing.Any] diff --git a/src/elevenlabs/text_to_speech/types/text_to_speech_convert_as_stream_request_output_format.py b/src/elevenlabs/speech_to_speech/types/speech_to_speech_stream_request_output_format.py similarity index 89% rename from src/elevenlabs/text_to_speech/types/text_to_speech_convert_as_stream_request_output_format.py rename to src/elevenlabs/speech_to_speech/types/speech_to_speech_stream_request_output_format.py index 05d5a323..d33152de 100644 --- a/src/elevenlabs/text_to_speech/types/text_to_speech_convert_as_stream_request_output_format.py +++ b/src/elevenlabs/speech_to_speech/types/speech_to_speech_stream_request_output_format.py @@ -2,7 +2,7 @@ import typing -TextToSpeechConvertAsStreamRequestOutputFormat = typing.Union[ +SpeechToSpeechStreamRequestOutputFormat = typing.Union[ typing.Literal[ "mp3_22050_32", "mp3_44100_32", diff --git a/src/elevenlabs/speech_to_text/__init__.py b/src/elevenlabs/speech_to_text/__init__.py index 00dba750..c1dda829 100644 --- a/src/elevenlabs/speech_to_text/__init__.py +++ b/src/elevenlabs/speech_to_text/__init__.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# isort: skip_file + from .types import SpeechToTextConvertRequestFileFormat, SpeechToTextConvertRequestTimestampsGranularity __all__ = ["SpeechToTextConvertRequestFileFormat", "SpeechToTextConvertRequestTimestampsGranularity"] diff --git a/src/elevenlabs/speech_to_text/client.py b/src/elevenlabs/speech_to_text/client.py index b2907c46..c7f1d8bb 100644 --- a/src/elevenlabs/speech_to_text/client.py +++ b/src/elevenlabs/speech_to_text/client.py @@ -1,23 +1,15 @@ # This file was auto-generated by Fern from our API Definition. import typing -from ..core.client_wrapper import SyncClientWrapper + from .. import core -from .types.speech_to_text_convert_request_timestamps_granularity import ( - SpeechToTextConvertRequestTimestampsGranularity, -) -from ..types.additional_formats import AdditionalFormats -from .types.speech_to_text_convert_request_file_format import ( - SpeechToTextConvertRequestFileFormat, -) +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ..core.request_options import RequestOptions +from ..types.additional_formats import AdditionalFormats from ..types.speech_to_text_chunk_response_model import SpeechToTextChunkResponseModel -from ..core.unchecked_base_model import construct_type -from ..errors.unprocessable_entity_error import UnprocessableEntityError -from ..types.http_validation_error import HttpValidationError -from json.decoder import JSONDecodeError -from ..core.api_error import ApiError -from ..core.client_wrapper import AsyncClientWrapper +from .raw_client import AsyncRawSpeechToTextClient, RawSpeechToTextClient +from .types.speech_to_text_convert_request_file_format import SpeechToTextConvertRequestFileFormat +from .types.speech_to_text_convert_request_timestamps_granularity import SpeechToTextConvertRequestTimestampsGranularity # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -25,7 +17,18 @@ class SpeechToTextClient: def __init__(self, *, client_wrapper: SyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = RawSpeechToTextClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawSpeechToTextClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawSpeechToTextClient + """ + return self._raw_client def convert( self, @@ -100,58 +103,37 @@ def convert( model_id="model_id", ) """ - _response = self._client_wrapper.httpx_client.request( - "v1/speech-to-text", - base_url=self._client_wrapper.get_environment().base, - method="POST", - params={ - "enable_logging": enable_logging, - }, - data={ - "model_id": model_id, - "language_code": language_code, - "tag_audio_events": tag_audio_events, - "num_speakers": num_speakers, - "timestamps_granularity": timestamps_granularity, - "diarize": diarize, - "additional_formats": additional_formats, - "file_format": file_format, - "cloud_storage_url": cloud_storage_url, - }, - files={ - "file": file, - }, + _response = self._raw_client.convert( + model_id=model_id, + enable_logging=enable_logging, + file=file, + language_code=language_code, + tag_audio_events=tag_audio_events, + num_speakers=num_speakers, + timestamps_granularity=timestamps_granularity, + diarize=diarize, + additional_formats=additional_formats, + file_format=file_format, + cloud_storage_url=cloud_storage_url, request_options=request_options, - omit=OMIT, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - SpeechToTextChunkResponseModel, - construct_type( - type_=SpeechToTextChunkResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + return _response.data class AsyncSpeechToTextClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = AsyncRawSpeechToTextClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawSpeechToTextClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawSpeechToTextClient + """ + return self._raw_client async def convert( self, @@ -234,50 +216,18 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - "v1/speech-to-text", - base_url=self._client_wrapper.get_environment().base, - method="POST", - params={ - "enable_logging": enable_logging, - }, - data={ - "model_id": model_id, - "language_code": language_code, - "tag_audio_events": tag_audio_events, - "num_speakers": num_speakers, - "timestamps_granularity": timestamps_granularity, - "diarize": diarize, - "additional_formats": additional_formats, - "file_format": file_format, - "cloud_storage_url": cloud_storage_url, - }, - files={ - "file": file, - }, + _response = await self._raw_client.convert( + model_id=model_id, + enable_logging=enable_logging, + file=file, + language_code=language_code, + tag_audio_events=tag_audio_events, + num_speakers=num_speakers, + timestamps_granularity=timestamps_granularity, + diarize=diarize, + additional_formats=additional_formats, + file_format=file_format, + cloud_storage_url=cloud_storage_url, request_options=request_options, - omit=OMIT, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - SpeechToTextChunkResponseModel, - construct_type( - type_=SpeechToTextChunkResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + return _response.data diff --git a/src/elevenlabs/speech_to_text/raw_client.py b/src/elevenlabs/speech_to_text/raw_client.py new file mode 100644 index 00000000..1fae0efc --- /dev/null +++ b/src/elevenlabs/speech_to_text/raw_client.py @@ -0,0 +1,256 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from .. import core +from ..core.api_error import ApiError +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ..core.http_response import AsyncHttpResponse, HttpResponse +from ..core.request_options import RequestOptions +from ..core.unchecked_base_model import construct_type +from ..errors.unprocessable_entity_error import UnprocessableEntityError +from ..types.additional_formats import AdditionalFormats +from ..types.http_validation_error import HttpValidationError +from ..types.speech_to_text_chunk_response_model import SpeechToTextChunkResponseModel +from .types.speech_to_text_convert_request_file_format import SpeechToTextConvertRequestFileFormat +from .types.speech_to_text_convert_request_timestamps_granularity import SpeechToTextConvertRequestTimestampsGranularity + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RawSpeechToTextClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def convert( + self, + *, + model_id: str, + enable_logging: typing.Optional[bool] = None, + file: typing.Optional[core.File] = OMIT, + language_code: typing.Optional[str] = OMIT, + tag_audio_events: typing.Optional[bool] = OMIT, + num_speakers: typing.Optional[int] = OMIT, + timestamps_granularity: typing.Optional[SpeechToTextConvertRequestTimestampsGranularity] = OMIT, + diarize: typing.Optional[bool] = OMIT, + additional_formats: typing.Optional[AdditionalFormats] = OMIT, + file_format: typing.Optional[SpeechToTextConvertRequestFileFormat] = OMIT, + cloud_storage_url: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[SpeechToTextChunkResponseModel]: + """ + Transcribe an audio or video file. + + Parameters + ---------- + model_id : str + The ID of the model to use for transcription, currently only 'scribe_v1' and 'scribe_v1_experimental' are available. + + enable_logging : typing.Optional[bool] + When enable_logging is set to false zero retention mode will be used for the request. This will mean history features are unavailable for this request, including request stitching. Zero retention mode may only be used by enterprise customers. + + file : typing.Optional[core.File] + See core.File for more documentation + + language_code : typing.Optional[str] + An ISO-639-1 or ISO-639-3 language_code corresponding to the language of the audio file. Can sometimes improve transcription performance if known beforehand. Defaults to null, in this case the language is predicted automatically. + + tag_audio_events : typing.Optional[bool] + Whether to tag audio events like (laughter), (footsteps), etc. in the transcription. + + num_speakers : typing.Optional[int] + The maximum amount of speakers talking in the uploaded file. Can help with predicting who speaks when. The maximum amount of speakers that can be predicted is 32. Defaults to null, in this case the amount of speakers is set to the maximum value the model supports. + + timestamps_granularity : typing.Optional[SpeechToTextConvertRequestTimestampsGranularity] + The granularity of the timestamps in the transcription. 'word' provides word-level timestamps and 'character' provides character-level timestamps per word. + + diarize : typing.Optional[bool] + Whether to annotate which speaker is currently talking in the uploaded file. + + additional_formats : typing.Optional[AdditionalFormats] + A list of additional formats to export the transcript to. + + file_format : typing.Optional[SpeechToTextConvertRequestFileFormat] + The format of input audio. Options are 'pcm_s16le_16' or 'other' For `pcm_s16le_16`, the input audio must be 16-bit PCM at a 16kHz sample rate, single channel (mono), and little-endian byte order. Latency will be lower than with passing an encoded waveform. + + cloud_storage_url : typing.Optional[str] + The valid AWS S3, Cloudflare R2 or Google Cloud Storage URL of the file to transcribe. Exactly one of the file or cloud_storage_url parameters must be provided. The file must be a valid publicly accessible cloud storage URL. The file size must be less than 2GB. URL can be pre-signed. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[SpeechToTextChunkResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + "v1/speech-to-text", + base_url=self._client_wrapper.get_environment().base, + method="POST", + params={ + "enable_logging": enable_logging, + }, + data={ + "model_id": model_id, + "language_code": language_code, + "tag_audio_events": tag_audio_events, + "num_speakers": num_speakers, + "timestamps_granularity": timestamps_granularity, + "diarize": diarize, + "additional_formats": additional_formats, + "file_format": file_format, + "cloud_storage_url": cloud_storage_url, + }, + files={ + **({"file": file} if file is not None else {}), + }, + request_options=request_options, + omit=OMIT, + force_multipart=True, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + SpeechToTextChunkResponseModel, + construct_type( + type_=SpeechToTextChunkResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + +class AsyncRawSpeechToTextClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def convert( + self, + *, + model_id: str, + enable_logging: typing.Optional[bool] = None, + file: typing.Optional[core.File] = OMIT, + language_code: typing.Optional[str] = OMIT, + tag_audio_events: typing.Optional[bool] = OMIT, + num_speakers: typing.Optional[int] = OMIT, + timestamps_granularity: typing.Optional[SpeechToTextConvertRequestTimestampsGranularity] = OMIT, + diarize: typing.Optional[bool] = OMIT, + additional_formats: typing.Optional[AdditionalFormats] = OMIT, + file_format: typing.Optional[SpeechToTextConvertRequestFileFormat] = OMIT, + cloud_storage_url: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[SpeechToTextChunkResponseModel]: + """ + Transcribe an audio or video file. + + Parameters + ---------- + model_id : str + The ID of the model to use for transcription, currently only 'scribe_v1' and 'scribe_v1_experimental' are available. + + enable_logging : typing.Optional[bool] + When enable_logging is set to false zero retention mode will be used for the request. This will mean history features are unavailable for this request, including request stitching. Zero retention mode may only be used by enterprise customers. + + file : typing.Optional[core.File] + See core.File for more documentation + + language_code : typing.Optional[str] + An ISO-639-1 or ISO-639-3 language_code corresponding to the language of the audio file. Can sometimes improve transcription performance if known beforehand. Defaults to null, in this case the language is predicted automatically. + + tag_audio_events : typing.Optional[bool] + Whether to tag audio events like (laughter), (footsteps), etc. in the transcription. + + num_speakers : typing.Optional[int] + The maximum amount of speakers talking in the uploaded file. Can help with predicting who speaks when. The maximum amount of speakers that can be predicted is 32. Defaults to null, in this case the amount of speakers is set to the maximum value the model supports. + + timestamps_granularity : typing.Optional[SpeechToTextConvertRequestTimestampsGranularity] + The granularity of the timestamps in the transcription. 'word' provides word-level timestamps and 'character' provides character-level timestamps per word. + + diarize : typing.Optional[bool] + Whether to annotate which speaker is currently talking in the uploaded file. + + additional_formats : typing.Optional[AdditionalFormats] + A list of additional formats to export the transcript to. + + file_format : typing.Optional[SpeechToTextConvertRequestFileFormat] + The format of input audio. Options are 'pcm_s16le_16' or 'other' For `pcm_s16le_16`, the input audio must be 16-bit PCM at a 16kHz sample rate, single channel (mono), and little-endian byte order. Latency will be lower than with passing an encoded waveform. + + cloud_storage_url : typing.Optional[str] + The valid AWS S3, Cloudflare R2 or Google Cloud Storage URL of the file to transcribe. Exactly one of the file or cloud_storage_url parameters must be provided. The file must be a valid publicly accessible cloud storage URL. The file size must be less than 2GB. URL can be pre-signed. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[SpeechToTextChunkResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + "v1/speech-to-text", + base_url=self._client_wrapper.get_environment().base, + method="POST", + params={ + "enable_logging": enable_logging, + }, + data={ + "model_id": model_id, + "language_code": language_code, + "tag_audio_events": tag_audio_events, + "num_speakers": num_speakers, + "timestamps_granularity": timestamps_granularity, + "diarize": diarize, + "additional_formats": additional_formats, + "file_format": file_format, + "cloud_storage_url": cloud_storage_url, + }, + files={ + **({"file": file} if file is not None else {}), + }, + request_options=request_options, + omit=OMIT, + force_multipart=True, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + SpeechToTextChunkResponseModel, + construct_type( + type_=SpeechToTextChunkResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/elevenlabs/speech_to_text/types/__init__.py b/src/elevenlabs/speech_to_text/types/__init__.py index ddb777a1..6601472c 100644 --- a/src/elevenlabs/speech_to_text/types/__init__.py +++ b/src/elevenlabs/speech_to_text/types/__init__.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# isort: skip_file + from .speech_to_text_convert_request_file_format import SpeechToTextConvertRequestFileFormat from .speech_to_text_convert_request_timestamps_granularity import SpeechToTextConvertRequestTimestampsGranularity diff --git a/src/elevenlabs/studio/__init__.py b/src/elevenlabs/studio/__init__.py index 62091720..ac1d347a 100644 --- a/src/elevenlabs/studio/__init__.py +++ b/src/elevenlabs/studio/__init__.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# isort: skip_file + from .types import ( BodyCreatePodcastV1StudioPodcastsPostDurationScale, BodyCreatePodcastV1StudioPodcastsPostMode, @@ -11,12 +13,12 @@ BodyCreatePodcastV1StudioPodcastsPostSourceItem_Text, BodyCreatePodcastV1StudioPodcastsPostSourceItem_Url, ) -from . import chapters, projects +from . import projects from .projects import ( - ProjectsAddRequestApplyTextNormalization, - ProjectsAddRequestFiction, - ProjectsAddRequestSourceType, - ProjectsAddRequestTargetAudience, + ProjectsCreateRequestApplyTextNormalization, + ProjectsCreateRequestFiction, + ProjectsCreateRequestSourceType, + ProjectsCreateRequestTargetAudience, ) __all__ = [ @@ -29,10 +31,9 @@ "BodyCreatePodcastV1StudioPodcastsPostSourceItem", "BodyCreatePodcastV1StudioPodcastsPostSourceItem_Text", "BodyCreatePodcastV1StudioPodcastsPostSourceItem_Url", - "ProjectsAddRequestApplyTextNormalization", - "ProjectsAddRequestFiction", - "ProjectsAddRequestSourceType", - "ProjectsAddRequestTargetAudience", - "chapters", + "ProjectsCreateRequestApplyTextNormalization", + "ProjectsCreateRequestFiction", + "ProjectsCreateRequestSourceType", + "ProjectsCreateRequestTargetAudience", "projects", ] diff --git a/src/elevenlabs/studio/chapters/client.py b/src/elevenlabs/studio/chapters/client.py deleted file mode 100644 index eb36a4dd..00000000 --- a/src/elevenlabs/studio/chapters/client.py +++ /dev/null @@ -1,1391 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import typing -from ...core.client_wrapper import SyncClientWrapper -from ...core.request_options import RequestOptions -from ...types.get_chapters_response import GetChaptersResponse -from ...core.jsonable_encoder import jsonable_encoder -from ...core.unchecked_base_model import construct_type -from ...errors.unprocessable_entity_error import UnprocessableEntityError -from ...types.http_validation_error import HttpValidationError -from json.decoder import JSONDecodeError -from ...core.api_error import ApiError -from ...types.add_chapter_response_model import AddChapterResponseModel -from ...types.chapter_with_content_response_model import ChapterWithContentResponseModel -from ...types.chapter_content_input_model import ChapterContentInputModel -from ...types.edit_chapter_response_model import EditChapterResponseModel -from ...core.serialization import convert_and_respect_annotation_metadata -from ...types.delete_chapter_response_model import DeleteChapterResponseModel -from ...types.convert_chapter_response_model import ConvertChapterResponseModel -from ...types.chapter_snapshots_response import ChapterSnapshotsResponse -from ...types.chapter_snapshot_extended_response_model import ( - ChapterSnapshotExtendedResponseModel, -) -from ...core.client_wrapper import AsyncClientWrapper - -# this is used as the default value for optional parameters -OMIT = typing.cast(typing.Any, ...) - - -class ChaptersClient: - def __init__(self, *, client_wrapper: SyncClientWrapper): - self._client_wrapper = client_wrapper - - def get_all( - self, - project_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, - ) -> GetChaptersResponse: - """ - Returns a list of a Studio project's chapters. - - Parameters - ---------- - project_id : str - The ID of the Studio project. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - GetChaptersResponse - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.studio.chapters.get_all( - project_id="21m00Tcm4TlvDq8ikWAM", - ) - """ - _response = self._client_wrapper.httpx_client.request( - f"v1/studio/projects/{jsonable_encoder(project_id)}/chapters", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - GetChaptersResponse, - construct_type( - type_=GetChaptersResponse, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def create( - self, - project_id: str, - *, - name: str, - from_url: typing.Optional[str] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> AddChapterResponseModel: - """ - Creates a new chapter either as blank or from a URL. - - Parameters - ---------- - project_id : str - The ID of the Studio project. - - name : str - The name of the chapter, used for identification only. - - from_url : typing.Optional[str] - An optional URL from which we will extract content to initialize the Studio project. If this is set, 'from_url' must be null. If neither 'from_url' or 'from_document' are provided we will initialize the Studio project as blank. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - AddChapterResponseModel - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.studio.chapters.create( - project_id="21m00Tcm4TlvDq8ikWAM", - name="Chapter 1", - ) - """ - _response = self._client_wrapper.httpx_client.request( - f"v1/studio/projects/{jsonable_encoder(project_id)}/chapters", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "name": name, - "from_url": from_url, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - AddChapterResponseModel, - construct_type( - type_=AddChapterResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def get( - self, - project_id: str, - chapter_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, - ) -> ChapterWithContentResponseModel: - """ - Returns information about a specific chapter. - - Parameters - ---------- - project_id : str - The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. - - chapter_id : str - The ID of the chapter to be used. You can use the [List project chapters](/docs/api-reference/studio/get-chapters) endpoint to list all the available chapters. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - ChapterWithContentResponseModel - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.studio.chapters.get( - project_id="21m00Tcm4TlvDq8ikWAM", - chapter_id="21m00Tcm4TlvDq8ikWAM", - ) - """ - _response = self._client_wrapper.httpx_client.request( - f"v1/studio/projects/{jsonable_encoder(project_id)}/chapters/{jsonable_encoder(chapter_id)}", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ChapterWithContentResponseModel, - construct_type( - type_=ChapterWithContentResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def edit( - self, - project_id: str, - chapter_id: str, - *, - name: typing.Optional[str] = OMIT, - content: typing.Optional[ChapterContentInputModel] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> EditChapterResponseModel: - """ - Updates a chapter. - - Parameters - ---------- - project_id : str - The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. - - chapter_id : str - The ID of the chapter to be used. You can use the [List project chapters](/docs/api-reference/studio/get-chapters) endpoint to list all the available chapters. - - name : typing.Optional[str] - The name of the chapter, used for identification only. - - content : typing.Optional[ChapterContentInputModel] - The chapter content to use. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - EditChapterResponseModel - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.studio.chapters.edit( - project_id="21m00Tcm4TlvDq8ikWAM", - chapter_id="21m00Tcm4TlvDq8ikWAM", - ) - """ - _response = self._client_wrapper.httpx_client.request( - f"v1/studio/projects/{jsonable_encoder(project_id)}/chapters/{jsonable_encoder(chapter_id)}", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "name": name, - "content": convert_and_respect_annotation_metadata( - object_=content, - annotation=ChapterContentInputModel, - direction="write", - ), - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - EditChapterResponseModel, - construct_type( - type_=EditChapterResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def delete( - self, - project_id: str, - chapter_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, - ) -> DeleteChapterResponseModel: - """ - Deletes a chapter. - - Parameters - ---------- - project_id : str - The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. - - chapter_id : str - The ID of the chapter to be used. You can use the [List project chapters](/docs/api-reference/studio/get-chapters) endpoint to list all the available chapters. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - DeleteChapterResponseModel - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.studio.chapters.delete( - project_id="21m00Tcm4TlvDq8ikWAM", - chapter_id="21m00Tcm4TlvDq8ikWAM", - ) - """ - _response = self._client_wrapper.httpx_client.request( - f"v1/studio/projects/{jsonable_encoder(project_id)}/chapters/{jsonable_encoder(chapter_id)}", - base_url=self._client_wrapper.get_environment().base, - method="DELETE", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - DeleteChapterResponseModel, - construct_type( - type_=DeleteChapterResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def convert( - self, - project_id: str, - chapter_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, - ) -> ConvertChapterResponseModel: - """ - Starts conversion of a specific chapter. - - Parameters - ---------- - project_id : str - The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. - - chapter_id : str - The ID of the chapter to be used. You can use the [List project chapters](/docs/api-reference/studio/get-chapters) endpoint to list all the available chapters. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - ConvertChapterResponseModel - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.studio.chapters.convert( - project_id="21m00Tcm4TlvDq8ikWAM", - chapter_id="21m00Tcm4TlvDq8ikWAM", - ) - """ - _response = self._client_wrapper.httpx_client.request( - f"v1/studio/projects/{jsonable_encoder(project_id)}/chapters/{jsonable_encoder(chapter_id)}/convert", - base_url=self._client_wrapper.get_environment().base, - method="POST", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ConvertChapterResponseModel, - construct_type( - type_=ConvertChapterResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def get_all_snapshots( - self, - project_id: str, - chapter_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, - ) -> ChapterSnapshotsResponse: - """ - Gets information about all the snapshots of a chapter. Each snapshot can be downloaded as audio. Whenever a chapter is converted a snapshot will automatically be created. - - Parameters - ---------- - project_id : str - The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. - - chapter_id : str - The ID of the chapter to be used. You can use the [List project chapters](/docs/api-reference/studio/get-chapters) endpoint to list all the available chapters. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - ChapterSnapshotsResponse - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.studio.chapters.get_all_snapshots( - project_id="21m00Tcm4TlvDq8ikWAM", - chapter_id="21m00Tcm4TlvDq8ikWAM", - ) - """ - _response = self._client_wrapper.httpx_client.request( - f"v1/studio/projects/{jsonable_encoder(project_id)}/chapters/{jsonable_encoder(chapter_id)}/snapshots", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ChapterSnapshotsResponse, - construct_type( - type_=ChapterSnapshotsResponse, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def get_chapter_snapshot( - self, - project_id: str, - chapter_id: str, - chapter_snapshot_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, - ) -> ChapterSnapshotExtendedResponseModel: - """ - Returns the chapter snapshot. - - Parameters - ---------- - project_id : str - The ID of the Studio project. - - chapter_id : str - The ID of the chapter. - - chapter_snapshot_id : str - The ID of the chapter snapshot. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - ChapterSnapshotExtendedResponseModel - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.studio.chapters.get_chapter_snapshot( - project_id="21m00Tcm4TlvDq8ikWAM", - chapter_id="21m00Tcm4TlvDq8ikWAM", - chapter_snapshot_id="21m00Tcm4TlvDq8ikWAM", - ) - """ - _response = self._client_wrapper.httpx_client.request( - f"v1/studio/projects/{jsonable_encoder(project_id)}/chapters/{jsonable_encoder(chapter_id)}/snapshots/{jsonable_encoder(chapter_snapshot_id)}", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ChapterSnapshotExtendedResponseModel, - construct_type( - type_=ChapterSnapshotExtendedResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def stream_snapshot( - self, - project_id: str, - chapter_id: str, - chapter_snapshot_id: str, - *, - convert_to_mpeg: typing.Optional[bool] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> typing.Iterator[bytes]: - """ - Stream the audio from a chapter snapshot. Use `GET /v1/studio/projects/{project_id}/chapters/{chapter_id}/snapshots` to return the snapshots of a chapter. - - Parameters - ---------- - project_id : str - The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. - - chapter_id : str - The ID of the chapter to be used. You can use the [List project chapters](/docs/api-reference/studio/get-chapters) endpoint to list all the available chapters. - - chapter_snapshot_id : str - The ID of the chapter snapshot to be used. You can use the [List project chapter snapshots](/docs/api-reference/studio/get-snapshots) endpoint to list all the available snapshots. - - convert_to_mpeg : typing.Optional[bool] - Whether to convert the audio to mpeg format. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. - - Yields - ------ - typing.Iterator[bytes] - Streaming audio data - """ - with self._client_wrapper.httpx_client.stream( - f"v1/studio/projects/{jsonable_encoder(project_id)}/chapters/{jsonable_encoder(chapter_id)}/snapshots/{jsonable_encoder(chapter_snapshot_id)}/stream", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "convert_to_mpeg": convert_to_mpeg, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) as _response: - try: - if 200 <= _response.status_code < 300: - _chunk_size = request_options.get("chunk_size", 1024) if request_options is not None else 1024 - for _chunk in _response.iter_bytes(chunk_size=_chunk_size): - yield _chunk - return - _response.read() - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - -class AsyncChaptersClient: - def __init__(self, *, client_wrapper: AsyncClientWrapper): - self._client_wrapper = client_wrapper - - async def get_all( - self, - project_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, - ) -> GetChaptersResponse: - """ - Returns a list of a Studio project's chapters. - - Parameters - ---------- - project_id : str - The ID of the Studio project. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - GetChaptersResponse - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.studio.chapters.get_all( - project_id="21m00Tcm4TlvDq8ikWAM", - ) - - - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/studio/projects/{jsonable_encoder(project_id)}/chapters", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - GetChaptersResponse, - construct_type( - type_=GetChaptersResponse, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def create( - self, - project_id: str, - *, - name: str, - from_url: typing.Optional[str] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> AddChapterResponseModel: - """ - Creates a new chapter either as blank or from a URL. - - Parameters - ---------- - project_id : str - The ID of the Studio project. - - name : str - The name of the chapter, used for identification only. - - from_url : typing.Optional[str] - An optional URL from which we will extract content to initialize the Studio project. If this is set, 'from_url' must be null. If neither 'from_url' or 'from_document' are provided we will initialize the Studio project as blank. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - AddChapterResponseModel - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.studio.chapters.create( - project_id="21m00Tcm4TlvDq8ikWAM", - name="Chapter 1", - ) - - - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/studio/projects/{jsonable_encoder(project_id)}/chapters", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "name": name, - "from_url": from_url, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - AddChapterResponseModel, - construct_type( - type_=AddChapterResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def get( - self, - project_id: str, - chapter_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, - ) -> ChapterWithContentResponseModel: - """ - Returns information about a specific chapter. - - Parameters - ---------- - project_id : str - The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. - - chapter_id : str - The ID of the chapter to be used. You can use the [List project chapters](/docs/api-reference/studio/get-chapters) endpoint to list all the available chapters. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - ChapterWithContentResponseModel - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.studio.chapters.get( - project_id="21m00Tcm4TlvDq8ikWAM", - chapter_id="21m00Tcm4TlvDq8ikWAM", - ) - - - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/studio/projects/{jsonable_encoder(project_id)}/chapters/{jsonable_encoder(chapter_id)}", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ChapterWithContentResponseModel, - construct_type( - type_=ChapterWithContentResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def edit( - self, - project_id: str, - chapter_id: str, - *, - name: typing.Optional[str] = OMIT, - content: typing.Optional[ChapterContentInputModel] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> EditChapterResponseModel: - """ - Updates a chapter. - - Parameters - ---------- - project_id : str - The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. - - chapter_id : str - The ID of the chapter to be used. You can use the [List project chapters](/docs/api-reference/studio/get-chapters) endpoint to list all the available chapters. - - name : typing.Optional[str] - The name of the chapter, used for identification only. - - content : typing.Optional[ChapterContentInputModel] - The chapter content to use. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - EditChapterResponseModel - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.studio.chapters.edit( - project_id="21m00Tcm4TlvDq8ikWAM", - chapter_id="21m00Tcm4TlvDq8ikWAM", - ) - - - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/studio/projects/{jsonable_encoder(project_id)}/chapters/{jsonable_encoder(chapter_id)}", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "name": name, - "content": convert_and_respect_annotation_metadata( - object_=content, - annotation=ChapterContentInputModel, - direction="write", - ), - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - EditChapterResponseModel, - construct_type( - type_=EditChapterResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def delete( - self, - project_id: str, - chapter_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, - ) -> DeleteChapterResponseModel: - """ - Deletes a chapter. - - Parameters - ---------- - project_id : str - The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. - - chapter_id : str - The ID of the chapter to be used. You can use the [List project chapters](/docs/api-reference/studio/get-chapters) endpoint to list all the available chapters. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - DeleteChapterResponseModel - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.studio.chapters.delete( - project_id="21m00Tcm4TlvDq8ikWAM", - chapter_id="21m00Tcm4TlvDq8ikWAM", - ) - - - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/studio/projects/{jsonable_encoder(project_id)}/chapters/{jsonable_encoder(chapter_id)}", - base_url=self._client_wrapper.get_environment().base, - method="DELETE", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - DeleteChapterResponseModel, - construct_type( - type_=DeleteChapterResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def convert( - self, - project_id: str, - chapter_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, - ) -> ConvertChapterResponseModel: - """ - Starts conversion of a specific chapter. - - Parameters - ---------- - project_id : str - The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. - - chapter_id : str - The ID of the chapter to be used. You can use the [List project chapters](/docs/api-reference/studio/get-chapters) endpoint to list all the available chapters. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - ConvertChapterResponseModel - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.studio.chapters.convert( - project_id="21m00Tcm4TlvDq8ikWAM", - chapter_id="21m00Tcm4TlvDq8ikWAM", - ) - - - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/studio/projects/{jsonable_encoder(project_id)}/chapters/{jsonable_encoder(chapter_id)}/convert", - base_url=self._client_wrapper.get_environment().base, - method="POST", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ConvertChapterResponseModel, - construct_type( - type_=ConvertChapterResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def get_all_snapshots( - self, - project_id: str, - chapter_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, - ) -> ChapterSnapshotsResponse: - """ - Gets information about all the snapshots of a chapter. Each snapshot can be downloaded as audio. Whenever a chapter is converted a snapshot will automatically be created. - - Parameters - ---------- - project_id : str - The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. - - chapter_id : str - The ID of the chapter to be used. You can use the [List project chapters](/docs/api-reference/studio/get-chapters) endpoint to list all the available chapters. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - ChapterSnapshotsResponse - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.studio.chapters.get_all_snapshots( - project_id="21m00Tcm4TlvDq8ikWAM", - chapter_id="21m00Tcm4TlvDq8ikWAM", - ) - - - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/studio/projects/{jsonable_encoder(project_id)}/chapters/{jsonable_encoder(chapter_id)}/snapshots", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ChapterSnapshotsResponse, - construct_type( - type_=ChapterSnapshotsResponse, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def get_chapter_snapshot( - self, - project_id: str, - chapter_id: str, - chapter_snapshot_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, - ) -> ChapterSnapshotExtendedResponseModel: - """ - Returns the chapter snapshot. - - Parameters - ---------- - project_id : str - The ID of the Studio project. - - chapter_id : str - The ID of the chapter. - - chapter_snapshot_id : str - The ID of the chapter snapshot. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - ChapterSnapshotExtendedResponseModel - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.studio.chapters.get_chapter_snapshot( - project_id="21m00Tcm4TlvDq8ikWAM", - chapter_id="21m00Tcm4TlvDq8ikWAM", - chapter_snapshot_id="21m00Tcm4TlvDq8ikWAM", - ) - - - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/studio/projects/{jsonable_encoder(project_id)}/chapters/{jsonable_encoder(chapter_id)}/snapshots/{jsonable_encoder(chapter_snapshot_id)}", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ChapterSnapshotExtendedResponseModel, - construct_type( - type_=ChapterSnapshotExtendedResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def stream_snapshot( - self, - project_id: str, - chapter_id: str, - chapter_snapshot_id: str, - *, - convert_to_mpeg: typing.Optional[bool] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> typing.AsyncIterator[bytes]: - """ - Stream the audio from a chapter snapshot. Use `GET /v1/studio/projects/{project_id}/chapters/{chapter_id}/snapshots` to return the snapshots of a chapter. - - Parameters - ---------- - project_id : str - The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. - - chapter_id : str - The ID of the chapter to be used. You can use the [List project chapters](/docs/api-reference/studio/get-chapters) endpoint to list all the available chapters. - - chapter_snapshot_id : str - The ID of the chapter snapshot to be used. You can use the [List project chapter snapshots](/docs/api-reference/studio/get-snapshots) endpoint to list all the available snapshots. - - convert_to_mpeg : typing.Optional[bool] - Whether to convert the audio to mpeg format. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. - - Yields - ------ - typing.AsyncIterator[bytes] - Streaming audio data - """ - async with self._client_wrapper.httpx_client.stream( - f"v1/studio/projects/{jsonable_encoder(project_id)}/chapters/{jsonable_encoder(chapter_id)}/snapshots/{jsonable_encoder(chapter_snapshot_id)}/stream", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "convert_to_mpeg": convert_to_mpeg, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) as _response: - try: - if 200 <= _response.status_code < 300: - _chunk_size = request_options.get("chunk_size", 1024) if request_options is not None else 1024 - async for _chunk in _response.aiter_bytes(chunk_size=_chunk_size): - yield _chunk - return - await _response.aread() - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) diff --git a/src/elevenlabs/studio/client.py b/src/elevenlabs/studio/client.py index bc231ef1..81f7ba22 100644 --- a/src/elevenlabs/studio/client.py +++ b/src/elevenlabs/studio/client.py @@ -1,32 +1,20 @@ # This file was auto-generated by Fern from our API Definition. import typing -from ..core.client_wrapper import SyncClientWrapper -from .projects.client import ProjectsClient -from .chapters.client import ChaptersClient -from .types.body_create_podcast_v_1_studio_podcasts_post_mode import ( - BodyCreatePodcastV1StudioPodcastsPostMode, -) -from .types.body_create_podcast_v_1_studio_podcasts_post_source import ( - BodyCreatePodcastV1StudioPodcastsPostSource, + +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ..core.request_options import RequestOptions +from ..types.podcast_project_response_model import PodcastProjectResponseModel +from .projects.client import AsyncProjectsClient, ProjectsClient +from .raw_client import AsyncRawStudioClient, RawStudioClient +from .types.body_create_podcast_v_1_studio_podcasts_post_duration_scale import ( + BodyCreatePodcastV1StudioPodcastsPostDurationScale, ) +from .types.body_create_podcast_v_1_studio_podcasts_post_mode import BodyCreatePodcastV1StudioPodcastsPostMode from .types.body_create_podcast_v_1_studio_podcasts_post_quality_preset import ( BodyCreatePodcastV1StudioPodcastsPostQualityPreset, ) -from .types.body_create_podcast_v_1_studio_podcasts_post_duration_scale import ( - BodyCreatePodcastV1StudioPodcastsPostDurationScale, -) -from ..core.request_options import RequestOptions -from ..types.podcast_project_response_model import PodcastProjectResponseModel -from ..core.serialization import convert_and_respect_annotation_metadata -from ..core.unchecked_base_model import construct_type -from ..errors.unprocessable_entity_error import UnprocessableEntityError -from ..types.http_validation_error import HttpValidationError -from json.decoder import JSONDecodeError -from ..core.api_error import ApiError -from ..core.client_wrapper import AsyncClientWrapper -from .projects.client import AsyncProjectsClient -from .chapters.client import AsyncChaptersClient +from .types.body_create_podcast_v_1_studio_podcasts_post_source import BodyCreatePodcastV1StudioPodcastsPostSource # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -34,9 +22,19 @@ class StudioClient: def __init__(self, *, client_wrapper: SyncClientWrapper): - self._client_wrapper = client_wrapper - self.projects = ProjectsClient(client_wrapper=self._client_wrapper) - self.chapters = ChaptersClient(client_wrapper=self._client_wrapper) + self._raw_client = RawStudioClient(client_wrapper=client_wrapper) + self.projects = ProjectsClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawStudioClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawStudioClient + """ + return self._raw_client def create_podcast( self, @@ -122,64 +120,35 @@ def create_podcast( ), ) """ - _response = self._client_wrapper.httpx_client.request( - "v1/studio/podcasts", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "model_id": model_id, - "mode": convert_and_respect_annotation_metadata( - object_=mode, - annotation=BodyCreatePodcastV1StudioPodcastsPostMode, - direction="write", - ), - "source": convert_and_respect_annotation_metadata( - object_=source, - annotation=BodyCreatePodcastV1StudioPodcastsPostSource, - direction="write", - ), - "quality_preset": quality_preset, - "duration_scale": duration_scale, - "language": language, - "highlights": highlights, - "callback_url": callback_url, - }, - headers={ - "content-type": "application/json", - }, + _response = self._raw_client.create_podcast( + model_id=model_id, + mode=mode, + source=source, + quality_preset=quality_preset, + duration_scale=duration_scale, + language=language, + highlights=highlights, + callback_url=callback_url, request_options=request_options, - omit=OMIT, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - PodcastProjectResponseModel, - construct_type( - type_=PodcastProjectResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + return _response.data class AsyncStudioClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): - self._client_wrapper = client_wrapper - self.projects = AsyncProjectsClient(client_wrapper=self._client_wrapper) - self.chapters = AsyncChaptersClient(client_wrapper=self._client_wrapper) + self._raw_client = AsyncRawStudioClient(client_wrapper=client_wrapper) + self.projects = AsyncProjectsClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawStudioClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawStudioClient + """ + return self._raw_client async def create_podcast( self, @@ -273,54 +242,15 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - "v1/studio/podcasts", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "model_id": model_id, - "mode": convert_and_respect_annotation_metadata( - object_=mode, - annotation=BodyCreatePodcastV1StudioPodcastsPostMode, - direction="write", - ), - "source": convert_and_respect_annotation_metadata( - object_=source, - annotation=BodyCreatePodcastV1StudioPodcastsPostSource, - direction="write", - ), - "quality_preset": quality_preset, - "duration_scale": duration_scale, - "language": language, - "highlights": highlights, - "callback_url": callback_url, - }, - headers={ - "content-type": "application/json", - }, + _response = await self._raw_client.create_podcast( + model_id=model_id, + mode=mode, + source=source, + quality_preset=quality_preset, + duration_scale=duration_scale, + language=language, + highlights=highlights, + callback_url=callback_url, request_options=request_options, - omit=OMIT, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - PodcastProjectResponseModel, - construct_type( - type_=PodcastProjectResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + return _response.data diff --git a/src/elevenlabs/studio/projects/__init__.py b/src/elevenlabs/studio/projects/__init__.py index 01f0386d..7618a0f3 100644 --- a/src/elevenlabs/studio/projects/__init__.py +++ b/src/elevenlabs/studio/projects/__init__.py @@ -1,15 +1,22 @@ # This file was auto-generated by Fern from our API Definition. +# isort: skip_file + from .types import ( - ProjectsAddRequestApplyTextNormalization, - ProjectsAddRequestFiction, - ProjectsAddRequestSourceType, - ProjectsAddRequestTargetAudience, + ProjectsCreateRequestApplyTextNormalization, + ProjectsCreateRequestFiction, + ProjectsCreateRequestSourceType, + ProjectsCreateRequestTargetAudience, ) +from . import chapters, content, pronunciation_dictionaries, snapshots __all__ = [ - "ProjectsAddRequestApplyTextNormalization", - "ProjectsAddRequestFiction", - "ProjectsAddRequestSourceType", - "ProjectsAddRequestTargetAudience", + "ProjectsCreateRequestApplyTextNormalization", + "ProjectsCreateRequestFiction", + "ProjectsCreateRequestSourceType", + "ProjectsCreateRequestTargetAudience", + "chapters", + "content", + "pronunciation_dictionaries", + "snapshots", ] diff --git a/src/elevenlabs/studio/projects/chapters/__init__.py b/src/elevenlabs/studio/projects/chapters/__init__.py new file mode 100644 index 00000000..fa184e74 --- /dev/null +++ b/src/elevenlabs/studio/projects/chapters/__init__.py @@ -0,0 +1,7 @@ +# This file was auto-generated by Fern from our API Definition. + +# isort: skip_file + +from . import snapshots + +__all__ = ["snapshots"] diff --git a/src/elevenlabs/studio/projects/chapters/client.py b/src/elevenlabs/studio/projects/chapters/client.py new file mode 100644 index 00000000..e99d867a --- /dev/null +++ b/src/elevenlabs/studio/projects/chapters/client.py @@ -0,0 +1,580 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +from ....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ....core.request_options import RequestOptions +from ....types.add_chapter_response_model import AddChapterResponseModel +from ....types.chapter_content_input_model import ChapterContentInputModel +from ....types.chapter_with_content_response_model import ChapterWithContentResponseModel +from ....types.convert_chapter_response_model import ConvertChapterResponseModel +from ....types.delete_chapter_response_model import DeleteChapterResponseModel +from ....types.edit_chapter_response_model import EditChapterResponseModel +from ....types.get_chapters_response import GetChaptersResponse +from .raw_client import AsyncRawChaptersClient, RawChaptersClient +from .snapshots.client import AsyncSnapshotsClient, SnapshotsClient + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class ChaptersClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._raw_client = RawChaptersClient(client_wrapper=client_wrapper) + self.snapshots = SnapshotsClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawChaptersClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawChaptersClient + """ + return self._raw_client + + def list(self, project_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> GetChaptersResponse: + """ + Returns a list of a Studio project's chapters. + + Parameters + ---------- + project_id : str + The ID of the Studio project. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + GetChaptersResponse + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.studio.projects.chapters.list( + project_id="21m00Tcm4TlvDq8ikWAM", + ) + """ + _response = self._raw_client.list(project_id, request_options=request_options) + return _response.data + + def create( + self, + project_id: str, + *, + name: str, + from_url: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AddChapterResponseModel: + """ + Creates a new chapter either as blank or from a URL. + + Parameters + ---------- + project_id : str + The ID of the Studio project. + + name : str + The name of the chapter, used for identification only. + + from_url : typing.Optional[str] + An optional URL from which we will extract content to initialize the Studio project. If this is set, 'from_url' must be null. If neither 'from_url' or 'from_document' are provided we will initialize the Studio project as blank. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AddChapterResponseModel + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.studio.projects.chapters.create( + project_id="21m00Tcm4TlvDq8ikWAM", + name="Chapter 1", + ) + """ + _response = self._raw_client.create(project_id, name=name, from_url=from_url, request_options=request_options) + return _response.data + + def get( + self, project_id: str, chapter_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> ChapterWithContentResponseModel: + """ + Returns information about a specific chapter. + + Parameters + ---------- + project_id : str + The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. + + chapter_id : str + The ID of the chapter to be used. You can use the [List project chapters](/docs/api-reference/studio/get-chapters) endpoint to list all the available chapters. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ChapterWithContentResponseModel + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.studio.projects.chapters.get( + project_id="21m00Tcm4TlvDq8ikWAM", + chapter_id="21m00Tcm4TlvDq8ikWAM", + ) + """ + _response = self._raw_client.get(project_id, chapter_id, request_options=request_options) + return _response.data + + def update( + self, + project_id: str, + chapter_id: str, + *, + name: typing.Optional[str] = OMIT, + content: typing.Optional[ChapterContentInputModel] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> EditChapterResponseModel: + """ + Updates a chapter. + + Parameters + ---------- + project_id : str + The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. + + chapter_id : str + The ID of the chapter to be used. You can use the [List project chapters](/docs/api-reference/studio/get-chapters) endpoint to list all the available chapters. + + name : typing.Optional[str] + The name of the chapter, used for identification only. + + content : typing.Optional[ChapterContentInputModel] + The chapter content to use. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + EditChapterResponseModel + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.studio.projects.chapters.update( + project_id="21m00Tcm4TlvDq8ikWAM", + chapter_id="21m00Tcm4TlvDq8ikWAM", + ) + """ + _response = self._raw_client.update( + project_id, chapter_id, name=name, content=content, request_options=request_options + ) + return _response.data + + def delete( + self, project_id: str, chapter_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> DeleteChapterResponseModel: + """ + Deletes a chapter. + + Parameters + ---------- + project_id : str + The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. + + chapter_id : str + The ID of the chapter to be used. You can use the [List project chapters](/docs/api-reference/studio/get-chapters) endpoint to list all the available chapters. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + DeleteChapterResponseModel + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.studio.projects.chapters.delete( + project_id="21m00Tcm4TlvDq8ikWAM", + chapter_id="21m00Tcm4TlvDq8ikWAM", + ) + """ + _response = self._raw_client.delete(project_id, chapter_id, request_options=request_options) + return _response.data + + def convert( + self, project_id: str, chapter_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> ConvertChapterResponseModel: + """ + Starts conversion of a specific chapter. + + Parameters + ---------- + project_id : str + The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. + + chapter_id : str + The ID of the chapter to be used. You can use the [List project chapters](/docs/api-reference/studio/get-chapters) endpoint to list all the available chapters. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ConvertChapterResponseModel + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.studio.projects.chapters.convert( + project_id="21m00Tcm4TlvDq8ikWAM", + chapter_id="21m00Tcm4TlvDq8ikWAM", + ) + """ + _response = self._raw_client.convert(project_id, chapter_id, request_options=request_options) + return _response.data + + +class AsyncChaptersClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawChaptersClient(client_wrapper=client_wrapper) + self.snapshots = AsyncSnapshotsClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawChaptersClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawChaptersClient + """ + return self._raw_client + + async def list( + self, project_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> GetChaptersResponse: + """ + Returns a list of a Studio project's chapters. + + Parameters + ---------- + project_id : str + The ID of the Studio project. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + GetChaptersResponse + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.studio.projects.chapters.list( + project_id="21m00Tcm4TlvDq8ikWAM", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.list(project_id, request_options=request_options) + return _response.data + + async def create( + self, + project_id: str, + *, + name: str, + from_url: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AddChapterResponseModel: + """ + Creates a new chapter either as blank or from a URL. + + Parameters + ---------- + project_id : str + The ID of the Studio project. + + name : str + The name of the chapter, used for identification only. + + from_url : typing.Optional[str] + An optional URL from which we will extract content to initialize the Studio project. If this is set, 'from_url' must be null. If neither 'from_url' or 'from_document' are provided we will initialize the Studio project as blank. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AddChapterResponseModel + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.studio.projects.chapters.create( + project_id="21m00Tcm4TlvDq8ikWAM", + name="Chapter 1", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.create( + project_id, name=name, from_url=from_url, request_options=request_options + ) + return _response.data + + async def get( + self, project_id: str, chapter_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> ChapterWithContentResponseModel: + """ + Returns information about a specific chapter. + + Parameters + ---------- + project_id : str + The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. + + chapter_id : str + The ID of the chapter to be used. You can use the [List project chapters](/docs/api-reference/studio/get-chapters) endpoint to list all the available chapters. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ChapterWithContentResponseModel + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.studio.projects.chapters.get( + project_id="21m00Tcm4TlvDq8ikWAM", + chapter_id="21m00Tcm4TlvDq8ikWAM", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.get(project_id, chapter_id, request_options=request_options) + return _response.data + + async def update( + self, + project_id: str, + chapter_id: str, + *, + name: typing.Optional[str] = OMIT, + content: typing.Optional[ChapterContentInputModel] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> EditChapterResponseModel: + """ + Updates a chapter. + + Parameters + ---------- + project_id : str + The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. + + chapter_id : str + The ID of the chapter to be used. You can use the [List project chapters](/docs/api-reference/studio/get-chapters) endpoint to list all the available chapters. + + name : typing.Optional[str] + The name of the chapter, used for identification only. + + content : typing.Optional[ChapterContentInputModel] + The chapter content to use. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + EditChapterResponseModel + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.studio.projects.chapters.update( + project_id="21m00Tcm4TlvDq8ikWAM", + chapter_id="21m00Tcm4TlvDq8ikWAM", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.update( + project_id, chapter_id, name=name, content=content, request_options=request_options + ) + return _response.data + + async def delete( + self, project_id: str, chapter_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> DeleteChapterResponseModel: + """ + Deletes a chapter. + + Parameters + ---------- + project_id : str + The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. + + chapter_id : str + The ID of the chapter to be used. You can use the [List project chapters](/docs/api-reference/studio/get-chapters) endpoint to list all the available chapters. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + DeleteChapterResponseModel + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.studio.projects.chapters.delete( + project_id="21m00Tcm4TlvDq8ikWAM", + chapter_id="21m00Tcm4TlvDq8ikWAM", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.delete(project_id, chapter_id, request_options=request_options) + return _response.data + + async def convert( + self, project_id: str, chapter_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> ConvertChapterResponseModel: + """ + Starts conversion of a specific chapter. + + Parameters + ---------- + project_id : str + The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. + + chapter_id : str + The ID of the chapter to be used. You can use the [List project chapters](/docs/api-reference/studio/get-chapters) endpoint to list all the available chapters. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ConvertChapterResponseModel + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.studio.projects.chapters.convert( + project_id="21m00Tcm4TlvDq8ikWAM", + chapter_id="21m00Tcm4TlvDq8ikWAM", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.convert(project_id, chapter_id, request_options=request_options) + return _response.data diff --git a/src/elevenlabs/studio/projects/chapters/raw_client.py b/src/elevenlabs/studio/projects/chapters/raw_client.py new file mode 100644 index 00000000..76d07862 --- /dev/null +++ b/src/elevenlabs/studio/projects/chapters/raw_client.py @@ -0,0 +1,752 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ....core.api_error import ApiError +from ....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ....core.http_response import AsyncHttpResponse, HttpResponse +from ....core.jsonable_encoder import jsonable_encoder +from ....core.request_options import RequestOptions +from ....core.serialization import convert_and_respect_annotation_metadata +from ....core.unchecked_base_model import construct_type +from ....errors.unprocessable_entity_error import UnprocessableEntityError +from ....types.add_chapter_response_model import AddChapterResponseModel +from ....types.chapter_content_input_model import ChapterContentInputModel +from ....types.chapter_with_content_response_model import ChapterWithContentResponseModel +from ....types.convert_chapter_response_model import ConvertChapterResponseModel +from ....types.delete_chapter_response_model import DeleteChapterResponseModel +from ....types.edit_chapter_response_model import EditChapterResponseModel +from ....types.get_chapters_response import GetChaptersResponse +from ....types.http_validation_error import HttpValidationError + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RawChaptersClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def list( + self, project_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[GetChaptersResponse]: + """ + Returns a list of a Studio project's chapters. + + Parameters + ---------- + project_id : str + The ID of the Studio project. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[GetChaptersResponse] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/studio/projects/{jsonable_encoder(project_id)}/chapters", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetChaptersResponse, + construct_type( + type_=GetChaptersResponse, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def create( + self, + project_id: str, + *, + name: str, + from_url: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[AddChapterResponseModel]: + """ + Creates a new chapter either as blank or from a URL. + + Parameters + ---------- + project_id : str + The ID of the Studio project. + + name : str + The name of the chapter, used for identification only. + + from_url : typing.Optional[str] + An optional URL from which we will extract content to initialize the Studio project. If this is set, 'from_url' must be null. If neither 'from_url' or 'from_document' are provided we will initialize the Studio project as blank. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[AddChapterResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/studio/projects/{jsonable_encoder(project_id)}/chapters", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "name": name, + "from_url": from_url, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + AddChapterResponseModel, + construct_type( + type_=AddChapterResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def get( + self, project_id: str, chapter_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[ChapterWithContentResponseModel]: + """ + Returns information about a specific chapter. + + Parameters + ---------- + project_id : str + The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. + + chapter_id : str + The ID of the chapter to be used. You can use the [List project chapters](/docs/api-reference/studio/get-chapters) endpoint to list all the available chapters. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[ChapterWithContentResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/studio/projects/{jsonable_encoder(project_id)}/chapters/{jsonable_encoder(chapter_id)}", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ChapterWithContentResponseModel, + construct_type( + type_=ChapterWithContentResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def update( + self, + project_id: str, + chapter_id: str, + *, + name: typing.Optional[str] = OMIT, + content: typing.Optional[ChapterContentInputModel] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[EditChapterResponseModel]: + """ + Updates a chapter. + + Parameters + ---------- + project_id : str + The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. + + chapter_id : str + The ID of the chapter to be used. You can use the [List project chapters](/docs/api-reference/studio/get-chapters) endpoint to list all the available chapters. + + name : typing.Optional[str] + The name of the chapter, used for identification only. + + content : typing.Optional[ChapterContentInputModel] + The chapter content to use. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[EditChapterResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/studio/projects/{jsonable_encoder(project_id)}/chapters/{jsonable_encoder(chapter_id)}", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "name": name, + "content": convert_and_respect_annotation_metadata( + object_=content, annotation=ChapterContentInputModel, direction="write" + ), + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + EditChapterResponseModel, + construct_type( + type_=EditChapterResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def delete( + self, project_id: str, chapter_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[DeleteChapterResponseModel]: + """ + Deletes a chapter. + + Parameters + ---------- + project_id : str + The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. + + chapter_id : str + The ID of the chapter to be used. You can use the [List project chapters](/docs/api-reference/studio/get-chapters) endpoint to list all the available chapters. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[DeleteChapterResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/studio/projects/{jsonable_encoder(project_id)}/chapters/{jsonable_encoder(chapter_id)}", + base_url=self._client_wrapper.get_environment().base, + method="DELETE", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + DeleteChapterResponseModel, + construct_type( + type_=DeleteChapterResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def convert( + self, project_id: str, chapter_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[ConvertChapterResponseModel]: + """ + Starts conversion of a specific chapter. + + Parameters + ---------- + project_id : str + The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. + + chapter_id : str + The ID of the chapter to be used. You can use the [List project chapters](/docs/api-reference/studio/get-chapters) endpoint to list all the available chapters. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[ConvertChapterResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/studio/projects/{jsonable_encoder(project_id)}/chapters/{jsonable_encoder(chapter_id)}/convert", + base_url=self._client_wrapper.get_environment().base, + method="POST", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ConvertChapterResponseModel, + construct_type( + type_=ConvertChapterResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + +class AsyncRawChaptersClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def list( + self, project_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[GetChaptersResponse]: + """ + Returns a list of a Studio project's chapters. + + Parameters + ---------- + project_id : str + The ID of the Studio project. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[GetChaptersResponse] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/studio/projects/{jsonable_encoder(project_id)}/chapters", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetChaptersResponse, + construct_type( + type_=GetChaptersResponse, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def create( + self, + project_id: str, + *, + name: str, + from_url: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[AddChapterResponseModel]: + """ + Creates a new chapter either as blank or from a URL. + + Parameters + ---------- + project_id : str + The ID of the Studio project. + + name : str + The name of the chapter, used for identification only. + + from_url : typing.Optional[str] + An optional URL from which we will extract content to initialize the Studio project. If this is set, 'from_url' must be null. If neither 'from_url' or 'from_document' are provided we will initialize the Studio project as blank. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[AddChapterResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/studio/projects/{jsonable_encoder(project_id)}/chapters", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "name": name, + "from_url": from_url, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + AddChapterResponseModel, + construct_type( + type_=AddChapterResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def get( + self, project_id: str, chapter_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[ChapterWithContentResponseModel]: + """ + Returns information about a specific chapter. + + Parameters + ---------- + project_id : str + The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. + + chapter_id : str + The ID of the chapter to be used. You can use the [List project chapters](/docs/api-reference/studio/get-chapters) endpoint to list all the available chapters. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[ChapterWithContentResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/studio/projects/{jsonable_encoder(project_id)}/chapters/{jsonable_encoder(chapter_id)}", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ChapterWithContentResponseModel, + construct_type( + type_=ChapterWithContentResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def update( + self, + project_id: str, + chapter_id: str, + *, + name: typing.Optional[str] = OMIT, + content: typing.Optional[ChapterContentInputModel] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[EditChapterResponseModel]: + """ + Updates a chapter. + + Parameters + ---------- + project_id : str + The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. + + chapter_id : str + The ID of the chapter to be used. You can use the [List project chapters](/docs/api-reference/studio/get-chapters) endpoint to list all the available chapters. + + name : typing.Optional[str] + The name of the chapter, used for identification only. + + content : typing.Optional[ChapterContentInputModel] + The chapter content to use. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[EditChapterResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/studio/projects/{jsonable_encoder(project_id)}/chapters/{jsonable_encoder(chapter_id)}", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "name": name, + "content": convert_and_respect_annotation_metadata( + object_=content, annotation=ChapterContentInputModel, direction="write" + ), + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + EditChapterResponseModel, + construct_type( + type_=EditChapterResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def delete( + self, project_id: str, chapter_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[DeleteChapterResponseModel]: + """ + Deletes a chapter. + + Parameters + ---------- + project_id : str + The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. + + chapter_id : str + The ID of the chapter to be used. You can use the [List project chapters](/docs/api-reference/studio/get-chapters) endpoint to list all the available chapters. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[DeleteChapterResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/studio/projects/{jsonable_encoder(project_id)}/chapters/{jsonable_encoder(chapter_id)}", + base_url=self._client_wrapper.get_environment().base, + method="DELETE", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + DeleteChapterResponseModel, + construct_type( + type_=DeleteChapterResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def convert( + self, project_id: str, chapter_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[ConvertChapterResponseModel]: + """ + Starts conversion of a specific chapter. + + Parameters + ---------- + project_id : str + The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. + + chapter_id : str + The ID of the chapter to be used. You can use the [List project chapters](/docs/api-reference/studio/get-chapters) endpoint to list all the available chapters. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[ConvertChapterResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/studio/projects/{jsonable_encoder(project_id)}/chapters/{jsonable_encoder(chapter_id)}/convert", + base_url=self._client_wrapper.get_environment().base, + method="POST", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ConvertChapterResponseModel, + construct_type( + type_=ConvertChapterResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/elevenlabs/studio/projects/chapters/snapshots/__init__.py b/src/elevenlabs/studio/projects/chapters/snapshots/__init__.py new file mode 100644 index 00000000..5cde0202 --- /dev/null +++ b/src/elevenlabs/studio/projects/chapters/snapshots/__init__.py @@ -0,0 +1,4 @@ +# This file was auto-generated by Fern from our API Definition. + +# isort: skip_file + diff --git a/src/elevenlabs/studio/projects/chapters/snapshots/client.py b/src/elevenlabs/studio/projects/chapters/snapshots/client.py new file mode 100644 index 00000000..4a657740 --- /dev/null +++ b/src/elevenlabs/studio/projects/chapters/snapshots/client.py @@ -0,0 +1,315 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +from .....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from .....core.request_options import RequestOptions +from .....types.chapter_snapshot_extended_response_model import ChapterSnapshotExtendedResponseModel +from .....types.chapter_snapshots_response import ChapterSnapshotsResponse +from .raw_client import AsyncRawSnapshotsClient, RawSnapshotsClient + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class SnapshotsClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._raw_client = RawSnapshotsClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawSnapshotsClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawSnapshotsClient + """ + return self._raw_client + + def list( + self, project_id: str, chapter_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> ChapterSnapshotsResponse: + """ + Gets information about all the snapshots of a chapter. Each snapshot can be downloaded as audio. Whenever a chapter is converted a snapshot will automatically be created. + + Parameters + ---------- + project_id : str + The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. + + chapter_id : str + The ID of the chapter to be used. You can use the [List project chapters](/docs/api-reference/studio/get-chapters) endpoint to list all the available chapters. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ChapterSnapshotsResponse + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.studio.projects.chapters.snapshots.list( + project_id="21m00Tcm4TlvDq8ikWAM", + chapter_id="21m00Tcm4TlvDq8ikWAM", + ) + """ + _response = self._raw_client.list(project_id, chapter_id, request_options=request_options) + return _response.data + + def get( + self, + project_id: str, + chapter_id: str, + chapter_snapshot_id: str, + *, + request_options: typing.Optional[RequestOptions] = None, + ) -> ChapterSnapshotExtendedResponseModel: + """ + Returns the chapter snapshot. + + Parameters + ---------- + project_id : str + The ID of the Studio project. + + chapter_id : str + The ID of the chapter. + + chapter_snapshot_id : str + The ID of the chapter snapshot. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ChapterSnapshotExtendedResponseModel + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.studio.projects.chapters.snapshots.get( + project_id="21m00Tcm4TlvDq8ikWAM", + chapter_id="21m00Tcm4TlvDq8ikWAM", + chapter_snapshot_id="21m00Tcm4TlvDq8ikWAM", + ) + """ + _response = self._raw_client.get(project_id, chapter_id, chapter_snapshot_id, request_options=request_options) + return _response.data + + def stream( + self, + project_id: str, + chapter_id: str, + chapter_snapshot_id: str, + *, + convert_to_mpeg: typing.Optional[bool] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> typing.Iterator[bytes]: + """ + Stream the audio from a chapter snapshot. Use `GET /v1/studio/projects/{project_id}/chapters/{chapter_id}/snapshots` to return the snapshots of a chapter. + + Parameters + ---------- + project_id : str + The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. + + chapter_id : str + The ID of the chapter to be used. You can use the [List project chapters](/docs/api-reference/studio/get-chapters) endpoint to list all the available chapters. + + chapter_snapshot_id : str + The ID of the chapter snapshot to be used. You can use the [List project chapter snapshots](/docs/api-reference/studio/get-snapshots) endpoint to list all the available snapshots. + + convert_to_mpeg : typing.Optional[bool] + Whether to convert the audio to mpeg format. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. + + Returns + ------- + typing.Iterator[bytes] + Streaming audio data + """ + with self._raw_client.stream( + project_id, + chapter_id, + chapter_snapshot_id, + convert_to_mpeg=convert_to_mpeg, + request_options=request_options, + ) as r: + yield from r.data + + +class AsyncSnapshotsClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawSnapshotsClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawSnapshotsClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawSnapshotsClient + """ + return self._raw_client + + async def list( + self, project_id: str, chapter_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> ChapterSnapshotsResponse: + """ + Gets information about all the snapshots of a chapter. Each snapshot can be downloaded as audio. Whenever a chapter is converted a snapshot will automatically be created. + + Parameters + ---------- + project_id : str + The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. + + chapter_id : str + The ID of the chapter to be used. You can use the [List project chapters](/docs/api-reference/studio/get-chapters) endpoint to list all the available chapters. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ChapterSnapshotsResponse + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.studio.projects.chapters.snapshots.list( + project_id="21m00Tcm4TlvDq8ikWAM", + chapter_id="21m00Tcm4TlvDq8ikWAM", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.list(project_id, chapter_id, request_options=request_options) + return _response.data + + async def get( + self, + project_id: str, + chapter_id: str, + chapter_snapshot_id: str, + *, + request_options: typing.Optional[RequestOptions] = None, + ) -> ChapterSnapshotExtendedResponseModel: + """ + Returns the chapter snapshot. + + Parameters + ---------- + project_id : str + The ID of the Studio project. + + chapter_id : str + The ID of the chapter. + + chapter_snapshot_id : str + The ID of the chapter snapshot. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ChapterSnapshotExtendedResponseModel + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.studio.projects.chapters.snapshots.get( + project_id="21m00Tcm4TlvDq8ikWAM", + chapter_id="21m00Tcm4TlvDq8ikWAM", + chapter_snapshot_id="21m00Tcm4TlvDq8ikWAM", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.get( + project_id, chapter_id, chapter_snapshot_id, request_options=request_options + ) + return _response.data + + async def stream( + self, + project_id: str, + chapter_id: str, + chapter_snapshot_id: str, + *, + convert_to_mpeg: typing.Optional[bool] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> typing.AsyncIterator[bytes]: + """ + Stream the audio from a chapter snapshot. Use `GET /v1/studio/projects/{project_id}/chapters/{chapter_id}/snapshots` to return the snapshots of a chapter. + + Parameters + ---------- + project_id : str + The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. + + chapter_id : str + The ID of the chapter to be used. You can use the [List project chapters](/docs/api-reference/studio/get-chapters) endpoint to list all the available chapters. + + chapter_snapshot_id : str + The ID of the chapter snapshot to be used. You can use the [List project chapter snapshots](/docs/api-reference/studio/get-snapshots) endpoint to list all the available snapshots. + + convert_to_mpeg : typing.Optional[bool] + Whether to convert the audio to mpeg format. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. + + Returns + ------- + typing.AsyncIterator[bytes] + Streaming audio data + """ + async with self._raw_client.stream( + project_id, + chapter_id, + chapter_snapshot_id, + convert_to_mpeg=convert_to_mpeg, + request_options=request_options, + ) as r: + async for _chunk in r.data: + yield _chunk diff --git a/src/elevenlabs/studio/projects/chapters/snapshots/raw_client.py b/src/elevenlabs/studio/projects/chapters/snapshots/raw_client.py new file mode 100644 index 00000000..4022752b --- /dev/null +++ b/src/elevenlabs/studio/projects/chapters/snapshots/raw_client.py @@ -0,0 +1,416 @@ +# This file was auto-generated by Fern from our API Definition. + +import contextlib +import typing +from json.decoder import JSONDecodeError + +from .....core.api_error import ApiError +from .....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from .....core.http_response import AsyncHttpResponse, HttpResponse +from .....core.jsonable_encoder import jsonable_encoder +from .....core.request_options import RequestOptions +from .....core.unchecked_base_model import construct_type +from .....errors.unprocessable_entity_error import UnprocessableEntityError +from .....types.chapter_snapshot_extended_response_model import ChapterSnapshotExtendedResponseModel +from .....types.chapter_snapshots_response import ChapterSnapshotsResponse +from .....types.http_validation_error import HttpValidationError + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RawSnapshotsClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def list( + self, project_id: str, chapter_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[ChapterSnapshotsResponse]: + """ + Gets information about all the snapshots of a chapter. Each snapshot can be downloaded as audio. Whenever a chapter is converted a snapshot will automatically be created. + + Parameters + ---------- + project_id : str + The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. + + chapter_id : str + The ID of the chapter to be used. You can use the [List project chapters](/docs/api-reference/studio/get-chapters) endpoint to list all the available chapters. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[ChapterSnapshotsResponse] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/studio/projects/{jsonable_encoder(project_id)}/chapters/{jsonable_encoder(chapter_id)}/snapshots", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ChapterSnapshotsResponse, + construct_type( + type_=ChapterSnapshotsResponse, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def get( + self, + project_id: str, + chapter_id: str, + chapter_snapshot_id: str, + *, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[ChapterSnapshotExtendedResponseModel]: + """ + Returns the chapter snapshot. + + Parameters + ---------- + project_id : str + The ID of the Studio project. + + chapter_id : str + The ID of the chapter. + + chapter_snapshot_id : str + The ID of the chapter snapshot. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[ChapterSnapshotExtendedResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/studio/projects/{jsonable_encoder(project_id)}/chapters/{jsonable_encoder(chapter_id)}/snapshots/{jsonable_encoder(chapter_snapshot_id)}", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ChapterSnapshotExtendedResponseModel, + construct_type( + type_=ChapterSnapshotExtendedResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + @contextlib.contextmanager + def stream( + self, + project_id: str, + chapter_id: str, + chapter_snapshot_id: str, + *, + convert_to_mpeg: typing.Optional[bool] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> typing.Iterator[HttpResponse[typing.Iterator[bytes]]]: + """ + Stream the audio from a chapter snapshot. Use `GET /v1/studio/projects/{project_id}/chapters/{chapter_id}/snapshots` to return the snapshots of a chapter. + + Parameters + ---------- + project_id : str + The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. + + chapter_id : str + The ID of the chapter to be used. You can use the [List project chapters](/docs/api-reference/studio/get-chapters) endpoint to list all the available chapters. + + chapter_snapshot_id : str + The ID of the chapter snapshot to be used. You can use the [List project chapter snapshots](/docs/api-reference/studio/get-snapshots) endpoint to list all the available snapshots. + + convert_to_mpeg : typing.Optional[bool] + Whether to convert the audio to mpeg format. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. + + Returns + ------- + typing.Iterator[HttpResponse[typing.Iterator[bytes]]] + Streaming audio data + """ + with self._client_wrapper.httpx_client.stream( + f"v1/studio/projects/{jsonable_encoder(project_id)}/chapters/{jsonable_encoder(chapter_id)}/snapshots/{jsonable_encoder(chapter_snapshot_id)}/stream", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "convert_to_mpeg": convert_to_mpeg, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) as _response: + + def _stream() -> HttpResponse[typing.Iterator[bytes]]: + try: + if 200 <= _response.status_code < 300: + _chunk_size = request_options.get("chunk_size", 1024) if request_options is not None else 1024 + return HttpResponse( + response=_response, data=(_chunk for _chunk in _response.iter_bytes(chunk_size=_chunk_size)) + ) + _response.read() + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + yield _stream() + + +class AsyncRawSnapshotsClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def list( + self, project_id: str, chapter_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[ChapterSnapshotsResponse]: + """ + Gets information about all the snapshots of a chapter. Each snapshot can be downloaded as audio. Whenever a chapter is converted a snapshot will automatically be created. + + Parameters + ---------- + project_id : str + The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. + + chapter_id : str + The ID of the chapter to be used. You can use the [List project chapters](/docs/api-reference/studio/get-chapters) endpoint to list all the available chapters. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[ChapterSnapshotsResponse] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/studio/projects/{jsonable_encoder(project_id)}/chapters/{jsonable_encoder(chapter_id)}/snapshots", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ChapterSnapshotsResponse, + construct_type( + type_=ChapterSnapshotsResponse, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def get( + self, + project_id: str, + chapter_id: str, + chapter_snapshot_id: str, + *, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[ChapterSnapshotExtendedResponseModel]: + """ + Returns the chapter snapshot. + + Parameters + ---------- + project_id : str + The ID of the Studio project. + + chapter_id : str + The ID of the chapter. + + chapter_snapshot_id : str + The ID of the chapter snapshot. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[ChapterSnapshotExtendedResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/studio/projects/{jsonable_encoder(project_id)}/chapters/{jsonable_encoder(chapter_id)}/snapshots/{jsonable_encoder(chapter_snapshot_id)}", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ChapterSnapshotExtendedResponseModel, + construct_type( + type_=ChapterSnapshotExtendedResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + @contextlib.asynccontextmanager + async def stream( + self, + project_id: str, + chapter_id: str, + chapter_snapshot_id: str, + *, + convert_to_mpeg: typing.Optional[bool] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> typing.AsyncIterator[AsyncHttpResponse[typing.AsyncIterator[bytes]]]: + """ + Stream the audio from a chapter snapshot. Use `GET /v1/studio/projects/{project_id}/chapters/{chapter_id}/snapshots` to return the snapshots of a chapter. + + Parameters + ---------- + project_id : str + The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. + + chapter_id : str + The ID of the chapter to be used. You can use the [List project chapters](/docs/api-reference/studio/get-chapters) endpoint to list all the available chapters. + + chapter_snapshot_id : str + The ID of the chapter snapshot to be used. You can use the [List project chapter snapshots](/docs/api-reference/studio/get-snapshots) endpoint to list all the available snapshots. + + convert_to_mpeg : typing.Optional[bool] + Whether to convert the audio to mpeg format. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. + + Returns + ------- + typing.AsyncIterator[AsyncHttpResponse[typing.AsyncIterator[bytes]]] + Streaming audio data + """ + async with self._client_wrapper.httpx_client.stream( + f"v1/studio/projects/{jsonable_encoder(project_id)}/chapters/{jsonable_encoder(chapter_id)}/snapshots/{jsonable_encoder(chapter_snapshot_id)}/stream", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "convert_to_mpeg": convert_to_mpeg, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) as _response: + + async def _stream() -> AsyncHttpResponse[typing.AsyncIterator[bytes]]: + try: + if 200 <= _response.status_code < 300: + _chunk_size = request_options.get("chunk_size", 1024) if request_options is not None else 1024 + return AsyncHttpResponse( + response=_response, + data=(_chunk async for _chunk in _response.aiter_bytes(chunk_size=_chunk_size)), + ) + await _response.aread() + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + yield await _stream() diff --git a/src/elevenlabs/studio/projects/client.py b/src/elevenlabs/studio/projects/client.py index 763a485b..1db74191 100644 --- a/src/elevenlabs/studio/projects/client.py +++ b/src/elevenlabs/studio/projects/client.py @@ -1,39 +1,25 @@ # This file was auto-generated by Fern from our API Definition. import typing -from ...core.client_wrapper import SyncClientWrapper -from ...core.request_options import RequestOptions -from ...types.get_projects_response import GetProjectsResponse -from ...core.unchecked_base_model import construct_type -from ...errors.unprocessable_entity_error import UnprocessableEntityError -from ...types.http_validation_error import HttpValidationError -from json.decoder import JSONDecodeError -from ...core.api_error import ApiError + from ... import core -from .types.projects_add_request_target_audience import ProjectsAddRequestTargetAudience -from .types.projects_add_request_fiction import ProjectsAddRequestFiction -from .types.projects_add_request_apply_text_normalization import ( - ProjectsAddRequestApplyTextNormalization, -) -from .types.projects_add_request_source_type import ProjectsAddRequestSourceType +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ...core.request_options import RequestOptions from ...types.add_project_response_model import AddProjectResponseModel -from ...types.project_extended_response import ProjectExtendedResponse -from ...core.jsonable_encoder import jsonable_encoder -from ...types.edit_project_response_model import EditProjectResponseModel -from ...types.delete_project_response_model import DeleteProjectResponseModel from ...types.convert_project_response_model import ConvertProjectResponseModel -from ...types.project_snapshots_response import ProjectSnapshotsResponse -from ...types.project_snapshot_extended_response_model import ( - ProjectSnapshotExtendedResponseModel, -) -from ...types.pronunciation_dictionary_version_locator import ( - PronunciationDictionaryVersionLocator, -) -from ...types.create_pronunciation_dictionary_response_model import ( - CreatePronunciationDictionaryResponseModel, -) -from ...core.serialization import convert_and_respect_annotation_metadata -from ...core.client_wrapper import AsyncClientWrapper +from ...types.delete_project_response_model import DeleteProjectResponseModel +from ...types.edit_project_response_model import EditProjectResponseModel +from ...types.get_projects_response import GetProjectsResponse +from ...types.project_extended_response import ProjectExtendedResponse +from .chapters.client import AsyncChaptersClient, ChaptersClient +from .content.client import AsyncContentClient, ContentClient +from .pronunciation_dictionaries.client import AsyncPronunciationDictionariesClient, PronunciationDictionariesClient +from .raw_client import AsyncRawProjectsClient, RawProjectsClient +from .snapshots.client import AsyncSnapshotsClient, SnapshotsClient +from .types.projects_create_request_apply_text_normalization import ProjectsCreateRequestApplyTextNormalization +from .types.projects_create_request_fiction import ProjectsCreateRequestFiction +from .types.projects_create_request_source_type import ProjectsCreateRequestSourceType +from .types.projects_create_request_target_audience import ProjectsCreateRequestTargetAudience # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -41,9 +27,27 @@ class ProjectsClient: def __init__(self, *, client_wrapper: SyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = RawProjectsClient(client_wrapper=client_wrapper) + self.content = ContentClient(client_wrapper=client_wrapper) + + self.snapshots = SnapshotsClient(client_wrapper=client_wrapper) + + self.chapters = ChaptersClient(client_wrapper=client_wrapper) + + self.pronunciation_dictionaries = PronunciationDictionariesClient(client_wrapper=client_wrapper) - def get_all(self, *, request_options: typing.Optional[RequestOptions] = None) -> GetProjectsResponse: + @property + def with_raw_response(self) -> RawProjectsClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawProjectsClient + """ + return self._raw_client + + def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> GetProjectsResponse: """ Returns a list of your Studio projects with metadata. @@ -64,39 +68,12 @@ def get_all(self, *, request_options: typing.Optional[RequestOptions] = None) -> client = ElevenLabs( api_key="YOUR_API_KEY", ) - client.studio.projects.get_all() + client.studio.projects.list() """ - _response = self._client_wrapper.httpx_client.request( - "v1/studio/projects", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - GetProjectsResponse, - construct_type( - type_=GetProjectsResponse, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def add( + _response = self._raw_client.list(request_options=request_options) + return _response.data + + def create( self, *, name: str, @@ -110,7 +87,7 @@ def add( author: typing.Optional[str] = OMIT, description: typing.Optional[str] = OMIT, genres: typing.Optional[typing.List[str]] = OMIT, - target_audience: typing.Optional[ProjectsAddRequestTargetAudience] = OMIT, + target_audience: typing.Optional[ProjectsCreateRequestTargetAudience] = OMIT, language: typing.Optional[str] = OMIT, content_type: typing.Optional[str] = OMIT, original_publication_date: typing.Optional[str] = OMIT, @@ -120,11 +97,11 @@ def add( volume_normalization: typing.Optional[bool] = OMIT, pronunciation_dictionary_locators: typing.Optional[typing.List[str]] = OMIT, callback_url: typing.Optional[str] = OMIT, - fiction: typing.Optional[ProjectsAddRequestFiction] = OMIT, - apply_text_normalization: typing.Optional[ProjectsAddRequestApplyTextNormalization] = OMIT, + fiction: typing.Optional[ProjectsCreateRequestFiction] = OMIT, + apply_text_normalization: typing.Optional[ProjectsCreateRequestApplyTextNormalization] = OMIT, auto_convert: typing.Optional[bool] = OMIT, auto_assign_voices: typing.Optional[bool] = OMIT, - source_type: typing.Optional[ProjectsAddRequestSourceType] = OMIT, + source_type: typing.Optional[ProjectsCreateRequestSourceType] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> AddProjectResponseModel: """ @@ -169,7 +146,7 @@ def add( genres : typing.Optional[typing.List[str]] An optional list of genres associated with the Studio project. - target_audience : typing.Optional[ProjectsAddRequestTargetAudience] + target_audience : typing.Optional[ProjectsCreateRequestTargetAudience] An optional target audience of the Studio project. language : typing.Optional[str] @@ -199,10 +176,10 @@ def add( callback_url : typing.Optional[str] A url that will be called by our service when the Studio project is converted. Request will contain a json blob containing the status of the conversion - fiction : typing.Optional[ProjectsAddRequestFiction] + fiction : typing.Optional[ProjectsCreateRequestFiction] An optional specification of whether the content of this Studio project is fiction. - apply_text_normalization : typing.Optional[ProjectsAddRequestApplyTextNormalization] + apply_text_normalization : typing.Optional[ProjectsCreateRequestApplyTextNormalization] This parameter controls text normalization with four modes: 'auto', 'on', 'apply_english' and 'off'. When set to 'auto', the system will automatically decide whether to apply text normalization @@ -216,7 +193,7 @@ def add( auto_assign_voices : typing.Optional[bool] [Alpha Feature] Whether automatically assign voices to phrases in the create Project. - source_type : typing.Optional[ProjectsAddRequestSourceType] + source_type : typing.Optional[ProjectsCreateRequestSourceType] The type of Studio project to create. request_options : typing.Optional[RequestOptions] @@ -234,79 +211,46 @@ def add( client = ElevenLabs( api_key="YOUR_API_KEY", ) - client.studio.projects.add( + client.studio.projects.create( name="name", default_title_voice_id="default_title_voice_id", default_paragraph_voice_id="default_paragraph_voice_id", default_model_id="default_model_id", ) """ - _response = self._client_wrapper.httpx_client.request( - "v1/studio/projects", - base_url=self._client_wrapper.get_environment().base, - method="POST", - data={ - "name": name, - "default_title_voice_id": default_title_voice_id, - "default_paragraph_voice_id": default_paragraph_voice_id, - "default_model_id": default_model_id, - "from_url": from_url, - "quality_preset": quality_preset, - "title": title, - "author": author, - "description": description, - "genres": genres, - "target_audience": target_audience, - "language": language, - "content_type": content_type, - "original_publication_date": original_publication_date, - "mature_content": mature_content, - "isbn_number": isbn_number, - "acx_volume_normalization": acx_volume_normalization, - "volume_normalization": volume_normalization, - "pronunciation_dictionary_locators": pronunciation_dictionary_locators, - "callback_url": callback_url, - "fiction": fiction, - "apply_text_normalization": apply_text_normalization, - "auto_convert": auto_convert, - "auto_assign_voices": auto_assign_voices, - "source_type": source_type, - }, - files={ - "from_document": from_document, - }, + _response = self._raw_client.create( + name=name, + default_title_voice_id=default_title_voice_id, + default_paragraph_voice_id=default_paragraph_voice_id, + default_model_id=default_model_id, + from_url=from_url, + from_document=from_document, + quality_preset=quality_preset, + title=title, + author=author, + description=description, + genres=genres, + target_audience=target_audience, + language=language, + content_type=content_type, + original_publication_date=original_publication_date, + mature_content=mature_content, + isbn_number=isbn_number, + acx_volume_normalization=acx_volume_normalization, + volume_normalization=volume_normalization, + pronunciation_dictionary_locators=pronunciation_dictionary_locators, + callback_url=callback_url, + fiction=fiction, + apply_text_normalization=apply_text_normalization, + auto_convert=auto_convert, + auto_assign_voices=auto_assign_voices, + source_type=source_type, request_options=request_options, - omit=OMIT, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - AddProjectResponseModel, - construct_type( - type_=AddProjectResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + return _response.data def get( - self, - project_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, + self, project_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> ProjectExtendedResponse: """ Returns information about a specific Studio project. This endpoint returns more detailed information about a project than `GET /v1/studio`. @@ -335,37 +279,10 @@ def get( project_id="21m00Tcm4TlvDq8ikWAM", ) """ - _response = self._client_wrapper.httpx_client.request( - f"v1/studio/projects/{jsonable_encoder(project_id)}", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ProjectExtendedResponse, - construct_type( - type_=ProjectExtendedResponse, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def update_metadata( + _response = self._raw_client.get(project_id, request_options=request_options) + return _response.data + + def update( self, project_id: str, *, @@ -422,61 +339,28 @@ def update_metadata( client = ElevenLabs( api_key="YOUR_API_KEY", ) - client.studio.projects.update_metadata( + client.studio.projects.update( project_id="21m00Tcm4TlvDq8ikWAM", name="Project 1", default_title_voice_id="21m00Tcm4TlvDq8ikWAM", default_paragraph_voice_id="21m00Tcm4TlvDq8ikWAM", ) """ - _response = self._client_wrapper.httpx_client.request( - f"v1/studio/projects/{jsonable_encoder(project_id)}", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "name": name, - "default_title_voice_id": default_title_voice_id, - "default_paragraph_voice_id": default_paragraph_voice_id, - "title": title, - "author": author, - "isbn_number": isbn_number, - "volume_normalization": volume_normalization, - }, - headers={ - "content-type": "application/json", - }, + _response = self._raw_client.update( + project_id, + name=name, + default_title_voice_id=default_title_voice_id, + default_paragraph_voice_id=default_paragraph_voice_id, + title=title, + author=author, + isbn_number=isbn_number, + volume_normalization=volume_normalization, request_options=request_options, - omit=OMIT, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - EditProjectResponseModel, - construct_type( - type_=EditProjectResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + return _response.data def delete( - self, - project_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, + self, project_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> DeleteProjectResponseModel: """ Deletes a Studio project. @@ -505,124 +389,11 @@ def delete( project_id="21m00Tcm4TlvDq8ikWAM", ) """ - _response = self._client_wrapper.httpx_client.request( - f"v1/studio/projects/{jsonable_encoder(project_id)}", - base_url=self._client_wrapper.get_environment().base, - method="DELETE", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - DeleteProjectResponseModel, - construct_type( - type_=DeleteProjectResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def update_content( - self, - project_id: str, - *, - from_url: typing.Optional[str] = OMIT, - from_document: typing.Optional[core.File] = OMIT, - auto_convert: typing.Optional[bool] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> EditProjectResponseModel: - """ - Updates Studio project content. - - Parameters - ---------- - project_id : str - The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. - - from_url : typing.Optional[str] - An optional URL from which we will extract content to initialize the Studio project. If this is set, 'from_url' must be null. If neither 'from_url' or 'from_document' are provided we will initialize the Studio project as blank. - - from_document : typing.Optional[core.File] - See core.File for more documentation - - auto_convert : typing.Optional[bool] - Whether to auto convert the Studio project to audio or not. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - EditProjectResponseModel - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.studio.projects.update_content( - project_id="21m00Tcm4TlvDq8ikWAM", - ) - """ - _response = self._client_wrapper.httpx_client.request( - f"v1/studio/projects/{jsonable_encoder(project_id)}/content", - base_url=self._client_wrapper.get_environment().base, - method="POST", - data={ - "from_url": from_url, - "auto_convert": auto_convert, - }, - files={ - "from_document": from_document, - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - EditProjectResponseModel, - construct_type( - type_=EditProjectResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.delete(project_id, request_options=request_options) + return _response.data def convert( - self, - project_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, + self, project_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> ConvertProjectResponseModel: """ Starts conversion of a Studio project and all of its chapters. @@ -651,380 +422,33 @@ def convert( project_id="21m00Tcm4TlvDq8ikWAM", ) """ - _response = self._client_wrapper.httpx_client.request( - f"v1/studio/projects/{jsonable_encoder(project_id)}/convert", - base_url=self._client_wrapper.get_environment().base, - method="POST", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ConvertProjectResponseModel, - construct_type( - type_=ConvertProjectResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def get_snapshots( - self, - project_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, - ) -> ProjectSnapshotsResponse: - """ - Retrieves a list of snapshots for a Studio project. + _response = self._raw_client.convert(project_id, request_options=request_options) + return _response.data - Parameters - ---------- - project_id : str - The ID of the Studio project. - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - ProjectSnapshotsResponse - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.studio.projects.get_snapshots( - project_id="21m00Tcm4TlvDq8ikWAM", - ) - """ - _response = self._client_wrapper.httpx_client.request( - f"v1/studio/projects/{jsonable_encoder(project_id)}/snapshots", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ProjectSnapshotsResponse, - construct_type( - type_=ProjectSnapshotsResponse, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def get_project_snapshot( - self, - project_id: str, - project_snapshot_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, - ) -> ProjectSnapshotExtendedResponseModel: - """ - Returns the project snapshot. - - Parameters - ---------- - project_id : str - The ID of the Studio project. - - project_snapshot_id : str - The ID of the Studio project snapshot. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - ProjectSnapshotExtendedResponseModel - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.studio.projects.get_project_snapshot( - project_id="21m00Tcm4TlvDq8ikWAM", - project_snapshot_id="21m00Tcm4TlvDq8ikWAM", - ) - """ - _response = self._client_wrapper.httpx_client.request( - f"v1/studio/projects/{jsonable_encoder(project_id)}/snapshots/{jsonable_encoder(project_snapshot_id)}", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ProjectSnapshotExtendedResponseModel, - construct_type( - type_=ProjectSnapshotExtendedResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def stream_audio( - self, - project_id: str, - project_snapshot_id: str, - *, - convert_to_mpeg: typing.Optional[bool] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> typing.Iterator[bytes]: - """ - Stream the audio from a Studio project snapshot. - - Parameters - ---------- - project_id : str - The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. - - project_snapshot_id : str - The ID of the Studio project snapshot. - - convert_to_mpeg : typing.Optional[bool] - Whether to convert the audio to mpeg format. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. - - Yields - ------ - typing.Iterator[bytes] - Successful Response - """ - with self._client_wrapper.httpx_client.stream( - f"v1/studio/projects/{jsonable_encoder(project_id)}/snapshots/{jsonable_encoder(project_snapshot_id)}/stream", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "convert_to_mpeg": convert_to_mpeg, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) as _response: - try: - if 200 <= _response.status_code < 300: - _chunk_size = request_options.get("chunk_size", 1024) if request_options is not None else 1024 - for _chunk in _response.iter_bytes(chunk_size=_chunk_size): - yield _chunk - return - _response.read() - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def stream_archive( - self, - project_id: str, - project_snapshot_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, - ) -> typing.Iterator[bytes]: - """ - Returns a compressed archive of the Studio project's audio. +class AsyncProjectsClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawProjectsClient(client_wrapper=client_wrapper) + self.content = AsyncContentClient(client_wrapper=client_wrapper) - Parameters - ---------- - project_id : str - The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. + self.snapshots = AsyncSnapshotsClient(client_wrapper=client_wrapper) - project_snapshot_id : str - The ID of the Studio project snapshot. + self.chapters = AsyncChaptersClient(client_wrapper=client_wrapper) - request_options : typing.Optional[RequestOptions] - Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. + self.pronunciation_dictionaries = AsyncPronunciationDictionariesClient(client_wrapper=client_wrapper) - Yields - ------ - typing.Iterator[bytes] - Streaming archive data + @property + def with_raw_response(self) -> AsyncRawProjectsClient: """ - with self._client_wrapper.httpx_client.stream( - f"v1/studio/projects/{jsonable_encoder(project_id)}/snapshots/{jsonable_encoder(project_snapshot_id)}/archive", - base_url=self._client_wrapper.get_environment().base, - method="POST", - request_options=request_options, - ) as _response: - try: - if 200 <= _response.status_code < 300: - _chunk_size = request_options.get("chunk_size", 1024) if request_options is not None else 1024 - for _chunk in _response.iter_bytes(chunk_size=_chunk_size): - yield _chunk - return - _response.read() - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def update_pronunciation_dictionaries( - self, - project_id: str, - *, - pronunciation_dictionary_locators: typing.Sequence[PronunciationDictionaryVersionLocator], - invalidate_affected_text: typing.Optional[bool] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> CreatePronunciationDictionaryResponseModel: - """ - Create a set of pronunciation dictionaries acting on a project. This will automatically mark text within this project as requiring reconverting where the new dictionary would apply or the old one no longer does. - - Parameters - ---------- - project_id : str - The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. - - pronunciation_dictionary_locators : typing.Sequence[PronunciationDictionaryVersionLocator] - A list of pronunciation dictionary locators (pronunciation_dictionary_id, version_id) encoded as a list of JSON strings for pronunciation dictionaries to be applied to the text. A list of json encoded strings is required as adding projects may occur through formData as opposed to jsonBody. To specify multiple dictionaries use multiple --form lines in your curl, such as --form 'pronunciation_dictionary_locators="{\"pronunciation_dictionary_id\":\"Vmd4Zor6fplcA7WrINey\",\"version_id\":\"hRPaxjlTdR7wFMhV4w0b\"}"' --form 'pronunciation_dictionary_locators="{\"pronunciation_dictionary_id\":\"JzWtcGQMJ6bnlWwyMo7e\",\"version_id\":\"lbmwxiLu4q6txYxgdZqn\"}"'. Note that multiple dictionaries are not currently supported by our UI which will only show the first. - - invalidate_affected_text : typing.Optional[bool] - This will automatically mark text in this project for reconversion when the new dictionary applies or the old one no longer does. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. + Retrieves a raw implementation of this client that returns raw responses. Returns ------- - CreatePronunciationDictionaryResponseModel - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs, PronunciationDictionaryVersionLocator - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.studio.projects.update_pronunciation_dictionaries( - project_id="21m00Tcm4TlvDq8ikWAM", - pronunciation_dictionary_locators=[ - PronunciationDictionaryVersionLocator( - pronunciation_dictionary_id="pronunciation_dictionary_id", - ) - ], - ) + AsyncRawProjectsClient """ - _response = self._client_wrapper.httpx_client.request( - f"v1/studio/projects/{jsonable_encoder(project_id)}/pronunciation-dictionaries", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "pronunciation_dictionary_locators": convert_and_respect_annotation_metadata( - object_=pronunciation_dictionary_locators, - annotation=typing.Sequence[PronunciationDictionaryVersionLocator], - direction="write", - ), - "invalidate_affected_text": invalidate_affected_text, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - CreatePronunciationDictionaryResponseModel, - construct_type( - type_=CreatePronunciationDictionaryResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + return self._raw_client - -class AsyncProjectsClient: - def __init__(self, *, client_wrapper: AsyncClientWrapper): - self._client_wrapper = client_wrapper - - async def get_all(self, *, request_options: typing.Optional[RequestOptions] = None) -> GetProjectsResponse: + async def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> GetProjectsResponse: """ Returns a list of your Studio projects with metadata. @@ -1050,42 +474,15 @@ async def get_all(self, *, request_options: typing.Optional[RequestOptions] = No async def main() -> None: - await client.studio.projects.get_all() + await client.studio.projects.list() asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - "v1/studio/projects", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - GetProjectsResponse, - construct_type( - type_=GetProjectsResponse, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def add( + _response = await self._raw_client.list(request_options=request_options) + return _response.data + + async def create( self, *, name: str, @@ -1099,7 +496,7 @@ async def add( author: typing.Optional[str] = OMIT, description: typing.Optional[str] = OMIT, genres: typing.Optional[typing.List[str]] = OMIT, - target_audience: typing.Optional[ProjectsAddRequestTargetAudience] = OMIT, + target_audience: typing.Optional[ProjectsCreateRequestTargetAudience] = OMIT, language: typing.Optional[str] = OMIT, content_type: typing.Optional[str] = OMIT, original_publication_date: typing.Optional[str] = OMIT, @@ -1109,11 +506,11 @@ async def add( volume_normalization: typing.Optional[bool] = OMIT, pronunciation_dictionary_locators: typing.Optional[typing.List[str]] = OMIT, callback_url: typing.Optional[str] = OMIT, - fiction: typing.Optional[ProjectsAddRequestFiction] = OMIT, - apply_text_normalization: typing.Optional[ProjectsAddRequestApplyTextNormalization] = OMIT, + fiction: typing.Optional[ProjectsCreateRequestFiction] = OMIT, + apply_text_normalization: typing.Optional[ProjectsCreateRequestApplyTextNormalization] = OMIT, auto_convert: typing.Optional[bool] = OMIT, auto_assign_voices: typing.Optional[bool] = OMIT, - source_type: typing.Optional[ProjectsAddRequestSourceType] = OMIT, + source_type: typing.Optional[ProjectsCreateRequestSourceType] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> AddProjectResponseModel: """ @@ -1158,7 +555,7 @@ async def add( genres : typing.Optional[typing.List[str]] An optional list of genres associated with the Studio project. - target_audience : typing.Optional[ProjectsAddRequestTargetAudience] + target_audience : typing.Optional[ProjectsCreateRequestTargetAudience] An optional target audience of the Studio project. language : typing.Optional[str] @@ -1188,10 +585,10 @@ async def add( callback_url : typing.Optional[str] A url that will be called by our service when the Studio project is converted. Request will contain a json blob containing the status of the conversion - fiction : typing.Optional[ProjectsAddRequestFiction] + fiction : typing.Optional[ProjectsCreateRequestFiction] An optional specification of whether the content of this Studio project is fiction. - apply_text_normalization : typing.Optional[ProjectsAddRequestApplyTextNormalization] + apply_text_normalization : typing.Optional[ProjectsCreateRequestApplyTextNormalization] This parameter controls text normalization with four modes: 'auto', 'on', 'apply_english' and 'off'. When set to 'auto', the system will automatically decide whether to apply text normalization @@ -1205,7 +602,7 @@ async def add( auto_assign_voices : typing.Optional[bool] [Alpha Feature] Whether automatically assign voices to phrases in the create Project. - source_type : typing.Optional[ProjectsAddRequestSourceType] + source_type : typing.Optional[ProjectsCreateRequestSourceType] The type of Studio project to create. request_options : typing.Optional[RequestOptions] @@ -1228,7 +625,7 @@ async def add( async def main() -> None: - await client.studio.projects.add( + await client.studio.projects.create( name="name", default_title_voice_id="default_title_voice_id", default_paragraph_voice_id="default_paragraph_voice_id", @@ -1238,72 +635,39 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - "v1/studio/projects", - base_url=self._client_wrapper.get_environment().base, - method="POST", - data={ - "name": name, - "default_title_voice_id": default_title_voice_id, - "default_paragraph_voice_id": default_paragraph_voice_id, - "default_model_id": default_model_id, - "from_url": from_url, - "quality_preset": quality_preset, - "title": title, - "author": author, - "description": description, - "genres": genres, - "target_audience": target_audience, - "language": language, - "content_type": content_type, - "original_publication_date": original_publication_date, - "mature_content": mature_content, - "isbn_number": isbn_number, - "acx_volume_normalization": acx_volume_normalization, - "volume_normalization": volume_normalization, - "pronunciation_dictionary_locators": pronunciation_dictionary_locators, - "callback_url": callback_url, - "fiction": fiction, - "apply_text_normalization": apply_text_normalization, - "auto_convert": auto_convert, - "auto_assign_voices": auto_assign_voices, - "source_type": source_type, - }, - files={ - "from_document": from_document, - }, + _response = await self._raw_client.create( + name=name, + default_title_voice_id=default_title_voice_id, + default_paragraph_voice_id=default_paragraph_voice_id, + default_model_id=default_model_id, + from_url=from_url, + from_document=from_document, + quality_preset=quality_preset, + title=title, + author=author, + description=description, + genres=genres, + target_audience=target_audience, + language=language, + content_type=content_type, + original_publication_date=original_publication_date, + mature_content=mature_content, + isbn_number=isbn_number, + acx_volume_normalization=acx_volume_normalization, + volume_normalization=volume_normalization, + pronunciation_dictionary_locators=pronunciation_dictionary_locators, + callback_url=callback_url, + fiction=fiction, + apply_text_normalization=apply_text_normalization, + auto_convert=auto_convert, + auto_assign_voices=auto_assign_voices, + source_type=source_type, request_options=request_options, - omit=OMIT, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - AddProjectResponseModel, - construct_type( - type_=AddProjectResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + return _response.data async def get( - self, - project_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, + self, project_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> ProjectExtendedResponse: """ Returns information about a specific Studio project. This endpoint returns more detailed information about a project than `GET /v1/studio`. @@ -1340,37 +704,10 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/studio/projects/{jsonable_encoder(project_id)}", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ProjectExtendedResponse, - construct_type( - type_=ProjectExtendedResponse, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def update_metadata( + _response = await self._raw_client.get(project_id, request_options=request_options) + return _response.data + + async def update( self, project_id: str, *, @@ -1432,7 +769,7 @@ async def update_metadata( async def main() -> None: - await client.studio.projects.update_metadata( + await client.studio.projects.update( project_id="21m00Tcm4TlvDq8ikWAM", name="Project 1", default_title_voice_id="21m00Tcm4TlvDq8ikWAM", @@ -1442,54 +779,21 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/studio/projects/{jsonable_encoder(project_id)}", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "name": name, - "default_title_voice_id": default_title_voice_id, - "default_paragraph_voice_id": default_paragraph_voice_id, - "title": title, - "author": author, - "isbn_number": isbn_number, - "volume_normalization": volume_normalization, - }, - headers={ - "content-type": "application/json", - }, + _response = await self._raw_client.update( + project_id, + name=name, + default_title_voice_id=default_title_voice_id, + default_paragraph_voice_id=default_paragraph_voice_id, + title=title, + author=author, + isbn_number=isbn_number, + volume_normalization=volume_normalization, request_options=request_options, - omit=OMIT, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - EditProjectResponseModel, - construct_type( - type_=EditProjectResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + return _response.data async def delete( - self, - project_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, + self, project_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> DeleteProjectResponseModel: """ Deletes a Studio project. @@ -1526,132 +830,11 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/studio/projects/{jsonable_encoder(project_id)}", - base_url=self._client_wrapper.get_environment().base, - method="DELETE", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - DeleteProjectResponseModel, - construct_type( - type_=DeleteProjectResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def update_content( - self, - project_id: str, - *, - from_url: typing.Optional[str] = OMIT, - from_document: typing.Optional[core.File] = OMIT, - auto_convert: typing.Optional[bool] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> EditProjectResponseModel: - """ - Updates Studio project content. - - Parameters - ---------- - project_id : str - The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. - - from_url : typing.Optional[str] - An optional URL from which we will extract content to initialize the Studio project. If this is set, 'from_url' must be null. If neither 'from_url' or 'from_document' are provided we will initialize the Studio project as blank. - - from_document : typing.Optional[core.File] - See core.File for more documentation - - auto_convert : typing.Optional[bool] - Whether to auto convert the Studio project to audio or not. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - EditProjectResponseModel - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.studio.projects.update_content( - project_id="21m00Tcm4TlvDq8ikWAM", - ) - - - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/studio/projects/{jsonable_encoder(project_id)}/content", - base_url=self._client_wrapper.get_environment().base, - method="POST", - data={ - "from_url": from_url, - "auto_convert": auto_convert, - }, - files={ - "from_document": from_document, - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - EditProjectResponseModel, - construct_type( - type_=EditProjectResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.delete(project_id, request_options=request_options) + return _response.data async def convert( - self, - project_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, + self, project_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> ConvertProjectResponseModel: """ Starts conversion of a Studio project and all of its chapters. @@ -1688,394 +871,5 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/studio/projects/{jsonable_encoder(project_id)}/convert", - base_url=self._client_wrapper.get_environment().base, - method="POST", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ConvertProjectResponseModel, - construct_type( - type_=ConvertProjectResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def get_snapshots( - self, - project_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, - ) -> ProjectSnapshotsResponse: - """ - Retrieves a list of snapshots for a Studio project. - - Parameters - ---------- - project_id : str - The ID of the Studio project. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - ProjectSnapshotsResponse - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.studio.projects.get_snapshots( - project_id="21m00Tcm4TlvDq8ikWAM", - ) - - - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/studio/projects/{jsonable_encoder(project_id)}/snapshots", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ProjectSnapshotsResponse, - construct_type( - type_=ProjectSnapshotsResponse, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def get_project_snapshot( - self, - project_id: str, - project_snapshot_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, - ) -> ProjectSnapshotExtendedResponseModel: - """ - Returns the project snapshot. - - Parameters - ---------- - project_id : str - The ID of the Studio project. - - project_snapshot_id : str - The ID of the Studio project snapshot. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - ProjectSnapshotExtendedResponseModel - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.studio.projects.get_project_snapshot( - project_id="21m00Tcm4TlvDq8ikWAM", - project_snapshot_id="21m00Tcm4TlvDq8ikWAM", - ) - - - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/studio/projects/{jsonable_encoder(project_id)}/snapshots/{jsonable_encoder(project_snapshot_id)}", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ProjectSnapshotExtendedResponseModel, - construct_type( - type_=ProjectSnapshotExtendedResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def stream_audio( - self, - project_id: str, - project_snapshot_id: str, - *, - convert_to_mpeg: typing.Optional[bool] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> typing.AsyncIterator[bytes]: - """ - Stream the audio from a Studio project snapshot. - - Parameters - ---------- - project_id : str - The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. - - project_snapshot_id : str - The ID of the Studio project snapshot. - - convert_to_mpeg : typing.Optional[bool] - Whether to convert the audio to mpeg format. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. - - Yields - ------ - typing.AsyncIterator[bytes] - Successful Response - """ - async with self._client_wrapper.httpx_client.stream( - f"v1/studio/projects/{jsonable_encoder(project_id)}/snapshots/{jsonable_encoder(project_snapshot_id)}/stream", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "convert_to_mpeg": convert_to_mpeg, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) as _response: - try: - if 200 <= _response.status_code < 300: - _chunk_size = request_options.get("chunk_size", 1024) if request_options is not None else 1024 - async for _chunk in _response.aiter_bytes(chunk_size=_chunk_size): - yield _chunk - return - await _response.aread() - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def stream_archive( - self, - project_id: str, - project_snapshot_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, - ) -> typing.AsyncIterator[bytes]: - """ - Returns a compressed archive of the Studio project's audio. - - Parameters - ---------- - project_id : str - The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. - - project_snapshot_id : str - The ID of the Studio project snapshot. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. - - Yields - ------ - typing.AsyncIterator[bytes] - Streaming archive data - """ - async with self._client_wrapper.httpx_client.stream( - f"v1/studio/projects/{jsonable_encoder(project_id)}/snapshots/{jsonable_encoder(project_snapshot_id)}/archive", - base_url=self._client_wrapper.get_environment().base, - method="POST", - request_options=request_options, - ) as _response: - try: - if 200 <= _response.status_code < 300: - _chunk_size = request_options.get("chunk_size", 1024) if request_options is not None else 1024 - async for _chunk in _response.aiter_bytes(chunk_size=_chunk_size): - yield _chunk - return - await _response.aread() - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def update_pronunciation_dictionaries( - self, - project_id: str, - *, - pronunciation_dictionary_locators: typing.Sequence[PronunciationDictionaryVersionLocator], - invalidate_affected_text: typing.Optional[bool] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> CreatePronunciationDictionaryResponseModel: - """ - Create a set of pronunciation dictionaries acting on a project. This will automatically mark text within this project as requiring reconverting where the new dictionary would apply or the old one no longer does. - - Parameters - ---------- - project_id : str - The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. - - pronunciation_dictionary_locators : typing.Sequence[PronunciationDictionaryVersionLocator] - A list of pronunciation dictionary locators (pronunciation_dictionary_id, version_id) encoded as a list of JSON strings for pronunciation dictionaries to be applied to the text. A list of json encoded strings is required as adding projects may occur through formData as opposed to jsonBody. To specify multiple dictionaries use multiple --form lines in your curl, such as --form 'pronunciation_dictionary_locators="{\"pronunciation_dictionary_id\":\"Vmd4Zor6fplcA7WrINey\",\"version_id\":\"hRPaxjlTdR7wFMhV4w0b\"}"' --form 'pronunciation_dictionary_locators="{\"pronunciation_dictionary_id\":\"JzWtcGQMJ6bnlWwyMo7e\",\"version_id\":\"lbmwxiLu4q6txYxgdZqn\"}"'. Note that multiple dictionaries are not currently supported by our UI which will only show the first. - - invalidate_affected_text : typing.Optional[bool] - This will automatically mark text in this project for reconversion when the new dictionary applies or the old one no longer does. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - CreatePronunciationDictionaryResponseModel - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs, PronunciationDictionaryVersionLocator - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.studio.projects.update_pronunciation_dictionaries( - project_id="21m00Tcm4TlvDq8ikWAM", - pronunciation_dictionary_locators=[ - PronunciationDictionaryVersionLocator( - pronunciation_dictionary_id="pronunciation_dictionary_id", - ) - ], - ) - - - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/studio/projects/{jsonable_encoder(project_id)}/pronunciation-dictionaries", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "pronunciation_dictionary_locators": convert_and_respect_annotation_metadata( - object_=pronunciation_dictionary_locators, - annotation=typing.Sequence[PronunciationDictionaryVersionLocator], - direction="write", - ), - "invalidate_affected_text": invalidate_affected_text, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - CreatePronunciationDictionaryResponseModel, - construct_type( - type_=CreatePronunciationDictionaryResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.convert(project_id, request_options=request_options) + return _response.data diff --git a/src/elevenlabs/studio/projects/content/__init__.py b/src/elevenlabs/studio/projects/content/__init__.py new file mode 100644 index 00000000..5cde0202 --- /dev/null +++ b/src/elevenlabs/studio/projects/content/__init__.py @@ -0,0 +1,4 @@ +# This file was auto-generated by Fern from our API Definition. + +# isort: skip_file + diff --git a/src/elevenlabs/studio/projects/content/client.py b/src/elevenlabs/studio/projects/content/client.py new file mode 100644 index 00000000..306a1647 --- /dev/null +++ b/src/elevenlabs/studio/projects/content/client.py @@ -0,0 +1,160 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +from .... import core +from ....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ....core.request_options import RequestOptions +from ....types.edit_project_response_model import EditProjectResponseModel +from .raw_client import AsyncRawContentClient, RawContentClient + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class ContentClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._raw_client = RawContentClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawContentClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawContentClient + """ + return self._raw_client + + def update( + self, + project_id: str, + *, + from_url: typing.Optional[str] = OMIT, + from_document: typing.Optional[core.File] = OMIT, + auto_convert: typing.Optional[bool] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> EditProjectResponseModel: + """ + Updates Studio project content. + + Parameters + ---------- + project_id : str + The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. + + from_url : typing.Optional[str] + An optional URL from which we will extract content to initialize the Studio project. If this is set, 'from_url' must be null. If neither 'from_url' or 'from_document' are provided we will initialize the Studio project as blank. + + from_document : typing.Optional[core.File] + See core.File for more documentation + + auto_convert : typing.Optional[bool] + Whether to auto convert the Studio project to audio or not. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + EditProjectResponseModel + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.studio.projects.content.update( + project_id="21m00Tcm4TlvDq8ikWAM", + ) + """ + _response = self._raw_client.update( + project_id, + from_url=from_url, + from_document=from_document, + auto_convert=auto_convert, + request_options=request_options, + ) + return _response.data + + +class AsyncContentClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawContentClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawContentClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawContentClient + """ + return self._raw_client + + async def update( + self, + project_id: str, + *, + from_url: typing.Optional[str] = OMIT, + from_document: typing.Optional[core.File] = OMIT, + auto_convert: typing.Optional[bool] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> EditProjectResponseModel: + """ + Updates Studio project content. + + Parameters + ---------- + project_id : str + The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. + + from_url : typing.Optional[str] + An optional URL from which we will extract content to initialize the Studio project. If this is set, 'from_url' must be null. If neither 'from_url' or 'from_document' are provided we will initialize the Studio project as blank. + + from_document : typing.Optional[core.File] + See core.File for more documentation + + auto_convert : typing.Optional[bool] + Whether to auto convert the Studio project to audio or not. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + EditProjectResponseModel + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.studio.projects.content.update( + project_id="21m00Tcm4TlvDq8ikWAM", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.update( + project_id, + from_url=from_url, + from_document=from_document, + auto_convert=auto_convert, + request_options=request_options, + ) + return _response.data diff --git a/src/elevenlabs/studio/projects/content/raw_client.py b/src/elevenlabs/studio/projects/content/raw_client.py new file mode 100644 index 00000000..04501bff --- /dev/null +++ b/src/elevenlabs/studio/projects/content/raw_client.py @@ -0,0 +1,178 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from .... import core +from ....core.api_error import ApiError +from ....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ....core.http_response import AsyncHttpResponse, HttpResponse +from ....core.jsonable_encoder import jsonable_encoder +from ....core.request_options import RequestOptions +from ....core.unchecked_base_model import construct_type +from ....errors.unprocessable_entity_error import UnprocessableEntityError +from ....types.edit_project_response_model import EditProjectResponseModel +from ....types.http_validation_error import HttpValidationError + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RawContentClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def update( + self, + project_id: str, + *, + from_url: typing.Optional[str] = OMIT, + from_document: typing.Optional[core.File] = OMIT, + auto_convert: typing.Optional[bool] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[EditProjectResponseModel]: + """ + Updates Studio project content. + + Parameters + ---------- + project_id : str + The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. + + from_url : typing.Optional[str] + An optional URL from which we will extract content to initialize the Studio project. If this is set, 'from_url' must be null. If neither 'from_url' or 'from_document' are provided we will initialize the Studio project as blank. + + from_document : typing.Optional[core.File] + See core.File for more documentation + + auto_convert : typing.Optional[bool] + Whether to auto convert the Studio project to audio or not. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[EditProjectResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/studio/projects/{jsonable_encoder(project_id)}/content", + base_url=self._client_wrapper.get_environment().base, + method="POST", + data={ + "from_url": from_url, + "auto_convert": auto_convert, + }, + files={ + **({"from_document": from_document} if from_document is not None else {}), + }, + request_options=request_options, + omit=OMIT, + force_multipart=True, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + EditProjectResponseModel, + construct_type( + type_=EditProjectResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + +class AsyncRawContentClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def update( + self, + project_id: str, + *, + from_url: typing.Optional[str] = OMIT, + from_document: typing.Optional[core.File] = OMIT, + auto_convert: typing.Optional[bool] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[EditProjectResponseModel]: + """ + Updates Studio project content. + + Parameters + ---------- + project_id : str + The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. + + from_url : typing.Optional[str] + An optional URL from which we will extract content to initialize the Studio project. If this is set, 'from_url' must be null. If neither 'from_url' or 'from_document' are provided we will initialize the Studio project as blank. + + from_document : typing.Optional[core.File] + See core.File for more documentation + + auto_convert : typing.Optional[bool] + Whether to auto convert the Studio project to audio or not. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[EditProjectResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/studio/projects/{jsonable_encoder(project_id)}/content", + base_url=self._client_wrapper.get_environment().base, + method="POST", + data={ + "from_url": from_url, + "auto_convert": auto_convert, + }, + files={ + **({"from_document": from_document} if from_document is not None else {}), + }, + request_options=request_options, + omit=OMIT, + force_multipart=True, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + EditProjectResponseModel, + construct_type( + type_=EditProjectResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/elevenlabs/studio/projects/pronunciation_dictionaries/__init__.py b/src/elevenlabs/studio/projects/pronunciation_dictionaries/__init__.py new file mode 100644 index 00000000..5cde0202 --- /dev/null +++ b/src/elevenlabs/studio/projects/pronunciation_dictionaries/__init__.py @@ -0,0 +1,4 @@ +# This file was auto-generated by Fern from our API Definition. + +# isort: skip_file + diff --git a/src/elevenlabs/studio/projects/pronunciation_dictionaries/client.py b/src/elevenlabs/studio/projects/pronunciation_dictionaries/client.py new file mode 100644 index 00000000..b8e13ffb --- /dev/null +++ b/src/elevenlabs/studio/projects/pronunciation_dictionaries/client.py @@ -0,0 +1,160 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +from ....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ....core.request_options import RequestOptions +from ....types.create_pronunciation_dictionary_response_model import CreatePronunciationDictionaryResponseModel +from ....types.pronunciation_dictionary_version_locator import PronunciationDictionaryVersionLocator +from .raw_client import AsyncRawPronunciationDictionariesClient, RawPronunciationDictionariesClient + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class PronunciationDictionariesClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._raw_client = RawPronunciationDictionariesClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawPronunciationDictionariesClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawPronunciationDictionariesClient + """ + return self._raw_client + + def create( + self, + project_id: str, + *, + pronunciation_dictionary_locators: typing.Sequence[PronunciationDictionaryVersionLocator], + invalidate_affected_text: typing.Optional[bool] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> CreatePronunciationDictionaryResponseModel: + """ + Create a set of pronunciation dictionaries acting on a project. This will automatically mark text within this project as requiring reconverting where the new dictionary would apply or the old one no longer does. + + Parameters + ---------- + project_id : str + The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. + + pronunciation_dictionary_locators : typing.Sequence[PronunciationDictionaryVersionLocator] + A list of pronunciation dictionary locators (pronunciation_dictionary_id, version_id) encoded as a list of JSON strings for pronunciation dictionaries to be applied to the text. A list of json encoded strings is required as adding projects may occur through formData as opposed to jsonBody. To specify multiple dictionaries use multiple --form lines in your curl, such as --form 'pronunciation_dictionary_locators="{\"pronunciation_dictionary_id\":\"Vmd4Zor6fplcA7WrINey\",\"version_id\":\"hRPaxjlTdR7wFMhV4w0b\"}"' --form 'pronunciation_dictionary_locators="{\"pronunciation_dictionary_id\":\"JzWtcGQMJ6bnlWwyMo7e\",\"version_id\":\"lbmwxiLu4q6txYxgdZqn\"}"'. Note that multiple dictionaries are not currently supported by our UI which will only show the first. + + invalidate_affected_text : typing.Optional[bool] + This will automatically mark text in this project for reconversion when the new dictionary applies or the old one no longer does. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + CreatePronunciationDictionaryResponseModel + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs, PronunciationDictionaryVersionLocator + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.studio.projects.pronunciation_dictionaries.create( + project_id="21m00Tcm4TlvDq8ikWAM", + pronunciation_dictionary_locators=[ + PronunciationDictionaryVersionLocator( + pronunciation_dictionary_id="pronunciation_dictionary_id", + ) + ], + ) + """ + _response = self._raw_client.create( + project_id, + pronunciation_dictionary_locators=pronunciation_dictionary_locators, + invalidate_affected_text=invalidate_affected_text, + request_options=request_options, + ) + return _response.data + + +class AsyncPronunciationDictionariesClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawPronunciationDictionariesClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawPronunciationDictionariesClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawPronunciationDictionariesClient + """ + return self._raw_client + + async def create( + self, + project_id: str, + *, + pronunciation_dictionary_locators: typing.Sequence[PronunciationDictionaryVersionLocator], + invalidate_affected_text: typing.Optional[bool] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> CreatePronunciationDictionaryResponseModel: + """ + Create a set of pronunciation dictionaries acting on a project. This will automatically mark text within this project as requiring reconverting where the new dictionary would apply or the old one no longer does. + + Parameters + ---------- + project_id : str + The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. + + pronunciation_dictionary_locators : typing.Sequence[PronunciationDictionaryVersionLocator] + A list of pronunciation dictionary locators (pronunciation_dictionary_id, version_id) encoded as a list of JSON strings for pronunciation dictionaries to be applied to the text. A list of json encoded strings is required as adding projects may occur through formData as opposed to jsonBody. To specify multiple dictionaries use multiple --form lines in your curl, such as --form 'pronunciation_dictionary_locators="{\"pronunciation_dictionary_id\":\"Vmd4Zor6fplcA7WrINey\",\"version_id\":\"hRPaxjlTdR7wFMhV4w0b\"}"' --form 'pronunciation_dictionary_locators="{\"pronunciation_dictionary_id\":\"JzWtcGQMJ6bnlWwyMo7e\",\"version_id\":\"lbmwxiLu4q6txYxgdZqn\"}"'. Note that multiple dictionaries are not currently supported by our UI which will only show the first. + + invalidate_affected_text : typing.Optional[bool] + This will automatically mark text in this project for reconversion when the new dictionary applies or the old one no longer does. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + CreatePronunciationDictionaryResponseModel + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs, PronunciationDictionaryVersionLocator + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.studio.projects.pronunciation_dictionaries.create( + project_id="21m00Tcm4TlvDq8ikWAM", + pronunciation_dictionary_locators=[ + PronunciationDictionaryVersionLocator( + pronunciation_dictionary_id="pronunciation_dictionary_id", + ) + ], + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.create( + project_id, + pronunciation_dictionary_locators=pronunciation_dictionary_locators, + invalidate_affected_text=invalidate_affected_text, + request_options=request_options, + ) + return _response.data diff --git a/src/elevenlabs/studio/projects/pronunciation_dictionaries/raw_client.py b/src/elevenlabs/studio/projects/pronunciation_dictionaries/raw_client.py new file mode 100644 index 00000000..8a0ca47d --- /dev/null +++ b/src/elevenlabs/studio/projects/pronunciation_dictionaries/raw_client.py @@ -0,0 +1,177 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ....core.api_error import ApiError +from ....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ....core.http_response import AsyncHttpResponse, HttpResponse +from ....core.jsonable_encoder import jsonable_encoder +from ....core.request_options import RequestOptions +from ....core.serialization import convert_and_respect_annotation_metadata +from ....core.unchecked_base_model import construct_type +from ....errors.unprocessable_entity_error import UnprocessableEntityError +from ....types.create_pronunciation_dictionary_response_model import CreatePronunciationDictionaryResponseModel +from ....types.http_validation_error import HttpValidationError +from ....types.pronunciation_dictionary_version_locator import PronunciationDictionaryVersionLocator + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RawPronunciationDictionariesClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def create( + self, + project_id: str, + *, + pronunciation_dictionary_locators: typing.Sequence[PronunciationDictionaryVersionLocator], + invalidate_affected_text: typing.Optional[bool] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[CreatePronunciationDictionaryResponseModel]: + """ + Create a set of pronunciation dictionaries acting on a project. This will automatically mark text within this project as requiring reconverting where the new dictionary would apply or the old one no longer does. + + Parameters + ---------- + project_id : str + The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. + + pronunciation_dictionary_locators : typing.Sequence[PronunciationDictionaryVersionLocator] + A list of pronunciation dictionary locators (pronunciation_dictionary_id, version_id) encoded as a list of JSON strings for pronunciation dictionaries to be applied to the text. A list of json encoded strings is required as adding projects may occur through formData as opposed to jsonBody. To specify multiple dictionaries use multiple --form lines in your curl, such as --form 'pronunciation_dictionary_locators="{\"pronunciation_dictionary_id\":\"Vmd4Zor6fplcA7WrINey\",\"version_id\":\"hRPaxjlTdR7wFMhV4w0b\"}"' --form 'pronunciation_dictionary_locators="{\"pronunciation_dictionary_id\":\"JzWtcGQMJ6bnlWwyMo7e\",\"version_id\":\"lbmwxiLu4q6txYxgdZqn\"}"'. Note that multiple dictionaries are not currently supported by our UI which will only show the first. + + invalidate_affected_text : typing.Optional[bool] + This will automatically mark text in this project for reconversion when the new dictionary applies or the old one no longer does. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[CreatePronunciationDictionaryResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/studio/projects/{jsonable_encoder(project_id)}/pronunciation-dictionaries", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "pronunciation_dictionary_locators": convert_and_respect_annotation_metadata( + object_=pronunciation_dictionary_locators, + annotation=typing.Sequence[PronunciationDictionaryVersionLocator], + direction="write", + ), + "invalidate_affected_text": invalidate_affected_text, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + CreatePronunciationDictionaryResponseModel, + construct_type( + type_=CreatePronunciationDictionaryResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + +class AsyncRawPronunciationDictionariesClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def create( + self, + project_id: str, + *, + pronunciation_dictionary_locators: typing.Sequence[PronunciationDictionaryVersionLocator], + invalidate_affected_text: typing.Optional[bool] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[CreatePronunciationDictionaryResponseModel]: + """ + Create a set of pronunciation dictionaries acting on a project. This will automatically mark text within this project as requiring reconverting where the new dictionary would apply or the old one no longer does. + + Parameters + ---------- + project_id : str + The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. + + pronunciation_dictionary_locators : typing.Sequence[PronunciationDictionaryVersionLocator] + A list of pronunciation dictionary locators (pronunciation_dictionary_id, version_id) encoded as a list of JSON strings for pronunciation dictionaries to be applied to the text. A list of json encoded strings is required as adding projects may occur through formData as opposed to jsonBody. To specify multiple dictionaries use multiple --form lines in your curl, such as --form 'pronunciation_dictionary_locators="{\"pronunciation_dictionary_id\":\"Vmd4Zor6fplcA7WrINey\",\"version_id\":\"hRPaxjlTdR7wFMhV4w0b\"}"' --form 'pronunciation_dictionary_locators="{\"pronunciation_dictionary_id\":\"JzWtcGQMJ6bnlWwyMo7e\",\"version_id\":\"lbmwxiLu4q6txYxgdZqn\"}"'. Note that multiple dictionaries are not currently supported by our UI which will only show the first. + + invalidate_affected_text : typing.Optional[bool] + This will automatically mark text in this project for reconversion when the new dictionary applies or the old one no longer does. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[CreatePronunciationDictionaryResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/studio/projects/{jsonable_encoder(project_id)}/pronunciation-dictionaries", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "pronunciation_dictionary_locators": convert_and_respect_annotation_metadata( + object_=pronunciation_dictionary_locators, + annotation=typing.Sequence[PronunciationDictionaryVersionLocator], + direction="write", + ), + "invalidate_affected_text": invalidate_affected_text, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + CreatePronunciationDictionaryResponseModel, + construct_type( + type_=CreatePronunciationDictionaryResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/elevenlabs/studio/projects/raw_client.py b/src/elevenlabs/studio/projects/raw_client.py new file mode 100644 index 00000000..0857125e --- /dev/null +++ b/src/elevenlabs/studio/projects/raw_client.py @@ -0,0 +1,1017 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ... import core +from ...core.api_error import ApiError +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ...core.http_response import AsyncHttpResponse, HttpResponse +from ...core.jsonable_encoder import jsonable_encoder +from ...core.request_options import RequestOptions +from ...core.unchecked_base_model import construct_type +from ...errors.unprocessable_entity_error import UnprocessableEntityError +from ...types.add_project_response_model import AddProjectResponseModel +from ...types.convert_project_response_model import ConvertProjectResponseModel +from ...types.delete_project_response_model import DeleteProjectResponseModel +from ...types.edit_project_response_model import EditProjectResponseModel +from ...types.get_projects_response import GetProjectsResponse +from ...types.http_validation_error import HttpValidationError +from ...types.project_extended_response import ProjectExtendedResponse +from .types.projects_create_request_apply_text_normalization import ProjectsCreateRequestApplyTextNormalization +from .types.projects_create_request_fiction import ProjectsCreateRequestFiction +from .types.projects_create_request_source_type import ProjectsCreateRequestSourceType +from .types.projects_create_request_target_audience import ProjectsCreateRequestTargetAudience + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RawProjectsClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> HttpResponse[GetProjectsResponse]: + """ + Returns a list of your Studio projects with metadata. + + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[GetProjectsResponse] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + "v1/studio/projects", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetProjectsResponse, + construct_type( + type_=GetProjectsResponse, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def create( + self, + *, + name: str, + default_title_voice_id: str, + default_paragraph_voice_id: str, + default_model_id: str, + from_url: typing.Optional[str] = OMIT, + from_document: typing.Optional[core.File] = OMIT, + quality_preset: typing.Optional[str] = OMIT, + title: typing.Optional[str] = OMIT, + author: typing.Optional[str] = OMIT, + description: typing.Optional[str] = OMIT, + genres: typing.Optional[typing.List[str]] = OMIT, + target_audience: typing.Optional[ProjectsCreateRequestTargetAudience] = OMIT, + language: typing.Optional[str] = OMIT, + content_type: typing.Optional[str] = OMIT, + original_publication_date: typing.Optional[str] = OMIT, + mature_content: typing.Optional[bool] = OMIT, + isbn_number: typing.Optional[str] = OMIT, + acx_volume_normalization: typing.Optional[bool] = OMIT, + volume_normalization: typing.Optional[bool] = OMIT, + pronunciation_dictionary_locators: typing.Optional[typing.List[str]] = OMIT, + callback_url: typing.Optional[str] = OMIT, + fiction: typing.Optional[ProjectsCreateRequestFiction] = OMIT, + apply_text_normalization: typing.Optional[ProjectsCreateRequestApplyTextNormalization] = OMIT, + auto_convert: typing.Optional[bool] = OMIT, + auto_assign_voices: typing.Optional[bool] = OMIT, + source_type: typing.Optional[ProjectsCreateRequestSourceType] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[AddProjectResponseModel]: + """ + Creates a new Studio project, it can be either initialized as blank, from a document or from a URL. + + Parameters + ---------- + name : str + The name of the Studio project, used for identification only. + + default_title_voice_id : str + The voice_id that corresponds to the default voice used for new titles. + + default_paragraph_voice_id : str + The voice_id that corresponds to the default voice used for new paragraphs. + + default_model_id : str + The ID of the model to be used for this Studio project, you can query GET /v1/models to list all available models. + + from_url : typing.Optional[str] + An optional URL from which we will extract content to initialize the Studio project. If this is set, 'from_url' must be null. If neither 'from_url' or 'from_document' are provided we will initialize the Studio project as blank. + + from_document : typing.Optional[core.File] + See core.File for more documentation + + quality_preset : typing.Optional[str] + Output quality of the generated audio. Must be one of: + standard - standard output format, 128kbps with 44.1kHz sample rate. + high - high quality output format, 192kbps with 44.1kHz sample rate and major improvements on our side. Using this setting increases the credit cost by 20%. + ultra - ultra quality output format, 192kbps with 44.1kHz sample rate and highest improvements on our side. Using this setting increases the credit cost by 50%. + ultra lossless - ultra quality output format, 705.6kbps with 44.1kHz sample rate and highest improvements on our side in a fully lossless format. Using this setting increases the credit cost by 100%. + + title : typing.Optional[str] + An optional name of the author of the Studio project, this will be added as metadata to the mp3 file on Studio project or chapter download. + + author : typing.Optional[str] + An optional name of the author of the Studio project, this will be added as metadata to the mp3 file on Studio project or chapter download. + + description : typing.Optional[str] + An optional description of the Studio project. + + genres : typing.Optional[typing.List[str]] + An optional list of genres associated with the Studio project. + + target_audience : typing.Optional[ProjectsCreateRequestTargetAudience] + An optional target audience of the Studio project. + + language : typing.Optional[str] + An optional language of the Studio project. Two-letter language code (ISO 639-1). + + content_type : typing.Optional[str] + An optional content type of the Studio project. + + original_publication_date : typing.Optional[str] + An optional original publication date of the Studio project, in the format YYYY-MM-DD or YYYY. + + mature_content : typing.Optional[bool] + An optional specification of whether this Studio project contains mature content. + + isbn_number : typing.Optional[str] + An optional ISBN number of the Studio project you want to create, this will be added as metadata to the mp3 file on Studio project or chapter download. + + acx_volume_normalization : typing.Optional[bool] + [Deprecated] When the Studio project is downloaded, should the returned audio have postprocessing in order to make it compliant with audiobook normalized volume requirements + + volume_normalization : typing.Optional[bool] + When the Studio project is downloaded, should the returned audio have postprocessing in order to make it compliant with audiobook normalized volume requirements + + pronunciation_dictionary_locators : typing.Optional[typing.List[str]] + A list of pronunciation dictionary locators (pronunciation_dictionary_id, version_id) encoded as a list of JSON strings for pronunciation dictionaries to be applied to the text. A list of json encoded strings is required as adding projects may occur through formData as opposed to jsonBody. To specify multiple dictionaries use multiple --form lines in your curl, such as --form 'pronunciation_dictionary_locators="{\"pronunciation_dictionary_id\":\"Vmd4Zor6fplcA7WrINey\",\"version_id\":\"hRPaxjlTdR7wFMhV4w0b\"}"' --form 'pronunciation_dictionary_locators="{\"pronunciation_dictionary_id\":\"JzWtcGQMJ6bnlWwyMo7e\",\"version_id\":\"lbmwxiLu4q6txYxgdZqn\"}"'. Note that multiple dictionaries are not currently supported by our UI which will only show the first. + + callback_url : typing.Optional[str] + A url that will be called by our service when the Studio project is converted. Request will contain a json blob containing the status of the conversion + + fiction : typing.Optional[ProjectsCreateRequestFiction] + An optional specification of whether the content of this Studio project is fiction. + + apply_text_normalization : typing.Optional[ProjectsCreateRequestApplyTextNormalization] + + This parameter controls text normalization with four modes: 'auto', 'on', 'apply_english' and 'off'. + When set to 'auto', the system will automatically decide whether to apply text normalization + (e.g., spelling out numbers). With 'on', text normalization will always be applied, while + with 'off', it will be skipped. 'apply_english' is the same as 'on' but will assume that text is in English. + + + auto_convert : typing.Optional[bool] + Whether to auto convert the Studio project to audio or not. + + auto_assign_voices : typing.Optional[bool] + [Alpha Feature] Whether automatically assign voices to phrases in the create Project. + + source_type : typing.Optional[ProjectsCreateRequestSourceType] + The type of Studio project to create. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[AddProjectResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + "v1/studio/projects", + base_url=self._client_wrapper.get_environment().base, + method="POST", + data={ + "name": name, + "default_title_voice_id": default_title_voice_id, + "default_paragraph_voice_id": default_paragraph_voice_id, + "default_model_id": default_model_id, + "from_url": from_url, + "quality_preset": quality_preset, + "title": title, + "author": author, + "description": description, + "genres": genres, + "target_audience": target_audience, + "language": language, + "content_type": content_type, + "original_publication_date": original_publication_date, + "mature_content": mature_content, + "isbn_number": isbn_number, + "acx_volume_normalization": acx_volume_normalization, + "volume_normalization": volume_normalization, + "pronunciation_dictionary_locators": pronunciation_dictionary_locators, + "callback_url": callback_url, + "fiction": fiction, + "apply_text_normalization": apply_text_normalization, + "auto_convert": auto_convert, + "auto_assign_voices": auto_assign_voices, + "source_type": source_type, + }, + files={ + **({"from_document": from_document} if from_document is not None else {}), + }, + request_options=request_options, + omit=OMIT, + force_multipart=True, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + AddProjectResponseModel, + construct_type( + type_=AddProjectResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def get( + self, project_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[ProjectExtendedResponse]: + """ + Returns information about a specific Studio project. This endpoint returns more detailed information about a project than `GET /v1/studio`. + + Parameters + ---------- + project_id : str + The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[ProjectExtendedResponse] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/studio/projects/{jsonable_encoder(project_id)}", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ProjectExtendedResponse, + construct_type( + type_=ProjectExtendedResponse, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def update( + self, + project_id: str, + *, + name: str, + default_title_voice_id: str, + default_paragraph_voice_id: str, + title: typing.Optional[str] = OMIT, + author: typing.Optional[str] = OMIT, + isbn_number: typing.Optional[str] = OMIT, + volume_normalization: typing.Optional[bool] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[EditProjectResponseModel]: + """ + Updates the specified Studio project by setting the values of the parameters passed. + + Parameters + ---------- + project_id : str + The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. + + name : str + The name of the Studio project, used for identification only. + + default_title_voice_id : str + The voice_id that corresponds to the default voice used for new titles. + + default_paragraph_voice_id : str + The voice_id that corresponds to the default voice used for new paragraphs. + + title : typing.Optional[str] + An optional name of the author of the Studio project, this will be added as metadata to the mp3 file on Studio project or chapter download. + + author : typing.Optional[str] + An optional name of the author of the Studio project, this will be added as metadata to the mp3 file on Studio project or chapter download. + + isbn_number : typing.Optional[str] + An optional ISBN number of the Studio project you want to create, this will be added as metadata to the mp3 file on Studio project or chapter download. + + volume_normalization : typing.Optional[bool] + When the Studio project is downloaded, should the returned audio have postprocessing in order to make it compliant with audiobook normalized volume requirements + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[EditProjectResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/studio/projects/{jsonable_encoder(project_id)}", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "name": name, + "default_title_voice_id": default_title_voice_id, + "default_paragraph_voice_id": default_paragraph_voice_id, + "title": title, + "author": author, + "isbn_number": isbn_number, + "volume_normalization": volume_normalization, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + EditProjectResponseModel, + construct_type( + type_=EditProjectResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def delete( + self, project_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[DeleteProjectResponseModel]: + """ + Deletes a Studio project. + + Parameters + ---------- + project_id : str + The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[DeleteProjectResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/studio/projects/{jsonable_encoder(project_id)}", + base_url=self._client_wrapper.get_environment().base, + method="DELETE", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + DeleteProjectResponseModel, + construct_type( + type_=DeleteProjectResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def convert( + self, project_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[ConvertProjectResponseModel]: + """ + Starts conversion of a Studio project and all of its chapters. + + Parameters + ---------- + project_id : str + The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[ConvertProjectResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/studio/projects/{jsonable_encoder(project_id)}/convert", + base_url=self._client_wrapper.get_environment().base, + method="POST", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ConvertProjectResponseModel, + construct_type( + type_=ConvertProjectResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + +class AsyncRawProjectsClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def list( + self, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[GetProjectsResponse]: + """ + Returns a list of your Studio projects with metadata. + + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[GetProjectsResponse] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + "v1/studio/projects", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetProjectsResponse, + construct_type( + type_=GetProjectsResponse, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def create( + self, + *, + name: str, + default_title_voice_id: str, + default_paragraph_voice_id: str, + default_model_id: str, + from_url: typing.Optional[str] = OMIT, + from_document: typing.Optional[core.File] = OMIT, + quality_preset: typing.Optional[str] = OMIT, + title: typing.Optional[str] = OMIT, + author: typing.Optional[str] = OMIT, + description: typing.Optional[str] = OMIT, + genres: typing.Optional[typing.List[str]] = OMIT, + target_audience: typing.Optional[ProjectsCreateRequestTargetAudience] = OMIT, + language: typing.Optional[str] = OMIT, + content_type: typing.Optional[str] = OMIT, + original_publication_date: typing.Optional[str] = OMIT, + mature_content: typing.Optional[bool] = OMIT, + isbn_number: typing.Optional[str] = OMIT, + acx_volume_normalization: typing.Optional[bool] = OMIT, + volume_normalization: typing.Optional[bool] = OMIT, + pronunciation_dictionary_locators: typing.Optional[typing.List[str]] = OMIT, + callback_url: typing.Optional[str] = OMIT, + fiction: typing.Optional[ProjectsCreateRequestFiction] = OMIT, + apply_text_normalization: typing.Optional[ProjectsCreateRequestApplyTextNormalization] = OMIT, + auto_convert: typing.Optional[bool] = OMIT, + auto_assign_voices: typing.Optional[bool] = OMIT, + source_type: typing.Optional[ProjectsCreateRequestSourceType] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[AddProjectResponseModel]: + """ + Creates a new Studio project, it can be either initialized as blank, from a document or from a URL. + + Parameters + ---------- + name : str + The name of the Studio project, used for identification only. + + default_title_voice_id : str + The voice_id that corresponds to the default voice used for new titles. + + default_paragraph_voice_id : str + The voice_id that corresponds to the default voice used for new paragraphs. + + default_model_id : str + The ID of the model to be used for this Studio project, you can query GET /v1/models to list all available models. + + from_url : typing.Optional[str] + An optional URL from which we will extract content to initialize the Studio project. If this is set, 'from_url' must be null. If neither 'from_url' or 'from_document' are provided we will initialize the Studio project as blank. + + from_document : typing.Optional[core.File] + See core.File for more documentation + + quality_preset : typing.Optional[str] + Output quality of the generated audio. Must be one of: + standard - standard output format, 128kbps with 44.1kHz sample rate. + high - high quality output format, 192kbps with 44.1kHz sample rate and major improvements on our side. Using this setting increases the credit cost by 20%. + ultra - ultra quality output format, 192kbps with 44.1kHz sample rate and highest improvements on our side. Using this setting increases the credit cost by 50%. + ultra lossless - ultra quality output format, 705.6kbps with 44.1kHz sample rate and highest improvements on our side in a fully lossless format. Using this setting increases the credit cost by 100%. + + title : typing.Optional[str] + An optional name of the author of the Studio project, this will be added as metadata to the mp3 file on Studio project or chapter download. + + author : typing.Optional[str] + An optional name of the author of the Studio project, this will be added as metadata to the mp3 file on Studio project or chapter download. + + description : typing.Optional[str] + An optional description of the Studio project. + + genres : typing.Optional[typing.List[str]] + An optional list of genres associated with the Studio project. + + target_audience : typing.Optional[ProjectsCreateRequestTargetAudience] + An optional target audience of the Studio project. + + language : typing.Optional[str] + An optional language of the Studio project. Two-letter language code (ISO 639-1). + + content_type : typing.Optional[str] + An optional content type of the Studio project. + + original_publication_date : typing.Optional[str] + An optional original publication date of the Studio project, in the format YYYY-MM-DD or YYYY. + + mature_content : typing.Optional[bool] + An optional specification of whether this Studio project contains mature content. + + isbn_number : typing.Optional[str] + An optional ISBN number of the Studio project you want to create, this will be added as metadata to the mp3 file on Studio project or chapter download. + + acx_volume_normalization : typing.Optional[bool] + [Deprecated] When the Studio project is downloaded, should the returned audio have postprocessing in order to make it compliant with audiobook normalized volume requirements + + volume_normalization : typing.Optional[bool] + When the Studio project is downloaded, should the returned audio have postprocessing in order to make it compliant with audiobook normalized volume requirements + + pronunciation_dictionary_locators : typing.Optional[typing.List[str]] + A list of pronunciation dictionary locators (pronunciation_dictionary_id, version_id) encoded as a list of JSON strings for pronunciation dictionaries to be applied to the text. A list of json encoded strings is required as adding projects may occur through formData as opposed to jsonBody. To specify multiple dictionaries use multiple --form lines in your curl, such as --form 'pronunciation_dictionary_locators="{\"pronunciation_dictionary_id\":\"Vmd4Zor6fplcA7WrINey\",\"version_id\":\"hRPaxjlTdR7wFMhV4w0b\"}"' --form 'pronunciation_dictionary_locators="{\"pronunciation_dictionary_id\":\"JzWtcGQMJ6bnlWwyMo7e\",\"version_id\":\"lbmwxiLu4q6txYxgdZqn\"}"'. Note that multiple dictionaries are not currently supported by our UI which will only show the first. + + callback_url : typing.Optional[str] + A url that will be called by our service when the Studio project is converted. Request will contain a json blob containing the status of the conversion + + fiction : typing.Optional[ProjectsCreateRequestFiction] + An optional specification of whether the content of this Studio project is fiction. + + apply_text_normalization : typing.Optional[ProjectsCreateRequestApplyTextNormalization] + + This parameter controls text normalization with four modes: 'auto', 'on', 'apply_english' and 'off'. + When set to 'auto', the system will automatically decide whether to apply text normalization + (e.g., spelling out numbers). With 'on', text normalization will always be applied, while + with 'off', it will be skipped. 'apply_english' is the same as 'on' but will assume that text is in English. + + + auto_convert : typing.Optional[bool] + Whether to auto convert the Studio project to audio or not. + + auto_assign_voices : typing.Optional[bool] + [Alpha Feature] Whether automatically assign voices to phrases in the create Project. + + source_type : typing.Optional[ProjectsCreateRequestSourceType] + The type of Studio project to create. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[AddProjectResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + "v1/studio/projects", + base_url=self._client_wrapper.get_environment().base, + method="POST", + data={ + "name": name, + "default_title_voice_id": default_title_voice_id, + "default_paragraph_voice_id": default_paragraph_voice_id, + "default_model_id": default_model_id, + "from_url": from_url, + "quality_preset": quality_preset, + "title": title, + "author": author, + "description": description, + "genres": genres, + "target_audience": target_audience, + "language": language, + "content_type": content_type, + "original_publication_date": original_publication_date, + "mature_content": mature_content, + "isbn_number": isbn_number, + "acx_volume_normalization": acx_volume_normalization, + "volume_normalization": volume_normalization, + "pronunciation_dictionary_locators": pronunciation_dictionary_locators, + "callback_url": callback_url, + "fiction": fiction, + "apply_text_normalization": apply_text_normalization, + "auto_convert": auto_convert, + "auto_assign_voices": auto_assign_voices, + "source_type": source_type, + }, + files={ + **({"from_document": from_document} if from_document is not None else {}), + }, + request_options=request_options, + omit=OMIT, + force_multipart=True, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + AddProjectResponseModel, + construct_type( + type_=AddProjectResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def get( + self, project_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[ProjectExtendedResponse]: + """ + Returns information about a specific Studio project. This endpoint returns more detailed information about a project than `GET /v1/studio`. + + Parameters + ---------- + project_id : str + The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[ProjectExtendedResponse] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/studio/projects/{jsonable_encoder(project_id)}", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ProjectExtendedResponse, + construct_type( + type_=ProjectExtendedResponse, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def update( + self, + project_id: str, + *, + name: str, + default_title_voice_id: str, + default_paragraph_voice_id: str, + title: typing.Optional[str] = OMIT, + author: typing.Optional[str] = OMIT, + isbn_number: typing.Optional[str] = OMIT, + volume_normalization: typing.Optional[bool] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[EditProjectResponseModel]: + """ + Updates the specified Studio project by setting the values of the parameters passed. + + Parameters + ---------- + project_id : str + The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. + + name : str + The name of the Studio project, used for identification only. + + default_title_voice_id : str + The voice_id that corresponds to the default voice used for new titles. + + default_paragraph_voice_id : str + The voice_id that corresponds to the default voice used for new paragraphs. + + title : typing.Optional[str] + An optional name of the author of the Studio project, this will be added as metadata to the mp3 file on Studio project or chapter download. + + author : typing.Optional[str] + An optional name of the author of the Studio project, this will be added as metadata to the mp3 file on Studio project or chapter download. + + isbn_number : typing.Optional[str] + An optional ISBN number of the Studio project you want to create, this will be added as metadata to the mp3 file on Studio project or chapter download. + + volume_normalization : typing.Optional[bool] + When the Studio project is downloaded, should the returned audio have postprocessing in order to make it compliant with audiobook normalized volume requirements + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[EditProjectResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/studio/projects/{jsonable_encoder(project_id)}", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "name": name, + "default_title_voice_id": default_title_voice_id, + "default_paragraph_voice_id": default_paragraph_voice_id, + "title": title, + "author": author, + "isbn_number": isbn_number, + "volume_normalization": volume_normalization, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + EditProjectResponseModel, + construct_type( + type_=EditProjectResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def delete( + self, project_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[DeleteProjectResponseModel]: + """ + Deletes a Studio project. + + Parameters + ---------- + project_id : str + The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[DeleteProjectResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/studio/projects/{jsonable_encoder(project_id)}", + base_url=self._client_wrapper.get_environment().base, + method="DELETE", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + DeleteProjectResponseModel, + construct_type( + type_=DeleteProjectResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def convert( + self, project_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[ConvertProjectResponseModel]: + """ + Starts conversion of a Studio project and all of its chapters. + + Parameters + ---------- + project_id : str + The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[ConvertProjectResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/studio/projects/{jsonable_encoder(project_id)}/convert", + base_url=self._client_wrapper.get_environment().base, + method="POST", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ConvertProjectResponseModel, + construct_type( + type_=ConvertProjectResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/elevenlabs/studio/projects/snapshots/__init__.py b/src/elevenlabs/studio/projects/snapshots/__init__.py new file mode 100644 index 00000000..5cde0202 --- /dev/null +++ b/src/elevenlabs/studio/projects/snapshots/__init__.py @@ -0,0 +1,4 @@ +# This file was auto-generated by Fern from our API Definition. + +# isort: skip_file + diff --git a/src/elevenlabs/studio/projects/snapshots/client.py b/src/elevenlabs/studio/projects/snapshots/client.py new file mode 100644 index 00000000..4481915e --- /dev/null +++ b/src/elevenlabs/studio/projects/snapshots/client.py @@ -0,0 +1,324 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +from ....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ....core.request_options import RequestOptions +from ....types.project_snapshot_extended_response_model import ProjectSnapshotExtendedResponseModel +from ....types.project_snapshots_response import ProjectSnapshotsResponse +from .raw_client import AsyncRawSnapshotsClient, RawSnapshotsClient + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class SnapshotsClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._raw_client = RawSnapshotsClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawSnapshotsClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawSnapshotsClient + """ + return self._raw_client + + def list( + self, project_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> ProjectSnapshotsResponse: + """ + Retrieves a list of snapshots for a Studio project. + + Parameters + ---------- + project_id : str + The ID of the Studio project. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ProjectSnapshotsResponse + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.studio.projects.snapshots.list( + project_id="21m00Tcm4TlvDq8ikWAM", + ) + """ + _response = self._raw_client.list(project_id, request_options=request_options) + return _response.data + + def get( + self, project_id: str, project_snapshot_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> ProjectSnapshotExtendedResponseModel: + """ + Returns the project snapshot. + + Parameters + ---------- + project_id : str + The ID of the Studio project. + + project_snapshot_id : str + The ID of the Studio project snapshot. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ProjectSnapshotExtendedResponseModel + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.studio.projects.snapshots.get( + project_id="21m00Tcm4TlvDq8ikWAM", + project_snapshot_id="21m00Tcm4TlvDq8ikWAM", + ) + """ + _response = self._raw_client.get(project_id, project_snapshot_id, request_options=request_options) + return _response.data + + def stream( + self, + project_id: str, + project_snapshot_id: str, + *, + convert_to_mpeg: typing.Optional[bool] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> typing.Iterator[bytes]: + """ + Stream the audio from a Studio project snapshot. + + Parameters + ---------- + project_id : str + The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. + + project_snapshot_id : str + The ID of the Studio project snapshot. + + convert_to_mpeg : typing.Optional[bool] + Whether to convert the audio to mpeg format. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. + + Returns + ------- + typing.Iterator[bytes] + Successful Response + """ + with self._raw_client.stream( + project_id, project_snapshot_id, convert_to_mpeg=convert_to_mpeg, request_options=request_options + ) as r: + yield from r.data + + def stream_archive( + self, project_id: str, project_snapshot_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> typing.Iterator[bytes]: + """ + Returns a compressed archive of the Studio project's audio. + + Parameters + ---------- + project_id : str + The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. + + project_snapshot_id : str + The ID of the Studio project snapshot. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. + + Returns + ------- + typing.Iterator[bytes] + Streaming archive data + """ + with self._raw_client.stream_archive(project_id, project_snapshot_id, request_options=request_options) as r: + yield from r.data + + +class AsyncSnapshotsClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawSnapshotsClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawSnapshotsClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawSnapshotsClient + """ + return self._raw_client + + async def list( + self, project_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> ProjectSnapshotsResponse: + """ + Retrieves a list of snapshots for a Studio project. + + Parameters + ---------- + project_id : str + The ID of the Studio project. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ProjectSnapshotsResponse + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.studio.projects.snapshots.list( + project_id="21m00Tcm4TlvDq8ikWAM", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.list(project_id, request_options=request_options) + return _response.data + + async def get( + self, project_id: str, project_snapshot_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> ProjectSnapshotExtendedResponseModel: + """ + Returns the project snapshot. + + Parameters + ---------- + project_id : str + The ID of the Studio project. + + project_snapshot_id : str + The ID of the Studio project snapshot. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ProjectSnapshotExtendedResponseModel + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.studio.projects.snapshots.get( + project_id="21m00Tcm4TlvDq8ikWAM", + project_snapshot_id="21m00Tcm4TlvDq8ikWAM", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.get(project_id, project_snapshot_id, request_options=request_options) + return _response.data + + async def stream( + self, + project_id: str, + project_snapshot_id: str, + *, + convert_to_mpeg: typing.Optional[bool] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> typing.AsyncIterator[bytes]: + """ + Stream the audio from a Studio project snapshot. + + Parameters + ---------- + project_id : str + The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. + + project_snapshot_id : str + The ID of the Studio project snapshot. + + convert_to_mpeg : typing.Optional[bool] + Whether to convert the audio to mpeg format. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. + + Returns + ------- + typing.AsyncIterator[bytes] + Successful Response + """ + async with self._raw_client.stream( + project_id, project_snapshot_id, convert_to_mpeg=convert_to_mpeg, request_options=request_options + ) as r: + async for _chunk in r.data: + yield _chunk + + async def stream_archive( + self, project_id: str, project_snapshot_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> typing.AsyncIterator[bytes]: + """ + Returns a compressed archive of the Studio project's audio. + + Parameters + ---------- + project_id : str + The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. + + project_snapshot_id : str + The ID of the Studio project snapshot. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. + + Returns + ------- + typing.AsyncIterator[bytes] + Streaming archive data + """ + async with self._raw_client.stream_archive( + project_id, project_snapshot_id, request_options=request_options + ) as r: + async for _chunk in r.data: + yield _chunk diff --git a/src/elevenlabs/studio/projects/snapshots/raw_client.py b/src/elevenlabs/studio/projects/snapshots/raw_client.py new file mode 100644 index 00000000..a5cb2fc5 --- /dev/null +++ b/src/elevenlabs/studio/projects/snapshots/raw_client.py @@ -0,0 +1,503 @@ +# This file was auto-generated by Fern from our API Definition. + +import contextlib +import typing +from json.decoder import JSONDecodeError + +from ....core.api_error import ApiError +from ....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ....core.http_response import AsyncHttpResponse, HttpResponse +from ....core.jsonable_encoder import jsonable_encoder +from ....core.request_options import RequestOptions +from ....core.unchecked_base_model import construct_type +from ....errors.unprocessable_entity_error import UnprocessableEntityError +from ....types.http_validation_error import HttpValidationError +from ....types.project_snapshot_extended_response_model import ProjectSnapshotExtendedResponseModel +from ....types.project_snapshots_response import ProjectSnapshotsResponse + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RawSnapshotsClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def list( + self, project_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[ProjectSnapshotsResponse]: + """ + Retrieves a list of snapshots for a Studio project. + + Parameters + ---------- + project_id : str + The ID of the Studio project. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[ProjectSnapshotsResponse] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/studio/projects/{jsonable_encoder(project_id)}/snapshots", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ProjectSnapshotsResponse, + construct_type( + type_=ProjectSnapshotsResponse, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def get( + self, project_id: str, project_snapshot_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[ProjectSnapshotExtendedResponseModel]: + """ + Returns the project snapshot. + + Parameters + ---------- + project_id : str + The ID of the Studio project. + + project_snapshot_id : str + The ID of the Studio project snapshot. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[ProjectSnapshotExtendedResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/studio/projects/{jsonable_encoder(project_id)}/snapshots/{jsonable_encoder(project_snapshot_id)}", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ProjectSnapshotExtendedResponseModel, + construct_type( + type_=ProjectSnapshotExtendedResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + @contextlib.contextmanager + def stream( + self, + project_id: str, + project_snapshot_id: str, + *, + convert_to_mpeg: typing.Optional[bool] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> typing.Iterator[HttpResponse[typing.Iterator[bytes]]]: + """ + Stream the audio from a Studio project snapshot. + + Parameters + ---------- + project_id : str + The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. + + project_snapshot_id : str + The ID of the Studio project snapshot. + + convert_to_mpeg : typing.Optional[bool] + Whether to convert the audio to mpeg format. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. + + Returns + ------- + typing.Iterator[HttpResponse[typing.Iterator[bytes]]] + Successful Response + """ + with self._client_wrapper.httpx_client.stream( + f"v1/studio/projects/{jsonable_encoder(project_id)}/snapshots/{jsonable_encoder(project_snapshot_id)}/stream", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "convert_to_mpeg": convert_to_mpeg, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) as _response: + + def _stream() -> HttpResponse[typing.Iterator[bytes]]: + try: + if 200 <= _response.status_code < 300: + _chunk_size = request_options.get("chunk_size", 1024) if request_options is not None else 1024 + return HttpResponse( + response=_response, data=(_chunk for _chunk in _response.iter_bytes(chunk_size=_chunk_size)) + ) + _response.read() + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + yield _stream() + + @contextlib.contextmanager + def stream_archive( + self, project_id: str, project_snapshot_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> typing.Iterator[HttpResponse[typing.Iterator[bytes]]]: + """ + Returns a compressed archive of the Studio project's audio. + + Parameters + ---------- + project_id : str + The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. + + project_snapshot_id : str + The ID of the Studio project snapshot. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. + + Returns + ------- + typing.Iterator[HttpResponse[typing.Iterator[bytes]]] + Streaming archive data + """ + with self._client_wrapper.httpx_client.stream( + f"v1/studio/projects/{jsonable_encoder(project_id)}/snapshots/{jsonable_encoder(project_snapshot_id)}/archive", + base_url=self._client_wrapper.get_environment().base, + method="POST", + request_options=request_options, + ) as _response: + + def _stream() -> HttpResponse[typing.Iterator[bytes]]: + try: + if 200 <= _response.status_code < 300: + _chunk_size = request_options.get("chunk_size", 1024) if request_options is not None else 1024 + return HttpResponse( + response=_response, data=(_chunk for _chunk in _response.iter_bytes(chunk_size=_chunk_size)) + ) + _response.read() + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + yield _stream() + + +class AsyncRawSnapshotsClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def list( + self, project_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[ProjectSnapshotsResponse]: + """ + Retrieves a list of snapshots for a Studio project. + + Parameters + ---------- + project_id : str + The ID of the Studio project. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[ProjectSnapshotsResponse] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/studio/projects/{jsonable_encoder(project_id)}/snapshots", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ProjectSnapshotsResponse, + construct_type( + type_=ProjectSnapshotsResponse, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def get( + self, project_id: str, project_snapshot_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[ProjectSnapshotExtendedResponseModel]: + """ + Returns the project snapshot. + + Parameters + ---------- + project_id : str + The ID of the Studio project. + + project_snapshot_id : str + The ID of the Studio project snapshot. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[ProjectSnapshotExtendedResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/studio/projects/{jsonable_encoder(project_id)}/snapshots/{jsonable_encoder(project_snapshot_id)}", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ProjectSnapshotExtendedResponseModel, + construct_type( + type_=ProjectSnapshotExtendedResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + @contextlib.asynccontextmanager + async def stream( + self, + project_id: str, + project_snapshot_id: str, + *, + convert_to_mpeg: typing.Optional[bool] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> typing.AsyncIterator[AsyncHttpResponse[typing.AsyncIterator[bytes]]]: + """ + Stream the audio from a Studio project snapshot. + + Parameters + ---------- + project_id : str + The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. + + project_snapshot_id : str + The ID of the Studio project snapshot. + + convert_to_mpeg : typing.Optional[bool] + Whether to convert the audio to mpeg format. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. + + Returns + ------- + typing.AsyncIterator[AsyncHttpResponse[typing.AsyncIterator[bytes]]] + Successful Response + """ + async with self._client_wrapper.httpx_client.stream( + f"v1/studio/projects/{jsonable_encoder(project_id)}/snapshots/{jsonable_encoder(project_snapshot_id)}/stream", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "convert_to_mpeg": convert_to_mpeg, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) as _response: + + async def _stream() -> AsyncHttpResponse[typing.AsyncIterator[bytes]]: + try: + if 200 <= _response.status_code < 300: + _chunk_size = request_options.get("chunk_size", 1024) if request_options is not None else 1024 + return AsyncHttpResponse( + response=_response, + data=(_chunk async for _chunk in _response.aiter_bytes(chunk_size=_chunk_size)), + ) + await _response.aread() + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + yield await _stream() + + @contextlib.asynccontextmanager + async def stream_archive( + self, project_id: str, project_snapshot_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> typing.AsyncIterator[AsyncHttpResponse[typing.AsyncIterator[bytes]]]: + """ + Returns a compressed archive of the Studio project's audio. + + Parameters + ---------- + project_id : str + The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects. + + project_snapshot_id : str + The ID of the Studio project snapshot. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. + + Returns + ------- + typing.AsyncIterator[AsyncHttpResponse[typing.AsyncIterator[bytes]]] + Streaming archive data + """ + async with self._client_wrapper.httpx_client.stream( + f"v1/studio/projects/{jsonable_encoder(project_id)}/snapshots/{jsonable_encoder(project_snapshot_id)}/archive", + base_url=self._client_wrapper.get_environment().base, + method="POST", + request_options=request_options, + ) as _response: + + async def _stream() -> AsyncHttpResponse[typing.AsyncIterator[bytes]]: + try: + if 200 <= _response.status_code < 300: + _chunk_size = request_options.get("chunk_size", 1024) if request_options is not None else 1024 + return AsyncHttpResponse( + response=_response, + data=(_chunk async for _chunk in _response.aiter_bytes(chunk_size=_chunk_size)), + ) + await _response.aread() + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + yield await _stream() diff --git a/src/elevenlabs/studio/projects/types/__init__.py b/src/elevenlabs/studio/projects/types/__init__.py index ddd19104..387315dc 100644 --- a/src/elevenlabs/studio/projects/types/__init__.py +++ b/src/elevenlabs/studio/projects/types/__init__.py @@ -1,13 +1,15 @@ # This file was auto-generated by Fern from our API Definition. -from .projects_add_request_apply_text_normalization import ProjectsAddRequestApplyTextNormalization -from .projects_add_request_fiction import ProjectsAddRequestFiction -from .projects_add_request_source_type import ProjectsAddRequestSourceType -from .projects_add_request_target_audience import ProjectsAddRequestTargetAudience +# isort: skip_file + +from .projects_create_request_apply_text_normalization import ProjectsCreateRequestApplyTextNormalization +from .projects_create_request_fiction import ProjectsCreateRequestFiction +from .projects_create_request_source_type import ProjectsCreateRequestSourceType +from .projects_create_request_target_audience import ProjectsCreateRequestTargetAudience __all__ = [ - "ProjectsAddRequestApplyTextNormalization", - "ProjectsAddRequestFiction", - "ProjectsAddRequestSourceType", - "ProjectsAddRequestTargetAudience", + "ProjectsCreateRequestApplyTextNormalization", + "ProjectsCreateRequestFiction", + "ProjectsCreateRequestSourceType", + "ProjectsCreateRequestTargetAudience", ] diff --git a/src/elevenlabs/studio/projects/types/projects_add_request_fiction.py b/src/elevenlabs/studio/projects/types/projects_add_request_fiction.py deleted file mode 100644 index a5232ff3..00000000 --- a/src/elevenlabs/studio/projects/types/projects_add_request_fiction.py +++ /dev/null @@ -1,5 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import typing - -ProjectsAddRequestFiction = typing.Union[typing.Literal["fiction", "non-fiction"], typing.Any] diff --git a/src/elevenlabs/studio/projects/types/projects_add_request_source_type.py b/src/elevenlabs/studio/projects/types/projects_add_request_source_type.py deleted file mode 100644 index 36180e08..00000000 --- a/src/elevenlabs/studio/projects/types/projects_add_request_source_type.py +++ /dev/null @@ -1,5 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import typing - -ProjectsAddRequestSourceType = typing.Union[typing.Literal["blank", "book", "article", "genfm"], typing.Any] diff --git a/src/elevenlabs/studio/projects/types/projects_add_request_apply_text_normalization.py b/src/elevenlabs/studio/projects/types/projects_create_request_apply_text_normalization.py similarity index 71% rename from src/elevenlabs/studio/projects/types/projects_add_request_apply_text_normalization.py rename to src/elevenlabs/studio/projects/types/projects_create_request_apply_text_normalization.py index fcac9bb6..d09d85ed 100644 --- a/src/elevenlabs/studio/projects/types/projects_add_request_apply_text_normalization.py +++ b/src/elevenlabs/studio/projects/types/projects_create_request_apply_text_normalization.py @@ -2,6 +2,6 @@ import typing -ProjectsAddRequestApplyTextNormalization = typing.Union[ +ProjectsCreateRequestApplyTextNormalization = typing.Union[ typing.Literal["auto", "on", "off", "apply_english"], typing.Any ] diff --git a/src/elevenlabs/studio/projects/types/projects_create_request_fiction.py b/src/elevenlabs/studio/projects/types/projects_create_request_fiction.py new file mode 100644 index 00000000..2303088a --- /dev/null +++ b/src/elevenlabs/studio/projects/types/projects_create_request_fiction.py @@ -0,0 +1,5 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +ProjectsCreateRequestFiction = typing.Union[typing.Literal["fiction", "non-fiction"], typing.Any] diff --git a/src/elevenlabs/studio/projects/types/projects_create_request_source_type.py b/src/elevenlabs/studio/projects/types/projects_create_request_source_type.py new file mode 100644 index 00000000..b2c35e56 --- /dev/null +++ b/src/elevenlabs/studio/projects/types/projects_create_request_source_type.py @@ -0,0 +1,5 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +ProjectsCreateRequestSourceType = typing.Union[typing.Literal["blank", "book", "article", "genfm"], typing.Any] diff --git a/src/elevenlabs/studio/projects/types/projects_add_request_target_audience.py b/src/elevenlabs/studio/projects/types/projects_create_request_target_audience.py similarity index 75% rename from src/elevenlabs/studio/projects/types/projects_add_request_target_audience.py rename to src/elevenlabs/studio/projects/types/projects_create_request_target_audience.py index 74c8b589..de38b332 100644 --- a/src/elevenlabs/studio/projects/types/projects_add_request_target_audience.py +++ b/src/elevenlabs/studio/projects/types/projects_create_request_target_audience.py @@ -2,6 +2,6 @@ import typing -ProjectsAddRequestTargetAudience = typing.Union[ +ProjectsCreateRequestTargetAudience = typing.Union[ typing.Literal["children", "young adult", "adult", "all ages"], typing.Any ] diff --git a/src/elevenlabs/studio/raw_client.py b/src/elevenlabs/studio/raw_client.py new file mode 100644 index 00000000..f45abe3a --- /dev/null +++ b/src/elevenlabs/studio/raw_client.py @@ -0,0 +1,249 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ..core.api_error import ApiError +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ..core.http_response import AsyncHttpResponse, HttpResponse +from ..core.request_options import RequestOptions +from ..core.serialization import convert_and_respect_annotation_metadata +from ..core.unchecked_base_model import construct_type +from ..errors.unprocessable_entity_error import UnprocessableEntityError +from ..types.http_validation_error import HttpValidationError +from ..types.podcast_project_response_model import PodcastProjectResponseModel +from .types.body_create_podcast_v_1_studio_podcasts_post_duration_scale import ( + BodyCreatePodcastV1StudioPodcastsPostDurationScale, +) +from .types.body_create_podcast_v_1_studio_podcasts_post_mode import BodyCreatePodcastV1StudioPodcastsPostMode +from .types.body_create_podcast_v_1_studio_podcasts_post_quality_preset import ( + BodyCreatePodcastV1StudioPodcastsPostQualityPreset, +) +from .types.body_create_podcast_v_1_studio_podcasts_post_source import BodyCreatePodcastV1StudioPodcastsPostSource + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RawStudioClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def create_podcast( + self, + *, + model_id: str, + mode: BodyCreatePodcastV1StudioPodcastsPostMode, + source: BodyCreatePodcastV1StudioPodcastsPostSource, + quality_preset: typing.Optional[BodyCreatePodcastV1StudioPodcastsPostQualityPreset] = OMIT, + duration_scale: typing.Optional[BodyCreatePodcastV1StudioPodcastsPostDurationScale] = OMIT, + language: typing.Optional[str] = OMIT, + highlights: typing.Optional[typing.Sequence[str]] = OMIT, + callback_url: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[PodcastProjectResponseModel]: + """ + Create and auto-convert a podcast project. Currently, the LLM cost is covered by us but you will still be charged for the audio generation. In the future, you will be charged for both the LLM and audio generation costs. + + Parameters + ---------- + model_id : str + The ID of the model to be used for this Studio project, you can query GET /v1/models to list all available models. + + mode : BodyCreatePodcastV1StudioPodcastsPostMode + The type of podcast to generate. Can be 'conversation', an interaction between two voices, or 'bulletin', a monologue. + + source : BodyCreatePodcastV1StudioPodcastsPostSource + The source content for the Podcast. + + quality_preset : typing.Optional[BodyCreatePodcastV1StudioPodcastsPostQualityPreset] + Output quality of the generated audio. Must be one of: + standard - standard output format, 128kbps with 44.1kHz sample rate. + high - high quality output format, 192kbps with 44.1kHz sample rate and major improvements on our side. Using this setting increases the credit cost by 20%. + ultra - ultra quality output format, 192kbps with 44.1kHz sample rate and highest improvements on our side. Using this setting increases the credit cost by 50%. + ultra lossless - ultra quality output format, 705.6kbps with 44.1kHz sample rate and highest improvements on our side in a fully lossless format. Using this setting increases the credit cost by 100%. + + duration_scale : typing.Optional[BodyCreatePodcastV1StudioPodcastsPostDurationScale] + Duration of the generated podcast. Must be one of: + short - produces podcasts shorter than 3 minutes. + default - produces podcasts roughly between 3-7 minutes. + long - prodces podcasts longer than 7 minutes. + + language : typing.Optional[str] + An optional language of the Studio project. Two-letter language code (ISO 639-1). + + highlights : typing.Optional[typing.Sequence[str]] + A brief summary or highlights of the Studio project's content, providing key points or themes. This should be between 10 and 70 characters. + + callback_url : typing.Optional[str] + A url that will be called by our service when the Studio project is converted. Request will contain a json blob containing the status of the conversion + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[PodcastProjectResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + "v1/studio/podcasts", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "model_id": model_id, + "mode": convert_and_respect_annotation_metadata( + object_=mode, annotation=BodyCreatePodcastV1StudioPodcastsPostMode, direction="write" + ), + "source": convert_and_respect_annotation_metadata( + object_=source, annotation=BodyCreatePodcastV1StudioPodcastsPostSource, direction="write" + ), + "quality_preset": quality_preset, + "duration_scale": duration_scale, + "language": language, + "highlights": highlights, + "callback_url": callback_url, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + PodcastProjectResponseModel, + construct_type( + type_=PodcastProjectResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + +class AsyncRawStudioClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def create_podcast( + self, + *, + model_id: str, + mode: BodyCreatePodcastV1StudioPodcastsPostMode, + source: BodyCreatePodcastV1StudioPodcastsPostSource, + quality_preset: typing.Optional[BodyCreatePodcastV1StudioPodcastsPostQualityPreset] = OMIT, + duration_scale: typing.Optional[BodyCreatePodcastV1StudioPodcastsPostDurationScale] = OMIT, + language: typing.Optional[str] = OMIT, + highlights: typing.Optional[typing.Sequence[str]] = OMIT, + callback_url: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[PodcastProjectResponseModel]: + """ + Create and auto-convert a podcast project. Currently, the LLM cost is covered by us but you will still be charged for the audio generation. In the future, you will be charged for both the LLM and audio generation costs. + + Parameters + ---------- + model_id : str + The ID of the model to be used for this Studio project, you can query GET /v1/models to list all available models. + + mode : BodyCreatePodcastV1StudioPodcastsPostMode + The type of podcast to generate. Can be 'conversation', an interaction between two voices, or 'bulletin', a monologue. + + source : BodyCreatePodcastV1StudioPodcastsPostSource + The source content for the Podcast. + + quality_preset : typing.Optional[BodyCreatePodcastV1StudioPodcastsPostQualityPreset] + Output quality of the generated audio. Must be one of: + standard - standard output format, 128kbps with 44.1kHz sample rate. + high - high quality output format, 192kbps with 44.1kHz sample rate and major improvements on our side. Using this setting increases the credit cost by 20%. + ultra - ultra quality output format, 192kbps with 44.1kHz sample rate and highest improvements on our side. Using this setting increases the credit cost by 50%. + ultra lossless - ultra quality output format, 705.6kbps with 44.1kHz sample rate and highest improvements on our side in a fully lossless format. Using this setting increases the credit cost by 100%. + + duration_scale : typing.Optional[BodyCreatePodcastV1StudioPodcastsPostDurationScale] + Duration of the generated podcast. Must be one of: + short - produces podcasts shorter than 3 minutes. + default - produces podcasts roughly between 3-7 minutes. + long - prodces podcasts longer than 7 minutes. + + language : typing.Optional[str] + An optional language of the Studio project. Two-letter language code (ISO 639-1). + + highlights : typing.Optional[typing.Sequence[str]] + A brief summary or highlights of the Studio project's content, providing key points or themes. This should be between 10 and 70 characters. + + callback_url : typing.Optional[str] + A url that will be called by our service when the Studio project is converted. Request will contain a json blob containing the status of the conversion + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[PodcastProjectResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + "v1/studio/podcasts", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "model_id": model_id, + "mode": convert_and_respect_annotation_metadata( + object_=mode, annotation=BodyCreatePodcastV1StudioPodcastsPostMode, direction="write" + ), + "source": convert_and_respect_annotation_metadata( + object_=source, annotation=BodyCreatePodcastV1StudioPodcastsPostSource, direction="write" + ), + "quality_preset": quality_preset, + "duration_scale": duration_scale, + "language": language, + "highlights": highlights, + "callback_url": callback_url, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + PodcastProjectResponseModel, + construct_type( + type_=PodcastProjectResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/elevenlabs/studio/types/__init__.py b/src/elevenlabs/studio/types/__init__.py index 70a2fd6c..ce8a0b35 100644 --- a/src/elevenlabs/studio/types/__init__.py +++ b/src/elevenlabs/studio/types/__init__.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# isort: skip_file + from .body_create_podcast_v_1_studio_podcasts_post_duration_scale import ( BodyCreatePodcastV1StudioPodcastsPostDurationScale, ) diff --git a/src/elevenlabs/studio/types/body_create_podcast_v_1_studio_podcasts_post_mode.py b/src/elevenlabs/studio/types/body_create_podcast_v_1_studio_podcasts_post_mode.py index de46389d..bfe0e14f 100644 --- a/src/elevenlabs/studio/types/body_create_podcast_v_1_studio_podcasts_post_mode.py +++ b/src/elevenlabs/studio/types/body_create_podcast_v_1_studio_podcasts_post_mode.py @@ -1,14 +1,15 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -from ...core.unchecked_base_model import UncheckedBaseModel + import typing -from ...types.podcast_conversation_mode_data import PodcastConversationModeData -from ...core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic -from ...types.podcast_bulletin_mode_data import PodcastBulletinModeData import typing_extensions -from ...core.unchecked_base_model import UnionMetadata +from ...core.pydantic_utilities import IS_PYDANTIC_V2 +from ...core.unchecked_base_model import UncheckedBaseModel, UnionMetadata +from ...types.podcast_bulletin_mode_data import PodcastBulletinModeData +from ...types.podcast_conversation_mode_data import PodcastConversationModeData class BodyCreatePodcastV1StudioPodcastsPostMode_Conversation(UncheckedBaseModel): @@ -49,8 +50,7 @@ class Config: BodyCreatePodcastV1StudioPodcastsPostMode = typing_extensions.Annotated[ typing.Union[ - BodyCreatePodcastV1StudioPodcastsPostMode_Conversation, - BodyCreatePodcastV1StudioPodcastsPostMode_Bulletin, + BodyCreatePodcastV1StudioPodcastsPostMode_Conversation, BodyCreatePodcastV1StudioPodcastsPostMode_Bulletin ], UnionMetadata(discriminant="type"), ] diff --git a/src/elevenlabs/studio/types/body_create_podcast_v_1_studio_podcasts_post_source.py b/src/elevenlabs/studio/types/body_create_podcast_v_1_studio_podcasts_post_source.py index 78890639..769b7233 100644 --- a/src/elevenlabs/studio/types/body_create_podcast_v_1_studio_podcasts_post_source.py +++ b/src/elevenlabs/studio/types/body_create_podcast_v_1_studio_podcasts_post_source.py @@ -1,14 +1,11 @@ # This file was auto-generated by Fern from our API Definition. import typing + from ...types.podcast_text_source import PodcastTextSource from ...types.podcast_url_source import PodcastUrlSource -from .body_create_podcast_v_1_studio_podcasts_post_source_item import ( - BodyCreatePodcastV1StudioPodcastsPostSourceItem, -) +from .body_create_podcast_v_1_studio_podcasts_post_source_item import BodyCreatePodcastV1StudioPodcastsPostSourceItem BodyCreatePodcastV1StudioPodcastsPostSource = typing.Union[ - PodcastTextSource, - PodcastUrlSource, - typing.List[BodyCreatePodcastV1StudioPodcastsPostSourceItem], + PodcastTextSource, PodcastUrlSource, typing.List[BodyCreatePodcastV1StudioPodcastsPostSourceItem] ] diff --git a/src/elevenlabs/studio/types/body_create_podcast_v_1_studio_podcasts_post_source_item.py b/src/elevenlabs/studio/types/body_create_podcast_v_1_studio_podcasts_post_source_item.py index b1211c0b..a4c89b34 100644 --- a/src/elevenlabs/studio/types/body_create_podcast_v_1_studio_podcasts_post_source_item.py +++ b/src/elevenlabs/studio/types/body_create_podcast_v_1_studio_podcasts_post_source_item.py @@ -1,12 +1,13 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -from ...core.unchecked_base_model import UncheckedBaseModel + import typing -from ...core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic import typing_extensions -from ...core.unchecked_base_model import UnionMetadata +from ...core.pydantic_utilities import IS_PYDANTIC_V2 +from ...core.unchecked_base_model import UncheckedBaseModel, UnionMetadata class BodyCreatePodcastV1StudioPodcastsPostSourceItem_Text(UncheckedBaseModel): @@ -39,8 +40,7 @@ class Config: BodyCreatePodcastV1StudioPodcastsPostSourceItem = typing_extensions.Annotated[ typing.Union[ - BodyCreatePodcastV1StudioPodcastsPostSourceItem_Text, - BodyCreatePodcastV1StudioPodcastsPostSourceItem_Url, + BodyCreatePodcastV1StudioPodcastsPostSourceItem_Text, BodyCreatePodcastV1StudioPodcastsPostSourceItem_Url ], UnionMetadata(discriminant="type"), ] diff --git a/src/elevenlabs/text_to_sound_effects/__init__.py b/src/elevenlabs/text_to_sound_effects/__init__.py index 7995a106..a47b33aa 100644 --- a/src/elevenlabs/text_to_sound_effects/__init__.py +++ b/src/elevenlabs/text_to_sound_effects/__init__.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# isort: skip_file + from .types import TextToSoundEffectsConvertRequestOutputFormat __all__ = ["TextToSoundEffectsConvertRequestOutputFormat"] diff --git a/src/elevenlabs/text_to_sound_effects/client.py b/src/elevenlabs/text_to_sound_effects/client.py index 89707a90..73aa41b2 100644 --- a/src/elevenlabs/text_to_sound_effects/client.py +++ b/src/elevenlabs/text_to_sound_effects/client.py @@ -1,17 +1,11 @@ # This file was auto-generated by Fern from our API Definition. import typing -from ..core.client_wrapper import SyncClientWrapper -from .types.text_to_sound_effects_convert_request_output_format import ( - TextToSoundEffectsConvertRequestOutputFormat, -) + +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ..core.request_options import RequestOptions -from ..errors.unprocessable_entity_error import UnprocessableEntityError -from ..types.http_validation_error import HttpValidationError -from ..core.unchecked_base_model import construct_type -from json.decoder import JSONDecodeError -from ..core.api_error import ApiError -from ..core.client_wrapper import AsyncClientWrapper +from .raw_client import AsyncRawTextToSoundEffectsClient, RawTextToSoundEffectsClient +from .types.text_to_sound_effects_convert_request_output_format import TextToSoundEffectsConvertRequestOutputFormat # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -19,7 +13,18 @@ class TextToSoundEffectsClient: def __init__(self, *, client_wrapper: SyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = RawTextToSoundEffectsClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawTextToSoundEffectsClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawTextToSoundEffectsClient + """ + return self._raw_client def convert( self, @@ -50,8 +55,8 @@ def convert( request_options : typing.Optional[RequestOptions] Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. - Yields - ------ + Returns + ------- typing.Iterator[bytes] The generated sound effect as an MP3 file @@ -66,50 +71,30 @@ def convert( text="Spacious braam suitable for high-impact movie trailer moments", ) """ - with self._client_wrapper.httpx_client.stream( - "v1/sound-generation", - base_url=self._client_wrapper.get_environment().base, - method="POST", - params={ - "output_format": output_format, - }, - json={ - "text": text, - "duration_seconds": duration_seconds, - "prompt_influence": prompt_influence, - }, - headers={ - "content-type": "application/json", - }, + with self._raw_client.convert( + text=text, + output_format=output_format, + duration_seconds=duration_seconds, + prompt_influence=prompt_influence, request_options=request_options, - omit=OMIT, - ) as _response: - try: - if 200 <= _response.status_code < 300: - _chunk_size = request_options.get("chunk_size", 1024) if request_options is not None else 1024 - for _chunk in _response.iter_bytes(chunk_size=_chunk_size): - yield _chunk - return - _response.read() - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + ) as r: + yield from r.data class AsyncTextToSoundEffectsClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = AsyncRawTextToSoundEffectsClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawTextToSoundEffectsClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawTextToSoundEffectsClient + """ + return self._raw_client async def convert( self, @@ -140,8 +125,8 @@ async def convert( request_options : typing.Optional[RequestOptions] Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. - Yields - ------ + Returns + ------- typing.AsyncIterator[bytes] The generated sound effect as an MP3 file @@ -164,42 +149,12 @@ async def main() -> None: asyncio.run(main()) """ - async with self._client_wrapper.httpx_client.stream( - "v1/sound-generation", - base_url=self._client_wrapper.get_environment().base, - method="POST", - params={ - "output_format": output_format, - }, - json={ - "text": text, - "duration_seconds": duration_seconds, - "prompt_influence": prompt_influence, - }, - headers={ - "content-type": "application/json", - }, + async with self._raw_client.convert( + text=text, + output_format=output_format, + duration_seconds=duration_seconds, + prompt_influence=prompt_influence, request_options=request_options, - omit=OMIT, - ) as _response: - try: - if 200 <= _response.status_code < 300: - _chunk_size = request_options.get("chunk_size", 1024) if request_options is not None else 1024 - async for _chunk in _response.aiter_bytes(chunk_size=_chunk_size): - yield _chunk - return - await _response.aread() - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + ) as r: + async for _chunk in r.data: + yield _chunk diff --git a/src/elevenlabs/text_to_sound_effects/raw_client.py b/src/elevenlabs/text_to_sound_effects/raw_client.py new file mode 100644 index 00000000..7918f94f --- /dev/null +++ b/src/elevenlabs/text_to_sound_effects/raw_client.py @@ -0,0 +1,192 @@ +# This file was auto-generated by Fern from our API Definition. + +import contextlib +import typing +from json.decoder import JSONDecodeError + +from ..core.api_error import ApiError +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ..core.http_response import AsyncHttpResponse, HttpResponse +from ..core.request_options import RequestOptions +from ..core.unchecked_base_model import construct_type +from ..errors.unprocessable_entity_error import UnprocessableEntityError +from ..types.http_validation_error import HttpValidationError +from .types.text_to_sound_effects_convert_request_output_format import TextToSoundEffectsConvertRequestOutputFormat + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RawTextToSoundEffectsClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + @contextlib.contextmanager + def convert( + self, + *, + text: str, + output_format: typing.Optional[TextToSoundEffectsConvertRequestOutputFormat] = None, + duration_seconds: typing.Optional[float] = OMIT, + prompt_influence: typing.Optional[float] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> typing.Iterator[HttpResponse[typing.Iterator[bytes]]]: + """ + Turn text into sound effects for your videos, voice-overs or video games using the most advanced sound effects model in the world. + + Parameters + ---------- + text : str + The text that will get converted into a sound effect. + + output_format : typing.Optional[TextToSoundEffectsConvertRequestOutputFormat] + Output format of the generated audio. Formatted as codec_sample_rate_bitrate. So an mp3 with 22.05kHz sample rate at 32kbs is represented as mp3_22050_32. MP3 with 192kbps bitrate requires you to be subscribed to Creator tier or above. PCM with 44.1kHz sample rate requires you to be subscribed to Pro tier or above. Note that the μ-law format (sometimes written mu-law, often approximated as u-law) is commonly used for Twilio audio inputs. + + duration_seconds : typing.Optional[float] + The duration of the sound which will be generated in seconds. Must be at least 0.5 and at most 22. If set to None we will guess the optimal duration using the prompt. Defaults to None. + + prompt_influence : typing.Optional[float] + A higher prompt influence makes your generation follow the prompt more closely while also making generations less variable. Must be a value between 0 and 1. Defaults to 0.3. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. + + Returns + ------- + typing.Iterator[HttpResponse[typing.Iterator[bytes]]] + The generated sound effect as an MP3 file + """ + with self._client_wrapper.httpx_client.stream( + "v1/sound-generation", + base_url=self._client_wrapper.get_environment().base, + method="POST", + params={ + "output_format": output_format, + }, + json={ + "text": text, + "duration_seconds": duration_seconds, + "prompt_influence": prompt_influence, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) as _response: + + def _stream() -> HttpResponse[typing.Iterator[bytes]]: + try: + if 200 <= _response.status_code < 300: + _chunk_size = request_options.get("chunk_size", 1024) if request_options is not None else 1024 + return HttpResponse( + response=_response, data=(_chunk for _chunk in _response.iter_bytes(chunk_size=_chunk_size)) + ) + _response.read() + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + yield _stream() + + +class AsyncRawTextToSoundEffectsClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + @contextlib.asynccontextmanager + async def convert( + self, + *, + text: str, + output_format: typing.Optional[TextToSoundEffectsConvertRequestOutputFormat] = None, + duration_seconds: typing.Optional[float] = OMIT, + prompt_influence: typing.Optional[float] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> typing.AsyncIterator[AsyncHttpResponse[typing.AsyncIterator[bytes]]]: + """ + Turn text into sound effects for your videos, voice-overs or video games using the most advanced sound effects model in the world. + + Parameters + ---------- + text : str + The text that will get converted into a sound effect. + + output_format : typing.Optional[TextToSoundEffectsConvertRequestOutputFormat] + Output format of the generated audio. Formatted as codec_sample_rate_bitrate. So an mp3 with 22.05kHz sample rate at 32kbs is represented as mp3_22050_32. MP3 with 192kbps bitrate requires you to be subscribed to Creator tier or above. PCM with 44.1kHz sample rate requires you to be subscribed to Pro tier or above. Note that the μ-law format (sometimes written mu-law, often approximated as u-law) is commonly used for Twilio audio inputs. + + duration_seconds : typing.Optional[float] + The duration of the sound which will be generated in seconds. Must be at least 0.5 and at most 22. If set to None we will guess the optimal duration using the prompt. Defaults to None. + + prompt_influence : typing.Optional[float] + A higher prompt influence makes your generation follow the prompt more closely while also making generations less variable. Must be a value between 0 and 1. Defaults to 0.3. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. + + Returns + ------- + typing.AsyncIterator[AsyncHttpResponse[typing.AsyncIterator[bytes]]] + The generated sound effect as an MP3 file + """ + async with self._client_wrapper.httpx_client.stream( + "v1/sound-generation", + base_url=self._client_wrapper.get_environment().base, + method="POST", + params={ + "output_format": output_format, + }, + json={ + "text": text, + "duration_seconds": duration_seconds, + "prompt_influence": prompt_influence, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) as _response: + + async def _stream() -> AsyncHttpResponse[typing.AsyncIterator[bytes]]: + try: + if 200 <= _response.status_code < 300: + _chunk_size = request_options.get("chunk_size", 1024) if request_options is not None else 1024 + return AsyncHttpResponse( + response=_response, + data=(_chunk async for _chunk in _response.aiter_bytes(chunk_size=_chunk_size)), + ) + await _response.aread() + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + yield await _stream() diff --git a/src/elevenlabs/text_to_sound_effects/types/__init__.py b/src/elevenlabs/text_to_sound_effects/types/__init__.py index 206b36de..8370d85d 100644 --- a/src/elevenlabs/text_to_sound_effects/types/__init__.py +++ b/src/elevenlabs/text_to_sound_effects/types/__init__.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# isort: skip_file + from .text_to_sound_effects_convert_request_output_format import TextToSoundEffectsConvertRequestOutputFormat __all__ = ["TextToSoundEffectsConvertRequestOutputFormat"] diff --git a/src/elevenlabs/text_to_speech/__init__.py b/src/elevenlabs/text_to_speech/__init__.py index a9d1a010..79ec22cb 100644 --- a/src/elevenlabs/text_to_speech/__init__.py +++ b/src/elevenlabs/text_to_speech/__init__.py @@ -1,13 +1,15 @@ # This file was auto-generated by Fern from our API Definition. +# isort: skip_file + from .types import ( BodyTextToSpeechStreamingV1TextToSpeechVoiceIdStreamPostApplyTextNormalization, BodyTextToSpeechStreamingWithTimestampsV1TextToSpeechVoiceIdStreamWithTimestampsPostApplyTextNormalization, BodyTextToSpeechV1TextToSpeechVoiceIdPostApplyTextNormalization, BodyTextToSpeechWithTimestampsV1TextToSpeechVoiceIdWithTimestampsPostApplyTextNormalization, - TextToSpeechConvertAsStreamRequestOutputFormat, TextToSpeechConvertRequestOutputFormat, TextToSpeechConvertWithTimestampsRequestOutputFormat, + TextToSpeechStreamRequestOutputFormat, TextToSpeechStreamWithTimestampsRequestOutputFormat, ) @@ -16,8 +18,8 @@ "BodyTextToSpeechStreamingWithTimestampsV1TextToSpeechVoiceIdStreamWithTimestampsPostApplyTextNormalization", "BodyTextToSpeechV1TextToSpeechVoiceIdPostApplyTextNormalization", "BodyTextToSpeechWithTimestampsV1TextToSpeechVoiceIdWithTimestampsPostApplyTextNormalization", - "TextToSpeechConvertAsStreamRequestOutputFormat", "TextToSpeechConvertRequestOutputFormat", "TextToSpeechConvertWithTimestampsRequestOutputFormat", + "TextToSpeechStreamRequestOutputFormat", "TextToSpeechStreamWithTimestampsRequestOutputFormat", ] diff --git a/src/elevenlabs/text_to_speech/client.py b/src/elevenlabs/text_to_speech/client.py index 17e6e2c6..0659c5b2 100644 --- a/src/elevenlabs/text_to_speech/client.py +++ b/src/elevenlabs/text_to_speech/client.py @@ -1,49 +1,34 @@ # This file was auto-generated by Fern from our API Definition. import typing -from ..core.client_wrapper import SyncClientWrapper -from .types.text_to_speech_convert_request_output_format import ( - TextToSpeechConvertRequestOutputFormat, -) + +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ..core.request_options import RequestOptions +from ..types.audio_with_timestamps_response import AudioWithTimestampsResponse +from ..types.pronunciation_dictionary_version_locator import PronunciationDictionaryVersionLocator +from ..types.streaming_audio_chunk_with_timestamps_response import StreamingAudioChunkWithTimestampsResponse from ..types.voice_settings import VoiceSettings -from ..types.pronunciation_dictionary_version_locator import ( - PronunciationDictionaryVersionLocator, +from .raw_client import AsyncRawTextToSpeechClient, RawTextToSpeechClient +from .types.body_text_to_speech_streaming_v_1_text_to_speech_voice_id_stream_post_apply_text_normalization import ( + BodyTextToSpeechStreamingV1TextToSpeechVoiceIdStreamPostApplyTextNormalization, +) +from .types.body_text_to_speech_streaming_with_timestamps_v_1_text_to_speech_voice_id_stream_with_timestamps_post_apply_text_normalization import ( + BodyTextToSpeechStreamingWithTimestampsV1TextToSpeechVoiceIdStreamWithTimestampsPostApplyTextNormalization, ) from .types.body_text_to_speech_v_1_text_to_speech_voice_id_post_apply_text_normalization import ( BodyTextToSpeechV1TextToSpeechVoiceIdPostApplyTextNormalization, ) -from ..core.request_options import RequestOptions -from ..core.jsonable_encoder import jsonable_encoder -from ..core.serialization import convert_and_respect_annotation_metadata -from ..errors.unprocessable_entity_error import UnprocessableEntityError -from ..types.http_validation_error import HttpValidationError -from ..core.unchecked_base_model import construct_type -from json.decoder import JSONDecodeError -from ..core.api_error import ApiError -from .types.text_to_speech_convert_with_timestamps_request_output_format import ( - TextToSpeechConvertWithTimestampsRequestOutputFormat, -) from .types.body_text_to_speech_with_timestamps_v_1_text_to_speech_voice_id_with_timestamps_post_apply_text_normalization import ( BodyTextToSpeechWithTimestampsV1TextToSpeechVoiceIdWithTimestampsPostApplyTextNormalization, ) -from ..types.audio_with_timestamps_response import AudioWithTimestampsResponse -from .types.text_to_speech_convert_as_stream_request_output_format import ( - TextToSpeechConvertAsStreamRequestOutputFormat, -) -from .types.body_text_to_speech_streaming_v_1_text_to_speech_voice_id_stream_post_apply_text_normalization import ( - BodyTextToSpeechStreamingV1TextToSpeechVoiceIdStreamPostApplyTextNormalization, +from .types.text_to_speech_convert_request_output_format import TextToSpeechConvertRequestOutputFormat +from .types.text_to_speech_convert_with_timestamps_request_output_format import ( + TextToSpeechConvertWithTimestampsRequestOutputFormat, ) +from .types.text_to_speech_stream_request_output_format import TextToSpeechStreamRequestOutputFormat from .types.text_to_speech_stream_with_timestamps_request_output_format import ( TextToSpeechStreamWithTimestampsRequestOutputFormat, ) -from .types.body_text_to_speech_streaming_with_timestamps_v_1_text_to_speech_voice_id_stream_with_timestamps_post_apply_text_normalization import ( - BodyTextToSpeechStreamingWithTimestampsV1TextToSpeechVoiceIdStreamWithTimestampsPostApplyTextNormalization, -) -from ..types.streaming_audio_chunk_with_timestamps_response import ( - StreamingAudioChunkWithTimestampsResponse, -) -import json -from ..core.client_wrapper import AsyncClientWrapper # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -51,7 +36,18 @@ class TextToSpeechClient: def __init__(self, *, client_wrapper: SyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = RawTextToSpeechClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawTextToSpeechClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawTextToSpeechClient + """ + return self._raw_client def convert( self, @@ -145,8 +141,8 @@ def convert( request_options : typing.Optional[RequestOptions] Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. - Yields - ------ + Returns + ------- typing.Iterator[bytes] The generated audio file @@ -164,63 +160,27 @@ def convert( model_id="eleven_multilingual_v2", ) """ - with self._client_wrapper.httpx_client.stream( - f"v1/text-to-speech/{jsonable_encoder(voice_id)}", - base_url=self._client_wrapper.get_environment().base, - method="POST", - params={ - "enable_logging": enable_logging, - "optimize_streaming_latency": optimize_streaming_latency, - "output_format": output_format, - }, - json={ - "text": text, - "model_id": model_id, - "language_code": language_code, - "voice_settings": convert_and_respect_annotation_metadata( - object_=voice_settings, annotation=VoiceSettings, direction="write" - ), - "pronunciation_dictionary_locators": convert_and_respect_annotation_metadata( - object_=pronunciation_dictionary_locators, - annotation=typing.Sequence[PronunciationDictionaryVersionLocator], - direction="write", - ), - "seed": seed, - "previous_text": previous_text, - "next_text": next_text, - "previous_request_ids": previous_request_ids, - "next_request_ids": next_request_ids, - "use_pvc_as_ivc": use_pvc_as_ivc, - "apply_text_normalization": apply_text_normalization, - "apply_language_text_normalization": apply_language_text_normalization, - }, - headers={ - "content-type": "application/json", - }, + with self._raw_client.convert( + voice_id, + text=text, + enable_logging=enable_logging, + optimize_streaming_latency=optimize_streaming_latency, + output_format=output_format, + model_id=model_id, + language_code=language_code, + voice_settings=voice_settings, + pronunciation_dictionary_locators=pronunciation_dictionary_locators, + seed=seed, + previous_text=previous_text, + next_text=next_text, + previous_request_ids=previous_request_ids, + next_request_ids=next_request_ids, + use_pvc_as_ivc=use_pvc_as_ivc, + apply_text_normalization=apply_text_normalization, + apply_language_text_normalization=apply_language_text_normalization, request_options=request_options, - omit=OMIT, - ) as _response: - try: - if 200 <= _response.status_code < 300: - _chunk_size = request_options.get("chunk_size", 1024) if request_options is not None else 1024 - for _chunk in _response.iter_bytes(chunk_size=_chunk_size): - yield _chunk - return - _response.read() - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + ) as r: + yield from r.data def convert_with_timestamps( self, @@ -331,74 +291,36 @@ def convert_with_timestamps( text="This is a test for the API of ElevenLabs.", ) """ - _response = self._client_wrapper.httpx_client.request( - f"v1/text-to-speech/{jsonable_encoder(voice_id)}/with-timestamps", - base_url=self._client_wrapper.get_environment().base, - method="POST", - params={ - "enable_logging": enable_logging, - "optimize_streaming_latency": optimize_streaming_latency, - "output_format": output_format, - }, - json={ - "text": text, - "model_id": model_id, - "language_code": language_code, - "voice_settings": convert_and_respect_annotation_metadata( - object_=voice_settings, annotation=VoiceSettings, direction="write" - ), - "pronunciation_dictionary_locators": convert_and_respect_annotation_metadata( - object_=pronunciation_dictionary_locators, - annotation=typing.Sequence[PronunciationDictionaryVersionLocator], - direction="write", - ), - "seed": seed, - "previous_text": previous_text, - "next_text": next_text, - "previous_request_ids": previous_request_ids, - "next_request_ids": next_request_ids, - "use_pvc_as_ivc": use_pvc_as_ivc, - "apply_text_normalization": apply_text_normalization, - "apply_language_text_normalization": apply_language_text_normalization, - }, - headers={ - "content-type": "application/json", - }, + _response = self._raw_client.convert_with_timestamps( + voice_id, + text=text, + enable_logging=enable_logging, + optimize_streaming_latency=optimize_streaming_latency, + output_format=output_format, + model_id=model_id, + language_code=language_code, + voice_settings=voice_settings, + pronunciation_dictionary_locators=pronunciation_dictionary_locators, + seed=seed, + previous_text=previous_text, + next_text=next_text, + previous_request_ids=previous_request_ids, + next_request_ids=next_request_ids, + use_pvc_as_ivc=use_pvc_as_ivc, + apply_text_normalization=apply_text_normalization, + apply_language_text_normalization=apply_language_text_normalization, request_options=request_options, - omit=OMIT, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - AudioWithTimestampsResponse, - construct_type( - type_=AudioWithTimestampsResponse, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def convert_as_stream( + return _response.data + + def stream( self, voice_id: str, *, text: str, enable_logging: typing.Optional[bool] = None, optimize_streaming_latency: typing.Optional[int] = None, - output_format: typing.Optional[TextToSpeechConvertAsStreamRequestOutputFormat] = None, + output_format: typing.Optional[TextToSpeechStreamRequestOutputFormat] = None, model_id: typing.Optional[str] = OMIT, language_code: typing.Optional[str] = OMIT, voice_settings: typing.Optional[VoiceSettings] = OMIT, @@ -441,7 +363,7 @@ def convert_as_stream( Defaults to None. - output_format : typing.Optional[TextToSpeechConvertAsStreamRequestOutputFormat] + output_format : typing.Optional[TextToSpeechStreamRequestOutputFormat] Output format of the generated audio. Formatted as codec_sample_rate_bitrate. So an mp3 with 22.05kHz sample rate at 32kbs is represented as mp3_22050_32. MP3 with 192kbps bitrate requires you to be subscribed to Creator tier or above. PCM with 44.1kHz sample rate requires you to be subscribed to Pro tier or above. Note that the μ-law format (sometimes written mu-law, often approximated as u-law) is commonly used for Twilio audio inputs. model_id : typing.Optional[str] @@ -483,8 +405,8 @@ def convert_as_stream( request_options : typing.Optional[RequestOptions] Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. - Yields - ------ + Returns + ------- typing.Iterator[bytes] Streaming audio data @@ -495,70 +417,34 @@ def convert_as_stream( client = ElevenLabs( api_key="YOUR_API_KEY", ) - client.text_to_speech.convert_as_stream( + client.text_to_speech.stream( voice_id="JBFqnCBsd6RMkjVDRZzb", output_format="mp3_44100_128", text="The first move is what sets everything in motion.", model_id="eleven_multilingual_v2", ) """ - with self._client_wrapper.httpx_client.stream( - f"v1/text-to-speech/{jsonable_encoder(voice_id)}/stream", - base_url=self._client_wrapper.get_environment().base, - method="POST", - params={ - "enable_logging": enable_logging, - "optimize_streaming_latency": optimize_streaming_latency, - "output_format": output_format, - }, - json={ - "text": text, - "model_id": model_id, - "language_code": language_code, - "voice_settings": convert_and_respect_annotation_metadata( - object_=voice_settings, annotation=VoiceSettings, direction="write" - ), - "pronunciation_dictionary_locators": convert_and_respect_annotation_metadata( - object_=pronunciation_dictionary_locators, - annotation=typing.Sequence[PronunciationDictionaryVersionLocator], - direction="write", - ), - "seed": seed, - "previous_text": previous_text, - "next_text": next_text, - "previous_request_ids": previous_request_ids, - "next_request_ids": next_request_ids, - "use_pvc_as_ivc": use_pvc_as_ivc, - "apply_text_normalization": apply_text_normalization, - "apply_language_text_normalization": apply_language_text_normalization, - }, - headers={ - "content-type": "application/json", - }, + with self._raw_client.stream( + voice_id, + text=text, + enable_logging=enable_logging, + optimize_streaming_latency=optimize_streaming_latency, + output_format=output_format, + model_id=model_id, + language_code=language_code, + voice_settings=voice_settings, + pronunciation_dictionary_locators=pronunciation_dictionary_locators, + seed=seed, + previous_text=previous_text, + next_text=next_text, + previous_request_ids=previous_request_ids, + next_request_ids=next_request_ids, + use_pvc_as_ivc=use_pvc_as_ivc, + apply_text_normalization=apply_text_normalization, + apply_language_text_normalization=apply_language_text_normalization, request_options=request_options, - omit=OMIT, - ) as _response: - try: - if 200 <= _response.status_code < 300: - _chunk_size = request_options.get("chunk_size", 1024) if request_options is not None else 1024 - for _chunk in _response.iter_bytes(chunk_size=_chunk_size): - yield _chunk - return - _response.read() - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + ) as r: + yield from r.data def stream_with_timestamps( self, @@ -673,78 +559,43 @@ def stream_with_timestamps( for chunk in response: yield chunk """ - with self._client_wrapper.httpx_client.stream( - f"v1/text-to-speech/{jsonable_encoder(voice_id)}/stream/with-timestamps", - base_url=self._client_wrapper.get_environment().base, - method="POST", - params={ - "enable_logging": enable_logging, - "optimize_streaming_latency": optimize_streaming_latency, - "output_format": output_format, - }, - json={ - "text": text, - "model_id": model_id, - "language_code": language_code, - "voice_settings": convert_and_respect_annotation_metadata( - object_=voice_settings, annotation=VoiceSettings, direction="write" - ), - "pronunciation_dictionary_locators": convert_and_respect_annotation_metadata( - object_=pronunciation_dictionary_locators, - annotation=typing.Sequence[PronunciationDictionaryVersionLocator], - direction="write", - ), - "seed": seed, - "previous_text": previous_text, - "next_text": next_text, - "previous_request_ids": previous_request_ids, - "next_request_ids": next_request_ids, - "use_pvc_as_ivc": use_pvc_as_ivc, - "apply_text_normalization": apply_text_normalization, - "apply_language_text_normalization": apply_language_text_normalization, - }, - headers={ - "content-type": "application/json", - }, + with self._raw_client.stream_with_timestamps( + voice_id, + text=text, + enable_logging=enable_logging, + optimize_streaming_latency=optimize_streaming_latency, + output_format=output_format, + model_id=model_id, + language_code=language_code, + voice_settings=voice_settings, + pronunciation_dictionary_locators=pronunciation_dictionary_locators, + seed=seed, + previous_text=previous_text, + next_text=next_text, + previous_request_ids=previous_request_ids, + next_request_ids=next_request_ids, + use_pvc_as_ivc=use_pvc_as_ivc, + apply_text_normalization=apply_text_normalization, + apply_language_text_normalization=apply_language_text_normalization, request_options=request_options, - omit=OMIT, - ) as _response: - try: - if 200 <= _response.status_code < 300: - for _text in _response.iter_lines(): - try: - if len(_text) == 0: - continue - yield typing.cast( - StreamingAudioChunkWithTimestampsResponse, - construct_type( - type_=StreamingAudioChunkWithTimestampsResponse, # type: ignore - object_=json.loads(_text), - ), - ) - except Exception: - pass - return - _response.read() - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + ) as r: + yield from r.data class AsyncTextToSpeechClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = AsyncRawTextToSpeechClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawTextToSpeechClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawTextToSpeechClient + """ + return self._raw_client async def convert( self, @@ -838,8 +689,8 @@ async def convert( request_options : typing.Optional[RequestOptions] Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. - Yields - ------ + Returns + ------- typing.AsyncIterator[bytes] The generated audio file @@ -865,63 +716,28 @@ async def main() -> None: asyncio.run(main()) """ - async with self._client_wrapper.httpx_client.stream( - f"v1/text-to-speech/{jsonable_encoder(voice_id)}", - base_url=self._client_wrapper.get_environment().base, - method="POST", - params={ - "enable_logging": enable_logging, - "optimize_streaming_latency": optimize_streaming_latency, - "output_format": output_format, - }, - json={ - "text": text, - "model_id": model_id, - "language_code": language_code, - "voice_settings": convert_and_respect_annotation_metadata( - object_=voice_settings, annotation=VoiceSettings, direction="write" - ), - "pronunciation_dictionary_locators": convert_and_respect_annotation_metadata( - object_=pronunciation_dictionary_locators, - annotation=typing.Sequence[PronunciationDictionaryVersionLocator], - direction="write", - ), - "seed": seed, - "previous_text": previous_text, - "next_text": next_text, - "previous_request_ids": previous_request_ids, - "next_request_ids": next_request_ids, - "use_pvc_as_ivc": use_pvc_as_ivc, - "apply_text_normalization": apply_text_normalization, - "apply_language_text_normalization": apply_language_text_normalization, - }, - headers={ - "content-type": "application/json", - }, + async with self._raw_client.convert( + voice_id, + text=text, + enable_logging=enable_logging, + optimize_streaming_latency=optimize_streaming_latency, + output_format=output_format, + model_id=model_id, + language_code=language_code, + voice_settings=voice_settings, + pronunciation_dictionary_locators=pronunciation_dictionary_locators, + seed=seed, + previous_text=previous_text, + next_text=next_text, + previous_request_ids=previous_request_ids, + next_request_ids=next_request_ids, + use_pvc_as_ivc=use_pvc_as_ivc, + apply_text_normalization=apply_text_normalization, + apply_language_text_normalization=apply_language_text_normalization, request_options=request_options, - omit=OMIT, - ) as _response: - try: - if 200 <= _response.status_code < 300: - _chunk_size = request_options.get("chunk_size", 1024) if request_options is not None else 1024 - async for _chunk in _response.aiter_bytes(chunk_size=_chunk_size): - yield _chunk - return - await _response.aread() - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + ) as r: + async for _chunk in r.data: + yield _chunk async def convert_with_timestamps( self, @@ -1040,74 +856,36 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/text-to-speech/{jsonable_encoder(voice_id)}/with-timestamps", - base_url=self._client_wrapper.get_environment().base, - method="POST", - params={ - "enable_logging": enable_logging, - "optimize_streaming_latency": optimize_streaming_latency, - "output_format": output_format, - }, - json={ - "text": text, - "model_id": model_id, - "language_code": language_code, - "voice_settings": convert_and_respect_annotation_metadata( - object_=voice_settings, annotation=VoiceSettings, direction="write" - ), - "pronunciation_dictionary_locators": convert_and_respect_annotation_metadata( - object_=pronunciation_dictionary_locators, - annotation=typing.Sequence[PronunciationDictionaryVersionLocator], - direction="write", - ), - "seed": seed, - "previous_text": previous_text, - "next_text": next_text, - "previous_request_ids": previous_request_ids, - "next_request_ids": next_request_ids, - "use_pvc_as_ivc": use_pvc_as_ivc, - "apply_text_normalization": apply_text_normalization, - "apply_language_text_normalization": apply_language_text_normalization, - }, - headers={ - "content-type": "application/json", - }, + _response = await self._raw_client.convert_with_timestamps( + voice_id, + text=text, + enable_logging=enable_logging, + optimize_streaming_latency=optimize_streaming_latency, + output_format=output_format, + model_id=model_id, + language_code=language_code, + voice_settings=voice_settings, + pronunciation_dictionary_locators=pronunciation_dictionary_locators, + seed=seed, + previous_text=previous_text, + next_text=next_text, + previous_request_ids=previous_request_ids, + next_request_ids=next_request_ids, + use_pvc_as_ivc=use_pvc_as_ivc, + apply_text_normalization=apply_text_normalization, + apply_language_text_normalization=apply_language_text_normalization, request_options=request_options, - omit=OMIT, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - AudioWithTimestampsResponse, - construct_type( - type_=AudioWithTimestampsResponse, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def convert_as_stream( + return _response.data + + async def stream( self, voice_id: str, *, text: str, enable_logging: typing.Optional[bool] = None, optimize_streaming_latency: typing.Optional[int] = None, - output_format: typing.Optional[TextToSpeechConvertAsStreamRequestOutputFormat] = None, + output_format: typing.Optional[TextToSpeechStreamRequestOutputFormat] = None, model_id: typing.Optional[str] = OMIT, language_code: typing.Optional[str] = OMIT, voice_settings: typing.Optional[VoiceSettings] = OMIT, @@ -1150,7 +928,7 @@ async def convert_as_stream( Defaults to None. - output_format : typing.Optional[TextToSpeechConvertAsStreamRequestOutputFormat] + output_format : typing.Optional[TextToSpeechStreamRequestOutputFormat] Output format of the generated audio. Formatted as codec_sample_rate_bitrate. So an mp3 with 22.05kHz sample rate at 32kbs is represented as mp3_22050_32. MP3 with 192kbps bitrate requires you to be subscribed to Creator tier or above. PCM with 44.1kHz sample rate requires you to be subscribed to Pro tier or above. Note that the μ-law format (sometimes written mu-law, often approximated as u-law) is commonly used for Twilio audio inputs. model_id : typing.Optional[str] @@ -1192,8 +970,8 @@ async def convert_as_stream( request_options : typing.Optional[RequestOptions] Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. - Yields - ------ + Returns + ------- typing.AsyncIterator[bytes] Streaming audio data @@ -1209,7 +987,7 @@ async def convert_as_stream( async def main() -> None: - await client.text_to_speech.convert_as_stream( + await client.text_to_speech.stream( voice_id="JBFqnCBsd6RMkjVDRZzb", output_format="mp3_44100_128", text="The first move is what sets everything in motion.", @@ -1219,63 +997,28 @@ async def main() -> None: asyncio.run(main()) """ - async with self._client_wrapper.httpx_client.stream( - f"v1/text-to-speech/{jsonable_encoder(voice_id)}/stream", - base_url=self._client_wrapper.get_environment().base, - method="POST", - params={ - "enable_logging": enable_logging, - "optimize_streaming_latency": optimize_streaming_latency, - "output_format": output_format, - }, - json={ - "text": text, - "model_id": model_id, - "language_code": language_code, - "voice_settings": convert_and_respect_annotation_metadata( - object_=voice_settings, annotation=VoiceSettings, direction="write" - ), - "pronunciation_dictionary_locators": convert_and_respect_annotation_metadata( - object_=pronunciation_dictionary_locators, - annotation=typing.Sequence[PronunciationDictionaryVersionLocator], - direction="write", - ), - "seed": seed, - "previous_text": previous_text, - "next_text": next_text, - "previous_request_ids": previous_request_ids, - "next_request_ids": next_request_ids, - "use_pvc_as_ivc": use_pvc_as_ivc, - "apply_text_normalization": apply_text_normalization, - "apply_language_text_normalization": apply_language_text_normalization, - }, - headers={ - "content-type": "application/json", - }, + async with self._raw_client.stream( + voice_id, + text=text, + enable_logging=enable_logging, + optimize_streaming_latency=optimize_streaming_latency, + output_format=output_format, + model_id=model_id, + language_code=language_code, + voice_settings=voice_settings, + pronunciation_dictionary_locators=pronunciation_dictionary_locators, + seed=seed, + previous_text=previous_text, + next_text=next_text, + previous_request_ids=previous_request_ids, + next_request_ids=next_request_ids, + use_pvc_as_ivc=use_pvc_as_ivc, + apply_text_normalization=apply_text_normalization, + apply_language_text_normalization=apply_language_text_normalization, request_options=request_options, - omit=OMIT, - ) as _response: - try: - if 200 <= _response.status_code < 300: - _chunk_size = request_options.get("chunk_size", 1024) if request_options is not None else 1024 - async for _chunk in _response.aiter_bytes(chunk_size=_chunk_size): - yield _chunk - return - await _response.aread() - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + ) as r: + async for _chunk in r.data: + yield _chunk async def stream_with_timestamps( self, @@ -1398,70 +1141,25 @@ async def main() -> None: asyncio.run(main()) """ - async with self._client_wrapper.httpx_client.stream( - f"v1/text-to-speech/{jsonable_encoder(voice_id)}/stream/with-timestamps", - base_url=self._client_wrapper.get_environment().base, - method="POST", - params={ - "enable_logging": enable_logging, - "optimize_streaming_latency": optimize_streaming_latency, - "output_format": output_format, - }, - json={ - "text": text, - "model_id": model_id, - "language_code": language_code, - "voice_settings": convert_and_respect_annotation_metadata( - object_=voice_settings, annotation=VoiceSettings, direction="write" - ), - "pronunciation_dictionary_locators": convert_and_respect_annotation_metadata( - object_=pronunciation_dictionary_locators, - annotation=typing.Sequence[PronunciationDictionaryVersionLocator], - direction="write", - ), - "seed": seed, - "previous_text": previous_text, - "next_text": next_text, - "previous_request_ids": previous_request_ids, - "next_request_ids": next_request_ids, - "use_pvc_as_ivc": use_pvc_as_ivc, - "apply_text_normalization": apply_text_normalization, - "apply_language_text_normalization": apply_language_text_normalization, - }, - headers={ - "content-type": "application/json", - }, + async with self._raw_client.stream_with_timestamps( + voice_id, + text=text, + enable_logging=enable_logging, + optimize_streaming_latency=optimize_streaming_latency, + output_format=output_format, + model_id=model_id, + language_code=language_code, + voice_settings=voice_settings, + pronunciation_dictionary_locators=pronunciation_dictionary_locators, + seed=seed, + previous_text=previous_text, + next_text=next_text, + previous_request_ids=previous_request_ids, + next_request_ids=next_request_ids, + use_pvc_as_ivc=use_pvc_as_ivc, + apply_text_normalization=apply_text_normalization, + apply_language_text_normalization=apply_language_text_normalization, request_options=request_options, - omit=OMIT, - ) as _response: - try: - if 200 <= _response.status_code < 300: - async for _text in _response.aiter_lines(): - try: - if len(_text) == 0: - continue - yield typing.cast( - StreamingAudioChunkWithTimestampsResponse, - construct_type( - type_=StreamingAudioChunkWithTimestampsResponse, # type: ignore - object_=json.loads(_text), - ), - ) - except Exception: - pass - return - await _response.aread() - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + ) as r: + async for _chunk in r.data: + yield _chunk diff --git a/src/elevenlabs/text_to_speech/raw_client.py b/src/elevenlabs/text_to_speech/raw_client.py new file mode 100644 index 00000000..bfb178b2 --- /dev/null +++ b/src/elevenlabs/text_to_speech/raw_client.py @@ -0,0 +1,1379 @@ +# This file was auto-generated by Fern from our API Definition. + +import contextlib +import json +import typing +from json.decoder import JSONDecodeError + +from ..core.api_error import ApiError +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ..core.http_response import AsyncHttpResponse, HttpResponse +from ..core.jsonable_encoder import jsonable_encoder +from ..core.request_options import RequestOptions +from ..core.serialization import convert_and_respect_annotation_metadata +from ..core.unchecked_base_model import construct_type +from ..errors.unprocessable_entity_error import UnprocessableEntityError +from ..types.audio_with_timestamps_response import AudioWithTimestampsResponse +from ..types.http_validation_error import HttpValidationError +from ..types.pronunciation_dictionary_version_locator import PronunciationDictionaryVersionLocator +from ..types.streaming_audio_chunk_with_timestamps_response import StreamingAudioChunkWithTimestampsResponse +from ..types.voice_settings import VoiceSettings +from .types.body_text_to_speech_streaming_v_1_text_to_speech_voice_id_stream_post_apply_text_normalization import ( + BodyTextToSpeechStreamingV1TextToSpeechVoiceIdStreamPostApplyTextNormalization, +) +from .types.body_text_to_speech_streaming_with_timestamps_v_1_text_to_speech_voice_id_stream_with_timestamps_post_apply_text_normalization import ( + BodyTextToSpeechStreamingWithTimestampsV1TextToSpeechVoiceIdStreamWithTimestampsPostApplyTextNormalization, +) +from .types.body_text_to_speech_v_1_text_to_speech_voice_id_post_apply_text_normalization import ( + BodyTextToSpeechV1TextToSpeechVoiceIdPostApplyTextNormalization, +) +from .types.body_text_to_speech_with_timestamps_v_1_text_to_speech_voice_id_with_timestamps_post_apply_text_normalization import ( + BodyTextToSpeechWithTimestampsV1TextToSpeechVoiceIdWithTimestampsPostApplyTextNormalization, +) +from .types.text_to_speech_convert_request_output_format import TextToSpeechConvertRequestOutputFormat +from .types.text_to_speech_convert_with_timestamps_request_output_format import ( + TextToSpeechConvertWithTimestampsRequestOutputFormat, +) +from .types.text_to_speech_stream_request_output_format import TextToSpeechStreamRequestOutputFormat +from .types.text_to_speech_stream_with_timestamps_request_output_format import ( + TextToSpeechStreamWithTimestampsRequestOutputFormat, +) + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RawTextToSpeechClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + @contextlib.contextmanager + def convert( + self, + voice_id: str, + *, + text: str, + enable_logging: typing.Optional[bool] = None, + optimize_streaming_latency: typing.Optional[int] = None, + output_format: typing.Optional[TextToSpeechConvertRequestOutputFormat] = None, + model_id: typing.Optional[str] = OMIT, + language_code: typing.Optional[str] = OMIT, + voice_settings: typing.Optional[VoiceSettings] = OMIT, + pronunciation_dictionary_locators: typing.Optional[ + typing.Sequence[PronunciationDictionaryVersionLocator] + ] = OMIT, + seed: typing.Optional[int] = OMIT, + previous_text: typing.Optional[str] = OMIT, + next_text: typing.Optional[str] = OMIT, + previous_request_ids: typing.Optional[typing.Sequence[str]] = OMIT, + next_request_ids: typing.Optional[typing.Sequence[str]] = OMIT, + use_pvc_as_ivc: typing.Optional[bool] = OMIT, + apply_text_normalization: typing.Optional[ + BodyTextToSpeechV1TextToSpeechVoiceIdPostApplyTextNormalization + ] = OMIT, + apply_language_text_normalization: typing.Optional[bool] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> typing.Iterator[HttpResponse[typing.Iterator[bytes]]]: + """ + Converts text into speech using a voice of your choice and returns audio. + + Parameters + ---------- + voice_id : str + ID of the voice to be used. Use the [Get voices](/docs/api-reference/voices/search) endpoint list all the available voices. + + text : str + The text that will get converted into speech. + + enable_logging : typing.Optional[bool] + When enable_logging is set to false zero retention mode will be used for the request. This will mean history features are unavailable for this request, including request stitching. Zero retention mode may only be used by enterprise customers. + + optimize_streaming_latency : typing.Optional[int] + You can turn on latency optimizations at some cost of quality. The best possible final latency varies by model. Possible values: + 0 - default mode (no latency optimizations) + 1 - normal latency optimizations (about 50% of possible latency improvement of option 3) + 2 - strong latency optimizations (about 75% of possible latency improvement of option 3) + 3 - max latency optimizations + 4 - max latency optimizations, but also with text normalizer turned off for even more latency savings (best latency, but can mispronounce eg numbers and dates). + + Defaults to None. + + output_format : typing.Optional[TextToSpeechConvertRequestOutputFormat] + Output format of the generated audio. Formatted as codec_sample_rate_bitrate. So an mp3 with 22.05kHz sample rate at 32kbs is represented as mp3_22050_32. MP3 with 192kbps bitrate requires you to be subscribed to Creator tier or above. PCM with 44.1kHz sample rate requires you to be subscribed to Pro tier or above. Note that the μ-law format (sometimes written mu-law, often approximated as u-law) is commonly used for Twilio audio inputs. + + model_id : typing.Optional[str] + Identifier of the model that will be used, you can query them using GET /v1/models. The model needs to have support for text to speech, you can check this using the can_do_text_to_speech property. + + language_code : typing.Optional[str] + Language code (ISO 639-1) used to enforce a language for the model. Currently only Turbo v2.5 and Flash v2.5 support language enforcement. For other models, an error will be returned if language code is provided. + + voice_settings : typing.Optional[VoiceSettings] + Voice settings overriding stored settings for the given voice. They are applied only on the given request. + + pronunciation_dictionary_locators : typing.Optional[typing.Sequence[PronunciationDictionaryVersionLocator]] + A list of pronunciation dictionary locators (id, version_id) to be applied to the text. They will be applied in order. You may have up to 3 locators per request + + seed : typing.Optional[int] + If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same seed and parameters should return the same result. Determinism is not guaranteed. Must be integer between 0 and 4294967295. + + previous_text : typing.Optional[str] + The text that came before the text of the current request. Can be used to improve the speech's continuity when concatenating together multiple generations or to influence the speech's continuity in the current generation. + + next_text : typing.Optional[str] + The text that comes after the text of the current request. Can be used to improve the speech's continuity when concatenating together multiple generations or to influence the speech's continuity in the current generation. + + previous_request_ids : typing.Optional[typing.Sequence[str]] + A list of request_id of the samples that were generated before this generation. Can be used to improve the speech's continuity when splitting up a large task into multiple requests. The results will be best when the same model is used across the generations. In case both previous_text and previous_request_ids is send, previous_text will be ignored. A maximum of 3 request_ids can be send. + + next_request_ids : typing.Optional[typing.Sequence[str]] + A list of request_id of the samples that come after this generation. next_request_ids is especially useful for maintaining the speech's continuity when regenerating a sample that has had some audio quality issues. For example, if you have generated 3 speech clips, and you want to improve clip 2, passing the request id of clip 3 as a next_request_id (and that of clip 1 as a previous_request_id) will help maintain natural flow in the combined speech. The results will be best when the same model is used across the generations. In case both next_text and next_request_ids is send, next_text will be ignored. A maximum of 3 request_ids can be send. + + use_pvc_as_ivc : typing.Optional[bool] + If true, we won't use PVC version of the voice for the generation but the IVC version. This is a temporary workaround for higher latency in PVC versions. + + apply_text_normalization : typing.Optional[BodyTextToSpeechV1TextToSpeechVoiceIdPostApplyTextNormalization] + This parameter controls text normalization with three modes: 'auto', 'on', and 'off'. When set to 'auto', the system will automatically decide whether to apply text normalization (e.g., spelling out numbers). With 'on', text normalization will always be applied, while with 'off', it will be skipped. Cannot be turned on for 'eleven_turbo_v2_5' or 'eleven_flash_v2_5' models. + + apply_language_text_normalization : typing.Optional[bool] + This parameter controls language text normalization. This helps with proper pronunciation of text in some supported languages. WARNING: This parameter can heavily increase the latency of the request. Currently only supported for Japanese. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. + + Returns + ------- + typing.Iterator[HttpResponse[typing.Iterator[bytes]]] + The generated audio file + """ + with self._client_wrapper.httpx_client.stream( + f"v1/text-to-speech/{jsonable_encoder(voice_id)}", + base_url=self._client_wrapper.get_environment().base, + method="POST", + params={ + "enable_logging": enable_logging, + "optimize_streaming_latency": optimize_streaming_latency, + "output_format": output_format, + }, + json={ + "text": text, + "model_id": model_id, + "language_code": language_code, + "voice_settings": convert_and_respect_annotation_metadata( + object_=voice_settings, annotation=VoiceSettings, direction="write" + ), + "pronunciation_dictionary_locators": convert_and_respect_annotation_metadata( + object_=pronunciation_dictionary_locators, + annotation=typing.Sequence[PronunciationDictionaryVersionLocator], + direction="write", + ), + "seed": seed, + "previous_text": previous_text, + "next_text": next_text, + "previous_request_ids": previous_request_ids, + "next_request_ids": next_request_ids, + "use_pvc_as_ivc": use_pvc_as_ivc, + "apply_text_normalization": apply_text_normalization, + "apply_language_text_normalization": apply_language_text_normalization, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) as _response: + + def _stream() -> HttpResponse[typing.Iterator[bytes]]: + try: + if 200 <= _response.status_code < 300: + _chunk_size = request_options.get("chunk_size", 1024) if request_options is not None else 1024 + return HttpResponse( + response=_response, data=(_chunk for _chunk in _response.iter_bytes(chunk_size=_chunk_size)) + ) + _response.read() + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + yield _stream() + + def convert_with_timestamps( + self, + voice_id: str, + *, + text: str, + enable_logging: typing.Optional[bool] = None, + optimize_streaming_latency: typing.Optional[int] = None, + output_format: typing.Optional[TextToSpeechConvertWithTimestampsRequestOutputFormat] = None, + model_id: typing.Optional[str] = OMIT, + language_code: typing.Optional[str] = OMIT, + voice_settings: typing.Optional[VoiceSettings] = OMIT, + pronunciation_dictionary_locators: typing.Optional[ + typing.Sequence[PronunciationDictionaryVersionLocator] + ] = OMIT, + seed: typing.Optional[int] = OMIT, + previous_text: typing.Optional[str] = OMIT, + next_text: typing.Optional[str] = OMIT, + previous_request_ids: typing.Optional[typing.Sequence[str]] = OMIT, + next_request_ids: typing.Optional[typing.Sequence[str]] = OMIT, + use_pvc_as_ivc: typing.Optional[bool] = OMIT, + apply_text_normalization: typing.Optional[ + BodyTextToSpeechWithTimestampsV1TextToSpeechVoiceIdWithTimestampsPostApplyTextNormalization + ] = OMIT, + apply_language_text_normalization: typing.Optional[bool] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[AudioWithTimestampsResponse]: + """ + Generate speech from text with precise character-level timing information for audio-text synchronization. + + Parameters + ---------- + voice_id : str + Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices. + + text : str + The text that will get converted into speech. + + enable_logging : typing.Optional[bool] + When enable_logging is set to false zero retention mode will be used for the request. This will mean history features are unavailable for this request, including request stitching. Zero retention mode may only be used by enterprise customers. + + optimize_streaming_latency : typing.Optional[int] + You can turn on latency optimizations at some cost of quality. The best possible final latency varies by model. Possible values: + 0 - default mode (no latency optimizations) + 1 - normal latency optimizations (about 50% of possible latency improvement of option 3) + 2 - strong latency optimizations (about 75% of possible latency improvement of option 3) + 3 - max latency optimizations + 4 - max latency optimizations, but also with text normalizer turned off for even more latency savings (best latency, but can mispronounce eg numbers and dates). + + Defaults to None. + + output_format : typing.Optional[TextToSpeechConvertWithTimestampsRequestOutputFormat] + Output format of the generated audio. Formatted as codec_sample_rate_bitrate. So an mp3 with 22.05kHz sample rate at 32kbs is represented as mp3_22050_32. MP3 with 192kbps bitrate requires you to be subscribed to Creator tier or above. PCM with 44.1kHz sample rate requires you to be subscribed to Pro tier or above. Note that the μ-law format (sometimes written mu-law, often approximated as u-law) is commonly used for Twilio audio inputs. + + model_id : typing.Optional[str] + Identifier of the model that will be used, you can query them using GET /v1/models. The model needs to have support for text to speech, you can check this using the can_do_text_to_speech property. + + language_code : typing.Optional[str] + Language code (ISO 639-1) used to enforce a language for the model. Currently only Turbo v2.5 and Flash v2.5 support language enforcement. For other models, an error will be returned if language code is provided. + + voice_settings : typing.Optional[VoiceSettings] + Voice settings overriding stored settings for the given voice. They are applied only on the given request. + + pronunciation_dictionary_locators : typing.Optional[typing.Sequence[PronunciationDictionaryVersionLocator]] + A list of pronunciation dictionary locators (id, version_id) to be applied to the text. They will be applied in order. You may have up to 3 locators per request + + seed : typing.Optional[int] + If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same seed and parameters should return the same result. Determinism is not guaranteed. Must be integer between 0 and 4294967295. + + previous_text : typing.Optional[str] + The text that came before the text of the current request. Can be used to improve the speech's continuity when concatenating together multiple generations or to influence the speech's continuity in the current generation. + + next_text : typing.Optional[str] + The text that comes after the text of the current request. Can be used to improve the speech's continuity when concatenating together multiple generations or to influence the speech's continuity in the current generation. + + previous_request_ids : typing.Optional[typing.Sequence[str]] + A list of request_id of the samples that were generated before this generation. Can be used to improve the speech's continuity when splitting up a large task into multiple requests. The results will be best when the same model is used across the generations. In case both previous_text and previous_request_ids is send, previous_text will be ignored. A maximum of 3 request_ids can be send. + + next_request_ids : typing.Optional[typing.Sequence[str]] + A list of request_id of the samples that come after this generation. next_request_ids is especially useful for maintaining the speech's continuity when regenerating a sample that has had some audio quality issues. For example, if you have generated 3 speech clips, and you want to improve clip 2, passing the request id of clip 3 as a next_request_id (and that of clip 1 as a previous_request_id) will help maintain natural flow in the combined speech. The results will be best when the same model is used across the generations. In case both next_text and next_request_ids is send, next_text will be ignored. A maximum of 3 request_ids can be send. + + use_pvc_as_ivc : typing.Optional[bool] + If true, we won't use PVC version of the voice for the generation but the IVC version. This is a temporary workaround for higher latency in PVC versions. + + apply_text_normalization : typing.Optional[BodyTextToSpeechWithTimestampsV1TextToSpeechVoiceIdWithTimestampsPostApplyTextNormalization] + This parameter controls text normalization with three modes: 'auto', 'on', and 'off'. When set to 'auto', the system will automatically decide whether to apply text normalization (e.g., spelling out numbers). With 'on', text normalization will always be applied, while with 'off', it will be skipped. Cannot be turned on for 'eleven_turbo_v2_5' or 'eleven_flash_v2_5' models. + + apply_language_text_normalization : typing.Optional[bool] + This parameter controls language text normalization. This helps with proper pronunciation of text in some supported languages. WARNING: This parameter can heavily increase the latency of the request. Currently only supported for Japanese. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[AudioWithTimestampsResponse] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/text-to-speech/{jsonable_encoder(voice_id)}/with-timestamps", + base_url=self._client_wrapper.get_environment().base, + method="POST", + params={ + "enable_logging": enable_logging, + "optimize_streaming_latency": optimize_streaming_latency, + "output_format": output_format, + }, + json={ + "text": text, + "model_id": model_id, + "language_code": language_code, + "voice_settings": convert_and_respect_annotation_metadata( + object_=voice_settings, annotation=VoiceSettings, direction="write" + ), + "pronunciation_dictionary_locators": convert_and_respect_annotation_metadata( + object_=pronunciation_dictionary_locators, + annotation=typing.Sequence[PronunciationDictionaryVersionLocator], + direction="write", + ), + "seed": seed, + "previous_text": previous_text, + "next_text": next_text, + "previous_request_ids": previous_request_ids, + "next_request_ids": next_request_ids, + "use_pvc_as_ivc": use_pvc_as_ivc, + "apply_text_normalization": apply_text_normalization, + "apply_language_text_normalization": apply_language_text_normalization, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + AudioWithTimestampsResponse, + construct_type( + type_=AudioWithTimestampsResponse, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + @contextlib.contextmanager + def stream( + self, + voice_id: str, + *, + text: str, + enable_logging: typing.Optional[bool] = None, + optimize_streaming_latency: typing.Optional[int] = None, + output_format: typing.Optional[TextToSpeechStreamRequestOutputFormat] = None, + model_id: typing.Optional[str] = OMIT, + language_code: typing.Optional[str] = OMIT, + voice_settings: typing.Optional[VoiceSettings] = OMIT, + pronunciation_dictionary_locators: typing.Optional[ + typing.Sequence[PronunciationDictionaryVersionLocator] + ] = OMIT, + seed: typing.Optional[int] = OMIT, + previous_text: typing.Optional[str] = OMIT, + next_text: typing.Optional[str] = OMIT, + previous_request_ids: typing.Optional[typing.Sequence[str]] = OMIT, + next_request_ids: typing.Optional[typing.Sequence[str]] = OMIT, + use_pvc_as_ivc: typing.Optional[bool] = OMIT, + apply_text_normalization: typing.Optional[ + BodyTextToSpeechStreamingV1TextToSpeechVoiceIdStreamPostApplyTextNormalization + ] = OMIT, + apply_language_text_normalization: typing.Optional[bool] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> typing.Iterator[HttpResponse[typing.Iterator[bytes]]]: + """ + Converts text into speech using a voice of your choice and returns audio as an audio stream. + + Parameters + ---------- + voice_id : str + ID of the voice to be used. Use the [Get voices](/docs/api-reference/voices/search) endpoint list all the available voices. + + text : str + The text that will get converted into speech. + + enable_logging : typing.Optional[bool] + When enable_logging is set to false zero retention mode will be used for the request. This will mean history features are unavailable for this request, including request stitching. Zero retention mode may only be used by enterprise customers. + + optimize_streaming_latency : typing.Optional[int] + You can turn on latency optimizations at some cost of quality. The best possible final latency varies by model. Possible values: + 0 - default mode (no latency optimizations) + 1 - normal latency optimizations (about 50% of possible latency improvement of option 3) + 2 - strong latency optimizations (about 75% of possible latency improvement of option 3) + 3 - max latency optimizations + 4 - max latency optimizations, but also with text normalizer turned off for even more latency savings (best latency, but can mispronounce eg numbers and dates). + + Defaults to None. + + output_format : typing.Optional[TextToSpeechStreamRequestOutputFormat] + Output format of the generated audio. Formatted as codec_sample_rate_bitrate. So an mp3 with 22.05kHz sample rate at 32kbs is represented as mp3_22050_32. MP3 with 192kbps bitrate requires you to be subscribed to Creator tier or above. PCM with 44.1kHz sample rate requires you to be subscribed to Pro tier or above. Note that the μ-law format (sometimes written mu-law, often approximated as u-law) is commonly used for Twilio audio inputs. + + model_id : typing.Optional[str] + Identifier of the model that will be used, you can query them using GET /v1/models. The model needs to have support for text to speech, you can check this using the can_do_text_to_speech property. + + language_code : typing.Optional[str] + Language code (ISO 639-1) used to enforce a language for the model. Currently only Turbo v2.5 and Flash v2.5 support language enforcement. For other models, an error will be returned if language code is provided. + + voice_settings : typing.Optional[VoiceSettings] + Voice settings overriding stored settings for the given voice. They are applied only on the given request. + + pronunciation_dictionary_locators : typing.Optional[typing.Sequence[PronunciationDictionaryVersionLocator]] + A list of pronunciation dictionary locators (id, version_id) to be applied to the text. They will be applied in order. You may have up to 3 locators per request + + seed : typing.Optional[int] + If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same seed and parameters should return the same result. Determinism is not guaranteed. Must be integer between 0 and 4294967295. + + previous_text : typing.Optional[str] + The text that came before the text of the current request. Can be used to improve the speech's continuity when concatenating together multiple generations or to influence the speech's continuity in the current generation. + + next_text : typing.Optional[str] + The text that comes after the text of the current request. Can be used to improve the speech's continuity when concatenating together multiple generations or to influence the speech's continuity in the current generation. + + previous_request_ids : typing.Optional[typing.Sequence[str]] + A list of request_id of the samples that were generated before this generation. Can be used to improve the speech's continuity when splitting up a large task into multiple requests. The results will be best when the same model is used across the generations. In case both previous_text and previous_request_ids is send, previous_text will be ignored. A maximum of 3 request_ids can be send. + + next_request_ids : typing.Optional[typing.Sequence[str]] + A list of request_id of the samples that come after this generation. next_request_ids is especially useful for maintaining the speech's continuity when regenerating a sample that has had some audio quality issues. For example, if you have generated 3 speech clips, and you want to improve clip 2, passing the request id of clip 3 as a next_request_id (and that of clip 1 as a previous_request_id) will help maintain natural flow in the combined speech. The results will be best when the same model is used across the generations. In case both next_text and next_request_ids is send, next_text will be ignored. A maximum of 3 request_ids can be send. + + use_pvc_as_ivc : typing.Optional[bool] + If true, we won't use PVC version of the voice for the generation but the IVC version. This is a temporary workaround for higher latency in PVC versions. + + apply_text_normalization : typing.Optional[BodyTextToSpeechStreamingV1TextToSpeechVoiceIdStreamPostApplyTextNormalization] + This parameter controls text normalization with three modes: 'auto', 'on', and 'off'. When set to 'auto', the system will automatically decide whether to apply text normalization (e.g., spelling out numbers). With 'on', text normalization will always be applied, while with 'off', it will be skipped. Cannot be turned on for 'eleven_turbo_v2_5' or 'eleven_flash_v2_5' models. + + apply_language_text_normalization : typing.Optional[bool] + This parameter controls language text normalization. This helps with proper pronunciation of text in some supported languages. WARNING: This parameter can heavily increase the latency of the request. Currently only supported for Japanese. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. + + Returns + ------- + typing.Iterator[HttpResponse[typing.Iterator[bytes]]] + Streaming audio data + """ + with self._client_wrapper.httpx_client.stream( + f"v1/text-to-speech/{jsonable_encoder(voice_id)}/stream", + base_url=self._client_wrapper.get_environment().base, + method="POST", + params={ + "enable_logging": enable_logging, + "optimize_streaming_latency": optimize_streaming_latency, + "output_format": output_format, + }, + json={ + "text": text, + "model_id": model_id, + "language_code": language_code, + "voice_settings": convert_and_respect_annotation_metadata( + object_=voice_settings, annotation=VoiceSettings, direction="write" + ), + "pronunciation_dictionary_locators": convert_and_respect_annotation_metadata( + object_=pronunciation_dictionary_locators, + annotation=typing.Sequence[PronunciationDictionaryVersionLocator], + direction="write", + ), + "seed": seed, + "previous_text": previous_text, + "next_text": next_text, + "previous_request_ids": previous_request_ids, + "next_request_ids": next_request_ids, + "use_pvc_as_ivc": use_pvc_as_ivc, + "apply_text_normalization": apply_text_normalization, + "apply_language_text_normalization": apply_language_text_normalization, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) as _response: + + def _stream() -> HttpResponse[typing.Iterator[bytes]]: + try: + if 200 <= _response.status_code < 300: + _chunk_size = request_options.get("chunk_size", 1024) if request_options is not None else 1024 + return HttpResponse( + response=_response, data=(_chunk for _chunk in _response.iter_bytes(chunk_size=_chunk_size)) + ) + _response.read() + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + yield _stream() + + @contextlib.contextmanager + def stream_with_timestamps( + self, + voice_id: str, + *, + text: str, + enable_logging: typing.Optional[bool] = None, + optimize_streaming_latency: typing.Optional[int] = None, + output_format: typing.Optional[TextToSpeechStreamWithTimestampsRequestOutputFormat] = None, + model_id: typing.Optional[str] = OMIT, + language_code: typing.Optional[str] = OMIT, + voice_settings: typing.Optional[VoiceSettings] = OMIT, + pronunciation_dictionary_locators: typing.Optional[ + typing.Sequence[PronunciationDictionaryVersionLocator] + ] = OMIT, + seed: typing.Optional[int] = OMIT, + previous_text: typing.Optional[str] = OMIT, + next_text: typing.Optional[str] = OMIT, + previous_request_ids: typing.Optional[typing.Sequence[str]] = OMIT, + next_request_ids: typing.Optional[typing.Sequence[str]] = OMIT, + use_pvc_as_ivc: typing.Optional[bool] = OMIT, + apply_text_normalization: typing.Optional[ + BodyTextToSpeechStreamingWithTimestampsV1TextToSpeechVoiceIdStreamWithTimestampsPostApplyTextNormalization + ] = OMIT, + apply_language_text_normalization: typing.Optional[bool] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> typing.Iterator[HttpResponse[typing.Iterator[StreamingAudioChunkWithTimestampsResponse]]]: + """ + Converts text into speech using a voice of your choice and returns a stream of JSONs containing audio as a base64 encoded string together with information on when which character was spoken. + + Parameters + ---------- + voice_id : str + ID of the voice to be used. Use the [Get voices](/docs/api-reference/voices/search) endpoint list all the available voices. + + text : str + The text that will get converted into speech. + + enable_logging : typing.Optional[bool] + When enable_logging is set to false zero retention mode will be used for the request. This will mean history features are unavailable for this request, including request stitching. Zero retention mode may only be used by enterprise customers. + + optimize_streaming_latency : typing.Optional[int] + You can turn on latency optimizations at some cost of quality. The best possible final latency varies by model. Possible values: + 0 - default mode (no latency optimizations) + 1 - normal latency optimizations (about 50% of possible latency improvement of option 3) + 2 - strong latency optimizations (about 75% of possible latency improvement of option 3) + 3 - max latency optimizations + 4 - max latency optimizations, but also with text normalizer turned off for even more latency savings (best latency, but can mispronounce eg numbers and dates). + + Defaults to None. + + output_format : typing.Optional[TextToSpeechStreamWithTimestampsRequestOutputFormat] + Output format of the generated audio. Formatted as codec_sample_rate_bitrate. So an mp3 with 22.05kHz sample rate at 32kbs is represented as mp3_22050_32. MP3 with 192kbps bitrate requires you to be subscribed to Creator tier or above. PCM with 44.1kHz sample rate requires you to be subscribed to Pro tier or above. Note that the μ-law format (sometimes written mu-law, often approximated as u-law) is commonly used for Twilio audio inputs. + + model_id : typing.Optional[str] + Identifier of the model that will be used, you can query them using GET /v1/models. The model needs to have support for text to speech, you can check this using the can_do_text_to_speech property. + + language_code : typing.Optional[str] + Language code (ISO 639-1) used to enforce a language for the model. Currently only Turbo v2.5 and Flash v2.5 support language enforcement. For other models, an error will be returned if language code is provided. + + voice_settings : typing.Optional[VoiceSettings] + Voice settings overriding stored settings for the given voice. They are applied only on the given request. + + pronunciation_dictionary_locators : typing.Optional[typing.Sequence[PronunciationDictionaryVersionLocator]] + A list of pronunciation dictionary locators (id, version_id) to be applied to the text. They will be applied in order. You may have up to 3 locators per request + + seed : typing.Optional[int] + If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same seed and parameters should return the same result. Determinism is not guaranteed. Must be integer between 0 and 4294967295. + + previous_text : typing.Optional[str] + The text that came before the text of the current request. Can be used to improve the speech's continuity when concatenating together multiple generations or to influence the speech's continuity in the current generation. + + next_text : typing.Optional[str] + The text that comes after the text of the current request. Can be used to improve the speech's continuity when concatenating together multiple generations or to influence the speech's continuity in the current generation. + + previous_request_ids : typing.Optional[typing.Sequence[str]] + A list of request_id of the samples that were generated before this generation. Can be used to improve the speech's continuity when splitting up a large task into multiple requests. The results will be best when the same model is used across the generations. In case both previous_text and previous_request_ids is send, previous_text will be ignored. A maximum of 3 request_ids can be send. + + next_request_ids : typing.Optional[typing.Sequence[str]] + A list of request_id of the samples that come after this generation. next_request_ids is especially useful for maintaining the speech's continuity when regenerating a sample that has had some audio quality issues. For example, if you have generated 3 speech clips, and you want to improve clip 2, passing the request id of clip 3 as a next_request_id (and that of clip 1 as a previous_request_id) will help maintain natural flow in the combined speech. The results will be best when the same model is used across the generations. In case both next_text and next_request_ids is send, next_text will be ignored. A maximum of 3 request_ids can be send. + + use_pvc_as_ivc : typing.Optional[bool] + If true, we won't use PVC version of the voice for the generation but the IVC version. This is a temporary workaround for higher latency in PVC versions. + + apply_text_normalization : typing.Optional[BodyTextToSpeechStreamingWithTimestampsV1TextToSpeechVoiceIdStreamWithTimestampsPostApplyTextNormalization] + This parameter controls text normalization with three modes: 'auto', 'on', and 'off'. When set to 'auto', the system will automatically decide whether to apply text normalization (e.g., spelling out numbers). With 'on', text normalization will always be applied, while with 'off', it will be skipped. Cannot be turned on for 'eleven_turbo_v2_5' or 'eleven_flash_v2_5' models. + + apply_language_text_normalization : typing.Optional[bool] + This parameter controls language text normalization. This helps with proper pronunciation of text in some supported languages. WARNING: This parameter can heavily increase the latency of the request. Currently only supported for Japanese. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Yields + ------ + typing.Iterator[HttpResponse[typing.Iterator[StreamingAudioChunkWithTimestampsResponse]]] + Stream of transcription chunks + """ + with self._client_wrapper.httpx_client.stream( + f"v1/text-to-speech/{jsonable_encoder(voice_id)}/stream/with-timestamps", + base_url=self._client_wrapper.get_environment().base, + method="POST", + params={ + "enable_logging": enable_logging, + "optimize_streaming_latency": optimize_streaming_latency, + "output_format": output_format, + }, + json={ + "text": text, + "model_id": model_id, + "language_code": language_code, + "voice_settings": convert_and_respect_annotation_metadata( + object_=voice_settings, annotation=VoiceSettings, direction="write" + ), + "pronunciation_dictionary_locators": convert_and_respect_annotation_metadata( + object_=pronunciation_dictionary_locators, + annotation=typing.Sequence[PronunciationDictionaryVersionLocator], + direction="write", + ), + "seed": seed, + "previous_text": previous_text, + "next_text": next_text, + "previous_request_ids": previous_request_ids, + "next_request_ids": next_request_ids, + "use_pvc_as_ivc": use_pvc_as_ivc, + "apply_text_normalization": apply_text_normalization, + "apply_language_text_normalization": apply_language_text_normalization, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) as _response: + + def _stream() -> HttpResponse[typing.Iterator[StreamingAudioChunkWithTimestampsResponse]]: + try: + if 200 <= _response.status_code < 300: + + def _iter(): + for _text in _response.iter_lines(): + try: + if len(_text) == 0: + continue + yield typing.cast( + StreamingAudioChunkWithTimestampsResponse, + construct_type( + type_=StreamingAudioChunkWithTimestampsResponse, # type: ignore + object_=json.loads(_text), + ), + ) + except Exception: + pass + return + + return HttpResponse(response=_response, data=_iter()) + _response.read() + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + yield _stream() + + +class AsyncRawTextToSpeechClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + @contextlib.asynccontextmanager + async def convert( + self, + voice_id: str, + *, + text: str, + enable_logging: typing.Optional[bool] = None, + optimize_streaming_latency: typing.Optional[int] = None, + output_format: typing.Optional[TextToSpeechConvertRequestOutputFormat] = None, + model_id: typing.Optional[str] = OMIT, + language_code: typing.Optional[str] = OMIT, + voice_settings: typing.Optional[VoiceSettings] = OMIT, + pronunciation_dictionary_locators: typing.Optional[ + typing.Sequence[PronunciationDictionaryVersionLocator] + ] = OMIT, + seed: typing.Optional[int] = OMIT, + previous_text: typing.Optional[str] = OMIT, + next_text: typing.Optional[str] = OMIT, + previous_request_ids: typing.Optional[typing.Sequence[str]] = OMIT, + next_request_ids: typing.Optional[typing.Sequence[str]] = OMIT, + use_pvc_as_ivc: typing.Optional[bool] = OMIT, + apply_text_normalization: typing.Optional[ + BodyTextToSpeechV1TextToSpeechVoiceIdPostApplyTextNormalization + ] = OMIT, + apply_language_text_normalization: typing.Optional[bool] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> typing.AsyncIterator[AsyncHttpResponse[typing.AsyncIterator[bytes]]]: + """ + Converts text into speech using a voice of your choice and returns audio. + + Parameters + ---------- + voice_id : str + ID of the voice to be used. Use the [Get voices](/docs/api-reference/voices/search) endpoint list all the available voices. + + text : str + The text that will get converted into speech. + + enable_logging : typing.Optional[bool] + When enable_logging is set to false zero retention mode will be used for the request. This will mean history features are unavailable for this request, including request stitching. Zero retention mode may only be used by enterprise customers. + + optimize_streaming_latency : typing.Optional[int] + You can turn on latency optimizations at some cost of quality. The best possible final latency varies by model. Possible values: + 0 - default mode (no latency optimizations) + 1 - normal latency optimizations (about 50% of possible latency improvement of option 3) + 2 - strong latency optimizations (about 75% of possible latency improvement of option 3) + 3 - max latency optimizations + 4 - max latency optimizations, but also with text normalizer turned off for even more latency savings (best latency, but can mispronounce eg numbers and dates). + + Defaults to None. + + output_format : typing.Optional[TextToSpeechConvertRequestOutputFormat] + Output format of the generated audio. Formatted as codec_sample_rate_bitrate. So an mp3 with 22.05kHz sample rate at 32kbs is represented as mp3_22050_32. MP3 with 192kbps bitrate requires you to be subscribed to Creator tier or above. PCM with 44.1kHz sample rate requires you to be subscribed to Pro tier or above. Note that the μ-law format (sometimes written mu-law, often approximated as u-law) is commonly used for Twilio audio inputs. + + model_id : typing.Optional[str] + Identifier of the model that will be used, you can query them using GET /v1/models. The model needs to have support for text to speech, you can check this using the can_do_text_to_speech property. + + language_code : typing.Optional[str] + Language code (ISO 639-1) used to enforce a language for the model. Currently only Turbo v2.5 and Flash v2.5 support language enforcement. For other models, an error will be returned if language code is provided. + + voice_settings : typing.Optional[VoiceSettings] + Voice settings overriding stored settings for the given voice. They are applied only on the given request. + + pronunciation_dictionary_locators : typing.Optional[typing.Sequence[PronunciationDictionaryVersionLocator]] + A list of pronunciation dictionary locators (id, version_id) to be applied to the text. They will be applied in order. You may have up to 3 locators per request + + seed : typing.Optional[int] + If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same seed and parameters should return the same result. Determinism is not guaranteed. Must be integer between 0 and 4294967295. + + previous_text : typing.Optional[str] + The text that came before the text of the current request. Can be used to improve the speech's continuity when concatenating together multiple generations or to influence the speech's continuity in the current generation. + + next_text : typing.Optional[str] + The text that comes after the text of the current request. Can be used to improve the speech's continuity when concatenating together multiple generations or to influence the speech's continuity in the current generation. + + previous_request_ids : typing.Optional[typing.Sequence[str]] + A list of request_id of the samples that were generated before this generation. Can be used to improve the speech's continuity when splitting up a large task into multiple requests. The results will be best when the same model is used across the generations. In case both previous_text and previous_request_ids is send, previous_text will be ignored. A maximum of 3 request_ids can be send. + + next_request_ids : typing.Optional[typing.Sequence[str]] + A list of request_id of the samples that come after this generation. next_request_ids is especially useful for maintaining the speech's continuity when regenerating a sample that has had some audio quality issues. For example, if you have generated 3 speech clips, and you want to improve clip 2, passing the request id of clip 3 as a next_request_id (and that of clip 1 as a previous_request_id) will help maintain natural flow in the combined speech. The results will be best when the same model is used across the generations. In case both next_text and next_request_ids is send, next_text will be ignored. A maximum of 3 request_ids can be send. + + use_pvc_as_ivc : typing.Optional[bool] + If true, we won't use PVC version of the voice for the generation but the IVC version. This is a temporary workaround for higher latency in PVC versions. + + apply_text_normalization : typing.Optional[BodyTextToSpeechV1TextToSpeechVoiceIdPostApplyTextNormalization] + This parameter controls text normalization with three modes: 'auto', 'on', and 'off'. When set to 'auto', the system will automatically decide whether to apply text normalization (e.g., spelling out numbers). With 'on', text normalization will always be applied, while with 'off', it will be skipped. Cannot be turned on for 'eleven_turbo_v2_5' or 'eleven_flash_v2_5' models. + + apply_language_text_normalization : typing.Optional[bool] + This parameter controls language text normalization. This helps with proper pronunciation of text in some supported languages. WARNING: This parameter can heavily increase the latency of the request. Currently only supported for Japanese. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. + + Returns + ------- + typing.AsyncIterator[AsyncHttpResponse[typing.AsyncIterator[bytes]]] + The generated audio file + """ + async with self._client_wrapper.httpx_client.stream( + f"v1/text-to-speech/{jsonable_encoder(voice_id)}", + base_url=self._client_wrapper.get_environment().base, + method="POST", + params={ + "enable_logging": enable_logging, + "optimize_streaming_latency": optimize_streaming_latency, + "output_format": output_format, + }, + json={ + "text": text, + "model_id": model_id, + "language_code": language_code, + "voice_settings": convert_and_respect_annotation_metadata( + object_=voice_settings, annotation=VoiceSettings, direction="write" + ), + "pronunciation_dictionary_locators": convert_and_respect_annotation_metadata( + object_=pronunciation_dictionary_locators, + annotation=typing.Sequence[PronunciationDictionaryVersionLocator], + direction="write", + ), + "seed": seed, + "previous_text": previous_text, + "next_text": next_text, + "previous_request_ids": previous_request_ids, + "next_request_ids": next_request_ids, + "use_pvc_as_ivc": use_pvc_as_ivc, + "apply_text_normalization": apply_text_normalization, + "apply_language_text_normalization": apply_language_text_normalization, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) as _response: + + async def _stream() -> AsyncHttpResponse[typing.AsyncIterator[bytes]]: + try: + if 200 <= _response.status_code < 300: + _chunk_size = request_options.get("chunk_size", 1024) if request_options is not None else 1024 + return AsyncHttpResponse( + response=_response, + data=(_chunk async for _chunk in _response.aiter_bytes(chunk_size=_chunk_size)), + ) + await _response.aread() + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + yield await _stream() + + async def convert_with_timestamps( + self, + voice_id: str, + *, + text: str, + enable_logging: typing.Optional[bool] = None, + optimize_streaming_latency: typing.Optional[int] = None, + output_format: typing.Optional[TextToSpeechConvertWithTimestampsRequestOutputFormat] = None, + model_id: typing.Optional[str] = OMIT, + language_code: typing.Optional[str] = OMIT, + voice_settings: typing.Optional[VoiceSettings] = OMIT, + pronunciation_dictionary_locators: typing.Optional[ + typing.Sequence[PronunciationDictionaryVersionLocator] + ] = OMIT, + seed: typing.Optional[int] = OMIT, + previous_text: typing.Optional[str] = OMIT, + next_text: typing.Optional[str] = OMIT, + previous_request_ids: typing.Optional[typing.Sequence[str]] = OMIT, + next_request_ids: typing.Optional[typing.Sequence[str]] = OMIT, + use_pvc_as_ivc: typing.Optional[bool] = OMIT, + apply_text_normalization: typing.Optional[ + BodyTextToSpeechWithTimestampsV1TextToSpeechVoiceIdWithTimestampsPostApplyTextNormalization + ] = OMIT, + apply_language_text_normalization: typing.Optional[bool] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[AudioWithTimestampsResponse]: + """ + Generate speech from text with precise character-level timing information for audio-text synchronization. + + Parameters + ---------- + voice_id : str + Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices. + + text : str + The text that will get converted into speech. + + enable_logging : typing.Optional[bool] + When enable_logging is set to false zero retention mode will be used for the request. This will mean history features are unavailable for this request, including request stitching. Zero retention mode may only be used by enterprise customers. + + optimize_streaming_latency : typing.Optional[int] + You can turn on latency optimizations at some cost of quality. The best possible final latency varies by model. Possible values: + 0 - default mode (no latency optimizations) + 1 - normal latency optimizations (about 50% of possible latency improvement of option 3) + 2 - strong latency optimizations (about 75% of possible latency improvement of option 3) + 3 - max latency optimizations + 4 - max latency optimizations, but also with text normalizer turned off for even more latency savings (best latency, but can mispronounce eg numbers and dates). + + Defaults to None. + + output_format : typing.Optional[TextToSpeechConvertWithTimestampsRequestOutputFormat] + Output format of the generated audio. Formatted as codec_sample_rate_bitrate. So an mp3 with 22.05kHz sample rate at 32kbs is represented as mp3_22050_32. MP3 with 192kbps bitrate requires you to be subscribed to Creator tier or above. PCM with 44.1kHz sample rate requires you to be subscribed to Pro tier or above. Note that the μ-law format (sometimes written mu-law, often approximated as u-law) is commonly used for Twilio audio inputs. + + model_id : typing.Optional[str] + Identifier of the model that will be used, you can query them using GET /v1/models. The model needs to have support for text to speech, you can check this using the can_do_text_to_speech property. + + language_code : typing.Optional[str] + Language code (ISO 639-1) used to enforce a language for the model. Currently only Turbo v2.5 and Flash v2.5 support language enforcement. For other models, an error will be returned if language code is provided. + + voice_settings : typing.Optional[VoiceSettings] + Voice settings overriding stored settings for the given voice. They are applied only on the given request. + + pronunciation_dictionary_locators : typing.Optional[typing.Sequence[PronunciationDictionaryVersionLocator]] + A list of pronunciation dictionary locators (id, version_id) to be applied to the text. They will be applied in order. You may have up to 3 locators per request + + seed : typing.Optional[int] + If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same seed and parameters should return the same result. Determinism is not guaranteed. Must be integer between 0 and 4294967295. + + previous_text : typing.Optional[str] + The text that came before the text of the current request. Can be used to improve the speech's continuity when concatenating together multiple generations or to influence the speech's continuity in the current generation. + + next_text : typing.Optional[str] + The text that comes after the text of the current request. Can be used to improve the speech's continuity when concatenating together multiple generations or to influence the speech's continuity in the current generation. + + previous_request_ids : typing.Optional[typing.Sequence[str]] + A list of request_id of the samples that were generated before this generation. Can be used to improve the speech's continuity when splitting up a large task into multiple requests. The results will be best when the same model is used across the generations. In case both previous_text and previous_request_ids is send, previous_text will be ignored. A maximum of 3 request_ids can be send. + + next_request_ids : typing.Optional[typing.Sequence[str]] + A list of request_id of the samples that come after this generation. next_request_ids is especially useful for maintaining the speech's continuity when regenerating a sample that has had some audio quality issues. For example, if you have generated 3 speech clips, and you want to improve clip 2, passing the request id of clip 3 as a next_request_id (and that of clip 1 as a previous_request_id) will help maintain natural flow in the combined speech. The results will be best when the same model is used across the generations. In case both next_text and next_request_ids is send, next_text will be ignored. A maximum of 3 request_ids can be send. + + use_pvc_as_ivc : typing.Optional[bool] + If true, we won't use PVC version of the voice for the generation but the IVC version. This is a temporary workaround for higher latency in PVC versions. + + apply_text_normalization : typing.Optional[BodyTextToSpeechWithTimestampsV1TextToSpeechVoiceIdWithTimestampsPostApplyTextNormalization] + This parameter controls text normalization with three modes: 'auto', 'on', and 'off'. When set to 'auto', the system will automatically decide whether to apply text normalization (e.g., spelling out numbers). With 'on', text normalization will always be applied, while with 'off', it will be skipped. Cannot be turned on for 'eleven_turbo_v2_5' or 'eleven_flash_v2_5' models. + + apply_language_text_normalization : typing.Optional[bool] + This parameter controls language text normalization. This helps with proper pronunciation of text in some supported languages. WARNING: This parameter can heavily increase the latency of the request. Currently only supported for Japanese. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[AudioWithTimestampsResponse] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/text-to-speech/{jsonable_encoder(voice_id)}/with-timestamps", + base_url=self._client_wrapper.get_environment().base, + method="POST", + params={ + "enable_logging": enable_logging, + "optimize_streaming_latency": optimize_streaming_latency, + "output_format": output_format, + }, + json={ + "text": text, + "model_id": model_id, + "language_code": language_code, + "voice_settings": convert_and_respect_annotation_metadata( + object_=voice_settings, annotation=VoiceSettings, direction="write" + ), + "pronunciation_dictionary_locators": convert_and_respect_annotation_metadata( + object_=pronunciation_dictionary_locators, + annotation=typing.Sequence[PronunciationDictionaryVersionLocator], + direction="write", + ), + "seed": seed, + "previous_text": previous_text, + "next_text": next_text, + "previous_request_ids": previous_request_ids, + "next_request_ids": next_request_ids, + "use_pvc_as_ivc": use_pvc_as_ivc, + "apply_text_normalization": apply_text_normalization, + "apply_language_text_normalization": apply_language_text_normalization, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + AudioWithTimestampsResponse, + construct_type( + type_=AudioWithTimestampsResponse, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + @contextlib.asynccontextmanager + async def stream( + self, + voice_id: str, + *, + text: str, + enable_logging: typing.Optional[bool] = None, + optimize_streaming_latency: typing.Optional[int] = None, + output_format: typing.Optional[TextToSpeechStreamRequestOutputFormat] = None, + model_id: typing.Optional[str] = OMIT, + language_code: typing.Optional[str] = OMIT, + voice_settings: typing.Optional[VoiceSettings] = OMIT, + pronunciation_dictionary_locators: typing.Optional[ + typing.Sequence[PronunciationDictionaryVersionLocator] + ] = OMIT, + seed: typing.Optional[int] = OMIT, + previous_text: typing.Optional[str] = OMIT, + next_text: typing.Optional[str] = OMIT, + previous_request_ids: typing.Optional[typing.Sequence[str]] = OMIT, + next_request_ids: typing.Optional[typing.Sequence[str]] = OMIT, + use_pvc_as_ivc: typing.Optional[bool] = OMIT, + apply_text_normalization: typing.Optional[ + BodyTextToSpeechStreamingV1TextToSpeechVoiceIdStreamPostApplyTextNormalization + ] = OMIT, + apply_language_text_normalization: typing.Optional[bool] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> typing.AsyncIterator[AsyncHttpResponse[typing.AsyncIterator[bytes]]]: + """ + Converts text into speech using a voice of your choice and returns audio as an audio stream. + + Parameters + ---------- + voice_id : str + ID of the voice to be used. Use the [Get voices](/docs/api-reference/voices/search) endpoint list all the available voices. + + text : str + The text that will get converted into speech. + + enable_logging : typing.Optional[bool] + When enable_logging is set to false zero retention mode will be used for the request. This will mean history features are unavailable for this request, including request stitching. Zero retention mode may only be used by enterprise customers. + + optimize_streaming_latency : typing.Optional[int] + You can turn on latency optimizations at some cost of quality. The best possible final latency varies by model. Possible values: + 0 - default mode (no latency optimizations) + 1 - normal latency optimizations (about 50% of possible latency improvement of option 3) + 2 - strong latency optimizations (about 75% of possible latency improvement of option 3) + 3 - max latency optimizations + 4 - max latency optimizations, but also with text normalizer turned off for even more latency savings (best latency, but can mispronounce eg numbers and dates). + + Defaults to None. + + output_format : typing.Optional[TextToSpeechStreamRequestOutputFormat] + Output format of the generated audio. Formatted as codec_sample_rate_bitrate. So an mp3 with 22.05kHz sample rate at 32kbs is represented as mp3_22050_32. MP3 with 192kbps bitrate requires you to be subscribed to Creator tier or above. PCM with 44.1kHz sample rate requires you to be subscribed to Pro tier or above. Note that the μ-law format (sometimes written mu-law, often approximated as u-law) is commonly used for Twilio audio inputs. + + model_id : typing.Optional[str] + Identifier of the model that will be used, you can query them using GET /v1/models. The model needs to have support for text to speech, you can check this using the can_do_text_to_speech property. + + language_code : typing.Optional[str] + Language code (ISO 639-1) used to enforce a language for the model. Currently only Turbo v2.5 and Flash v2.5 support language enforcement. For other models, an error will be returned if language code is provided. + + voice_settings : typing.Optional[VoiceSettings] + Voice settings overriding stored settings for the given voice. They are applied only on the given request. + + pronunciation_dictionary_locators : typing.Optional[typing.Sequence[PronunciationDictionaryVersionLocator]] + A list of pronunciation dictionary locators (id, version_id) to be applied to the text. They will be applied in order. You may have up to 3 locators per request + + seed : typing.Optional[int] + If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same seed and parameters should return the same result. Determinism is not guaranteed. Must be integer between 0 and 4294967295. + + previous_text : typing.Optional[str] + The text that came before the text of the current request. Can be used to improve the speech's continuity when concatenating together multiple generations or to influence the speech's continuity in the current generation. + + next_text : typing.Optional[str] + The text that comes after the text of the current request. Can be used to improve the speech's continuity when concatenating together multiple generations or to influence the speech's continuity in the current generation. + + previous_request_ids : typing.Optional[typing.Sequence[str]] + A list of request_id of the samples that were generated before this generation. Can be used to improve the speech's continuity when splitting up a large task into multiple requests. The results will be best when the same model is used across the generations. In case both previous_text and previous_request_ids is send, previous_text will be ignored. A maximum of 3 request_ids can be send. + + next_request_ids : typing.Optional[typing.Sequence[str]] + A list of request_id of the samples that come after this generation. next_request_ids is especially useful for maintaining the speech's continuity when regenerating a sample that has had some audio quality issues. For example, if you have generated 3 speech clips, and you want to improve clip 2, passing the request id of clip 3 as a next_request_id (and that of clip 1 as a previous_request_id) will help maintain natural flow in the combined speech. The results will be best when the same model is used across the generations. In case both next_text and next_request_ids is send, next_text will be ignored. A maximum of 3 request_ids can be send. + + use_pvc_as_ivc : typing.Optional[bool] + If true, we won't use PVC version of the voice for the generation but the IVC version. This is a temporary workaround for higher latency in PVC versions. + + apply_text_normalization : typing.Optional[BodyTextToSpeechStreamingV1TextToSpeechVoiceIdStreamPostApplyTextNormalization] + This parameter controls text normalization with three modes: 'auto', 'on', and 'off'. When set to 'auto', the system will automatically decide whether to apply text normalization (e.g., spelling out numbers). With 'on', text normalization will always be applied, while with 'off', it will be skipped. Cannot be turned on for 'eleven_turbo_v2_5' or 'eleven_flash_v2_5' models. + + apply_language_text_normalization : typing.Optional[bool] + This parameter controls language text normalization. This helps with proper pronunciation of text in some supported languages. WARNING: This parameter can heavily increase the latency of the request. Currently only supported for Japanese. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. + + Returns + ------- + typing.AsyncIterator[AsyncHttpResponse[typing.AsyncIterator[bytes]]] + Streaming audio data + """ + async with self._client_wrapper.httpx_client.stream( + f"v1/text-to-speech/{jsonable_encoder(voice_id)}/stream", + base_url=self._client_wrapper.get_environment().base, + method="POST", + params={ + "enable_logging": enable_logging, + "optimize_streaming_latency": optimize_streaming_latency, + "output_format": output_format, + }, + json={ + "text": text, + "model_id": model_id, + "language_code": language_code, + "voice_settings": convert_and_respect_annotation_metadata( + object_=voice_settings, annotation=VoiceSettings, direction="write" + ), + "pronunciation_dictionary_locators": convert_and_respect_annotation_metadata( + object_=pronunciation_dictionary_locators, + annotation=typing.Sequence[PronunciationDictionaryVersionLocator], + direction="write", + ), + "seed": seed, + "previous_text": previous_text, + "next_text": next_text, + "previous_request_ids": previous_request_ids, + "next_request_ids": next_request_ids, + "use_pvc_as_ivc": use_pvc_as_ivc, + "apply_text_normalization": apply_text_normalization, + "apply_language_text_normalization": apply_language_text_normalization, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) as _response: + + async def _stream() -> AsyncHttpResponse[typing.AsyncIterator[bytes]]: + try: + if 200 <= _response.status_code < 300: + _chunk_size = request_options.get("chunk_size", 1024) if request_options is not None else 1024 + return AsyncHttpResponse( + response=_response, + data=(_chunk async for _chunk in _response.aiter_bytes(chunk_size=_chunk_size)), + ) + await _response.aread() + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + yield await _stream() + + @contextlib.asynccontextmanager + async def stream_with_timestamps( + self, + voice_id: str, + *, + text: str, + enable_logging: typing.Optional[bool] = None, + optimize_streaming_latency: typing.Optional[int] = None, + output_format: typing.Optional[TextToSpeechStreamWithTimestampsRequestOutputFormat] = None, + model_id: typing.Optional[str] = OMIT, + language_code: typing.Optional[str] = OMIT, + voice_settings: typing.Optional[VoiceSettings] = OMIT, + pronunciation_dictionary_locators: typing.Optional[ + typing.Sequence[PronunciationDictionaryVersionLocator] + ] = OMIT, + seed: typing.Optional[int] = OMIT, + previous_text: typing.Optional[str] = OMIT, + next_text: typing.Optional[str] = OMIT, + previous_request_ids: typing.Optional[typing.Sequence[str]] = OMIT, + next_request_ids: typing.Optional[typing.Sequence[str]] = OMIT, + use_pvc_as_ivc: typing.Optional[bool] = OMIT, + apply_text_normalization: typing.Optional[ + BodyTextToSpeechStreamingWithTimestampsV1TextToSpeechVoiceIdStreamWithTimestampsPostApplyTextNormalization + ] = OMIT, + apply_language_text_normalization: typing.Optional[bool] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> typing.AsyncIterator[AsyncHttpResponse[typing.AsyncIterator[StreamingAudioChunkWithTimestampsResponse]]]: + """ + Converts text into speech using a voice of your choice and returns a stream of JSONs containing audio as a base64 encoded string together with information on when which character was spoken. + + Parameters + ---------- + voice_id : str + ID of the voice to be used. Use the [Get voices](/docs/api-reference/voices/search) endpoint list all the available voices. + + text : str + The text that will get converted into speech. + + enable_logging : typing.Optional[bool] + When enable_logging is set to false zero retention mode will be used for the request. This will mean history features are unavailable for this request, including request stitching. Zero retention mode may only be used by enterprise customers. + + optimize_streaming_latency : typing.Optional[int] + You can turn on latency optimizations at some cost of quality. The best possible final latency varies by model. Possible values: + 0 - default mode (no latency optimizations) + 1 - normal latency optimizations (about 50% of possible latency improvement of option 3) + 2 - strong latency optimizations (about 75% of possible latency improvement of option 3) + 3 - max latency optimizations + 4 - max latency optimizations, but also with text normalizer turned off for even more latency savings (best latency, but can mispronounce eg numbers and dates). + + Defaults to None. + + output_format : typing.Optional[TextToSpeechStreamWithTimestampsRequestOutputFormat] + Output format of the generated audio. Formatted as codec_sample_rate_bitrate. So an mp3 with 22.05kHz sample rate at 32kbs is represented as mp3_22050_32. MP3 with 192kbps bitrate requires you to be subscribed to Creator tier or above. PCM with 44.1kHz sample rate requires you to be subscribed to Pro tier or above. Note that the μ-law format (sometimes written mu-law, often approximated as u-law) is commonly used for Twilio audio inputs. + + model_id : typing.Optional[str] + Identifier of the model that will be used, you can query them using GET /v1/models. The model needs to have support for text to speech, you can check this using the can_do_text_to_speech property. + + language_code : typing.Optional[str] + Language code (ISO 639-1) used to enforce a language for the model. Currently only Turbo v2.5 and Flash v2.5 support language enforcement. For other models, an error will be returned if language code is provided. + + voice_settings : typing.Optional[VoiceSettings] + Voice settings overriding stored settings for the given voice. They are applied only on the given request. + + pronunciation_dictionary_locators : typing.Optional[typing.Sequence[PronunciationDictionaryVersionLocator]] + A list of pronunciation dictionary locators (id, version_id) to be applied to the text. They will be applied in order. You may have up to 3 locators per request + + seed : typing.Optional[int] + If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same seed and parameters should return the same result. Determinism is not guaranteed. Must be integer between 0 and 4294967295. + + previous_text : typing.Optional[str] + The text that came before the text of the current request. Can be used to improve the speech's continuity when concatenating together multiple generations or to influence the speech's continuity in the current generation. + + next_text : typing.Optional[str] + The text that comes after the text of the current request. Can be used to improve the speech's continuity when concatenating together multiple generations or to influence the speech's continuity in the current generation. + + previous_request_ids : typing.Optional[typing.Sequence[str]] + A list of request_id of the samples that were generated before this generation. Can be used to improve the speech's continuity when splitting up a large task into multiple requests. The results will be best when the same model is used across the generations. In case both previous_text and previous_request_ids is send, previous_text will be ignored. A maximum of 3 request_ids can be send. + + next_request_ids : typing.Optional[typing.Sequence[str]] + A list of request_id of the samples that come after this generation. next_request_ids is especially useful for maintaining the speech's continuity when regenerating a sample that has had some audio quality issues. For example, if you have generated 3 speech clips, and you want to improve clip 2, passing the request id of clip 3 as a next_request_id (and that of clip 1 as a previous_request_id) will help maintain natural flow in the combined speech. The results will be best when the same model is used across the generations. In case both next_text and next_request_ids is send, next_text will be ignored. A maximum of 3 request_ids can be send. + + use_pvc_as_ivc : typing.Optional[bool] + If true, we won't use PVC version of the voice for the generation but the IVC version. This is a temporary workaround for higher latency in PVC versions. + + apply_text_normalization : typing.Optional[BodyTextToSpeechStreamingWithTimestampsV1TextToSpeechVoiceIdStreamWithTimestampsPostApplyTextNormalization] + This parameter controls text normalization with three modes: 'auto', 'on', and 'off'. When set to 'auto', the system will automatically decide whether to apply text normalization (e.g., spelling out numbers). With 'on', text normalization will always be applied, while with 'off', it will be skipped. Cannot be turned on for 'eleven_turbo_v2_5' or 'eleven_flash_v2_5' models. + + apply_language_text_normalization : typing.Optional[bool] + This parameter controls language text normalization. This helps with proper pronunciation of text in some supported languages. WARNING: This parameter can heavily increase the latency of the request. Currently only supported for Japanese. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Yields + ------ + typing.AsyncIterator[AsyncHttpResponse[typing.AsyncIterator[StreamingAudioChunkWithTimestampsResponse]]] + Stream of transcription chunks + """ + async with self._client_wrapper.httpx_client.stream( + f"v1/text-to-speech/{jsonable_encoder(voice_id)}/stream/with-timestamps", + base_url=self._client_wrapper.get_environment().base, + method="POST", + params={ + "enable_logging": enable_logging, + "optimize_streaming_latency": optimize_streaming_latency, + "output_format": output_format, + }, + json={ + "text": text, + "model_id": model_id, + "language_code": language_code, + "voice_settings": convert_and_respect_annotation_metadata( + object_=voice_settings, annotation=VoiceSettings, direction="write" + ), + "pronunciation_dictionary_locators": convert_and_respect_annotation_metadata( + object_=pronunciation_dictionary_locators, + annotation=typing.Sequence[PronunciationDictionaryVersionLocator], + direction="write", + ), + "seed": seed, + "previous_text": previous_text, + "next_text": next_text, + "previous_request_ids": previous_request_ids, + "next_request_ids": next_request_ids, + "use_pvc_as_ivc": use_pvc_as_ivc, + "apply_text_normalization": apply_text_normalization, + "apply_language_text_normalization": apply_language_text_normalization, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) as _response: + + async def _stream() -> AsyncHttpResponse[typing.AsyncIterator[StreamingAudioChunkWithTimestampsResponse]]: + try: + if 200 <= _response.status_code < 300: + + async def _iter(): + async for _text in _response.aiter_lines(): + try: + if len(_text) == 0: + continue + yield typing.cast( + StreamingAudioChunkWithTimestampsResponse, + construct_type( + type_=StreamingAudioChunkWithTimestampsResponse, # type: ignore + object_=json.loads(_text), + ), + ) + except Exception: + pass + return + + return AsyncHttpResponse(response=_response, data=_iter()) + await _response.aread() + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + yield await _stream() diff --git a/src/elevenlabs/text_to_speech/types/__init__.py b/src/elevenlabs/text_to_speech/types/__init__.py index a37b0102..74808724 100644 --- a/src/elevenlabs/text_to_speech/types/__init__.py +++ b/src/elevenlabs/text_to_speech/types/__init__.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# isort: skip_file + from .body_text_to_speech_streaming_v_1_text_to_speech_voice_id_stream_post_apply_text_normalization import ( BodyTextToSpeechStreamingV1TextToSpeechVoiceIdStreamPostApplyTextNormalization, ) @@ -12,11 +14,11 @@ from .body_text_to_speech_with_timestamps_v_1_text_to_speech_voice_id_with_timestamps_post_apply_text_normalization import ( BodyTextToSpeechWithTimestampsV1TextToSpeechVoiceIdWithTimestampsPostApplyTextNormalization, ) -from .text_to_speech_convert_as_stream_request_output_format import TextToSpeechConvertAsStreamRequestOutputFormat from .text_to_speech_convert_request_output_format import TextToSpeechConvertRequestOutputFormat from .text_to_speech_convert_with_timestamps_request_output_format import ( TextToSpeechConvertWithTimestampsRequestOutputFormat, ) +from .text_to_speech_stream_request_output_format import TextToSpeechStreamRequestOutputFormat from .text_to_speech_stream_with_timestamps_request_output_format import ( TextToSpeechStreamWithTimestampsRequestOutputFormat, ) @@ -26,8 +28,8 @@ "BodyTextToSpeechStreamingWithTimestampsV1TextToSpeechVoiceIdStreamWithTimestampsPostApplyTextNormalization", "BodyTextToSpeechV1TextToSpeechVoiceIdPostApplyTextNormalization", "BodyTextToSpeechWithTimestampsV1TextToSpeechVoiceIdWithTimestampsPostApplyTextNormalization", - "TextToSpeechConvertAsStreamRequestOutputFormat", "TextToSpeechConvertRequestOutputFormat", "TextToSpeechConvertWithTimestampsRequestOutputFormat", + "TextToSpeechStreamRequestOutputFormat", "TextToSpeechStreamWithTimestampsRequestOutputFormat", ] diff --git a/src/elevenlabs/speech_to_speech/types/speech_to_speech_convert_as_stream_request_output_format.py b/src/elevenlabs/text_to_speech/types/text_to_speech_stream_request_output_format.py similarity index 89% rename from src/elevenlabs/speech_to_speech/types/speech_to_speech_convert_as_stream_request_output_format.py rename to src/elevenlabs/text_to_speech/types/text_to_speech_stream_request_output_format.py index bf7212b7..910c0392 100644 --- a/src/elevenlabs/speech_to_speech/types/speech_to_speech_convert_as_stream_request_output_format.py +++ b/src/elevenlabs/text_to_speech/types/text_to_speech_stream_request_output_format.py @@ -2,7 +2,7 @@ import typing -SpeechToSpeechConvertAsStreamRequestOutputFormat = typing.Union[ +TextToSpeechStreamRequestOutputFormat = typing.Union[ typing.Literal[ "mp3_22050_32", "mp3_44100_32", diff --git a/src/elevenlabs/text_to_voice/__init__.py b/src/elevenlabs/text_to_voice/__init__.py index 1a606e5d..de76103f 100644 --- a/src/elevenlabs/text_to_voice/__init__.py +++ b/src/elevenlabs/text_to_voice/__init__.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# isort: skip_file + from .types import TextToVoiceCreatePreviewsRequestOutputFormat __all__ = ["TextToVoiceCreatePreviewsRequestOutputFormat"] diff --git a/src/elevenlabs/text_to_voice/client.py b/src/elevenlabs/text_to_voice/client.py index e112b7c2..77ab3b78 100644 --- a/src/elevenlabs/text_to_voice/client.py +++ b/src/elevenlabs/text_to_voice/client.py @@ -1,19 +1,13 @@ # This file was auto-generated by Fern from our API Definition. import typing -from ..core.client_wrapper import SyncClientWrapper -from .types.text_to_voice_create_previews_request_output_format import ( - TextToVoiceCreatePreviewsRequestOutputFormat, -) + +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ..core.request_options import RequestOptions -from ..types.voice_design_preview_response import VoiceDesignPreviewResponse -from ..core.unchecked_base_model import construct_type -from ..errors.unprocessable_entity_error import UnprocessableEntityError -from ..types.http_validation_error import HttpValidationError -from json.decoder import JSONDecodeError -from ..core.api_error import ApiError from ..types.voice import Voice -from ..core.client_wrapper import AsyncClientWrapper +from ..types.voice_design_preview_response import VoiceDesignPreviewResponse +from .raw_client import AsyncRawTextToVoiceClient, RawTextToVoiceClient +from .types.text_to_voice_create_previews_request_output_format import TextToVoiceCreatePreviewsRequestOutputFormat # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -21,7 +15,18 @@ class TextToVoiceClient: def __init__(self, *, client_wrapper: SyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = RawTextToVoiceClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawTextToVoiceClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawTextToVoiceClient + """ + return self._raw_client def create_previews( self, @@ -84,51 +89,18 @@ def create_previews( voice_description="A sassy squeaky mouse", ) """ - _response = self._client_wrapper.httpx_client.request( - "v1/text-to-voice/create-previews", - base_url=self._client_wrapper.get_environment().base, - method="POST", - params={ - "output_format": output_format, - }, - json={ - "voice_description": voice_description, - "text": text, - "auto_generate_text": auto_generate_text, - "loudness": loudness, - "quality": quality, - "seed": seed, - "guidance_scale": guidance_scale, - }, - headers={ - "content-type": "application/json", - }, + _response = self._raw_client.create_previews( + voice_description=voice_description, + output_format=output_format, + text=text, + auto_generate_text=auto_generate_text, + loudness=loudness, + quality=quality, + seed=seed, + guidance_scale=guidance_scale, request_options=request_options, - omit=OMIT, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - VoiceDesignPreviewResponse, - construct_type( - type_=VoiceDesignPreviewResponse, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + return _response.data def create_voice_from_preview( self, @@ -181,51 +153,31 @@ def create_voice_from_preview( generated_voice_id="37HceQefKmEi3bGovXjL", ) """ - _response = self._client_wrapper.httpx_client.request( - "v1/text-to-voice/create-voice-from-preview", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "voice_name": voice_name, - "voice_description": voice_description, - "generated_voice_id": generated_voice_id, - "labels": labels, - "played_not_selected_voice_ids": played_not_selected_voice_ids, - }, - headers={ - "content-type": "application/json", - }, + _response = self._raw_client.create_voice_from_preview( + voice_name=voice_name, + voice_description=voice_description, + generated_voice_id=generated_voice_id, + labels=labels, + played_not_selected_voice_ids=played_not_selected_voice_ids, request_options=request_options, - omit=OMIT, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - Voice, - construct_type( - type_=Voice, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + return _response.data class AsyncTextToVoiceClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = AsyncRawTextToVoiceClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawTextToVoiceClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawTextToVoiceClient + """ + return self._raw_client async def create_previews( self, @@ -296,51 +248,18 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - "v1/text-to-voice/create-previews", - base_url=self._client_wrapper.get_environment().base, - method="POST", - params={ - "output_format": output_format, - }, - json={ - "voice_description": voice_description, - "text": text, - "auto_generate_text": auto_generate_text, - "loudness": loudness, - "quality": quality, - "seed": seed, - "guidance_scale": guidance_scale, - }, - headers={ - "content-type": "application/json", - }, + _response = await self._raw_client.create_previews( + voice_description=voice_description, + output_format=output_format, + text=text, + auto_generate_text=auto_generate_text, + loudness=loudness, + quality=quality, + seed=seed, + guidance_scale=guidance_scale, request_options=request_options, - omit=OMIT, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - VoiceDesignPreviewResponse, - construct_type( - type_=VoiceDesignPreviewResponse, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + return _response.data async def create_voice_from_preview( self, @@ -401,43 +320,12 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - "v1/text-to-voice/create-voice-from-preview", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "voice_name": voice_name, - "voice_description": voice_description, - "generated_voice_id": generated_voice_id, - "labels": labels, - "played_not_selected_voice_ids": played_not_selected_voice_ids, - }, - headers={ - "content-type": "application/json", - }, + _response = await self._raw_client.create_voice_from_preview( + voice_name=voice_name, + voice_description=voice_description, + generated_voice_id=generated_voice_id, + labels=labels, + played_not_selected_voice_ids=played_not_selected_voice_ids, request_options=request_options, - omit=OMIT, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - Voice, - construct_type( - type_=Voice, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + return _response.data diff --git a/src/elevenlabs/text_to_voice/raw_client.py b/src/elevenlabs/text_to_voice/raw_client.py new file mode 100644 index 00000000..27a43154 --- /dev/null +++ b/src/elevenlabs/text_to_voice/raw_client.py @@ -0,0 +1,386 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ..core.api_error import ApiError +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ..core.http_response import AsyncHttpResponse, HttpResponse +from ..core.request_options import RequestOptions +from ..core.unchecked_base_model import construct_type +from ..errors.unprocessable_entity_error import UnprocessableEntityError +from ..types.http_validation_error import HttpValidationError +from ..types.voice import Voice +from ..types.voice_design_preview_response import VoiceDesignPreviewResponse +from .types.text_to_voice_create_previews_request_output_format import TextToVoiceCreatePreviewsRequestOutputFormat + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RawTextToVoiceClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def create_previews( + self, + *, + voice_description: str, + output_format: typing.Optional[TextToVoiceCreatePreviewsRequestOutputFormat] = None, + text: typing.Optional[str] = OMIT, + auto_generate_text: typing.Optional[bool] = OMIT, + loudness: typing.Optional[float] = OMIT, + quality: typing.Optional[float] = OMIT, + seed: typing.Optional[int] = OMIT, + guidance_scale: typing.Optional[float] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[VoiceDesignPreviewResponse]: + """ + Create a voice from a text prompt. + + Parameters + ---------- + voice_description : str + Description to use for the created voice. + + output_format : typing.Optional[TextToVoiceCreatePreviewsRequestOutputFormat] + The output format of the generated audio. + + text : typing.Optional[str] + Text to generate, text length has to be between 100 and 1000. + + auto_generate_text : typing.Optional[bool] + Whether to automatically generate a text suitable for the voice description. + + loudness : typing.Optional[float] + Controls the volume level of the generated voice. -1 is quietest, 1 is loudest, 0 corresponds to roughly -24 LUFS. + + quality : typing.Optional[float] + Higher quality results in better voice output but less variety. + + seed : typing.Optional[int] + Random number that controls the voice generation. Same seed with same inputs produces same voice. + + guidance_scale : typing.Optional[float] + Controls how closely the AI follows the prompt. Lower numbers give the AI more freedom to be creative, while higher numbers force it to stick more to the prompt. High numbers can cause voice to sound artificial or robotic. We recommend to use longer, more detailed prompts at lower Guidance Scale. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[VoiceDesignPreviewResponse] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + "v1/text-to-voice/create-previews", + base_url=self._client_wrapper.get_environment().base, + method="POST", + params={ + "output_format": output_format, + }, + json={ + "voice_description": voice_description, + "text": text, + "auto_generate_text": auto_generate_text, + "loudness": loudness, + "quality": quality, + "seed": seed, + "guidance_scale": guidance_scale, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + VoiceDesignPreviewResponse, + construct_type( + type_=VoiceDesignPreviewResponse, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def create_voice_from_preview( + self, + *, + voice_name: str, + voice_description: str, + generated_voice_id: str, + labels: typing.Optional[typing.Dict[str, typing.Optional[str]]] = OMIT, + played_not_selected_voice_ids: typing.Optional[typing.Sequence[str]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[Voice]: + """ + Add a generated voice to the voice library. + + Parameters + ---------- + voice_name : str + Name to use for the created voice. + + voice_description : str + Description to use for the created voice. + + generated_voice_id : str + The generated_voice_id to create, call POST /v1/text-to-voice/create-previews and fetch the generated_voice_id from the response header if don't have one yet. + + labels : typing.Optional[typing.Dict[str, typing.Optional[str]]] + Optional, metadata to add to the created voice. Defaults to None. + + played_not_selected_voice_ids : typing.Optional[typing.Sequence[str]] + List of voice ids that the user has played but not selected. Used for RLHF. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[Voice] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + "v1/text-to-voice/create-voice-from-preview", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "voice_name": voice_name, + "voice_description": voice_description, + "generated_voice_id": generated_voice_id, + "labels": labels, + "played_not_selected_voice_ids": played_not_selected_voice_ids, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + Voice, + construct_type( + type_=Voice, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + +class AsyncRawTextToVoiceClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def create_previews( + self, + *, + voice_description: str, + output_format: typing.Optional[TextToVoiceCreatePreviewsRequestOutputFormat] = None, + text: typing.Optional[str] = OMIT, + auto_generate_text: typing.Optional[bool] = OMIT, + loudness: typing.Optional[float] = OMIT, + quality: typing.Optional[float] = OMIT, + seed: typing.Optional[int] = OMIT, + guidance_scale: typing.Optional[float] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[VoiceDesignPreviewResponse]: + """ + Create a voice from a text prompt. + + Parameters + ---------- + voice_description : str + Description to use for the created voice. + + output_format : typing.Optional[TextToVoiceCreatePreviewsRequestOutputFormat] + The output format of the generated audio. + + text : typing.Optional[str] + Text to generate, text length has to be between 100 and 1000. + + auto_generate_text : typing.Optional[bool] + Whether to automatically generate a text suitable for the voice description. + + loudness : typing.Optional[float] + Controls the volume level of the generated voice. -1 is quietest, 1 is loudest, 0 corresponds to roughly -24 LUFS. + + quality : typing.Optional[float] + Higher quality results in better voice output but less variety. + + seed : typing.Optional[int] + Random number that controls the voice generation. Same seed with same inputs produces same voice. + + guidance_scale : typing.Optional[float] + Controls how closely the AI follows the prompt. Lower numbers give the AI more freedom to be creative, while higher numbers force it to stick more to the prompt. High numbers can cause voice to sound artificial or robotic. We recommend to use longer, more detailed prompts at lower Guidance Scale. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[VoiceDesignPreviewResponse] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + "v1/text-to-voice/create-previews", + base_url=self._client_wrapper.get_environment().base, + method="POST", + params={ + "output_format": output_format, + }, + json={ + "voice_description": voice_description, + "text": text, + "auto_generate_text": auto_generate_text, + "loudness": loudness, + "quality": quality, + "seed": seed, + "guidance_scale": guidance_scale, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + VoiceDesignPreviewResponse, + construct_type( + type_=VoiceDesignPreviewResponse, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def create_voice_from_preview( + self, + *, + voice_name: str, + voice_description: str, + generated_voice_id: str, + labels: typing.Optional[typing.Dict[str, typing.Optional[str]]] = OMIT, + played_not_selected_voice_ids: typing.Optional[typing.Sequence[str]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[Voice]: + """ + Add a generated voice to the voice library. + + Parameters + ---------- + voice_name : str + Name to use for the created voice. + + voice_description : str + Description to use for the created voice. + + generated_voice_id : str + The generated_voice_id to create, call POST /v1/text-to-voice/create-previews and fetch the generated_voice_id from the response header if don't have one yet. + + labels : typing.Optional[typing.Dict[str, typing.Optional[str]]] + Optional, metadata to add to the created voice. Defaults to None. + + played_not_selected_voice_ids : typing.Optional[typing.Sequence[str]] + List of voice ids that the user has played but not selected. Used for RLHF. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[Voice] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + "v1/text-to-voice/create-voice-from-preview", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "voice_name": voice_name, + "voice_description": voice_description, + "generated_voice_id": generated_voice_id, + "labels": labels, + "played_not_selected_voice_ids": played_not_selected_voice_ids, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + Voice, + construct_type( + type_=Voice, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/elevenlabs/text_to_voice/types/__init__.py b/src/elevenlabs/text_to_voice/types/__init__.py index 39c033b9..16e08ef3 100644 --- a/src/elevenlabs/text_to_voice/types/__init__.py +++ b/src/elevenlabs/text_to_voice/types/__init__.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# isort: skip_file + from .text_to_voice_create_previews_request_output_format import TextToVoiceCreatePreviewsRequestOutputFormat __all__ = ["TextToVoiceCreatePreviewsRequestOutputFormat"] diff --git a/src/elevenlabs/types/__init__.py b/src/elevenlabs/types/__init__.py index 7ca55ed6..3a6e571c 100644 --- a/src/elevenlabs/types/__init__.py +++ b/src/elevenlabs/types/__init__.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# isort: skip_file + from .add_chapter_response_model import AddChapterResponseModel from .add_knowledge_base_response_model import AddKnowledgeBaseResponseModel from .add_project_request import AddProjectRequest @@ -52,6 +54,7 @@ from .ban_reason_type import BanReasonType from .batch_call_detailed_response import BatchCallDetailedResponse from .batch_call_recipient_status import BatchCallRecipientStatus +from .batch_call_response import BatchCallResponse from .batch_call_status import BatchCallStatus from .body_add_chapter_to_a_project_v_1_projects_project_id_chapters_add_post import ( BodyAddChapterToAProjectV1ProjectsProjectIdChaptersAddPost, @@ -140,6 +143,7 @@ from .close_connection import CloseConnection from .close_context import CloseContext from .close_socket import CloseSocket +from .conv_ai_dynamic_variable import ConvAiDynamicVariable from .conv_ai_secret_locator import ConvAiSecretLocator from .conv_ai_stored_secret_dependencies import ConvAiStoredSecretDependencies from .conv_ai_stored_secret_dependencies_agent_tools_item import ( @@ -160,6 +164,8 @@ from .conversation_config_client_override_config_output import ConversationConfigClientOverrideConfigOutput from .conversation_config_client_override_input import ConversationConfigClientOverrideInput from .conversation_config_client_override_output import ConversationConfigClientOverrideOutput +from .conversation_config_override import ConversationConfigOverride +from .conversation_config_override_config import ConversationConfigOverrideConfig from .conversation_deletion_settings import ConversationDeletionSettings from .conversation_history_analysis_common_model import ConversationHistoryAnalysisCommonModel from .conversation_history_batch_call_model import ConversationHistoryBatchCallModel @@ -181,8 +187,14 @@ ) from .conversation_history_transcript_common_model_input import ConversationHistoryTranscriptCommonModelInput from .conversation_history_transcript_common_model_input_role import ConversationHistoryTranscriptCommonModelInputRole +from .conversation_history_transcript_common_model_input_source_medium import ( + ConversationHistoryTranscriptCommonModelInputSourceMedium, +) from .conversation_history_transcript_common_model_output import ConversationHistoryTranscriptCommonModelOutput from .conversation_history_transcript_common_model_output_role import ConversationHistoryTranscriptCommonModelOutputRole +from .conversation_history_transcript_common_model_output_source_medium import ( + ConversationHistoryTranscriptCommonModelOutputSourceMedium, +) from .conversation_history_transcript_tool_call_client_details import ConversationHistoryTranscriptToolCallClientDetails from .conversation_history_transcript_tool_call_common_model import ConversationHistoryTranscriptToolCallCommonModel from .conversation_history_transcript_tool_call_common_model_tool_details import ( @@ -436,6 +448,7 @@ from .object_json_schema_property_output import ObjectJsonSchemaPropertyOutput from .object_json_schema_property_output_properties_value import ObjectJsonSchemaPropertyOutputPropertiesValue from .orb_avatar import OrbAvatar +from .outbound_call_recipient import OutboundCallRecipient from .outbound_call_recipient_response_model import OutboundCallRecipientResponseModel from .output_format import OutputFormat from .pdf_export_options import PdfExportOptions @@ -567,8 +580,6 @@ from .srt_export_options import SrtExportOptions from .start_pvc_voice_training_response_model import StartPvcVoiceTrainingResponseModel from .start_speaker_separation_response_model import StartSpeakerSeparationResponseModel -from .stream_input_query_parameters import StreamInputQueryParameters -from .stream_input_query_parameters_optimize_streaming_latency import StreamInputQueryParametersOptimizeStreamingLatency from .streaming_audio_chunk_with_timestamps_response import StreamingAudioChunkWithTimestampsResponse from .subscription import Subscription from .subscription_extras_response_model import SubscriptionExtrasResponseModel @@ -674,6 +685,7 @@ ) from .widget_expandable import WidgetExpandable from .widget_feedback_mode import WidgetFeedbackMode +from .workspace_batch_calls_response import WorkspaceBatchCallsResponse from .workspace_group_by_name_response_model import WorkspaceGroupByNameResponseModel from .workspace_resource_type import WorkspaceResourceType @@ -728,6 +740,7 @@ "BanReasonType", "BatchCallDetailedResponse", "BatchCallRecipientStatus", + "BatchCallResponse", "BatchCallStatus", "BodyAddChapterToAProjectV1ProjectsProjectIdChaptersAddPost", "BodyAddProjectV1ProjectsAddPostApplyTextNormalization", @@ -782,6 +795,7 @@ "CloseConnection", "CloseContext", "CloseSocket", + "ConvAiDynamicVariable", "ConvAiSecretLocator", "ConvAiStoredSecretDependencies", "ConvAiStoredSecretDependenciesAgentToolsItem", @@ -798,6 +812,8 @@ "ConversationConfigClientOverrideConfigOutput", "ConversationConfigClientOverrideInput", "ConversationConfigClientOverrideOutput", + "ConversationConfigOverride", + "ConversationConfigOverrideConfig", "ConversationDeletionSettings", "ConversationHistoryAnalysisCommonModel", "ConversationHistoryBatchCallModel", @@ -813,8 +829,10 @@ "ConversationHistorySipTrunkingPhoneCallModelDirection", "ConversationHistoryTranscriptCommonModelInput", "ConversationHistoryTranscriptCommonModelInputRole", + "ConversationHistoryTranscriptCommonModelInputSourceMedium", "ConversationHistoryTranscriptCommonModelOutput", "ConversationHistoryTranscriptCommonModelOutputRole", + "ConversationHistoryTranscriptCommonModelOutputSourceMedium", "ConversationHistoryTranscriptToolCallClientDetails", "ConversationHistoryTranscriptToolCallCommonModel", "ConversationHistoryTranscriptToolCallCommonModelToolDetails", @@ -1034,6 +1052,7 @@ "ObjectJsonSchemaPropertyOutput", "ObjectJsonSchemaPropertyOutputPropertiesValue", "OrbAvatar", + "OutboundCallRecipient", "OutboundCallRecipientResponseModel", "OutputFormat", "PdfExportOptions", @@ -1157,8 +1176,6 @@ "SrtExportOptions", "StartPvcVoiceTrainingResponseModel", "StartSpeakerSeparationResponseModel", - "StreamInputQueryParameters", - "StreamInputQueryParametersOptimizeStreamingLatency", "StreamingAudioChunkWithTimestampsResponse", "Subscription", "SubscriptionExtrasResponseModel", @@ -1252,6 +1269,7 @@ "WidgetConfigResponseModelAvatar_Url", "WidgetExpandable", "WidgetFeedbackMode", + "WorkspaceBatchCallsResponse", "WorkspaceGroupByNameResponseModel", "WorkspaceResourceType", ] diff --git a/src/elevenlabs/types/add_chapter_response_model.py b/src/elevenlabs/types/add_chapter_response_model.py index 807890ef..6b3208a3 100644 --- a/src/elevenlabs/types/add_chapter_response_model.py +++ b/src/elevenlabs/types/add_chapter_response_model.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from .chapter_with_content_response_model import ChapterWithContentResponseModel -from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .chapter_with_content_response_model import ChapterWithContentResponseModel class AddChapterResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/add_knowledge_base_response_model.py b/src/elevenlabs/types/add_knowledge_base_response_model.py index d18a76a1..a229eac6 100644 --- a/src/elevenlabs/types/add_knowledge_base_response_model.py +++ b/src/elevenlabs/types/add_knowledge_base_response_model.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class AddKnowledgeBaseResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/add_project_request.py b/src/elevenlabs/types/add_project_request.py index 41a760ab..50f65c78 100644 --- a/src/elevenlabs/types/add_project_request.py +++ b/src/elevenlabs/types/add_project_request.py @@ -1,21 +1,16 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -import pydantic import typing -from .body_add_project_v_1_projects_add_post_target_audience import ( - BodyAddProjectV1ProjectsAddPostTargetAudience, -) -from .body_add_project_v_1_projects_add_post_fiction import ( - BodyAddProjectV1ProjectsAddPostFiction, -) + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel from .body_add_project_v_1_projects_add_post_apply_text_normalization import ( BodyAddProjectV1ProjectsAddPostApplyTextNormalization, ) -from .body_add_project_v_1_projects_add_post_source_type import ( - BodyAddProjectV1ProjectsAddPostSourceType, -) -from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from .body_add_project_v_1_projects_add_post_fiction import BodyAddProjectV1ProjectsAddPostFiction +from .body_add_project_v_1_projects_add_post_source_type import BodyAddProjectV1ProjectsAddPostSourceType +from .body_add_project_v_1_projects_add_post_target_audience import BodyAddProjectV1ProjectsAddPostTargetAudience class AddProjectRequest(UncheckedBaseModel): diff --git a/src/elevenlabs/types/add_project_response_model.py b/src/elevenlabs/types/add_project_response_model.py index 5e69fc8e..983b1a3e 100644 --- a/src/elevenlabs/types/add_project_response_model.py +++ b/src/elevenlabs/types/add_project_response_model.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from .project_response import ProjectResponse -from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .project_response import ProjectResponse class AddProjectResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/add_pronunciation_dictionary_response_model.py b/src/elevenlabs/types/add_pronunciation_dictionary_response_model.py index 4498ce65..66703b5d 100644 --- a/src/elevenlabs/types/add_pronunciation_dictionary_response_model.py +++ b/src/elevenlabs/types/add_pronunciation_dictionary_response_model.py @@ -1,12 +1,13 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -import pydantic import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel from .add_pronunciation_dictionary_response_model_permission_on_resource import ( AddPronunciationDictionaryResponseModelPermissionOnResource, ) -from ..core.pydantic_utilities import IS_PYDANTIC_V2 class AddPronunciationDictionaryResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/add_voice_ivc_response_model.py b/src/elevenlabs/types/add_voice_ivc_response_model.py index f84d7dfa..e06feddc 100644 --- a/src/elevenlabs/types/add_voice_ivc_response_model.py +++ b/src/elevenlabs/types/add_voice_ivc_response_model.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel +import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import typing +from ..core.unchecked_base_model import UncheckedBaseModel class AddVoiceIvcResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/add_voice_response_model.py b/src/elevenlabs/types/add_voice_response_model.py index f914dd61..e50483c8 100644 --- a/src/elevenlabs/types/add_voice_response_model.py +++ b/src/elevenlabs/types/add_voice_response_model.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel +import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import typing +from ..core.unchecked_base_model import UncheckedBaseModel class AddVoiceResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/add_workspace_group_member_response_model.py b/src/elevenlabs/types/add_workspace_group_member_response_model.py index 55e2cc2b..bc61232d 100644 --- a/src/elevenlabs/types/add_workspace_group_member_response_model.py +++ b/src/elevenlabs/types/add_workspace_group_member_response_model.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel +import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import typing +from ..core.unchecked_base_model import UncheckedBaseModel class AddWorkspaceGroupMemberResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/add_workspace_invite_response_model.py b/src/elevenlabs/types/add_workspace_invite_response_model.py index 1d3749f5..0c8d3c77 100644 --- a/src/elevenlabs/types/add_workspace_invite_response_model.py +++ b/src/elevenlabs/types/add_workspace_invite_response_model.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel +import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import typing +from ..core.unchecked_base_model import UncheckedBaseModel class AddWorkspaceInviteResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/additional_format_response_model.py b/src/elevenlabs/types/additional_format_response_model.py index d7db99f9..5b05e08b 100644 --- a/src/elevenlabs/types/additional_format_response_model.py +++ b/src/elevenlabs/types/additional_format_response_model.py @@ -1,11 +1,12 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel +import typing + import pydantic import typing_extensions -from ..core.serialization import FieldMetadata from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import typing +from ..core.serialization import FieldMetadata +from ..core.unchecked_base_model import UncheckedBaseModel class AdditionalFormatResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/additional_formats.py b/src/elevenlabs/types/additional_formats.py index a16f3c68..f2a5f5e1 100644 --- a/src/elevenlabs/types/additional_formats.py +++ b/src/elevenlabs/types/additional_formats.py @@ -1,6 +1,7 @@ # This file was auto-generated by Fern from our API Definition. import typing + from .export_options import ExportOptions AdditionalFormats = typing.List[ExportOptions] diff --git a/src/elevenlabs/types/agent_ban.py b/src/elevenlabs/types/agent_ban.py index ac7027b6..78494965 100644 --- a/src/elevenlabs/types/agent_ban.py +++ b/src/elevenlabs/types/agent_ban.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .ban_reason_type import BanReasonType -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .ban_reason_type import BanReasonType class AgentBan(UncheckedBaseModel): diff --git a/src/elevenlabs/types/agent_call_limits.py b/src/elevenlabs/types/agent_call_limits.py index 903ab286..5f643a7d 100644 --- a/src/elevenlabs/types/agent_call_limits.py +++ b/src/elevenlabs/types/agent_call_limits.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class AgentCallLimits(UncheckedBaseModel): diff --git a/src/elevenlabs/types/agent_config.py b/src/elevenlabs/types/agent_config.py index d57c9a1e..a5014e52 100644 --- a/src/elevenlabs/types/agent_config.py +++ b/src/elevenlabs/types/agent_config.py @@ -1,13 +1,14 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from .array_json_schema_property_output import ArrayJsonSchemaPropertyOutput -from .object_json_schema_property_output import ObjectJsonSchemaPropertyOutput +from __future__ import annotations + import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, update_forward_refs +from ..core.unchecked_base_model import UncheckedBaseModel from .dynamic_variables_config import DynamicVariablesConfig from .prompt_agent import PromptAgent -from ..core.pydantic_utilities import IS_PYDANTIC_V2 class AgentConfig(UncheckedBaseModel): @@ -39,3 +40,9 @@ class Config: frozen = True smart_union = True extra = pydantic.Extra.allow + + +from .array_json_schema_property_output import ArrayJsonSchemaPropertyOutput # noqa: E402, F401, I001 +from .object_json_schema_property_output import ObjectJsonSchemaPropertyOutput # noqa: E402, F401, I001 + +update_forward_refs(AgentConfig) diff --git a/src/elevenlabs/types/agent_config_db_model.py b/src/elevenlabs/types/agent_config_db_model.py index 3aac0694..e71cd570 100644 --- a/src/elevenlabs/types/agent_config_db_model.py +++ b/src/elevenlabs/types/agent_config_db_model.py @@ -1,13 +1,14 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from .array_json_schema_property_input import ArrayJsonSchemaPropertyInput -from .object_json_schema_property_input import ObjectJsonSchemaPropertyInput +from __future__ import annotations + import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, update_forward_refs +from ..core.unchecked_base_model import UncheckedBaseModel from .dynamic_variables_config import DynamicVariablesConfig from .prompt_agent_db_model import PromptAgentDbModel -from ..core.pydantic_utilities import IS_PYDANTIC_V2 class AgentConfigDbModel(UncheckedBaseModel): @@ -36,3 +37,9 @@ class Config: frozen = True smart_union = True extra = pydantic.Extra.allow + + +from .array_json_schema_property_input import ArrayJsonSchemaPropertyInput # noqa: E402, F401, I001 +from .object_json_schema_property_input import ObjectJsonSchemaPropertyInput # noqa: E402, F401, I001 + +update_forward_refs(AgentConfigDbModel) diff --git a/src/elevenlabs/types/agent_config_override.py b/src/elevenlabs/types/agent_config_override.py index 943f915f..d001efd6 100644 --- a/src/elevenlabs/types/agent_config_override.py +++ b/src/elevenlabs/types/agent_config_override.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .prompt_agent_override import PromptAgentOverride + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .prompt_agent_override import PromptAgentOverride class AgentConfigOverride(UncheckedBaseModel): diff --git a/src/elevenlabs/types/agent_config_override_config.py b/src/elevenlabs/types/agent_config_override_config.py index 3d65d8b5..d8fcd265 100644 --- a/src/elevenlabs/types/agent_config_override_config.py +++ b/src/elevenlabs/types/agent_config_override_config.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .prompt_agent_override_config import PromptAgentOverrideConfig + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .prompt_agent_override_config import PromptAgentOverrideConfig class AgentConfigOverrideConfig(UncheckedBaseModel): diff --git a/src/elevenlabs/types/agent_metadata_response_model.py b/src/elevenlabs/types/agent_metadata_response_model.py index 548aae74..8a2ff5b9 100644 --- a/src/elevenlabs/types/agent_metadata_response_model.py +++ b/src/elevenlabs/types/agent_metadata_response_model.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel +import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import typing +from ..core.unchecked_base_model import UncheckedBaseModel class AgentMetadataResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/agent_platform_settings_request_model.py b/src/elevenlabs/types/agent_platform_settings_request_model.py index a5f60827..c766f0ec 100644 --- a/src/elevenlabs/types/agent_platform_settings_request_model.py +++ b/src/elevenlabs/types/agent_platform_settings_request_model.py @@ -1,19 +1,18 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .auth_settings import AuthSettings + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .agent_call_limits import AgentCallLimits +from .agent_workspace_overrides_input import AgentWorkspaceOverridesInput +from .auth_settings import AuthSettings +from .conversation_initiation_client_data_config_input import ConversationInitiationClientDataConfigInput from .evaluation_settings import EvaluationSettings -from .widget_config import WidgetConfig from .literal_json_schema_property import LiteralJsonSchemaProperty -from .conversation_initiation_client_data_config_input import ( - ConversationInitiationClientDataConfigInput, -) -from .agent_call_limits import AgentCallLimits from .privacy_config import PrivacyConfig -from .agent_workspace_overrides_input import AgentWorkspaceOverridesInput -from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from .widget_config import WidgetConfig class AgentPlatformSettingsRequestModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/agent_platform_settings_response_model.py b/src/elevenlabs/types/agent_platform_settings_response_model.py index d36e2fc3..cf416774 100644 --- a/src/elevenlabs/types/agent_platform_settings_response_model.py +++ b/src/elevenlabs/types/agent_platform_settings_response_model.py @@ -1,20 +1,19 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .auth_settings import AuthSettings + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .agent_call_limits import AgentCallLimits +from .agent_workspace_overrides_output import AgentWorkspaceOverridesOutput +from .auth_settings import AuthSettings +from .conversation_initiation_client_data_config_output import ConversationInitiationClientDataConfigOutput from .evaluation_settings import EvaluationSettings -from .widget_config import WidgetConfig from .literal_json_schema_property import LiteralJsonSchemaProperty -from .conversation_initiation_client_data_config_output import ( - ConversationInitiationClientDataConfigOutput, -) -from .agent_call_limits import AgentCallLimits from .privacy_config import PrivacyConfig -from .agent_workspace_overrides_output import AgentWorkspaceOverridesOutput from .safety_response_model import SafetyResponseModel -from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from .widget_config import WidgetConfig class AgentPlatformSettingsResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/agent_simulated_chat_test_response_model.py b/src/elevenlabs/types/agent_simulated_chat_test_response_model.py index 4038e4fc..adea39a5 100644 --- a/src/elevenlabs/types/agent_simulated_chat_test_response_model.py +++ b/src/elevenlabs/types/agent_simulated_chat_test_response_model.py @@ -1,15 +1,12 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .conversation_history_transcript_common_model_output import ( - ConversationHistoryTranscriptCommonModelOutput, -) -from .conversation_history_analysis_common_model import ( - ConversationHistoryAnalysisCommonModel, -) -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .conversation_history_analysis_common_model import ConversationHistoryAnalysisCommonModel +from .conversation_history_transcript_common_model_output import ConversationHistoryTranscriptCommonModelOutput class AgentSimulatedChatTestResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/agent_summary_response_model.py b/src/elevenlabs/types/agent_summary_response_model.py index c441c8c5..622ad10d 100644 --- a/src/elevenlabs/types/agent_summary_response_model.py +++ b/src/elevenlabs/types/agent_summary_response_model.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -import pydantic import typing -from .resource_access_info import ResourceAccessInfo + +import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .resource_access_info import ResourceAccessInfo class AgentSummaryResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/agent_transfer.py b/src/elevenlabs/types/agent_transfer.py index 73eeb0ac..91fed50a 100644 --- a/src/elevenlabs/types/agent_transfer.py +++ b/src/elevenlabs/types/agent_transfer.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class AgentTransfer(UncheckedBaseModel): diff --git a/src/elevenlabs/types/agent_workspace_overrides_input.py b/src/elevenlabs/types/agent_workspace_overrides_input.py index 0bd806d5..565dc821 100644 --- a/src/elevenlabs/types/agent_workspace_overrides_input.py +++ b/src/elevenlabs/types/agent_workspace_overrides_input.py @@ -1,13 +1,12 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .conversation_initiation_client_data_webhook import ( - ConversationInitiationClientDataWebhook, -) + import pydantic -from .conv_ai_webhooks import ConvAiWebhooks from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .conv_ai_webhooks import ConvAiWebhooks +from .conversation_initiation_client_data_webhook import ConversationInitiationClientDataWebhook class AgentWorkspaceOverridesInput(UncheckedBaseModel): diff --git a/src/elevenlabs/types/agent_workspace_overrides_output.py b/src/elevenlabs/types/agent_workspace_overrides_output.py index 0af6d410..99d64da3 100644 --- a/src/elevenlabs/types/agent_workspace_overrides_output.py +++ b/src/elevenlabs/types/agent_workspace_overrides_output.py @@ -1,13 +1,12 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .conversation_initiation_client_data_webhook import ( - ConversationInitiationClientDataWebhook, -) + import pydantic -from .conv_ai_webhooks import ConvAiWebhooks from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .conv_ai_webhooks import ConvAiWebhooks +from .conversation_initiation_client_data_webhook import ConversationInitiationClientDataWebhook class AgentWorkspaceOverridesOutput(UncheckedBaseModel): diff --git a/src/elevenlabs/types/alignment.py b/src/elevenlabs/types/alignment.py index 269f9360..ae03e97e 100644 --- a/src/elevenlabs/types/alignment.py +++ b/src/elevenlabs/types/alignment.py @@ -1,11 +1,12 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -import typing_extensions import typing -from ..core.serialization import FieldMetadata + import pydantic +import typing_extensions from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.serialization import FieldMetadata +from ..core.unchecked_base_model import UncheckedBaseModel class Alignment(UncheckedBaseModel): diff --git a/src/elevenlabs/types/allowlist_item.py b/src/elevenlabs/types/allowlist_item.py index 6fda4e30..d56277d4 100644 --- a/src/elevenlabs/types/allowlist_item.py +++ b/src/elevenlabs/types/allowlist_item.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel +import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import typing +from ..core.unchecked_base_model import UncheckedBaseModel class AllowlistItem(UncheckedBaseModel): diff --git a/src/elevenlabs/types/array_json_schema_property_input.py b/src/elevenlabs/types/array_json_schema_property_input.py index bb63310d..a991d11f 100644 --- a/src/elevenlabs/types/array_json_schema_property_input.py +++ b/src/elevenlabs/types/array_json_schema_property_input.py @@ -1,11 +1,12 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -from ..core.unchecked_base_model import UncheckedBaseModel + import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic -from ..core.pydantic_utilities import update_forward_refs +from ..core.pydantic_utilities import IS_PYDANTIC_V2, update_forward_refs +from ..core.unchecked_base_model import UncheckedBaseModel class ArrayJsonSchemaPropertyInput(UncheckedBaseModel): @@ -23,7 +24,7 @@ class Config: extra = pydantic.Extra.allow -from .object_json_schema_property_input import ObjectJsonSchemaPropertyInput # noqa: E402 -from .array_json_schema_property_input_items import ArrayJsonSchemaPropertyInputItems # noqa: E402 +from .object_json_schema_property_input import ObjectJsonSchemaPropertyInput # noqa: E402, F401, I001 +from .array_json_schema_property_input_items import ArrayJsonSchemaPropertyInputItems # noqa: E402, F401, I001 update_forward_refs(ArrayJsonSchemaPropertyInput) diff --git a/src/elevenlabs/types/array_json_schema_property_input_items.py b/src/elevenlabs/types/array_json_schema_property_input_items.py index 804857dc..88fc53eb 100644 --- a/src/elevenlabs/types/array_json_schema_property_input_items.py +++ b/src/elevenlabs/types/array_json_schema_property_input_items.py @@ -1,15 +1,14 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations + import typing + from .literal_json_schema_property import LiteralJsonSchemaProperty -import typing if typing.TYPE_CHECKING: - from .object_json_schema_property_input import ObjectJsonSchemaPropertyInput from .array_json_schema_property_input import ArrayJsonSchemaPropertyInput + from .object_json_schema_property_input import ObjectJsonSchemaPropertyInput ArrayJsonSchemaPropertyInputItems = typing.Union[ - LiteralJsonSchemaProperty, - "ObjectJsonSchemaPropertyInput", - "ArrayJsonSchemaPropertyInput", + LiteralJsonSchemaProperty, "ObjectJsonSchemaPropertyInput", "ArrayJsonSchemaPropertyInput" ] diff --git a/src/elevenlabs/types/array_json_schema_property_output.py b/src/elevenlabs/types/array_json_schema_property_output.py index 6ffeb5bc..bdc98803 100644 --- a/src/elevenlabs/types/array_json_schema_property_output.py +++ b/src/elevenlabs/types/array_json_schema_property_output.py @@ -1,11 +1,12 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -from ..core.unchecked_base_model import UncheckedBaseModel + import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic -from ..core.pydantic_utilities import update_forward_refs +from ..core.pydantic_utilities import IS_PYDANTIC_V2, update_forward_refs +from ..core.unchecked_base_model import UncheckedBaseModel class ArrayJsonSchemaPropertyOutput(UncheckedBaseModel): @@ -23,7 +24,7 @@ class Config: extra = pydantic.Extra.allow -from .object_json_schema_property_output import ObjectJsonSchemaPropertyOutput # noqa: E402 -from .array_json_schema_property_output_items import ArrayJsonSchemaPropertyOutputItems # noqa: E402 +from .object_json_schema_property_output import ObjectJsonSchemaPropertyOutput # noqa: E402, F401, I001 +from .array_json_schema_property_output_items import ArrayJsonSchemaPropertyOutputItems # noqa: E402, F401, I001 update_forward_refs(ArrayJsonSchemaPropertyOutput) diff --git a/src/elevenlabs/types/array_json_schema_property_output_items.py b/src/elevenlabs/types/array_json_schema_property_output_items.py index 91eac635..c9b10db8 100644 --- a/src/elevenlabs/types/array_json_schema_property_output_items.py +++ b/src/elevenlabs/types/array_json_schema_property_output_items.py @@ -1,15 +1,14 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations + import typing + from .literal_json_schema_property import LiteralJsonSchemaProperty -import typing if typing.TYPE_CHECKING: - from .object_json_schema_property_output import ObjectJsonSchemaPropertyOutput from .array_json_schema_property_output import ArrayJsonSchemaPropertyOutput + from .object_json_schema_property_output import ObjectJsonSchemaPropertyOutput ArrayJsonSchemaPropertyOutputItems = typing.Union[ - LiteralJsonSchemaProperty, - "ObjectJsonSchemaPropertyOutput", - "ArrayJsonSchemaPropertyOutput", + LiteralJsonSchemaProperty, "ObjectJsonSchemaPropertyOutput", "ArrayJsonSchemaPropertyOutput" ] diff --git a/src/elevenlabs/types/asr_conversational_config.py b/src/elevenlabs/types/asr_conversational_config.py index 86a1b33c..3afcf29b 100644 --- a/src/elevenlabs/types/asr_conversational_config.py +++ b/src/elevenlabs/types/asr_conversational_config.py @@ -1,12 +1,13 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .asr_quality import AsrQuality + import pydantic -from .asr_provider import AsrProvider -from .asr_input_format import AsrInputFormat from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .asr_input_format import AsrInputFormat +from .asr_provider import AsrProvider +from .asr_quality import AsrQuality class AsrConversationalConfig(UncheckedBaseModel): diff --git a/src/elevenlabs/types/asr_input_format.py b/src/elevenlabs/types/asr_input_format.py index ab7dae21..07fc6305 100644 --- a/src/elevenlabs/types/asr_input_format.py +++ b/src/elevenlabs/types/asr_input_format.py @@ -3,14 +3,5 @@ import typing AsrInputFormat = typing.Union[ - typing.Literal[ - "pcm_8000", - "pcm_16000", - "pcm_22050", - "pcm_24000", - "pcm_44100", - "pcm_48000", - "ulaw_8000", - ], - typing.Any, + typing.Literal["pcm_8000", "pcm_16000", "pcm_22050", "pcm_24000", "pcm_44100", "pcm_48000", "ulaw_8000"], typing.Any ] diff --git a/src/elevenlabs/types/audio_native_create_project_response_model.py b/src/elevenlabs/types/audio_native_create_project_response_model.py index acf5484c..9a5adf9f 100644 --- a/src/elevenlabs/types/audio_native_create_project_response_model.py +++ b/src/elevenlabs/types/audio_native_create_project_response_model.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel +import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import typing +from ..core.unchecked_base_model import UncheckedBaseModel class AudioNativeCreateProjectResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/audio_native_edit_content_response_model.py b/src/elevenlabs/types/audio_native_edit_content_response_model.py index 4dd1f574..109cd979 100644 --- a/src/elevenlabs/types/audio_native_edit_content_response_model.py +++ b/src/elevenlabs/types/audio_native_edit_content_response_model.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel +import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import typing +from ..core.unchecked_base_model import UncheckedBaseModel class AudioNativeEditContentResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/audio_native_project_settings_response_model.py b/src/elevenlabs/types/audio_native_project_settings_response_model.py index 3b79f2ad..ba102748 100644 --- a/src/elevenlabs/types/audio_native_project_settings_response_model.py +++ b/src/elevenlabs/types/audio_native_project_settings_response_model.py @@ -1,12 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -import pydantic import typing -from .audio_native_project_settings_response_model_status import ( - AudioNativeProjectSettingsResponseModelStatus, -) + +import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .audio_native_project_settings_response_model_status import AudioNativeProjectSettingsResponseModelStatus class AudioNativeProjectSettingsResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/audio_output.py b/src/elevenlabs/types/audio_output.py index de918e5c..0e2feb87 100644 --- a/src/elevenlabs/types/audio_output.py +++ b/src/elevenlabs/types/audio_output.py @@ -1,13 +1,14 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel +import typing + import pydantic import typing_extensions -import typing -from .normalized_alignment import NormalizedAlignment +from ..core.pydantic_utilities import IS_PYDANTIC_V2 from ..core.serialization import FieldMetadata +from ..core.unchecked_base_model import UncheckedBaseModel from .alignment import Alignment -from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from .normalized_alignment import NormalizedAlignment class AudioOutput(UncheckedBaseModel): diff --git a/src/elevenlabs/types/audio_output_multi.py b/src/elevenlabs/types/audio_output_multi.py index 2c9a5a42..970d969c 100644 --- a/src/elevenlabs/types/audio_output_multi.py +++ b/src/elevenlabs/types/audio_output_multi.py @@ -1,13 +1,14 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel +import typing + import pydantic import typing_extensions -import typing -from .normalized_alignment import NormalizedAlignment +from ..core.pydantic_utilities import IS_PYDANTIC_V2 from ..core.serialization import FieldMetadata +from ..core.unchecked_base_model import UncheckedBaseModel from .alignment import Alignment -from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from .normalized_alignment import NormalizedAlignment class AudioOutputMulti(UncheckedBaseModel): diff --git a/src/elevenlabs/types/audio_with_timestamps_response.py b/src/elevenlabs/types/audio_with_timestamps_response.py index ffe9483b..e4068a57 100644 --- a/src/elevenlabs/types/audio_with_timestamps_response.py +++ b/src/elevenlabs/types/audio_with_timestamps_response.py @@ -1,12 +1,13 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel +import typing + +import pydantic import typing_extensions +from ..core.pydantic_utilities import IS_PYDANTIC_V2 from ..core.serialization import FieldMetadata -import pydantic -import typing +from ..core.unchecked_base_model import UncheckedBaseModel from .character_alignment_response_model import CharacterAlignmentResponseModel -from ..core.pydantic_utilities import IS_PYDANTIC_V2 class AudioWithTimestampsResponse(UncheckedBaseModel): diff --git a/src/elevenlabs/types/auth_settings.py b/src/elevenlabs/types/auth_settings.py index a26b0cfc..54de46b7 100644 --- a/src/elevenlabs/types/auth_settings.py +++ b/src/elevenlabs/types/auth_settings.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing + import pydantic -from .allowlist_item import AllowlistItem from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .allowlist_item import AllowlistItem class AuthSettings(UncheckedBaseModel): diff --git a/src/elevenlabs/types/batch_call_detailed_response.py b/src/elevenlabs/types/batch_call_detailed_response.py index 342438e3..f6849313 100644 --- a/src/elevenlabs/types/batch_call_detailed_response.py +++ b/src/elevenlabs/types/batch_call_detailed_response.py @@ -1,11 +1,13 @@ # This file was auto-generated by Fern from our API Definition. +import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 from ..core.unchecked_base_model import UncheckedBaseModel from .batch_call_status import BatchCallStatus -import typing from .outbound_call_recipient_response_model import OutboundCallRecipientResponseModel -from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import pydantic +from .telephony_provider import TelephonyProvider class BatchCallDetailedResponse(UncheckedBaseModel): @@ -15,6 +17,7 @@ class BatchCallDetailedResponse(UncheckedBaseModel): id: str phone_number_id: str + phone_provider: typing.Optional[TelephonyProvider] = None name: str agent_id: str created_at_unix: int diff --git a/src/elevenlabs/types/batch_call_recipient_status.py b/src/elevenlabs/types/batch_call_recipient_status.py index b10cc237..d4676b7a 100644 --- a/src/elevenlabs/types/batch_call_recipient_status.py +++ b/src/elevenlabs/types/batch_call_recipient_status.py @@ -3,6 +3,5 @@ import typing BatchCallRecipientStatus = typing.Union[ - typing.Literal["pending", "in_progress", "completed", "failed", "cancelled"], - typing.Any, + typing.Literal["pending", "initiated", "in_progress", "completed", "failed", "cancelled"], typing.Any ] diff --git a/src/elevenlabs/types/batch_call_response.py b/src/elevenlabs/types/batch_call_response.py new file mode 100644 index 00000000..e29afc03 --- /dev/null +++ b/src/elevenlabs/types/batch_call_response.py @@ -0,0 +1,33 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .batch_call_status import BatchCallStatus +from .telephony_provider import TelephonyProvider + + +class BatchCallResponse(UncheckedBaseModel): + id: str + phone_number_id: str + phone_provider: typing.Optional[TelephonyProvider] = None + name: str + agent_id: str + created_at_unix: int + scheduled_time_unix: int + total_calls_dispatched: int + total_calls_scheduled: int + last_updated_at_unix: int + status: BatchCallStatus + agent_name: str + + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 + else: + + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/elevenlabs/types/batch_call_status.py b/src/elevenlabs/types/batch_call_status.py index be65cb6b..696763c0 100644 --- a/src/elevenlabs/types/batch_call_status.py +++ b/src/elevenlabs/types/batch_call_status.py @@ -2,7 +2,4 @@ import typing -BatchCallStatus = typing.Union[ - typing.Literal["pending", "in_progress", "completed", "failed", "cancelled"], - typing.Any, -] +BatchCallStatus = typing.Union[typing.Literal["pending", "in_progress", "completed", "failed", "cancelled"], typing.Any] diff --git a/src/elevenlabs/types/body_add_chapter_to_a_project_v_1_projects_project_id_chapters_add_post.py b/src/elevenlabs/types/body_add_chapter_to_a_project_v_1_projects_project_id_chapters_add_post.py index bd7d39d4..aa60c9d6 100644 --- a/src/elevenlabs/types/body_add_chapter_to_a_project_v_1_projects_project_id_chapters_add_post.py +++ b/src/elevenlabs/types/body_add_chapter_to_a_project_v_1_projects_project_id_chapters_add_post.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -import pydantic import typing + +import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class BodyAddChapterToAProjectV1ProjectsProjectIdChaptersAddPost(UncheckedBaseModel): diff --git a/src/elevenlabs/types/body_add_to_knowledge_base_v_1_convai_add_to_knowledge_base_post.py b/src/elevenlabs/types/body_add_to_knowledge_base_v_1_convai_add_to_knowledge_base_post.py index 134ef767..c3db24c9 100644 --- a/src/elevenlabs/types/body_add_to_knowledge_base_v_1_convai_add_to_knowledge_base_post.py +++ b/src/elevenlabs/types/body_add_to_knowledge_base_v_1_convai_add_to_knowledge_base_post.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class BodyAddToKnowledgeBaseV1ConvaiAddToKnowledgeBasePost(UncheckedBaseModel): diff --git a/src/elevenlabs/types/body_add_to_knowledge_base_v_1_convai_agents_agent_id_add_to_knowledge_base_post.py b/src/elevenlabs/types/body_add_to_knowledge_base_v_1_convai_agents_agent_id_add_to_knowledge_base_post.py index 592599e4..7f81e9ee 100644 --- a/src/elevenlabs/types/body_add_to_knowledge_base_v_1_convai_agents_agent_id_add_to_knowledge_base_post.py +++ b/src/elevenlabs/types/body_add_to_knowledge_base_v_1_convai_agents_agent_id_add_to_knowledge_base_post.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class BodyAddToKnowledgeBaseV1ConvaiAgentsAgentIdAddToKnowledgeBasePost(UncheckedBaseModel): diff --git a/src/elevenlabs/types/body_create_podcast_v_1_projects_podcast_create_post.py b/src/elevenlabs/types/body_create_podcast_v_1_projects_podcast_create_post.py index 77b1d07e..37f1f7a5 100644 --- a/src/elevenlabs/types/body_create_podcast_v_1_projects_podcast_create_post.py +++ b/src/elevenlabs/types/body_create_podcast_v_1_projects_podcast_create_post.py @@ -1,21 +1,20 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel +import typing + import pydantic -from .body_create_podcast_v_1_projects_podcast_create_post_mode import ( - BodyCreatePodcastV1ProjectsPodcastCreatePostMode, -) -from .body_create_podcast_v_1_projects_podcast_create_post_source import ( - BodyCreatePodcastV1ProjectsPodcastCreatePostSource, +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .body_create_podcast_v_1_projects_podcast_create_post_duration_scale import ( + BodyCreatePodcastV1ProjectsPodcastCreatePostDurationScale, ) -import typing +from .body_create_podcast_v_1_projects_podcast_create_post_mode import BodyCreatePodcastV1ProjectsPodcastCreatePostMode from .body_create_podcast_v_1_projects_podcast_create_post_quality_preset import ( BodyCreatePodcastV1ProjectsPodcastCreatePostQualityPreset, ) -from .body_create_podcast_v_1_projects_podcast_create_post_duration_scale import ( - BodyCreatePodcastV1ProjectsPodcastCreatePostDurationScale, +from .body_create_podcast_v_1_projects_podcast_create_post_source import ( + BodyCreatePodcastV1ProjectsPodcastCreatePostSource, ) -from ..core.pydantic_utilities import IS_PYDANTIC_V2 class BodyCreatePodcastV1ProjectsPodcastCreatePost(UncheckedBaseModel): diff --git a/src/elevenlabs/types/body_create_podcast_v_1_projects_podcast_create_post_mode.py b/src/elevenlabs/types/body_create_podcast_v_1_projects_podcast_create_post_mode.py index 527479f2..07b6edcb 100644 --- a/src/elevenlabs/types/body_create_podcast_v_1_projects_podcast_create_post_mode.py +++ b/src/elevenlabs/types/body_create_podcast_v_1_projects_podcast_create_post_mode.py @@ -1,14 +1,15 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -from ..core.unchecked_base_model import UncheckedBaseModel + import typing -from .podcast_conversation_mode_data import PodcastConversationModeData -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic -from .podcast_bulletin_mode_data import PodcastBulletinModeData import typing_extensions -from ..core.unchecked_base_model import UnionMetadata +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel, UnionMetadata +from .podcast_bulletin_mode_data import PodcastBulletinModeData +from .podcast_conversation_mode_data import PodcastConversationModeData class BodyCreatePodcastV1ProjectsPodcastCreatePostMode_Conversation(UncheckedBaseModel): diff --git a/src/elevenlabs/types/body_create_podcast_v_1_projects_podcast_create_post_source.py b/src/elevenlabs/types/body_create_podcast_v_1_projects_podcast_create_post_source.py index b3c068ce..d9bb466a 100644 --- a/src/elevenlabs/types/body_create_podcast_v_1_projects_podcast_create_post_source.py +++ b/src/elevenlabs/types/body_create_podcast_v_1_projects_podcast_create_post_source.py @@ -1,14 +1,13 @@ # This file was auto-generated by Fern from our API Definition. import typing -from .podcast_text_source import PodcastTextSource -from .podcast_url_source import PodcastUrlSource + from .body_create_podcast_v_1_projects_podcast_create_post_source_item import ( BodyCreatePodcastV1ProjectsPodcastCreatePostSourceItem, ) +from .podcast_text_source import PodcastTextSource +from .podcast_url_source import PodcastUrlSource BodyCreatePodcastV1ProjectsPodcastCreatePostSource = typing.Union[ - PodcastTextSource, - PodcastUrlSource, - typing.List[BodyCreatePodcastV1ProjectsPodcastCreatePostSourceItem], + PodcastTextSource, PodcastUrlSource, typing.List[BodyCreatePodcastV1ProjectsPodcastCreatePostSourceItem] ] diff --git a/src/elevenlabs/types/body_create_podcast_v_1_projects_podcast_create_post_source_item.py b/src/elevenlabs/types/body_create_podcast_v_1_projects_podcast_create_post_source_item.py index 11a74523..355f1fe8 100644 --- a/src/elevenlabs/types/body_create_podcast_v_1_projects_podcast_create_post_source_item.py +++ b/src/elevenlabs/types/body_create_podcast_v_1_projects_podcast_create_post_source_item.py @@ -1,12 +1,13 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -from ..core.unchecked_base_model import UncheckedBaseModel + import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic import typing_extensions -from ..core.unchecked_base_model import UnionMetadata +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel, UnionMetadata class BodyCreatePodcastV1ProjectsPodcastCreatePostSourceItem_Text(UncheckedBaseModel): diff --git a/src/elevenlabs/types/body_edit_basic_project_info_v_1_projects_project_id_post.py b/src/elevenlabs/types/body_edit_basic_project_info_v_1_projects_project_id_post.py index 9fbbde93..f66db011 100644 --- a/src/elevenlabs/types/body_edit_basic_project_info_v_1_projects_project_id_post.py +++ b/src/elevenlabs/types/body_edit_basic_project_info_v_1_projects_project_id_post.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -import pydantic import typing + +import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class BodyEditBasicProjectInfoV1ProjectsProjectIdPost(UncheckedBaseModel): diff --git a/src/elevenlabs/types/body_edit_chapter_v_1_projects_project_id_chapters_chapter_id_patch.py b/src/elevenlabs/types/body_edit_chapter_v_1_projects_project_id_chapters_chapter_id_patch.py index 9e94a7a4..0d3a0328 100644 --- a/src/elevenlabs/types/body_edit_chapter_v_1_projects_project_id_chapters_chapter_id_patch.py +++ b/src/elevenlabs/types/body_edit_chapter_v_1_projects_project_id_chapters_chapter_id_patch.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing + import pydantic -from .chapter_content_input_model import ChapterContentInputModel from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .chapter_content_input_model import ChapterContentInputModel class BodyEditChapterV1ProjectsProjectIdChaptersChapterIdPatch(UncheckedBaseModel): diff --git a/src/elevenlabs/types/body_edit_project_content_v_1_projects_project_id_content_post.py b/src/elevenlabs/types/body_edit_project_content_v_1_projects_project_id_content_post.py index 0aab18d9..ecbd5206 100644 --- a/src/elevenlabs/types/body_edit_project_content_v_1_projects_project_id_content_post.py +++ b/src/elevenlabs/types/body_edit_project_content_v_1_projects_project_id_content_post.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class BodyEditProjectContentV1ProjectsProjectIdContentPost(UncheckedBaseModel): diff --git a/src/elevenlabs/types/body_retrieve_voice_sample_audio_v_1_voices_pvc_voice_id_samples_sample_id_audio_get.py b/src/elevenlabs/types/body_retrieve_voice_sample_audio_v_1_voices_pvc_voice_id_samples_sample_id_audio_get.py index 889dc788..9a7221d6 100644 --- a/src/elevenlabs/types/body_retrieve_voice_sample_audio_v_1_voices_pvc_voice_id_samples_sample_id_audio_get.py +++ b/src/elevenlabs/types/body_retrieve_voice_sample_audio_v_1_voices_pvc_voice_id_samples_sample_id_audio_get.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class BodyRetrieveVoiceSampleAudioV1VoicesPvcVoiceIdSamplesSampleIdAudioGet(UncheckedBaseModel): diff --git a/src/elevenlabs/types/body_stream_chapter_audio_v_1_projects_project_id_chapters_chapter_id_snapshots_chapter_snapshot_id_stream_post.py b/src/elevenlabs/types/body_stream_chapter_audio_v_1_projects_project_id_chapters_chapter_id_snapshots_chapter_snapshot_id_stream_post.py index e72b2f88..e594033e 100644 --- a/src/elevenlabs/types/body_stream_chapter_audio_v_1_projects_project_id_chapters_chapter_id_snapshots_chapter_snapshot_id_stream_post.py +++ b/src/elevenlabs/types/body_stream_chapter_audio_v_1_projects_project_id_chapters_chapter_id_snapshots_chapter_snapshot_id_stream_post.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class BodyStreamChapterAudioV1ProjectsProjectIdChaptersChapterIdSnapshotsChapterSnapshotIdStreamPost( diff --git a/src/elevenlabs/types/body_stream_project_audio_v_1_projects_project_id_snapshots_project_snapshot_id_stream_post.py b/src/elevenlabs/types/body_stream_project_audio_v_1_projects_project_id_snapshots_project_snapshot_id_stream_post.py index 60bab296..617cf0c3 100644 --- a/src/elevenlabs/types/body_stream_project_audio_v_1_projects_project_id_snapshots_project_snapshot_id_stream_post.py +++ b/src/elevenlabs/types/body_stream_project_audio_v_1_projects_project_id_snapshots_project_snapshot_id_stream_post.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class BodyStreamProjectAudioV1ProjectsProjectIdSnapshotsProjectSnapshotIdStreamPost(UncheckedBaseModel): diff --git a/src/elevenlabs/types/chapter_content_block_extendable_node_response_model.py b/src/elevenlabs/types/chapter_content_block_extendable_node_response_model.py index a07e532a..7fa0452d 100644 --- a/src/elevenlabs/types/chapter_content_block_extendable_node_response_model.py +++ b/src/elevenlabs/types/chapter_content_block_extendable_node_response_model.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class ChapterContentBlockExtendableNodeResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/chapter_content_block_input_model.py b/src/elevenlabs/types/chapter_content_block_input_model.py index 33a5b0d5..28aed629 100644 --- a/src/elevenlabs/types/chapter_content_block_input_model.py +++ b/src/elevenlabs/types/chapter_content_block_input_model.py @@ -1,12 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .chapter_content_paragraph_tts_node_input_model import ( - ChapterContentParagraphTtsNodeInputModel, -) -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .chapter_content_paragraph_tts_node_input_model import ChapterContentParagraphTtsNodeInputModel class ChapterContentBlockInputModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/chapter_content_block_response_model.py b/src/elevenlabs/types/chapter_content_block_response_model.py index 498dcac0..be3fa284 100644 --- a/src/elevenlabs/types/chapter_content_block_response_model.py +++ b/src/elevenlabs/types/chapter_content_block_response_model.py @@ -1,12 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .chapter_content_block_response_model_nodes_item import ( - ChapterContentBlockResponseModelNodesItem, -) -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .chapter_content_block_response_model_nodes_item import ChapterContentBlockResponseModelNodesItem class ChapterContentBlockResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/chapter_content_block_response_model_nodes_item.py b/src/elevenlabs/types/chapter_content_block_response_model_nodes_item.py index 9e0f42b1..f9aa6330 100644 --- a/src/elevenlabs/types/chapter_content_block_response_model_nodes_item.py +++ b/src/elevenlabs/types/chapter_content_block_response_model_nodes_item.py @@ -1,12 +1,13 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -from ..core.unchecked_base_model import UncheckedBaseModel + import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic import typing_extensions -from ..core.unchecked_base_model import UnionMetadata +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel, UnionMetadata class ChapterContentBlockResponseModelNodesItem_TtsNode(UncheckedBaseModel): @@ -38,9 +39,6 @@ class Config: ChapterContentBlockResponseModelNodesItem = typing_extensions.Annotated[ - typing.Union[ - ChapterContentBlockResponseModelNodesItem_TtsNode, - ChapterContentBlockResponseModelNodesItem_Other, - ], + typing.Union[ChapterContentBlockResponseModelNodesItem_TtsNode, ChapterContentBlockResponseModelNodesItem_Other], UnionMetadata(discriminant="type"), ] diff --git a/src/elevenlabs/types/chapter_content_block_tts_node_response_model.py b/src/elevenlabs/types/chapter_content_block_tts_node_response_model.py index 90206621..6adb8e32 100644 --- a/src/elevenlabs/types/chapter_content_block_tts_node_response_model.py +++ b/src/elevenlabs/types/chapter_content_block_tts_node_response_model.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class ChapterContentBlockTtsNodeResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/chapter_content_input_model.py b/src/elevenlabs/types/chapter_content_input_model.py index ac3539cc..9c50884a 100644 --- a/src/elevenlabs/types/chapter_content_input_model.py +++ b/src/elevenlabs/types/chapter_content_input_model.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .chapter_content_block_input_model import ChapterContentBlockInputModel -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .chapter_content_block_input_model import ChapterContentBlockInputModel class ChapterContentInputModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/chapter_content_paragraph_tts_node_input_model.py b/src/elevenlabs/types/chapter_content_paragraph_tts_node_input_model.py index 13390681..b124c9f0 100644 --- a/src/elevenlabs/types/chapter_content_paragraph_tts_node_input_model.py +++ b/src/elevenlabs/types/chapter_content_paragraph_tts_node_input_model.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class ChapterContentParagraphTtsNodeInputModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/chapter_content_response_model.py b/src/elevenlabs/types/chapter_content_response_model.py index 2140cece..3471cf34 100644 --- a/src/elevenlabs/types/chapter_content_response_model.py +++ b/src/elevenlabs/types/chapter_content_response_model.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .chapter_content_block_response_model import ChapterContentBlockResponseModel -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .chapter_content_block_response_model import ChapterContentBlockResponseModel class ChapterContentResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/chapter_response.py b/src/elevenlabs/types/chapter_response.py index 8410cb8e..fed8acdd 100644 --- a/src/elevenlabs/types/chapter_response.py +++ b/src/elevenlabs/types/chapter_response.py @@ -1,11 +1,12 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -import pydantic import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel from .chapter_state import ChapterState from .chapter_statistics_response import ChapterStatisticsResponse -from ..core.pydantic_utilities import IS_PYDANTIC_V2 class ChapterResponse(UncheckedBaseModel): diff --git a/src/elevenlabs/types/chapter_snapshot_extended_response_model.py b/src/elevenlabs/types/chapter_snapshot_extended_response_model.py index 4abc2a3e..b5304abf 100644 --- a/src/elevenlabs/types/chapter_snapshot_extended_response_model.py +++ b/src/elevenlabs/types/chapter_snapshot_extended_response_model.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -import pydantic import typing -from .character_alignment_model import CharacterAlignmentModel + +import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .character_alignment_model import CharacterAlignmentModel class ChapterSnapshotExtendedResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/chapter_snapshot_response.py b/src/elevenlabs/types/chapter_snapshot_response.py index bdfaf456..6ef04607 100644 --- a/src/elevenlabs/types/chapter_snapshot_response.py +++ b/src/elevenlabs/types/chapter_snapshot_response.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel +import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import typing +from ..core.unchecked_base_model import UncheckedBaseModel class ChapterSnapshotResponse(UncheckedBaseModel): diff --git a/src/elevenlabs/types/chapter_snapshots_response.py b/src/elevenlabs/types/chapter_snapshots_response.py index 2bc9bf85..3a4ad11f 100644 --- a/src/elevenlabs/types/chapter_snapshots_response.py +++ b/src/elevenlabs/types/chapter_snapshots_response.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .chapter_snapshot_response import ChapterSnapshotResponse + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .chapter_snapshot_response import ChapterSnapshotResponse class ChapterSnapshotsResponse(UncheckedBaseModel): diff --git a/src/elevenlabs/types/chapter_statistics_response.py b/src/elevenlabs/types/chapter_statistics_response.py index 5cc5c049..68906fd9 100644 --- a/src/elevenlabs/types/chapter_statistics_response.py +++ b/src/elevenlabs/types/chapter_statistics_response.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel +import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import typing +from ..core.unchecked_base_model import UncheckedBaseModel class ChapterStatisticsResponse(UncheckedBaseModel): diff --git a/src/elevenlabs/types/chapter_with_content_response_model.py b/src/elevenlabs/types/chapter_with_content_response_model.py index c4a7a116..eb049370 100644 --- a/src/elevenlabs/types/chapter_with_content_response_model.py +++ b/src/elevenlabs/types/chapter_with_content_response_model.py @@ -1,14 +1,13 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -import pydantic import typing -from .chapter_with_content_response_model_state import ( - ChapterWithContentResponseModelState, -) -from .chapter_statistics_response import ChapterStatisticsResponse -from .chapter_content_response_model import ChapterContentResponseModel + +import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .chapter_content_response_model import ChapterContentResponseModel +from .chapter_statistics_response import ChapterStatisticsResponse +from .chapter_with_content_response_model_state import ChapterWithContentResponseModelState class ChapterWithContentResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/character_alignment_model.py b/src/elevenlabs/types/character_alignment_model.py index 00fb275d..db9553a5 100644 --- a/src/elevenlabs/types/character_alignment_model.py +++ b/src/elevenlabs/types/character_alignment_model.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class CharacterAlignmentModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/character_alignment_response_model.py b/src/elevenlabs/types/character_alignment_response_model.py index e493b6c5..4374233d 100644 --- a/src/elevenlabs/types/character_alignment_response_model.py +++ b/src/elevenlabs/types/character_alignment_response_model.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class CharacterAlignmentResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/client_tool_config_input.py b/src/elevenlabs/types/client_tool_config_input.py index 8f11940e..96a650d0 100644 --- a/src/elevenlabs/types/client_tool_config_input.py +++ b/src/elevenlabs/types/client_tool_config_input.py @@ -1,12 +1,13 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from .array_json_schema_property_input import ArrayJsonSchemaPropertyInput -from .object_json_schema_property_input import ObjectJsonSchemaPropertyInput +from __future__ import annotations + import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, update_forward_refs +from ..core.unchecked_base_model import UncheckedBaseModel from .dynamic_variables_config import DynamicVariablesConfig -from ..core.pydantic_utilities import IS_PYDANTIC_V2 class ClientToolConfigInput(UncheckedBaseModel): @@ -22,7 +23,7 @@ class ClientToolConfigInput(UncheckedBaseModel): The maximum time in seconds to wait for the tool call to complete. Must be between 1 and 30 seconds (inclusive). """ - parameters: typing.Optional[ObjectJsonSchemaPropertyInput] = pydantic.Field(default=None) + parameters: typing.Optional["ObjectJsonSchemaPropertyInput"] = pydantic.Field(default=None) """ Schema for any parameters to pass to the client """ @@ -45,3 +46,9 @@ class Config: frozen = True smart_union = True extra = pydantic.Extra.allow + + +from .array_json_schema_property_input import ArrayJsonSchemaPropertyInput # noqa: E402, F401, I001 +from .object_json_schema_property_input import ObjectJsonSchemaPropertyInput # noqa: E402, F401, I001 + +update_forward_refs(ClientToolConfigInput) diff --git a/src/elevenlabs/types/client_tool_config_output.py b/src/elevenlabs/types/client_tool_config_output.py index 1f04b0d3..557f64cd 100644 --- a/src/elevenlabs/types/client_tool_config_output.py +++ b/src/elevenlabs/types/client_tool_config_output.py @@ -1,12 +1,13 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from .array_json_schema_property_output import ArrayJsonSchemaPropertyOutput -from .object_json_schema_property_output import ObjectJsonSchemaPropertyOutput +from __future__ import annotations + import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, update_forward_refs +from ..core.unchecked_base_model import UncheckedBaseModel from .dynamic_variables_config import DynamicVariablesConfig -from ..core.pydantic_utilities import IS_PYDANTIC_V2 class ClientToolConfigOutput(UncheckedBaseModel): @@ -22,7 +23,7 @@ class ClientToolConfigOutput(UncheckedBaseModel): The maximum time in seconds to wait for the tool call to complete. Must be between 1 and 30 seconds (inclusive). """ - parameters: typing.Optional[ObjectJsonSchemaPropertyOutput] = pydantic.Field(default=None) + parameters: typing.Optional["ObjectJsonSchemaPropertyOutput"] = pydantic.Field(default=None) """ Schema for any parameters to pass to the client """ @@ -45,3 +46,9 @@ class Config: frozen = True smart_union = True extra = pydantic.Extra.allow + + +from .array_json_schema_property_output import ArrayJsonSchemaPropertyOutput # noqa: E402, F401, I001 +from .object_json_schema_property_output import ObjectJsonSchemaPropertyOutput # noqa: E402, F401, I001 + +update_forward_refs(ClientToolConfigOutput) diff --git a/src/elevenlabs/types/close_connection.py b/src/elevenlabs/types/close_connection.py index 42a428f2..6f2f2587 100644 --- a/src/elevenlabs/types/close_connection.py +++ b/src/elevenlabs/types/close_connection.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class CloseConnection(UncheckedBaseModel): diff --git a/src/elevenlabs/types/close_context.py b/src/elevenlabs/types/close_context.py index 68fc9cfb..e5a94ef6 100644 --- a/src/elevenlabs/types/close_context.py +++ b/src/elevenlabs/types/close_context.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel +import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import typing +from ..core.unchecked_base_model import UncheckedBaseModel class CloseContext(UncheckedBaseModel): diff --git a/src/elevenlabs/types/close_socket.py b/src/elevenlabs/types/close_socket.py index 355688b8..769778f9 100644 --- a/src/elevenlabs/types/close_socket.py +++ b/src/elevenlabs/types/close_socket.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class CloseSocket(UncheckedBaseModel): diff --git a/src/elevenlabs/types/conv_ai_dynamic_variable.py b/src/elevenlabs/types/conv_ai_dynamic_variable.py new file mode 100644 index 00000000..3944f73a --- /dev/null +++ b/src/elevenlabs/types/conv_ai_dynamic_variable.py @@ -0,0 +1,24 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel + + +class ConvAiDynamicVariable(UncheckedBaseModel): + """ + Used to reference a dynamic variable. + """ + + variable_name: str + + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 + else: + + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/elevenlabs/types/conv_ai_secret_locator.py b/src/elevenlabs/types/conv_ai_secret_locator.py index 9aa49a80..d1aa9d5b 100644 --- a/src/elevenlabs/types/conv_ai_secret_locator.py +++ b/src/elevenlabs/types/conv_ai_secret_locator.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class ConvAiSecretLocator(UncheckedBaseModel): diff --git a/src/elevenlabs/types/conv_ai_stored_secret_dependencies.py b/src/elevenlabs/types/conv_ai_stored_secret_dependencies.py index fb57e3b6..b488c175 100644 --- a/src/elevenlabs/types/conv_ai_stored_secret_dependencies.py +++ b/src/elevenlabs/types/conv_ai_stored_secret_dependencies.py @@ -1,17 +1,14 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .conv_ai_stored_secret_dependencies_tools_item import ( - ConvAiStoredSecretDependenciesToolsItem, -) -from .conv_ai_stored_secret_dependencies_agent_tools_item import ( - ConvAiStoredSecretDependenciesAgentToolsItem, -) -from .secret_dependency_type import SecretDependencyType -from .dependent_phone_number_identifier import DependentPhoneNumberIdentifier -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .conv_ai_stored_secret_dependencies_agent_tools_item import ConvAiStoredSecretDependenciesAgentToolsItem +from .conv_ai_stored_secret_dependencies_tools_item import ConvAiStoredSecretDependenciesToolsItem +from .dependent_phone_number_identifier import DependentPhoneNumberIdentifier +from .secret_dependency_type import SecretDependencyType class ConvAiStoredSecretDependencies(UncheckedBaseModel): diff --git a/src/elevenlabs/types/conv_ai_stored_secret_dependencies_agent_tools_item.py b/src/elevenlabs/types/conv_ai_stored_secret_dependencies_agent_tools_item.py index cc828996..a6b369a7 100644 --- a/src/elevenlabs/types/conv_ai_stored_secret_dependencies_agent_tools_item.py +++ b/src/elevenlabs/types/conv_ai_stored_secret_dependencies_agent_tools_item.py @@ -1,15 +1,14 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -from ..core.unchecked_base_model import UncheckedBaseModel + import typing -from .dependent_available_agent_tool_identifier_access_level import ( - DependentAvailableAgentToolIdentifierAccessLevel, -) -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic import typing_extensions -from ..core.unchecked_base_model import UnionMetadata +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel, UnionMetadata +from .dependent_available_agent_tool_identifier_access_level import DependentAvailableAgentToolIdentifierAccessLevel class ConvAiStoredSecretDependenciesAgentToolsItem_Available(UncheckedBaseModel): @@ -45,8 +44,7 @@ class Config: ConvAiStoredSecretDependenciesAgentToolsItem = typing_extensions.Annotated[ typing.Union[ - ConvAiStoredSecretDependenciesAgentToolsItem_Available, - ConvAiStoredSecretDependenciesAgentToolsItem_Unknown, + ConvAiStoredSecretDependenciesAgentToolsItem_Available, ConvAiStoredSecretDependenciesAgentToolsItem_Unknown ], UnionMetadata(discriminant="type"), ] diff --git a/src/elevenlabs/types/conv_ai_stored_secret_dependencies_tools_item.py b/src/elevenlabs/types/conv_ai_stored_secret_dependencies_tools_item.py index 381efd5a..ea6733ed 100644 --- a/src/elevenlabs/types/conv_ai_stored_secret_dependencies_tools_item.py +++ b/src/elevenlabs/types/conv_ai_stored_secret_dependencies_tools_item.py @@ -1,15 +1,14 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -from ..core.unchecked_base_model import UncheckedBaseModel + import typing -from .dependent_available_tool_identifier_access_level import ( - DependentAvailableToolIdentifierAccessLevel, -) -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic import typing_extensions -from ..core.unchecked_base_model import UnionMetadata +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel, UnionMetadata +from .dependent_available_tool_identifier_access_level import DependentAvailableToolIdentifierAccessLevel class ConvAiStoredSecretDependenciesToolsItem_Available(UncheckedBaseModel): @@ -43,9 +42,6 @@ class Config: ConvAiStoredSecretDependenciesToolsItem = typing_extensions.Annotated[ - typing.Union[ - ConvAiStoredSecretDependenciesToolsItem_Available, - ConvAiStoredSecretDependenciesToolsItem_Unknown, - ], + typing.Union[ConvAiStoredSecretDependenciesToolsItem_Available, ConvAiStoredSecretDependenciesToolsItem_Unknown], UnionMetadata(discriminant="type"), ] diff --git a/src/elevenlabs/types/conv_ai_webhooks.py b/src/elevenlabs/types/conv_ai_webhooks.py index 27839bfc..b21e043b 100644 --- a/src/elevenlabs/types/conv_ai_webhooks.py +++ b/src/elevenlabs/types/conv_ai_webhooks.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class ConvAiWebhooks(UncheckedBaseModel): diff --git a/src/elevenlabs/types/conv_ai_workspace_stored_secret_config.py b/src/elevenlabs/types/conv_ai_workspace_stored_secret_config.py index 04edf768..a9563f9e 100644 --- a/src/elevenlabs/types/conv_ai_workspace_stored_secret_config.py +++ b/src/elevenlabs/types/conv_ai_workspace_stored_secret_config.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .conv_ai_stored_secret_dependencies import ConvAiStoredSecretDependencies -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .conv_ai_stored_secret_dependencies import ConvAiStoredSecretDependencies class ConvAiWorkspaceStoredSecretConfig(UncheckedBaseModel): diff --git a/src/elevenlabs/types/conversation_charging_common_model.py b/src/elevenlabs/types/conversation_charging_common_model.py index 77aa7007..58db3337 100644 --- a/src/elevenlabs/types/conversation_charging_common_model.py +++ b/src/elevenlabs/types/conversation_charging_common_model.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .llm_category_usage import LlmCategoryUsage -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .llm_category_usage import LlmCategoryUsage class ConversationChargingCommonModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/conversation_config.py b/src/elevenlabs/types/conversation_config.py index b3e2b912..add8d6f9 100644 --- a/src/elevenlabs/types/conversation_config.py +++ b/src/elevenlabs/types/conversation_config.py @@ -1,13 +1,19 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing + import pydantic -from .client_event import ClientEvent from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .client_event import ClientEvent class ConversationConfig(UncheckedBaseModel): + text_only: typing.Optional[bool] = pydantic.Field(default=None) + """ + If enabled audio will not be processed and only text will be used, use to avoid audio pricing. + """ + max_duration_seconds: typing.Optional[int] = pydantic.Field(default=None) """ The maximum duration of a conversation in seconds diff --git a/src/elevenlabs/types/conversation_config_client_override_config_input.py b/src/elevenlabs/types/conversation_config_client_override_config_input.py index 88c587fd..4b9eb463 100644 --- a/src/elevenlabs/types/conversation_config_client_override_config_input.py +++ b/src/elevenlabs/types/conversation_config_client_override_config_input.py @@ -1,13 +1,13 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .agent_config_override_config import AgentConfigOverrideConfig + import pydantic -from .tts_conversational_config_override_config import ( - TtsConversationalConfigOverrideConfig, -) from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .agent_config_override_config import AgentConfigOverrideConfig +from .conversation_config_override_config import ConversationConfigOverrideConfig +from .tts_conversational_config_override_config import TtsConversationalConfigOverrideConfig class ConversationConfigClientOverrideConfigInput(UncheckedBaseModel): @@ -21,6 +21,11 @@ class ConversationConfigClientOverrideConfigInput(UncheckedBaseModel): Overrides for the TTS configuration """ + conversation: typing.Optional[ConversationConfigOverrideConfig] = pydantic.Field(default=None) + """ + Overrides for the conversation configuration + """ + if IS_PYDANTIC_V2: model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 else: diff --git a/src/elevenlabs/types/conversation_config_client_override_config_output.py b/src/elevenlabs/types/conversation_config_client_override_config_output.py index 3b99c472..00bd4bfa 100644 --- a/src/elevenlabs/types/conversation_config_client_override_config_output.py +++ b/src/elevenlabs/types/conversation_config_client_override_config_output.py @@ -1,13 +1,13 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .agent_config_override_config import AgentConfigOverrideConfig + import pydantic -from .tts_conversational_config_override_config import ( - TtsConversationalConfigOverrideConfig, -) from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .agent_config_override_config import AgentConfigOverrideConfig +from .conversation_config_override_config import ConversationConfigOverrideConfig +from .tts_conversational_config_override_config import TtsConversationalConfigOverrideConfig class ConversationConfigClientOverrideConfigOutput(UncheckedBaseModel): @@ -21,6 +21,11 @@ class ConversationConfigClientOverrideConfigOutput(UncheckedBaseModel): Overrides for the TTS configuration """ + conversation: typing.Optional[ConversationConfigOverrideConfig] = pydantic.Field(default=None) + """ + Overrides for the conversation configuration + """ + if IS_PYDANTIC_V2: model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 else: diff --git a/src/elevenlabs/types/conversation_config_client_override_input.py b/src/elevenlabs/types/conversation_config_client_override_input.py index 10d52a8a..8a34f324 100644 --- a/src/elevenlabs/types/conversation_config_client_override_input.py +++ b/src/elevenlabs/types/conversation_config_client_override_input.py @@ -1,11 +1,13 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .agent_config_override import AgentConfigOverride + import pydantic -from .tts_conversational_config_override import TtsConversationalConfigOverride from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .agent_config_override import AgentConfigOverride +from .conversation_config_override import ConversationConfigOverride +from .tts_conversational_config_override import TtsConversationalConfigOverride class ConversationConfigClientOverrideInput(UncheckedBaseModel): @@ -19,6 +21,11 @@ class ConversationConfigClientOverrideInput(UncheckedBaseModel): The overrides for the TTS configuration """ + conversation: typing.Optional[ConversationConfigOverride] = pydantic.Field(default=None) + """ + The overrides for the conversation configuration + """ + if IS_PYDANTIC_V2: model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 else: diff --git a/src/elevenlabs/types/conversation_config_client_override_output.py b/src/elevenlabs/types/conversation_config_client_override_output.py index ef66d0ff..650f05e2 100644 --- a/src/elevenlabs/types/conversation_config_client_override_output.py +++ b/src/elevenlabs/types/conversation_config_client_override_output.py @@ -1,11 +1,13 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .agent_config_override import AgentConfigOverride + import pydantic -from .tts_conversational_config_override import TtsConversationalConfigOverride from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .agent_config_override import AgentConfigOverride +from .conversation_config_override import ConversationConfigOverride +from .tts_conversational_config_override import TtsConversationalConfigOverride class ConversationConfigClientOverrideOutput(UncheckedBaseModel): @@ -19,6 +21,11 @@ class ConversationConfigClientOverrideOutput(UncheckedBaseModel): The overrides for the TTS configuration """ + conversation: typing.Optional[ConversationConfigOverride] = pydantic.Field(default=None) + """ + The overrides for the conversation configuration + """ + if IS_PYDANTIC_V2: model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 else: diff --git a/src/elevenlabs/types/conversation_config_override.py b/src/elevenlabs/types/conversation_config_override.py new file mode 100644 index 00000000..48e614e9 --- /dev/null +++ b/src/elevenlabs/types/conversation_config_override.py @@ -0,0 +1,20 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel + + +class ConversationConfigOverride(UncheckedBaseModel): + text_only: typing.Optional[bool] = None + + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 + else: + + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/elevenlabs/types/conversation_config_override_config.py b/src/elevenlabs/types/conversation_config_override_config.py new file mode 100644 index 00000000..592043ca --- /dev/null +++ b/src/elevenlabs/types/conversation_config_override_config.py @@ -0,0 +1,23 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel + + +class ConversationConfigOverrideConfig(UncheckedBaseModel): + text_only: typing.Optional[bool] = pydantic.Field(default=None) + """ + Whether to allow overriding the text only configuration + """ + + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 + else: + + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/elevenlabs/types/conversation_deletion_settings.py b/src/elevenlabs/types/conversation_deletion_settings.py index e6249a30..4c4f3ef5 100644 --- a/src/elevenlabs/types/conversation_deletion_settings.py +++ b/src/elevenlabs/types/conversation_deletion_settings.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class ConversationDeletionSettings(UncheckedBaseModel): diff --git a/src/elevenlabs/types/conversation_history_analysis_common_model.py b/src/elevenlabs/types/conversation_history_analysis_common_model.py index cfbbe147..4de32aba 100644 --- a/src/elevenlabs/types/conversation_history_analysis_common_model.py +++ b/src/elevenlabs/types/conversation_history_analysis_common_model.py @@ -1,14 +1,15 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel from .conversation_history_evaluation_criteria_result_common_model import ( ConversationHistoryEvaluationCriteriaResultCommonModel, ) from .data_collection_result_common_model import DataCollectionResultCommonModel from .evaluation_success_result import EvaluationSuccessResult -from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import pydantic class ConversationHistoryAnalysisCommonModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/conversation_history_batch_call_model.py b/src/elevenlabs/types/conversation_history_batch_call_model.py index 1b07c5bc..920bb798 100644 --- a/src/elevenlabs/types/conversation_history_batch_call_model.py +++ b/src/elevenlabs/types/conversation_history_batch_call_model.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class ConversationHistoryBatchCallModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/conversation_history_error_common_model.py b/src/elevenlabs/types/conversation_history_error_common_model.py index 1e1ba57a..bff4915d 100644 --- a/src/elevenlabs/types/conversation_history_error_common_model.py +++ b/src/elevenlabs/types/conversation_history_error_common_model.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class ConversationHistoryErrorCommonModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/conversation_history_evaluation_criteria_result_common_model.py b/src/elevenlabs/types/conversation_history_evaluation_criteria_result_common_model.py index af659a80..c62a18d2 100644 --- a/src/elevenlabs/types/conversation_history_evaluation_criteria_result_common_model.py +++ b/src/elevenlabs/types/conversation_history_evaluation_criteria_result_common_model.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from .evaluation_success_result import EvaluationSuccessResult -from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .evaluation_success_result import EvaluationSuccessResult class ConversationHistoryEvaluationCriteriaResultCommonModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/conversation_history_feedback_common_model.py b/src/elevenlabs/types/conversation_history_feedback_common_model.py index 7b265e3c..f130bfdc 100644 --- a/src/elevenlabs/types/conversation_history_feedback_common_model.py +++ b/src/elevenlabs/types/conversation_history_feedback_common_model.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .user_feedback_score import UserFeedbackScore -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .user_feedback_score import UserFeedbackScore class ConversationHistoryFeedbackCommonModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/conversation_history_metadata_common_model.py b/src/elevenlabs/types/conversation_history_metadata_common_model.py index 79122fb4..35cc460d 100644 --- a/src/elevenlabs/types/conversation_history_metadata_common_model.py +++ b/src/elevenlabs/types/conversation_history_metadata_common_model.py @@ -1,23 +1,18 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .conversation_deletion_settings import ConversationDeletionSettings -from .conversation_history_feedback_common_model import ( - ConversationHistoryFeedbackCommonModel, -) + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel from .authorization_method import AuthorizationMethod from .conversation_charging_common_model import ConversationChargingCommonModel -from .conversation_history_metadata_common_model_phone_call import ( - ConversationHistoryMetadataCommonModelPhoneCall, -) +from .conversation_deletion_settings import ConversationDeletionSettings from .conversation_history_batch_call_model import ConversationHistoryBatchCallModel from .conversation_history_error_common_model import ConversationHistoryErrorCommonModel -from .conversation_history_rag_usage_common_model import ( - ConversationHistoryRagUsageCommonModel, -) -from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import pydantic +from .conversation_history_feedback_common_model import ConversationHistoryFeedbackCommonModel +from .conversation_history_metadata_common_model_phone_call import ConversationHistoryMetadataCommonModelPhoneCall +from .conversation_history_rag_usage_common_model import ConversationHistoryRagUsageCommonModel class ConversationHistoryMetadataCommonModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/conversation_history_metadata_common_model_phone_call.py b/src/elevenlabs/types/conversation_history_metadata_common_model_phone_call.py index de0ed913..2d197f3d 100644 --- a/src/elevenlabs/types/conversation_history_metadata_common_model_phone_call.py +++ b/src/elevenlabs/types/conversation_history_metadata_common_model_phone_call.py @@ -1,18 +1,17 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -from ..core.unchecked_base_model import UncheckedBaseModel + import typing + +import pydantic +import typing_extensions +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel, UnionMetadata from .conversation_history_sip_trunking_phone_call_model_direction import ( ConversationHistorySipTrunkingPhoneCallModelDirection, ) -from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import pydantic -from .conversation_history_twilio_phone_call_model_direction import ( - ConversationHistoryTwilioPhoneCallModelDirection, -) -import typing_extensions -from ..core.unchecked_base_model import UnionMetadata +from .conversation_history_twilio_phone_call_model_direction import ConversationHistoryTwilioPhoneCallModelDirection class ConversationHistoryMetadataCommonModelPhoneCall_SipTrunking(UncheckedBaseModel): diff --git a/src/elevenlabs/types/conversation_history_rag_usage_common_model.py b/src/elevenlabs/types/conversation_history_rag_usage_common_model.py index c2df23ee..34f86ffa 100644 --- a/src/elevenlabs/types/conversation_history_rag_usage_common_model.py +++ b/src/elevenlabs/types/conversation_history_rag_usage_common_model.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class ConversationHistoryRagUsageCommonModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/conversation_history_sip_trunking_phone_call_model.py b/src/elevenlabs/types/conversation_history_sip_trunking_phone_call_model.py index 6d508427..ef7e841d 100644 --- a/src/elevenlabs/types/conversation_history_sip_trunking_phone_call_model.py +++ b/src/elevenlabs/types/conversation_history_sip_trunking_phone_call_model.py @@ -1,12 +1,13 @@ # This file was auto-generated by Fern from our API Definition. +import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 from ..core.unchecked_base_model import UncheckedBaseModel from .conversation_history_sip_trunking_phone_call_model_direction import ( ConversationHistorySipTrunkingPhoneCallModelDirection, ) -from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import typing -import pydantic class ConversationHistorySipTrunkingPhoneCallModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/conversation_history_transcript_common_model_input.py b/src/elevenlabs/types/conversation_history_transcript_common_model_input.py index 855fd684..662eda40 100644 --- a/src/elevenlabs/types/conversation_history_transcript_common_model_input.py +++ b/src/elevenlabs/types/conversation_history_transcript_common_model_input.py @@ -1,22 +1,20 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from .conversation_history_transcript_common_model_input_role import ( - ConversationHistoryTranscriptCommonModelInputRole, -) import typing -from .conversation_history_transcript_tool_call_common_model import ( - ConversationHistoryTranscriptToolCallCommonModel, -) -from .conversation_history_transcript_tool_result_common_model import ( - ConversationHistoryTranscriptToolResultCommonModel, + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .conversation_history_transcript_common_model_input_role import ConversationHistoryTranscriptCommonModelInputRole +from .conversation_history_transcript_common_model_input_source_medium import ( + ConversationHistoryTranscriptCommonModelInputSourceMedium, ) -from .user_feedback import UserFeedback +from .conversation_history_transcript_tool_call_common_model import ConversationHistoryTranscriptToolCallCommonModel +from .conversation_history_transcript_tool_result_common_model import ConversationHistoryTranscriptToolResultCommonModel from .conversation_turn_metrics import ConversationTurnMetrics -from .rag_retrieval_info import RagRetrievalInfo from .llm_usage_input import LlmUsageInput -from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import pydantic +from .rag_retrieval_info import RagRetrievalInfo +from .user_feedback import UserFeedback class ConversationHistoryTranscriptCommonModelInput(UncheckedBaseModel): @@ -26,10 +24,13 @@ class ConversationHistoryTranscriptCommonModelInput(UncheckedBaseModel): tool_results: typing.Optional[typing.List[ConversationHistoryTranscriptToolResultCommonModel]] = None feedback: typing.Optional[UserFeedback] = None llm_override: typing.Optional[str] = None + source_medium: typing.Optional[ConversationHistoryTranscriptCommonModelInputSourceMedium] = None time_in_call_secs: int conversation_turn_metrics: typing.Optional[ConversationTurnMetrics] = None rag_retrieval_info: typing.Optional[RagRetrievalInfo] = None llm_usage: typing.Optional[LlmUsageInput] = None + interrupted: typing.Optional[bool] = None + original_message: typing.Optional[str] = None if IS_PYDANTIC_V2: model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 diff --git a/src/elevenlabs/types/conversation_history_transcript_common_model_input_source_medium.py b/src/elevenlabs/types/conversation_history_transcript_common_model_input_source_medium.py new file mode 100644 index 00000000..47f8e9c2 --- /dev/null +++ b/src/elevenlabs/types/conversation_history_transcript_common_model_input_source_medium.py @@ -0,0 +1,5 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +ConversationHistoryTranscriptCommonModelInputSourceMedium = typing.Union[typing.Literal["audio", "text"], typing.Any] diff --git a/src/elevenlabs/types/conversation_history_transcript_common_model_output.py b/src/elevenlabs/types/conversation_history_transcript_common_model_output.py index 8792c17e..07a80617 100644 --- a/src/elevenlabs/types/conversation_history_transcript_common_model_output.py +++ b/src/elevenlabs/types/conversation_history_transcript_common_model_output.py @@ -1,22 +1,20 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from .conversation_history_transcript_common_model_output_role import ( - ConversationHistoryTranscriptCommonModelOutputRole, -) import typing -from .conversation_history_transcript_tool_call_common_model import ( - ConversationHistoryTranscriptToolCallCommonModel, -) -from .conversation_history_transcript_tool_result_common_model import ( - ConversationHistoryTranscriptToolResultCommonModel, + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .conversation_history_transcript_common_model_output_role import ConversationHistoryTranscriptCommonModelOutputRole +from .conversation_history_transcript_common_model_output_source_medium import ( + ConversationHistoryTranscriptCommonModelOutputSourceMedium, ) -from .user_feedback import UserFeedback +from .conversation_history_transcript_tool_call_common_model import ConversationHistoryTranscriptToolCallCommonModel +from .conversation_history_transcript_tool_result_common_model import ConversationHistoryTranscriptToolResultCommonModel from .conversation_turn_metrics import ConversationTurnMetrics -from .rag_retrieval_info import RagRetrievalInfo from .llm_usage_output import LlmUsageOutput -from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import pydantic +from .rag_retrieval_info import RagRetrievalInfo +from .user_feedback import UserFeedback class ConversationHistoryTranscriptCommonModelOutput(UncheckedBaseModel): @@ -26,10 +24,13 @@ class ConversationHistoryTranscriptCommonModelOutput(UncheckedBaseModel): tool_results: typing.Optional[typing.List[ConversationHistoryTranscriptToolResultCommonModel]] = None feedback: typing.Optional[UserFeedback] = None llm_override: typing.Optional[str] = None + source_medium: typing.Optional[ConversationHistoryTranscriptCommonModelOutputSourceMedium] = None time_in_call_secs: int conversation_turn_metrics: typing.Optional[ConversationTurnMetrics] = None rag_retrieval_info: typing.Optional[RagRetrievalInfo] = None llm_usage: typing.Optional[LlmUsageOutput] = None + interrupted: typing.Optional[bool] = None + original_message: typing.Optional[str] = None if IS_PYDANTIC_V2: model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 diff --git a/src/elevenlabs/types/conversation_history_transcript_common_model_output_source_medium.py b/src/elevenlabs/types/conversation_history_transcript_common_model_output_source_medium.py new file mode 100644 index 00000000..bfa2b7f2 --- /dev/null +++ b/src/elevenlabs/types/conversation_history_transcript_common_model_output_source_medium.py @@ -0,0 +1,5 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +ConversationHistoryTranscriptCommonModelOutputSourceMedium = typing.Union[typing.Literal["audio", "text"], typing.Any] diff --git a/src/elevenlabs/types/conversation_history_transcript_tool_call_client_details.py b/src/elevenlabs/types/conversation_history_transcript_tool_call_client_details.py index 9f84fddf..ee73d105 100644 --- a/src/elevenlabs/types/conversation_history_transcript_tool_call_client_details.py +++ b/src/elevenlabs/types/conversation_history_transcript_tool_call_client_details.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class ConversationHistoryTranscriptToolCallClientDetails(UncheckedBaseModel): diff --git a/src/elevenlabs/types/conversation_history_transcript_tool_call_common_model.py b/src/elevenlabs/types/conversation_history_transcript_tool_call_common_model.py index 0ead68fb..d079f863 100644 --- a/src/elevenlabs/types/conversation_history_transcript_tool_call_common_model.py +++ b/src/elevenlabs/types/conversation_history_transcript_tool_call_common_model.py @@ -1,12 +1,13 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel from .conversation_history_transcript_tool_call_common_model_tool_details import ( ConversationHistoryTranscriptToolCallCommonModelToolDetails, ) -from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import pydantic class ConversationHistoryTranscriptToolCallCommonModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/conversation_history_transcript_tool_call_common_model_tool_details.py b/src/elevenlabs/types/conversation_history_transcript_tool_call_common_model_tool_details.py index ca860d50..e5b3a107 100644 --- a/src/elevenlabs/types/conversation_history_transcript_tool_call_common_model_tool_details.py +++ b/src/elevenlabs/types/conversation_history_transcript_tool_call_common_model_tool_details.py @@ -1,12 +1,13 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -from ..core.unchecked_base_model import UncheckedBaseModel + import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic import typing_extensions -from ..core.unchecked_base_model import UnionMetadata +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel, UnionMetadata class ConversationHistoryTranscriptToolCallCommonModelToolDetails_Client(UncheckedBaseModel): diff --git a/src/elevenlabs/types/conversation_history_transcript_tool_call_webhook_details.py b/src/elevenlabs/types/conversation_history_transcript_tool_call_webhook_details.py index c5787ce6..6f4c50f5 100644 --- a/src/elevenlabs/types/conversation_history_transcript_tool_call_webhook_details.py +++ b/src/elevenlabs/types/conversation_history_transcript_tool_call_webhook_details.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class ConversationHistoryTranscriptToolCallWebhookDetails(UncheckedBaseModel): diff --git a/src/elevenlabs/types/conversation_history_transcript_tool_result_common_model.py b/src/elevenlabs/types/conversation_history_transcript_tool_result_common_model.py index 15038af8..9dab09d1 100644 --- a/src/elevenlabs/types/conversation_history_transcript_tool_result_common_model.py +++ b/src/elevenlabs/types/conversation_history_transcript_tool_result_common_model.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class ConversationHistoryTranscriptToolResultCommonModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/conversation_history_twilio_phone_call_model.py b/src/elevenlabs/types/conversation_history_twilio_phone_call_model.py index 2413c743..c01713e6 100644 --- a/src/elevenlabs/types/conversation_history_twilio_phone_call_model.py +++ b/src/elevenlabs/types/conversation_history_twilio_phone_call_model.py @@ -1,12 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from .conversation_history_twilio_phone_call_model_direction import ( - ConversationHistoryTwilioPhoneCallModelDirection, -) -from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .conversation_history_twilio_phone_call_model_direction import ConversationHistoryTwilioPhoneCallModelDirection class ConversationHistoryTwilioPhoneCallModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/conversation_initiation_client_data_config_input.py b/src/elevenlabs/types/conversation_initiation_client_data_config_input.py index c05ab226..cc870472 100644 --- a/src/elevenlabs/types/conversation_initiation_client_data_config_input.py +++ b/src/elevenlabs/types/conversation_initiation_client_data_config_input.py @@ -1,12 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .conversation_config_client_override_config_input import ( - ConversationConfigClientOverrideConfigInput, -) + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .conversation_config_client_override_config_input import ConversationConfigClientOverrideConfigInput class ConversationInitiationClientDataConfigInput(UncheckedBaseModel): diff --git a/src/elevenlabs/types/conversation_initiation_client_data_config_output.py b/src/elevenlabs/types/conversation_initiation_client_data_config_output.py index e63b8c22..3fd1cdbb 100644 --- a/src/elevenlabs/types/conversation_initiation_client_data_config_output.py +++ b/src/elevenlabs/types/conversation_initiation_client_data_config_output.py @@ -1,12 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .conversation_config_client_override_config_output import ( - ConversationConfigClientOverrideConfigOutput, -) + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .conversation_config_client_override_config_output import ConversationConfigClientOverrideConfigOutput class ConversationInitiationClientDataConfigOutput(UncheckedBaseModel): diff --git a/src/elevenlabs/types/conversation_initiation_client_data_internal.py b/src/elevenlabs/types/conversation_initiation_client_data_internal.py index 179b3031..ab0fa28e 100644 --- a/src/elevenlabs/types/conversation_initiation_client_data_internal.py +++ b/src/elevenlabs/types/conversation_initiation_client_data_internal.py @@ -1,25 +1,21 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .conversation_config_client_override_output import ( - ConversationConfigClientOverrideOutput, -) + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .conversation_config_client_override_output import ConversationConfigClientOverrideOutput from .conversation_initiation_client_data_internal_dynamic_variables_value import ( ConversationInitiationClientDataInternalDynamicVariablesValue, ) -from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import pydantic class ConversationInitiationClientDataInternal(UncheckedBaseModel): conversation_config_override: typing.Optional[ConversationConfigClientOverrideOutput] = None custom_llm_extra_body: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = None dynamic_variables: typing.Optional[ - typing.Dict[ - str, - typing.Optional[ConversationInitiationClientDataInternalDynamicVariablesValue], - ] + typing.Dict[str, typing.Optional[ConversationInitiationClientDataInternalDynamicVariablesValue]] ] = None if IS_PYDANTIC_V2: diff --git a/src/elevenlabs/types/conversation_initiation_client_data_request_input.py b/src/elevenlabs/types/conversation_initiation_client_data_request_input.py index bc3527ea..06f02aa4 100644 --- a/src/elevenlabs/types/conversation_initiation_client_data_request_input.py +++ b/src/elevenlabs/types/conversation_initiation_client_data_request_input.py @@ -1,25 +1,21 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .conversation_config_client_override_input import ( - ConversationConfigClientOverrideInput, -) + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .conversation_config_client_override_input import ConversationConfigClientOverrideInput from .conversation_initiation_client_data_request_input_dynamic_variables_value import ( ConversationInitiationClientDataRequestInputDynamicVariablesValue, ) -from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import pydantic class ConversationInitiationClientDataRequestInput(UncheckedBaseModel): conversation_config_override: typing.Optional[ConversationConfigClientOverrideInput] = None custom_llm_extra_body: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = None dynamic_variables: typing.Optional[ - typing.Dict[ - str, - typing.Optional[ConversationInitiationClientDataRequestInputDynamicVariablesValue], - ] + typing.Dict[str, typing.Optional[ConversationInitiationClientDataRequestInputDynamicVariablesValue]] ] = None if IS_PYDANTIC_V2: diff --git a/src/elevenlabs/types/conversation_initiation_client_data_request_output.py b/src/elevenlabs/types/conversation_initiation_client_data_request_output.py index 193a983c..7d84437e 100644 --- a/src/elevenlabs/types/conversation_initiation_client_data_request_output.py +++ b/src/elevenlabs/types/conversation_initiation_client_data_request_output.py @@ -1,25 +1,21 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .conversation_config_client_override_output import ( - ConversationConfigClientOverrideOutput, -) + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .conversation_config_client_override_output import ConversationConfigClientOverrideOutput from .conversation_initiation_client_data_request_output_dynamic_variables_value import ( ConversationInitiationClientDataRequestOutputDynamicVariablesValue, ) -from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import pydantic class ConversationInitiationClientDataRequestOutput(UncheckedBaseModel): conversation_config_override: typing.Optional[ConversationConfigClientOverrideOutput] = None custom_llm_extra_body: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = None dynamic_variables: typing.Optional[ - typing.Dict[ - str, - typing.Optional[ConversationInitiationClientDataRequestOutputDynamicVariablesValue], - ] + typing.Dict[str, typing.Optional[ConversationInitiationClientDataRequestOutputDynamicVariablesValue]] ] = None if IS_PYDANTIC_V2: diff --git a/src/elevenlabs/types/conversation_initiation_client_data_webhook.py b/src/elevenlabs/types/conversation_initiation_client_data_webhook.py index 2b977823..e55d0a9e 100644 --- a/src/elevenlabs/types/conversation_initiation_client_data_webhook.py +++ b/src/elevenlabs/types/conversation_initiation_client_data_webhook.py @@ -1,12 +1,13 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -import pydantic import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel from .conversation_initiation_client_data_webhook_request_headers_value import ( ConversationInitiationClientDataWebhookRequestHeadersValue, ) -from ..core.pydantic_utilities import IS_PYDANTIC_V2 class ConversationInitiationClientDataWebhook(UncheckedBaseModel): diff --git a/src/elevenlabs/types/conversation_initiation_client_data_webhook_request_headers_value.py b/src/elevenlabs/types/conversation_initiation_client_data_webhook_request_headers_value.py index aaa3a8ac..1e079727 100644 --- a/src/elevenlabs/types/conversation_initiation_client_data_webhook_request_headers_value.py +++ b/src/elevenlabs/types/conversation_initiation_client_data_webhook_request_headers_value.py @@ -1,6 +1,7 @@ # This file was auto-generated by Fern from our API Definition. import typing + from .conv_ai_secret_locator import ConvAiSecretLocator ConversationInitiationClientDataWebhookRequestHeadersValue = typing.Union[str, ConvAiSecretLocator] diff --git a/src/elevenlabs/types/conversation_signed_url_response_model.py b/src/elevenlabs/types/conversation_signed_url_response_model.py index b38e5f87..c282f46e 100644 --- a/src/elevenlabs/types/conversation_signed_url_response_model.py +++ b/src/elevenlabs/types/conversation_signed_url_response_model.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class ConversationSignedUrlResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/conversation_simulation_specification.py b/src/elevenlabs/types/conversation_simulation_specification.py index 71c6468e..fe31e824 100644 --- a/src/elevenlabs/types/conversation_simulation_specification.py +++ b/src/elevenlabs/types/conversation_simulation_specification.py @@ -1,16 +1,15 @@ # This file was auto-generated by Fern from our API Definition. +from __future__ import annotations + +import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, update_forward_refs from ..core.unchecked_base_model import UncheckedBaseModel -from .array_json_schema_property_input import ArrayJsonSchemaPropertyInput -from .object_json_schema_property_input import ObjectJsonSchemaPropertyInput from .agent_config_db_model import AgentConfigDbModel -import typing +from .conversation_history_transcript_common_model_input import ConversationHistoryTranscriptCommonModelInput from .tool_mock_config import ToolMockConfig -from .conversation_history_transcript_common_model_input import ( - ConversationHistoryTranscriptCommonModelInput, -) -import pydantic -from ..core.pydantic_utilities import IS_PYDANTIC_V2 class ConversationSimulationSpecification(UncheckedBaseModel): @@ -35,3 +34,9 @@ class Config: frozen = True smart_union = True extra = pydantic.Extra.allow + + +from .array_json_schema_property_input import ArrayJsonSchemaPropertyInput # noqa: E402, F401, I001 +from .object_json_schema_property_input import ObjectJsonSchemaPropertyInput # noqa: E402, F401, I001 + +update_forward_refs(ConversationSimulationSpecification) diff --git a/src/elevenlabs/types/conversation_summary_response_model.py b/src/elevenlabs/types/conversation_summary_response_model.py index f7094433..7d3ebda0 100644 --- a/src/elevenlabs/types/conversation_summary_response_model.py +++ b/src/elevenlabs/types/conversation_summary_response_model.py @@ -1,13 +1,12 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .conversation_summary_response_model_status import ( - ConversationSummaryResponseModelStatus, -) -from .evaluation_success_result import EvaluationSuccessResult -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .conversation_summary_response_model_status import ConversationSummaryResponseModelStatus +from .evaluation_success_result import EvaluationSuccessResult class ConversationSummaryResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/conversation_summary_response_model_status.py b/src/elevenlabs/types/conversation_summary_response_model_status.py index 08b073c3..9fc10287 100644 --- a/src/elevenlabs/types/conversation_summary_response_model_status.py +++ b/src/elevenlabs/types/conversation_summary_response_model_status.py @@ -3,5 +3,5 @@ import typing ConversationSummaryResponseModelStatus = typing.Union[ - typing.Literal["in-progress", "processing", "done", "failed"], typing.Any + typing.Literal["initiated", "in-progress", "processing", "done", "failed"], typing.Any ] diff --git a/src/elevenlabs/types/conversation_token_db_model.py b/src/elevenlabs/types/conversation_token_db_model.py index 94ca1fd2..c20e96bf 100644 --- a/src/elevenlabs/types/conversation_token_db_model.py +++ b/src/elevenlabs/types/conversation_token_db_model.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -import pydantic import typing -from .conversation_token_purpose import ConversationTokenPurpose + +import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .conversation_token_purpose import ConversationTokenPurpose class ConversationTokenDbModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/conversation_turn_metrics.py b/src/elevenlabs/types/conversation_turn_metrics.py index b6e74b39..6fdff91b 100644 --- a/src/elevenlabs/types/conversation_turn_metrics.py +++ b/src/elevenlabs/types/conversation_turn_metrics.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .metric_record import MetricRecord -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .metric_record import MetricRecord class ConversationTurnMetrics(UncheckedBaseModel): diff --git a/src/elevenlabs/types/conversational_config.py b/src/elevenlabs/types/conversational_config.py index 815bcdae..5bc34bd1 100644 --- a/src/elevenlabs/types/conversational_config.py +++ b/src/elevenlabs/types/conversational_config.py @@ -1,17 +1,18 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from .array_json_schema_property_output import ArrayJsonSchemaPropertyOutput -from .object_json_schema_property_output import ObjectJsonSchemaPropertyOutput +from __future__ import annotations + import typing -from .asr_conversational_config import AsrConversationalConfig + import pydantic -from .turn_config import TurnConfig -from .tts_conversational_config import TtsConversationalConfig +from ..core.pydantic_utilities import IS_PYDANTIC_V2, update_forward_refs +from ..core.unchecked_base_model import UncheckedBaseModel +from .agent_config import AgentConfig +from .asr_conversational_config import AsrConversationalConfig from .conversation_config import ConversationConfig from .language_preset_output import LanguagePresetOutput -from .agent_config import AgentConfig -from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from .tts_conversational_config import TtsConversationalConfig +from .turn_config import TurnConfig class ConversationalConfig(UncheckedBaseModel): @@ -53,3 +54,9 @@ class Config: frozen = True smart_union = True extra = pydantic.Extra.allow + + +from .array_json_schema_property_output import ArrayJsonSchemaPropertyOutput # noqa: E402, F401, I001 +from .object_json_schema_property_output import ObjectJsonSchemaPropertyOutput # noqa: E402, F401, I001 + +update_forward_refs(ConversationalConfig) diff --git a/src/elevenlabs/types/convert_chapter_response_model.py b/src/elevenlabs/types/convert_chapter_response_model.py index 13b81bdf..4a1a21d1 100644 --- a/src/elevenlabs/types/convert_chapter_response_model.py +++ b/src/elevenlabs/types/convert_chapter_response_model.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel +import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import typing +from ..core.unchecked_base_model import UncheckedBaseModel class ConvertChapterResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/convert_project_response_model.py b/src/elevenlabs/types/convert_project_response_model.py index 36b2f1ef..1c229d86 100644 --- a/src/elevenlabs/types/convert_project_response_model.py +++ b/src/elevenlabs/types/convert_project_response_model.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel +import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import typing +from ..core.unchecked_base_model import UncheckedBaseModel class ConvertProjectResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/create_agent_response_model.py b/src/elevenlabs/types/create_agent_response_model.py index 6cf6b9ec..3c66211d 100644 --- a/src/elevenlabs/types/create_agent_response_model.py +++ b/src/elevenlabs/types/create_agent_response_model.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel +import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import typing +from ..core.unchecked_base_model import UncheckedBaseModel class CreateAgentResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/create_phone_number_response_model.py b/src/elevenlabs/types/create_phone_number_response_model.py index 2c1e9b2e..7246bc75 100644 --- a/src/elevenlabs/types/create_phone_number_response_model.py +++ b/src/elevenlabs/types/create_phone_number_response_model.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel +import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import typing +from ..core.unchecked_base_model import UncheckedBaseModel class CreatePhoneNumberResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/create_previously_generated_voice_request.py b/src/elevenlabs/types/create_previously_generated_voice_request.py index 599de727..78a609fb 100644 --- a/src/elevenlabs/types/create_previously_generated_voice_request.py +++ b/src/elevenlabs/types/create_previously_generated_voice_request.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -import pydantic import typing + +import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class CreatePreviouslyGeneratedVoiceRequest(UncheckedBaseModel): diff --git a/src/elevenlabs/types/create_pronunciation_dictionary_response_model.py b/src/elevenlabs/types/create_pronunciation_dictionary_response_model.py index d9dc1f41..161c448e 100644 --- a/src/elevenlabs/types/create_pronunciation_dictionary_response_model.py +++ b/src/elevenlabs/types/create_pronunciation_dictionary_response_model.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel +import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import typing +from ..core.unchecked_base_model import UncheckedBaseModel class CreatePronunciationDictionaryResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/create_sip_trunk_phone_number_request.py b/src/elevenlabs/types/create_sip_trunk_phone_number_request.py index 38fadb4a..a6445a8b 100644 --- a/src/elevenlabs/types/create_sip_trunk_phone_number_request.py +++ b/src/elevenlabs/types/create_sip_trunk_phone_number_request.py @@ -1,12 +1,13 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -import pydantic import typing -from .sip_trunk_transport_enum import SipTrunkTransportEnum + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel from .sip_media_encryption_enum import SipMediaEncryptionEnum from .sip_trunk_credentials import SipTrunkCredentials -from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from .sip_trunk_transport_enum import SipTrunkTransportEnum class CreateSipTrunkPhoneNumberRequest(UncheckedBaseModel): diff --git a/src/elevenlabs/types/create_twilio_phone_number_request.py b/src/elevenlabs/types/create_twilio_phone_number_request.py index fa9870d3..d26c5383 100644 --- a/src/elevenlabs/types/create_twilio_phone_number_request.py +++ b/src/elevenlabs/types/create_twilio_phone_number_request.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel +import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import typing +from ..core.unchecked_base_model import UncheckedBaseModel class CreateTwilioPhoneNumberRequest(UncheckedBaseModel): diff --git a/src/elevenlabs/types/custom_llm.py b/src/elevenlabs/types/custom_llm.py index 3e4e78ba..08d5df9b 100644 --- a/src/elevenlabs/types/custom_llm.py +++ b/src/elevenlabs/types/custom_llm.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -import pydantic import typing -from .conv_ai_secret_locator import ConvAiSecretLocator + +import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .conv_ai_secret_locator import ConvAiSecretLocator class CustomLlm(UncheckedBaseModel): diff --git a/src/elevenlabs/types/dashboard_call_success_chart_model.py b/src/elevenlabs/types/dashboard_call_success_chart_model.py index 4fc4f761..37dba93b 100644 --- a/src/elevenlabs/types/dashboard_call_success_chart_model.py +++ b/src/elevenlabs/types/dashboard_call_success_chart_model.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class DashboardCallSuccessChartModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/dashboard_criteria_chart_model.py b/src/elevenlabs/types/dashboard_criteria_chart_model.py index 1f6ca058..fc4a0d33 100644 --- a/src/elevenlabs/types/dashboard_criteria_chart_model.py +++ b/src/elevenlabs/types/dashboard_criteria_chart_model.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class DashboardCriteriaChartModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/dashboard_data_collection_chart_model.py b/src/elevenlabs/types/dashboard_data_collection_chart_model.py index 724d49b4..80cc5305 100644 --- a/src/elevenlabs/types/dashboard_data_collection_chart_model.py +++ b/src/elevenlabs/types/dashboard_data_collection_chart_model.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class DashboardDataCollectionChartModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/data_collection_result_common_model.py b/src/elevenlabs/types/data_collection_result_common_model.py index 1c4856ba..efcc25b5 100644 --- a/src/elevenlabs/types/data_collection_result_common_model.py +++ b/src/elevenlabs/types/data_collection_result_common_model.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .literal_json_schema_property import LiteralJsonSchemaProperty -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .literal_json_schema_property import LiteralJsonSchemaProperty class DataCollectionResultCommonModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/delete_chapter_response_model.py b/src/elevenlabs/types/delete_chapter_response_model.py index 2213b8c5..c04b5c43 100644 --- a/src/elevenlabs/types/delete_chapter_response_model.py +++ b/src/elevenlabs/types/delete_chapter_response_model.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel +import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import typing +from ..core.unchecked_base_model import UncheckedBaseModel class DeleteChapterResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/delete_dubbing_response_model.py b/src/elevenlabs/types/delete_dubbing_response_model.py index 8b372990..66b9d8ae 100644 --- a/src/elevenlabs/types/delete_dubbing_response_model.py +++ b/src/elevenlabs/types/delete_dubbing_response_model.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel +import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import typing +from ..core.unchecked_base_model import UncheckedBaseModel class DeleteDubbingResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/delete_history_item_response.py b/src/elevenlabs/types/delete_history_item_response.py index 57422ee6..e3bae919 100644 --- a/src/elevenlabs/types/delete_history_item_response.py +++ b/src/elevenlabs/types/delete_history_item_response.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel +import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import typing +from ..core.unchecked_base_model import UncheckedBaseModel class DeleteHistoryItemResponse(UncheckedBaseModel): diff --git a/src/elevenlabs/types/delete_project_response_model.py b/src/elevenlabs/types/delete_project_response_model.py index dcf7402a..2f78d121 100644 --- a/src/elevenlabs/types/delete_project_response_model.py +++ b/src/elevenlabs/types/delete_project_response_model.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel +import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import typing +from ..core.unchecked_base_model import UncheckedBaseModel class DeleteProjectResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/delete_sample_response.py b/src/elevenlabs/types/delete_sample_response.py index 12e4777f..28ea4d97 100644 --- a/src/elevenlabs/types/delete_sample_response.py +++ b/src/elevenlabs/types/delete_sample_response.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel +import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import typing +from ..core.unchecked_base_model import UncheckedBaseModel class DeleteSampleResponse(UncheckedBaseModel): diff --git a/src/elevenlabs/types/delete_voice_response_model.py b/src/elevenlabs/types/delete_voice_response_model.py index 6464ca65..4638fcd0 100644 --- a/src/elevenlabs/types/delete_voice_response_model.py +++ b/src/elevenlabs/types/delete_voice_response_model.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel +import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import typing +from ..core.unchecked_base_model import UncheckedBaseModel class DeleteVoiceResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/delete_voice_sample_response_model.py b/src/elevenlabs/types/delete_voice_sample_response_model.py index 75a72505..6ffb2e42 100644 --- a/src/elevenlabs/types/delete_voice_sample_response_model.py +++ b/src/elevenlabs/types/delete_voice_sample_response_model.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel +import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import typing +from ..core.unchecked_base_model import UncheckedBaseModel class DeleteVoiceSampleResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/delete_workspace_group_member_response_model.py b/src/elevenlabs/types/delete_workspace_group_member_response_model.py index 40b01066..aa51ea0f 100644 --- a/src/elevenlabs/types/delete_workspace_group_member_response_model.py +++ b/src/elevenlabs/types/delete_workspace_group_member_response_model.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel +import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import typing +from ..core.unchecked_base_model import UncheckedBaseModel class DeleteWorkspaceGroupMemberResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/delete_workspace_invite_response_model.py b/src/elevenlabs/types/delete_workspace_invite_response_model.py index a16c7cb6..6976368c 100644 --- a/src/elevenlabs/types/delete_workspace_invite_response_model.py +++ b/src/elevenlabs/types/delete_workspace_invite_response_model.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel +import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import typing +from ..core.unchecked_base_model import UncheckedBaseModel class DeleteWorkspaceInviteResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/delete_workspace_member_response_model.py b/src/elevenlabs/types/delete_workspace_member_response_model.py index 05515c9d..41044c5f 100644 --- a/src/elevenlabs/types/delete_workspace_member_response_model.py +++ b/src/elevenlabs/types/delete_workspace_member_response_model.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel +import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import typing +from ..core.unchecked_base_model import UncheckedBaseModel class DeleteWorkspaceMemberResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/dependent_available_agent_identifier.py b/src/elevenlabs/types/dependent_available_agent_identifier.py index 8491cdcb..8b12f479 100644 --- a/src/elevenlabs/types/dependent_available_agent_identifier.py +++ b/src/elevenlabs/types/dependent_available_agent_identifier.py @@ -1,12 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from .dependent_available_agent_identifier_access_level import ( - DependentAvailableAgentIdentifierAccessLevel, -) -from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .dependent_available_agent_identifier_access_level import DependentAvailableAgentIdentifierAccessLevel class DependentAvailableAgentIdentifier(UncheckedBaseModel): diff --git a/src/elevenlabs/types/dependent_available_agent_tool_identifier.py b/src/elevenlabs/types/dependent_available_agent_tool_identifier.py index 38c83645..554741e2 100644 --- a/src/elevenlabs/types/dependent_available_agent_tool_identifier.py +++ b/src/elevenlabs/types/dependent_available_agent_tool_identifier.py @@ -1,12 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .dependent_available_agent_tool_identifier_access_level import ( - DependentAvailableAgentToolIdentifierAccessLevel, -) -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .dependent_available_agent_tool_identifier_access_level import DependentAvailableAgentToolIdentifierAccessLevel class DependentAvailableAgentToolIdentifier(UncheckedBaseModel): diff --git a/src/elevenlabs/types/dependent_available_tool_identifier.py b/src/elevenlabs/types/dependent_available_tool_identifier.py index 48fb3640..9afa8207 100644 --- a/src/elevenlabs/types/dependent_available_tool_identifier.py +++ b/src/elevenlabs/types/dependent_available_tool_identifier.py @@ -1,12 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from .dependent_available_tool_identifier_access_level import ( - DependentAvailableToolIdentifierAccessLevel, -) -from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .dependent_available_tool_identifier_access_level import DependentAvailableToolIdentifierAccessLevel class DependentAvailableToolIdentifier(UncheckedBaseModel): diff --git a/src/elevenlabs/types/dependent_phone_number_identifier.py b/src/elevenlabs/types/dependent_phone_number_identifier.py index faa2ba89..5a9f4aeb 100644 --- a/src/elevenlabs/types/dependent_phone_number_identifier.py +++ b/src/elevenlabs/types/dependent_phone_number_identifier.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from .telephony_provider import TelephonyProvider -from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .telephony_provider import TelephonyProvider class DependentPhoneNumberIdentifier(UncheckedBaseModel): diff --git a/src/elevenlabs/types/dependent_unknown_agent_identifier.py b/src/elevenlabs/types/dependent_unknown_agent_identifier.py index e32dc4fb..04c307ae 100644 --- a/src/elevenlabs/types/dependent_unknown_agent_identifier.py +++ b/src/elevenlabs/types/dependent_unknown_agent_identifier.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class DependentUnknownAgentIdentifier(UncheckedBaseModel): diff --git a/src/elevenlabs/types/dependent_unknown_agent_tool_identifier.py b/src/elevenlabs/types/dependent_unknown_agent_tool_identifier.py index b321835d..e9765823 100644 --- a/src/elevenlabs/types/dependent_unknown_agent_tool_identifier.py +++ b/src/elevenlabs/types/dependent_unknown_agent_tool_identifier.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class DependentUnknownAgentToolIdentifier(UncheckedBaseModel): diff --git a/src/elevenlabs/types/dependent_unknown_tool_identifier.py b/src/elevenlabs/types/dependent_unknown_tool_identifier.py index 0bb875c7..475e8609 100644 --- a/src/elevenlabs/types/dependent_unknown_tool_identifier.py +++ b/src/elevenlabs/types/dependent_unknown_tool_identifier.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class DependentUnknownToolIdentifier(UncheckedBaseModel): diff --git a/src/elevenlabs/types/do_dubbing_response.py b/src/elevenlabs/types/do_dubbing_response.py index 29f033d5..749e5218 100644 --- a/src/elevenlabs/types/do_dubbing_response.py +++ b/src/elevenlabs/types/do_dubbing_response.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel +import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import typing +from ..core.unchecked_base_model import UncheckedBaseModel class DoDubbingResponse(UncheckedBaseModel): diff --git a/src/elevenlabs/types/docx_export_options.py b/src/elevenlabs/types/docx_export_options.py index b9426484..ad3b982e 100644 --- a/src/elevenlabs/types/docx_export_options.py +++ b/src/elevenlabs/types/docx_export_options.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class DocxExportOptions(UncheckedBaseModel): diff --git a/src/elevenlabs/types/dubbed_segment.py b/src/elevenlabs/types/dubbed_segment.py index e628a510..756084f8 100644 --- a/src/elevenlabs/types/dubbed_segment.py +++ b/src/elevenlabs/types/dubbed_segment.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .dubbing_media_reference import DubbingMediaReference -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .dubbing_media_reference import DubbingMediaReference class DubbedSegment(UncheckedBaseModel): diff --git a/src/elevenlabs/types/dubbing_media_metadata.py b/src/elevenlabs/types/dubbing_media_metadata.py index f5da4a96..c4fdd9dd 100644 --- a/src/elevenlabs/types/dubbing_media_metadata.py +++ b/src/elevenlabs/types/dubbing_media_metadata.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel +import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import typing +from ..core.unchecked_base_model import UncheckedBaseModel class DubbingMediaMetadata(UncheckedBaseModel): diff --git a/src/elevenlabs/types/dubbing_media_reference.py b/src/elevenlabs/types/dubbing_media_reference.py index 32741dfe..b4f5ef34 100644 --- a/src/elevenlabs/types/dubbing_media_reference.py +++ b/src/elevenlabs/types/dubbing_media_reference.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class DubbingMediaReference(UncheckedBaseModel): diff --git a/src/elevenlabs/types/dubbing_metadata_response.py b/src/elevenlabs/types/dubbing_metadata_response.py index 7d2d48d2..4d742106 100644 --- a/src/elevenlabs/types/dubbing_metadata_response.py +++ b/src/elevenlabs/types/dubbing_metadata_response.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -import pydantic import typing -from .dubbing_media_metadata import DubbingMediaMetadata + +import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .dubbing_media_metadata import DubbingMediaMetadata class DubbingMetadataResponse(UncheckedBaseModel): diff --git a/src/elevenlabs/types/dubbing_render_response_model.py b/src/elevenlabs/types/dubbing_render_response_model.py index e0cd09fd..cc4886f9 100644 --- a/src/elevenlabs/types/dubbing_render_response_model.py +++ b/src/elevenlabs/types/dubbing_render_response_model.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class DubbingRenderResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/dubbing_resource.py b/src/elevenlabs/types/dubbing_resource.py index e1d17a44..0571a701 100644 --- a/src/elevenlabs/types/dubbing_resource.py +++ b/src/elevenlabs/types/dubbing_resource.py @@ -1,13 +1,14 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel from .dubbing_media_reference import DubbingMediaReference -from .speaker_track import SpeakerTrack -from .speaker_segment import SpeakerSegment from .render import Render -from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import pydantic +from .speaker_segment import SpeakerSegment +from .speaker_track import SpeakerTrack class DubbingResource(UncheckedBaseModel): diff --git a/src/elevenlabs/types/dynamic_variables_config.py b/src/elevenlabs/types/dynamic_variables_config.py index ccf30824..aa185a0d 100644 --- a/src/elevenlabs/types/dynamic_variables_config.py +++ b/src/elevenlabs/types/dynamic_variables_config.py @@ -1,12 +1,13 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel from .dynamic_variables_config_dynamic_variable_placeholders_value import ( DynamicVariablesConfigDynamicVariablePlaceholdersValue, ) -import pydantic -from ..core.pydantic_utilities import IS_PYDANTIC_V2 class DynamicVariablesConfig(UncheckedBaseModel): diff --git a/src/elevenlabs/types/edit_chapter_response_model.py b/src/elevenlabs/types/edit_chapter_response_model.py index 0823beb3..2f4de578 100644 --- a/src/elevenlabs/types/edit_chapter_response_model.py +++ b/src/elevenlabs/types/edit_chapter_response_model.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from .chapter_with_content_response_model import ChapterWithContentResponseModel -from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .chapter_with_content_response_model import ChapterWithContentResponseModel class EditChapterResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/edit_project_response_model.py b/src/elevenlabs/types/edit_project_response_model.py index 62d0f6d0..e4d54fe1 100644 --- a/src/elevenlabs/types/edit_project_response_model.py +++ b/src/elevenlabs/types/edit_project_response_model.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from .project_response import ProjectResponse -from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .project_response import ProjectResponse class EditProjectResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/edit_voice_response_model.py b/src/elevenlabs/types/edit_voice_response_model.py index d9b3c8d7..ba1c140c 100644 --- a/src/elevenlabs/types/edit_voice_response_model.py +++ b/src/elevenlabs/types/edit_voice_response_model.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel +import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import typing +from ..core.unchecked_base_model import UncheckedBaseModel class EditVoiceResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/edit_voice_settings_response_model.py b/src/elevenlabs/types/edit_voice_settings_response_model.py index 8fc3de99..6a5bc4cf 100644 --- a/src/elevenlabs/types/edit_voice_settings_response_model.py +++ b/src/elevenlabs/types/edit_voice_settings_response_model.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel +import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import typing +from ..core.unchecked_base_model import UncheckedBaseModel class EditVoiceSettingsResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/embedding_model_enum.py b/src/elevenlabs/types/embedding_model_enum.py index d350804b..1844f8e9 100644 --- a/src/elevenlabs/types/embedding_model_enum.py +++ b/src/elevenlabs/types/embedding_model_enum.py @@ -3,6 +3,5 @@ import typing EmbeddingModelEnum = typing.Union[ - typing.Literal["e5_mistral_7b_instruct", "multilingual_e5_large_instruct"], - typing.Any, + typing.Literal["e5_mistral_7b_instruct", "multilingual_e5_large_instruct"], typing.Any ] diff --git a/src/elevenlabs/types/end_call_tool_config.py b/src/elevenlabs/types/end_call_tool_config.py index e48f5398..fd5fcee0 100644 --- a/src/elevenlabs/types/end_call_tool_config.py +++ b/src/elevenlabs/types/end_call_tool_config.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class EndCallToolConfig(UncheckedBaseModel): diff --git a/src/elevenlabs/types/evaluation_settings.py b/src/elevenlabs/types/evaluation_settings.py index e60d6973..99b7200f 100644 --- a/src/elevenlabs/types/evaluation_settings.py +++ b/src/elevenlabs/types/evaluation_settings.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .prompt_evaluation_criteria import PromptEvaluationCriteria + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .prompt_evaluation_criteria import PromptEvaluationCriteria class EvaluationSettings(UncheckedBaseModel): diff --git a/src/elevenlabs/types/export_options.py b/src/elevenlabs/types/export_options.py index 7d59978e..48d454a3 100644 --- a/src/elevenlabs/types/export_options.py +++ b/src/elevenlabs/types/export_options.py @@ -1,12 +1,13 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -from ..core.unchecked_base_model import UncheckedBaseModel + import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic import typing_extensions -from ..core.unchecked_base_model import UnionMetadata +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel, UnionMetadata class ExportOptions_Docx(UncheckedBaseModel): diff --git a/src/elevenlabs/types/extended_subscription_response_model_status.py b/src/elevenlabs/types/extended_subscription_response_model_status.py index 7ee98ba8..38146243 100644 --- a/src/elevenlabs/types/extended_subscription_response_model_status.py +++ b/src/elevenlabs/types/extended_subscription_response_model_status.py @@ -3,15 +3,6 @@ import typing ExtendedSubscriptionResponseModelStatus = typing.Union[ - typing.Literal[ - "trialing", - "active", - "incomplete", - "incomplete_expired", - "past_due", - "canceled", - "unpaid", - "free", - ], + typing.Literal["trialing", "active", "incomplete", "incomplete_expired", "past_due", "canceled", "unpaid", "free"], typing.Any, ] diff --git a/src/elevenlabs/types/feedback_item.py b/src/elevenlabs/types/feedback_item.py index 5b58eeb0..e2813950 100644 --- a/src/elevenlabs/types/feedback_item.py +++ b/src/elevenlabs/types/feedback_item.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -import pydantic import typing + +import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class FeedbackItem(UncheckedBaseModel): diff --git a/src/elevenlabs/types/final_output.py b/src/elevenlabs/types/final_output.py index c65e4667..2ad69960 100644 --- a/src/elevenlabs/types/final_output.py +++ b/src/elevenlabs/types/final_output.py @@ -1,11 +1,12 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -import typing_extensions import typing -from ..core.serialization import FieldMetadata + import pydantic +import typing_extensions from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.serialization import FieldMetadata +from ..core.unchecked_base_model import UncheckedBaseModel class FinalOutput(UncheckedBaseModel): diff --git a/src/elevenlabs/types/final_output_multi.py b/src/elevenlabs/types/final_output_multi.py index f2cee7ea..edf62760 100644 --- a/src/elevenlabs/types/final_output_multi.py +++ b/src/elevenlabs/types/final_output_multi.py @@ -1,11 +1,12 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -import typing_extensions import typing -from ..core.serialization import FieldMetadata + import pydantic +import typing_extensions from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.serialization import FieldMetadata +from ..core.unchecked_base_model import UncheckedBaseModel class FinalOutputMulti(UncheckedBaseModel): diff --git a/src/elevenlabs/types/fine_tuning_response.py b/src/elevenlabs/types/fine_tuning_response.py index d40c2cf1..a43c4d04 100644 --- a/src/elevenlabs/types/fine_tuning_response.py +++ b/src/elevenlabs/types/fine_tuning_response.py @@ -1,12 +1,13 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel from .fine_tuning_response_model_state_value import FineTuningResponseModelStateValue -from .verification_attempt_response import VerificationAttemptResponse from .manual_verification_response import ManualVerificationResponse -from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from .verification_attempt_response import VerificationAttemptResponse class FineTuningResponse(UncheckedBaseModel): diff --git a/src/elevenlabs/types/fine_tuning_response_model_state_value.py b/src/elevenlabs/types/fine_tuning_response_model_state_value.py index c15200fa..ee34c0ae 100644 --- a/src/elevenlabs/types/fine_tuning_response_model_state_value.py +++ b/src/elevenlabs/types/fine_tuning_response_model_state_value.py @@ -3,6 +3,5 @@ import typing FineTuningResponseModelStateValue = typing.Union[ - typing.Literal["not_started", "queued", "fine_tuning", "fine_tuned", "failed", "delayed"], - typing.Any, + typing.Literal["not_started", "queued", "fine_tuning", "fine_tuned", "failed", "delayed"], typing.Any ] diff --git a/src/elevenlabs/types/flush_context.py b/src/elevenlabs/types/flush_context.py index c828fe55..464f25f5 100644 --- a/src/elevenlabs/types/flush_context.py +++ b/src/elevenlabs/types/flush_context.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -import pydantic import typing + +import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class FlushContext(UncheckedBaseModel): diff --git a/src/elevenlabs/types/forced_alignment_character_response_model.py b/src/elevenlabs/types/forced_alignment_character_response_model.py index f871e9d5..9b93d249 100644 --- a/src/elevenlabs/types/forced_alignment_character_response_model.py +++ b/src/elevenlabs/types/forced_alignment_character_response_model.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel +import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import typing +from ..core.unchecked_base_model import UncheckedBaseModel class ForcedAlignmentCharacterResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/forced_alignment_response_model.py b/src/elevenlabs/types/forced_alignment_response_model.py index 16be33f0..77ee2ef8 100644 --- a/src/elevenlabs/types/forced_alignment_response_model.py +++ b/src/elevenlabs/types/forced_alignment_response_model.py @@ -1,13 +1,12 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .forced_alignment_character_response_model import ( - ForcedAlignmentCharacterResponseModel, -) + import pydantic -from .forced_alignment_word_response_model import ForcedAlignmentWordResponseModel from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .forced_alignment_character_response_model import ForcedAlignmentCharacterResponseModel +from .forced_alignment_word_response_model import ForcedAlignmentWordResponseModel class ForcedAlignmentResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/forced_alignment_word_response_model.py b/src/elevenlabs/types/forced_alignment_word_response_model.py index 7b25761e..4b4deff7 100644 --- a/src/elevenlabs/types/forced_alignment_word_response_model.py +++ b/src/elevenlabs/types/forced_alignment_word_response_model.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel +import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import typing +from ..core.unchecked_base_model import UncheckedBaseModel class ForcedAlignmentWordResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/generate_voice_request.py b/src/elevenlabs/types/generate_voice_request.py index 19332b49..3abe2daf 100644 --- a/src/elevenlabs/types/generate_voice_request.py +++ b/src/elevenlabs/types/generate_voice_request.py @@ -1,15 +1,16 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from .body_generate_a_random_voice_v_1_voice_generation_generate_voice_post_gender import ( - BodyGenerateARandomVoiceV1VoiceGenerationGenerateVoicePostGender, -) +import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel from .body_generate_a_random_voice_v_1_voice_generation_generate_voice_post_age import ( BodyGenerateARandomVoiceV1VoiceGenerationGenerateVoicePostAge, ) -from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import typing +from .body_generate_a_random_voice_v_1_voice_generation_generate_voice_post_gender import ( + BodyGenerateARandomVoiceV1VoiceGenerationGenerateVoicePostGender, +) class GenerateVoiceRequest(UncheckedBaseModel): diff --git a/src/elevenlabs/types/generation_config.py b/src/elevenlabs/types/generation_config.py index b6c7f298..0fbe517c 100644 --- a/src/elevenlabs/types/generation_config.py +++ b/src/elevenlabs/types/generation_config.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class GenerationConfig(UncheckedBaseModel): diff --git a/src/elevenlabs/types/get_agent_embed_response_model.py b/src/elevenlabs/types/get_agent_embed_response_model.py index 48808799..e108ad33 100644 --- a/src/elevenlabs/types/get_agent_embed_response_model.py +++ b/src/elevenlabs/types/get_agent_embed_response_model.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from .widget_config_response_model import WidgetConfigResponseModel -from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .widget_config_response_model import WidgetConfigResponseModel class GetAgentEmbedResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/get_agent_link_response_model.py b/src/elevenlabs/types/get_agent_link_response_model.py index 625d4bf1..2d256c35 100644 --- a/src/elevenlabs/types/get_agent_link_response_model.py +++ b/src/elevenlabs/types/get_agent_link_response_model.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -import pydantic import typing -from .conversation_token_db_model import ConversationTokenDbModel + +import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .conversation_token_db_model import ConversationTokenDbModel class GetAgentLinkResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/get_agent_response_model.py b/src/elevenlabs/types/get_agent_response_model.py index 930b3549..6e37d263 100644 --- a/src/elevenlabs/types/get_agent_response_model.py +++ b/src/elevenlabs/types/get_agent_response_model.py @@ -1,13 +1,17 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel +from __future__ import annotations + +import typing + import pydantic -from .conversational_config import ConversationalConfig +from ..core.pydantic_utilities import IS_PYDANTIC_V2, update_forward_refs +from ..core.unchecked_base_model import UncheckedBaseModel from .agent_metadata_response_model import AgentMetadataResponseModel -import typing from .agent_platform_settings_response_model import AgentPlatformSettingsResponseModel -from .get_phone_number_response import GetPhoneNumberResponse -from ..core.pydantic_utilities import IS_PYDANTIC_V2, update_forward_refs +from .conversational_config import ConversationalConfig +from .get_agent_response_model_phone_numbers_item import GetAgentResponseModelPhoneNumbersItem +from .resource_access_info import ResourceAccessInfo class GetAgentResponseModel(UncheckedBaseModel): @@ -36,11 +40,21 @@ class GetAgentResponseModel(UncheckedBaseModel): The platform settings of the agent """ - phone_numbers: typing.Optional[typing.List[GetPhoneNumberResponse]] = pydantic.Field(default=None) + phone_numbers: typing.Optional[typing.List[GetAgentResponseModelPhoneNumbersItem]] = pydantic.Field(default=None) """ The phone numbers of the agent """ + access_info: typing.Optional[ResourceAccessInfo] = pydantic.Field(default=None) + """ + The access information of the agent for the user + """ + + tags: typing.Optional[typing.List[str]] = pydantic.Field(default=None) + """ + Agent tags used to categorize the agent + """ + if IS_PYDANTIC_V2: model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 else: @@ -51,9 +65,7 @@ class Config: extra = pydantic.Extra.allow -from .array_json_schema_property_output import ArrayJsonSchemaPropertyOutput # noqa: E402 - -update_forward_refs(ArrayJsonSchemaPropertyOutput) +from .array_json_schema_property_output import ArrayJsonSchemaPropertyOutput # noqa: E402, F401, I001 +from .object_json_schema_property_output import ObjectJsonSchemaPropertyOutput # noqa: E402, F401, I001 -if IS_PYDANTIC_V2: - GetAgentResponseModel.model_rebuild() +update_forward_refs(GetAgentResponseModel) diff --git a/src/elevenlabs/types/get_agent_response_model_phone_numbers_item.py b/src/elevenlabs/types/get_agent_response_model_phone_numbers_item.py index 92388366..05c8a22a 100644 --- a/src/elevenlabs/types/get_agent_response_model_phone_numbers_item.py +++ b/src/elevenlabs/types/get_agent_response_model_phone_numbers_item.py @@ -1,14 +1,15 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -from ..core.unchecked_base_model import UncheckedBaseModel + import typing -from .phone_number_agent_info import PhoneNumberAgentInfo -from .sip_trunk_config_response_model import SipTrunkConfigResponseModel -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic import typing_extensions -from ..core.unchecked_base_model import UnionMetadata +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel, UnionMetadata +from .phone_number_agent_info import PhoneNumberAgentInfo +from .sip_trunk_config_response_model import SipTrunkConfigResponseModel class GetAgentResponseModelPhoneNumbersItem_SipTrunk(UncheckedBaseModel): @@ -47,9 +48,6 @@ class Config: GetAgentResponseModelPhoneNumbersItem = typing_extensions.Annotated[ - typing.Union[ - GetAgentResponseModelPhoneNumbersItem_SipTrunk, - GetAgentResponseModelPhoneNumbersItem_Twilio, - ], + typing.Union[GetAgentResponseModelPhoneNumbersItem_SipTrunk, GetAgentResponseModelPhoneNumbersItem_Twilio], UnionMetadata(discriminant="provider"), ] diff --git a/src/elevenlabs/types/get_agents_page_response_model.py b/src/elevenlabs/types/get_agents_page_response_model.py index 5429444d..78aa2d96 100644 --- a/src/elevenlabs/types/get_agents_page_response_model.py +++ b/src/elevenlabs/types/get_agents_page_response_model.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .agent_summary_response_model import AgentSummaryResponseModel + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .agent_summary_response_model import AgentSummaryResponseModel class GetAgentsPageResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/get_audio_native_project_settings_response_model.py b/src/elevenlabs/types/get_audio_native_project_settings_response_model.py index eb922cf3..2daa1a1f 100644 --- a/src/elevenlabs/types/get_audio_native_project_settings_response_model.py +++ b/src/elevenlabs/types/get_audio_native_project_settings_response_model.py @@ -1,12 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -import pydantic import typing -from .audio_native_project_settings_response_model import ( - AudioNativeProjectSettingsResponseModel, -) + +import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .audio_native_project_settings_response_model import AudioNativeProjectSettingsResponseModel class GetAudioNativeProjectSettingsResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/get_chapters_response.py b/src/elevenlabs/types/get_chapters_response.py index f172dc09..3d5e3833 100644 --- a/src/elevenlabs/types/get_chapters_response.py +++ b/src/elevenlabs/types/get_chapters_response.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .chapter_response import ChapterResponse -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .chapter_response import ChapterResponse class GetChaptersResponse(UncheckedBaseModel): diff --git a/src/elevenlabs/types/get_conv_ai_dashboard_settings_response_model.py b/src/elevenlabs/types/get_conv_ai_dashboard_settings_response_model.py index 4a2d7f3c..c4613b0d 100644 --- a/src/elevenlabs/types/get_conv_ai_dashboard_settings_response_model.py +++ b/src/elevenlabs/types/get_conv_ai_dashboard_settings_response_model.py @@ -1,12 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .get_conv_ai_dashboard_settings_response_model_charts_item import ( - GetConvAiDashboardSettingsResponseModelChartsItem, -) -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .get_conv_ai_dashboard_settings_response_model_charts_item import GetConvAiDashboardSettingsResponseModelChartsItem class GetConvAiDashboardSettingsResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/get_conv_ai_dashboard_settings_response_model_charts_item.py b/src/elevenlabs/types/get_conv_ai_dashboard_settings_response_model_charts_item.py index bdbfc337..a89d1aeb 100644 --- a/src/elevenlabs/types/get_conv_ai_dashboard_settings_response_model_charts_item.py +++ b/src/elevenlabs/types/get_conv_ai_dashboard_settings_response_model_charts_item.py @@ -1,12 +1,13 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -from ..core.unchecked_base_model import UncheckedBaseModel + import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic import typing_extensions -from ..core.unchecked_base_model import UnionMetadata +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel, UnionMetadata class GetConvAiDashboardSettingsResponseModelChartsItem_CallSuccess(UncheckedBaseModel): diff --git a/src/elevenlabs/types/get_conv_ai_settings_response_model.py b/src/elevenlabs/types/get_conv_ai_settings_response_model.py index 8694b4ea..48de046f 100644 --- a/src/elevenlabs/types/get_conv_ai_settings_response_model.py +++ b/src/elevenlabs/types/get_conv_ai_settings_response_model.py @@ -1,18 +1,22 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .conversation_initiation_client_data_webhook import ( - ConversationInitiationClientDataWebhook, -) -from .conv_ai_webhooks import ConvAiWebhooks -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .conv_ai_webhooks import ConvAiWebhooks +from .conversation_initiation_client_data_webhook import ConversationInitiationClientDataWebhook class GetConvAiSettingsResponseModel(UncheckedBaseModel): conversation_initiation_client_data_webhook: typing.Optional[ConversationInitiationClientDataWebhook] = None webhooks: typing.Optional[ConvAiWebhooks] = None + can_use_mcp_servers: typing.Optional[bool] = pydantic.Field(default=None) + """ + Whether the workspace can use MCP servers + """ + rag_retention_period_days: typing.Optional[int] = None if IS_PYDANTIC_V2: diff --git a/src/elevenlabs/types/get_conversation_response_model.py b/src/elevenlabs/types/get_conversation_response_model.py index 246b0f90..00373fb8 100644 --- a/src/elevenlabs/types/get_conversation_response_model.py +++ b/src/elevenlabs/types/get_conversation_response_model.py @@ -1,22 +1,15 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from .get_conversation_response_model_status import GetConversationResponseModelStatus import typing -from .conversation_history_transcript_common_model_output import ( - ConversationHistoryTranscriptCommonModelOutput, -) -from .conversation_history_metadata_common_model import ( - ConversationHistoryMetadataCommonModel, -) -from .conversation_history_analysis_common_model import ( - ConversationHistoryAnalysisCommonModel, -) -from .conversation_initiation_client_data_request_output import ( - ConversationInitiationClientDataRequestOutput, -) -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .conversation_history_analysis_common_model import ConversationHistoryAnalysisCommonModel +from .conversation_history_metadata_common_model import ConversationHistoryMetadataCommonModel +from .conversation_history_transcript_common_model_output import ConversationHistoryTranscriptCommonModelOutput +from .conversation_initiation_client_data_request_output import ConversationInitiationClientDataRequestOutput +from .get_conversation_response_model_status import GetConversationResponseModelStatus class GetConversationResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/get_conversation_response_model_status.py b/src/elevenlabs/types/get_conversation_response_model_status.py index a379e672..949b9fb7 100644 --- a/src/elevenlabs/types/get_conversation_response_model_status.py +++ b/src/elevenlabs/types/get_conversation_response_model_status.py @@ -3,5 +3,5 @@ import typing GetConversationResponseModelStatus = typing.Union[ - typing.Literal["in-progress", "processing", "done", "failed"], typing.Any + typing.Literal["initiated", "in-progress", "processing", "done", "failed"], typing.Any ] diff --git a/src/elevenlabs/types/get_conversations_page_response_model.py b/src/elevenlabs/types/get_conversations_page_response_model.py index 4deefb52..07eda444 100644 --- a/src/elevenlabs/types/get_conversations_page_response_model.py +++ b/src/elevenlabs/types/get_conversations_page_response_model.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .conversation_summary_response_model import ConversationSummaryResponseModel -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .conversation_summary_response_model import ConversationSummaryResponseModel class GetConversationsPageResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/get_knowledge_base_dependent_agents_response_model.py b/src/elevenlabs/types/get_knowledge_base_dependent_agents_response_model.py index ef229744..b2625472 100644 --- a/src/elevenlabs/types/get_knowledge_base_dependent_agents_response_model.py +++ b/src/elevenlabs/types/get_knowledge_base_dependent_agents_response_model.py @@ -1,12 +1,13 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel from .get_knowledge_base_dependent_agents_response_model_agents_item import ( GetKnowledgeBaseDependentAgentsResponseModelAgentsItem, ) -from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import pydantic class GetKnowledgeBaseDependentAgentsResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/get_knowledge_base_dependent_agents_response_model_agents_item.py b/src/elevenlabs/types/get_knowledge_base_dependent_agents_response_model_agents_item.py index d6e70044..2e5e2123 100644 --- a/src/elevenlabs/types/get_knowledge_base_dependent_agents_response_model_agents_item.py +++ b/src/elevenlabs/types/get_knowledge_base_dependent_agents_response_model_agents_item.py @@ -1,15 +1,14 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -from ..core.unchecked_base_model import UncheckedBaseModel + import typing -from .dependent_available_agent_identifier_access_level import ( - DependentAvailableAgentIdentifierAccessLevel, -) -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic import typing_extensions -from ..core.unchecked_base_model import UnionMetadata +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel, UnionMetadata +from .dependent_available_agent_identifier_access_level import DependentAvailableAgentIdentifierAccessLevel class GetKnowledgeBaseDependentAgentsResponseModelAgentsItem_Available(UncheckedBaseModel): diff --git a/src/elevenlabs/types/get_knowledge_base_file_response_model.py b/src/elevenlabs/types/get_knowledge_base_file_response_model.py index 76a380d2..b3c31d4a 100644 --- a/src/elevenlabs/types/get_knowledge_base_file_response_model.py +++ b/src/elevenlabs/types/get_knowledge_base_file_response_model.py @@ -1,13 +1,12 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from .knowledge_base_document_metadata_response_model import ( - KnowledgeBaseDocumentMetadataResponseModel, -) -from .resource_access_info import ResourceAccessInfo -from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .knowledge_base_document_metadata_response_model import KnowledgeBaseDocumentMetadataResponseModel +from .resource_access_info import ResourceAccessInfo class GetKnowledgeBaseFileResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/get_knowledge_base_list_response_model.py b/src/elevenlabs/types/get_knowledge_base_list_response_model.py index 70b9ef1a..ac55f634 100644 --- a/src/elevenlabs/types/get_knowledge_base_list_response_model.py +++ b/src/elevenlabs/types/get_knowledge_base_list_response_model.py @@ -1,12 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .get_knowledge_base_list_response_model_documents_item import ( - GetKnowledgeBaseListResponseModelDocumentsItem, -) -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .get_knowledge_base_list_response_model_documents_item import GetKnowledgeBaseListResponseModelDocumentsItem class GetKnowledgeBaseListResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/get_knowledge_base_list_response_model_documents_item.py b/src/elevenlabs/types/get_knowledge_base_list_response_model_documents_item.py index 983de7b9..e1e786cf 100644 --- a/src/elevenlabs/types/get_knowledge_base_list_response_model_documents_item.py +++ b/src/elevenlabs/types/get_knowledge_base_list_response_model_documents_item.py @@ -1,25 +1,24 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -from ..core.unchecked_base_model import UncheckedBaseModel + import typing -from .knowledge_base_document_metadata_response_model import ( - KnowledgeBaseDocumentMetadataResponseModel, -) -from .resource_access_info import ResourceAccessInfo + +import pydantic +import typing_extensions +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel, UnionMetadata from .get_knowledge_base_summary_file_response_model_dependent_agents_item import ( GetKnowledgeBaseSummaryFileResponseModelDependentAgentsItem, ) -from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import pydantic from .get_knowledge_base_summary_text_response_model_dependent_agents_item import ( GetKnowledgeBaseSummaryTextResponseModelDependentAgentsItem, ) from .get_knowledge_base_summary_url_response_model_dependent_agents_item import ( GetKnowledgeBaseSummaryUrlResponseModelDependentAgentsItem, ) -import typing_extensions -from ..core.unchecked_base_model import UnionMetadata +from .knowledge_base_document_metadata_response_model import KnowledgeBaseDocumentMetadataResponseModel +from .resource_access_info import ResourceAccessInfo class GetKnowledgeBaseListResponseModelDocumentsItem_File(UncheckedBaseModel): diff --git a/src/elevenlabs/types/get_knowledge_base_summary_file_response_model.py b/src/elevenlabs/types/get_knowledge_base_summary_file_response_model.py index 7b71c86b..0d2634f4 100644 --- a/src/elevenlabs/types/get_knowledge_base_summary_file_response_model.py +++ b/src/elevenlabs/types/get_knowledge_base_summary_file_response_model.py @@ -1,16 +1,15 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from .knowledge_base_document_metadata_response_model import ( - KnowledgeBaseDocumentMetadataResponseModel, -) -from .resource_access_info import ResourceAccessInfo import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel from .get_knowledge_base_summary_file_response_model_dependent_agents_item import ( GetKnowledgeBaseSummaryFileResponseModelDependentAgentsItem, ) -from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import pydantic +from .knowledge_base_document_metadata_response_model import KnowledgeBaseDocumentMetadataResponseModel +from .resource_access_info import ResourceAccessInfo class GetKnowledgeBaseSummaryFileResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/get_knowledge_base_summary_file_response_model_dependent_agents_item.py b/src/elevenlabs/types/get_knowledge_base_summary_file_response_model_dependent_agents_item.py index f5e4809b..426ff77f 100644 --- a/src/elevenlabs/types/get_knowledge_base_summary_file_response_model_dependent_agents_item.py +++ b/src/elevenlabs/types/get_knowledge_base_summary_file_response_model_dependent_agents_item.py @@ -1,15 +1,14 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -from ..core.unchecked_base_model import UncheckedBaseModel + import typing -from .dependent_available_agent_identifier_access_level import ( - DependentAvailableAgentIdentifierAccessLevel, -) -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic import typing_extensions -from ..core.unchecked_base_model import UnionMetadata +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel, UnionMetadata +from .dependent_available_agent_identifier_access_level import DependentAvailableAgentIdentifierAccessLevel class GetKnowledgeBaseSummaryFileResponseModelDependentAgentsItem_Available(UncheckedBaseModel): diff --git a/src/elevenlabs/types/get_knowledge_base_summary_text_response_model.py b/src/elevenlabs/types/get_knowledge_base_summary_text_response_model.py index 0092137e..8fe24ef6 100644 --- a/src/elevenlabs/types/get_knowledge_base_summary_text_response_model.py +++ b/src/elevenlabs/types/get_knowledge_base_summary_text_response_model.py @@ -1,16 +1,15 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from .knowledge_base_document_metadata_response_model import ( - KnowledgeBaseDocumentMetadataResponseModel, -) -from .resource_access_info import ResourceAccessInfo import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel from .get_knowledge_base_summary_text_response_model_dependent_agents_item import ( GetKnowledgeBaseSummaryTextResponseModelDependentAgentsItem, ) -from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import pydantic +from .knowledge_base_document_metadata_response_model import KnowledgeBaseDocumentMetadataResponseModel +from .resource_access_info import ResourceAccessInfo class GetKnowledgeBaseSummaryTextResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/get_knowledge_base_summary_text_response_model_dependent_agents_item.py b/src/elevenlabs/types/get_knowledge_base_summary_text_response_model_dependent_agents_item.py index b8aacd3c..945bc172 100644 --- a/src/elevenlabs/types/get_knowledge_base_summary_text_response_model_dependent_agents_item.py +++ b/src/elevenlabs/types/get_knowledge_base_summary_text_response_model_dependent_agents_item.py @@ -1,15 +1,14 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -from ..core.unchecked_base_model import UncheckedBaseModel + import typing -from .dependent_available_agent_identifier_access_level import ( - DependentAvailableAgentIdentifierAccessLevel, -) -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic import typing_extensions -from ..core.unchecked_base_model import UnionMetadata +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel, UnionMetadata +from .dependent_available_agent_identifier_access_level import DependentAvailableAgentIdentifierAccessLevel class GetKnowledgeBaseSummaryTextResponseModelDependentAgentsItem_Available(UncheckedBaseModel): diff --git a/src/elevenlabs/types/get_knowledge_base_summary_url_response_model.py b/src/elevenlabs/types/get_knowledge_base_summary_url_response_model.py index 7faae00e..1dbbb657 100644 --- a/src/elevenlabs/types/get_knowledge_base_summary_url_response_model.py +++ b/src/elevenlabs/types/get_knowledge_base_summary_url_response_model.py @@ -1,16 +1,15 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from .knowledge_base_document_metadata_response_model import ( - KnowledgeBaseDocumentMetadataResponseModel, -) -from .resource_access_info import ResourceAccessInfo import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel from .get_knowledge_base_summary_url_response_model_dependent_agents_item import ( GetKnowledgeBaseSummaryUrlResponseModelDependentAgentsItem, ) -from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import pydantic +from .knowledge_base_document_metadata_response_model import KnowledgeBaseDocumentMetadataResponseModel +from .resource_access_info import ResourceAccessInfo class GetKnowledgeBaseSummaryUrlResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/get_knowledge_base_summary_url_response_model_dependent_agents_item.py b/src/elevenlabs/types/get_knowledge_base_summary_url_response_model_dependent_agents_item.py index 841598db..677f4da9 100644 --- a/src/elevenlabs/types/get_knowledge_base_summary_url_response_model_dependent_agents_item.py +++ b/src/elevenlabs/types/get_knowledge_base_summary_url_response_model_dependent_agents_item.py @@ -1,15 +1,14 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -from ..core.unchecked_base_model import UncheckedBaseModel + import typing -from .dependent_available_agent_identifier_access_level import ( - DependentAvailableAgentIdentifierAccessLevel, -) -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic import typing_extensions -from ..core.unchecked_base_model import UnionMetadata +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel, UnionMetadata +from .dependent_available_agent_identifier_access_level import DependentAvailableAgentIdentifierAccessLevel class GetKnowledgeBaseSummaryUrlResponseModelDependentAgentsItem_Available(UncheckedBaseModel): diff --git a/src/elevenlabs/types/get_knowledge_base_text_response_model.py b/src/elevenlabs/types/get_knowledge_base_text_response_model.py index f98f8e0e..1b291f04 100644 --- a/src/elevenlabs/types/get_knowledge_base_text_response_model.py +++ b/src/elevenlabs/types/get_knowledge_base_text_response_model.py @@ -1,13 +1,12 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from .knowledge_base_document_metadata_response_model import ( - KnowledgeBaseDocumentMetadataResponseModel, -) -from .resource_access_info import ResourceAccessInfo -from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .knowledge_base_document_metadata_response_model import KnowledgeBaseDocumentMetadataResponseModel +from .resource_access_info import ResourceAccessInfo class GetKnowledgeBaseTextResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/get_knowledge_base_url_response_model.py b/src/elevenlabs/types/get_knowledge_base_url_response_model.py index 69b1508f..540a59ad 100644 --- a/src/elevenlabs/types/get_knowledge_base_url_response_model.py +++ b/src/elevenlabs/types/get_knowledge_base_url_response_model.py @@ -1,13 +1,12 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from .knowledge_base_document_metadata_response_model import ( - KnowledgeBaseDocumentMetadataResponseModel, -) -from .resource_access_info import ResourceAccessInfo -from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .knowledge_base_document_metadata_response_model import KnowledgeBaseDocumentMetadataResponseModel +from .resource_access_info import ResourceAccessInfo class GetKnowledgeBaseUrlResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/get_library_voices_response.py b/src/elevenlabs/types/get_library_voices_response.py index 24762451..f24a8146 100644 --- a/src/elevenlabs/types/get_library_voices_response.py +++ b/src/elevenlabs/types/get_library_voices_response.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .library_voice_response import LibraryVoiceResponse + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .library_voice_response import LibraryVoiceResponse class GetLibraryVoicesResponse(UncheckedBaseModel): diff --git a/src/elevenlabs/types/get_phone_number_sip_trunk_response_model.py b/src/elevenlabs/types/get_phone_number_sip_trunk_response_model.py index c5d85b6d..2c96691b 100644 --- a/src/elevenlabs/types/get_phone_number_sip_trunk_response_model.py +++ b/src/elevenlabs/types/get_phone_number_sip_trunk_response_model.py @@ -1,11 +1,12 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -import pydantic import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel from .phone_number_agent_info import PhoneNumberAgentInfo from .sip_trunk_config_response_model import SipTrunkConfigResponseModel -from ..core.pydantic_utilities import IS_PYDANTIC_V2 class GetPhoneNumberSipTrunkResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/get_phone_number_twilio_response_model.py b/src/elevenlabs/types/get_phone_number_twilio_response_model.py index f7c1d297..f00a84aa 100644 --- a/src/elevenlabs/types/get_phone_number_twilio_response_model.py +++ b/src/elevenlabs/types/get_phone_number_twilio_response_model.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -import pydantic import typing -from .phone_number_agent_info import PhoneNumberAgentInfo + +import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .phone_number_agent_info import PhoneNumberAgentInfo class GetPhoneNumberTwilioResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/get_projects_response.py b/src/elevenlabs/types/get_projects_response.py index d9be69f2..76b8052b 100644 --- a/src/elevenlabs/types/get_projects_response.py +++ b/src/elevenlabs/types/get_projects_response.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .project_response import ProjectResponse + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .project_response import ProjectResponse class GetProjectsResponse(UncheckedBaseModel): diff --git a/src/elevenlabs/types/get_pronunciation_dictionaries_metadata_response_model.py b/src/elevenlabs/types/get_pronunciation_dictionaries_metadata_response_model.py index ef70ca24..1cac99a8 100644 --- a/src/elevenlabs/types/get_pronunciation_dictionaries_metadata_response_model.py +++ b/src/elevenlabs/types/get_pronunciation_dictionaries_metadata_response_model.py @@ -1,12 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .get_pronunciation_dictionary_metadata_response import ( - GetPronunciationDictionaryMetadataResponse, -) + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .get_pronunciation_dictionary_metadata_response import GetPronunciationDictionaryMetadataResponse class GetPronunciationDictionariesMetadataResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/get_pronunciation_dictionary_metadata_response.py b/src/elevenlabs/types/get_pronunciation_dictionary_metadata_response.py index e4dc7c4f..35e022c7 100644 --- a/src/elevenlabs/types/get_pronunciation_dictionary_metadata_response.py +++ b/src/elevenlabs/types/get_pronunciation_dictionary_metadata_response.py @@ -1,12 +1,13 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -import pydantic import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel from .get_pronunciation_dictionary_metadata_response_model_permission_on_resource import ( GetPronunciationDictionaryMetadataResponseModelPermissionOnResource, ) -from ..core.pydantic_utilities import IS_PYDANTIC_V2 class GetPronunciationDictionaryMetadataResponse(UncheckedBaseModel): diff --git a/src/elevenlabs/types/get_speech_history_response.py b/src/elevenlabs/types/get_speech_history_response.py index 7f324927..609fda3c 100644 --- a/src/elevenlabs/types/get_speech_history_response.py +++ b/src/elevenlabs/types/get_speech_history_response.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .speech_history_item_response import SpeechHistoryItemResponse + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .speech_history_item_response import SpeechHistoryItemResponse class GetSpeechHistoryResponse(UncheckedBaseModel): diff --git a/src/elevenlabs/types/get_voices_response.py b/src/elevenlabs/types/get_voices_response.py index 2bbc47c6..2065c2ee 100644 --- a/src/elevenlabs/types/get_voices_response.py +++ b/src/elevenlabs/types/get_voices_response.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .voice import Voice + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .voice import Voice class GetVoicesResponse(UncheckedBaseModel): diff --git a/src/elevenlabs/types/get_voices_v_2_response.py b/src/elevenlabs/types/get_voices_v_2_response.py index 89119427..d7018b3a 100644 --- a/src/elevenlabs/types/get_voices_v_2_response.py +++ b/src/elevenlabs/types/get_voices_v_2_response.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .voice import Voice -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .voice import Voice class GetVoicesV2Response(UncheckedBaseModel): diff --git a/src/elevenlabs/types/get_workspace_secrets_response_model.py b/src/elevenlabs/types/get_workspace_secrets_response_model.py index bf8d43ea..a189fa14 100644 --- a/src/elevenlabs/types/get_workspace_secrets_response_model.py +++ b/src/elevenlabs/types/get_workspace_secrets_response_model.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .conv_ai_workspace_stored_secret_config import ConvAiWorkspaceStoredSecretConfig -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .conv_ai_workspace_stored_secret_config import ConvAiWorkspaceStoredSecretConfig class GetWorkspaceSecretsResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/history_alignment_response_model.py b/src/elevenlabs/types/history_alignment_response_model.py index e34a9c24..b393b924 100644 --- a/src/elevenlabs/types/history_alignment_response_model.py +++ b/src/elevenlabs/types/history_alignment_response_model.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class HistoryAlignmentResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/history_alignments_response_model.py b/src/elevenlabs/types/history_alignments_response_model.py index 9b8715b5..c8e57b38 100644 --- a/src/elevenlabs/types/history_alignments_response_model.py +++ b/src/elevenlabs/types/history_alignments_response_model.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from .history_alignment_response_model import HistoryAlignmentResponseModel +import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import typing +from ..core.unchecked_base_model import UncheckedBaseModel +from .history_alignment_response_model import HistoryAlignmentResponseModel class HistoryAlignmentsResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/history_item_response.py b/src/elevenlabs/types/history_item_response.py index 0a5aff62..6e6bbb81 100644 --- a/src/elevenlabs/types/history_item_response.py +++ b/src/elevenlabs/types/history_item_response.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class HistoryItemResponse(UncheckedBaseModel): diff --git a/src/elevenlabs/types/html_export_options.py b/src/elevenlabs/types/html_export_options.py index ddeded3d..8121cc47 100644 --- a/src/elevenlabs/types/html_export_options.py +++ b/src/elevenlabs/types/html_export_options.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class HtmlExportOptions(UncheckedBaseModel): diff --git a/src/elevenlabs/types/http_validation_error.py b/src/elevenlabs/types/http_validation_error.py index 5449e986..188935a0 100644 --- a/src/elevenlabs/types/http_validation_error.py +++ b/src/elevenlabs/types/http_validation_error.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .validation_error import ValidationError -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .validation_error import ValidationError class HttpValidationError(UncheckedBaseModel): diff --git a/src/elevenlabs/types/image_avatar.py b/src/elevenlabs/types/image_avatar.py index 17ef2612..4104991c 100644 --- a/src/elevenlabs/types/image_avatar.py +++ b/src/elevenlabs/types/image_avatar.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class ImageAvatar(UncheckedBaseModel): diff --git a/src/elevenlabs/types/initialise_context.py b/src/elevenlabs/types/initialise_context.py index d80b9f97..725e8c0d 100644 --- a/src/elevenlabs/types/initialise_context.py +++ b/src/elevenlabs/types/initialise_context.py @@ -1,12 +1,13 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -import pydantic import typing -from .realtime_voice_settings import RealtimeVoiceSettings + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel from .generation_config import GenerationConfig from .pronunciation_dictionary_locator import PronunciationDictionaryLocator -from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from .realtime_voice_settings import RealtimeVoiceSettings class InitialiseContext(UncheckedBaseModel): diff --git a/src/elevenlabs/types/initialize_connection.py b/src/elevenlabs/types/initialize_connection.py index effd0e09..8c6b4021 100644 --- a/src/elevenlabs/types/initialize_connection.py +++ b/src/elevenlabs/types/initialize_connection.py @@ -1,14 +1,15 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing + import pydantic -from .realtime_voice_settings import RealtimeVoiceSettings -from .generation_config import GenerationConfig -from .pronunciation_dictionary_locator import PronunciationDictionaryLocator import typing_extensions -from ..core.serialization import FieldMetadata from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.serialization import FieldMetadata +from ..core.unchecked_base_model import UncheckedBaseModel +from .generation_config import GenerationConfig +from .pronunciation_dictionary_locator import PronunciationDictionaryLocator +from .realtime_voice_settings import RealtimeVoiceSettings class InitializeConnection(UncheckedBaseModel): diff --git a/src/elevenlabs/types/initialize_connection_multi.py b/src/elevenlabs/types/initialize_connection_multi.py index e792c301..cb4b89db 100644 --- a/src/elevenlabs/types/initialize_connection_multi.py +++ b/src/elevenlabs/types/initialize_connection_multi.py @@ -1,12 +1,13 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing + import pydantic -from .realtime_voice_settings import RealtimeVoiceSettings +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel from .generation_config import GenerationConfig from .pronunciation_dictionary_locator import PronunciationDictionaryLocator -from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from .realtime_voice_settings import RealtimeVoiceSettings class InitializeConnectionMulti(UncheckedBaseModel): diff --git a/src/elevenlabs/types/invoice_response.py b/src/elevenlabs/types/invoice_response.py index 7360db8b..df98b103 100644 --- a/src/elevenlabs/types/invoice_response.py +++ b/src/elevenlabs/types/invoice_response.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -import pydantic import typing + +import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class InvoiceResponse(UncheckedBaseModel): diff --git a/src/elevenlabs/types/keep_context_alive.py b/src/elevenlabs/types/keep_context_alive.py index 7cbe0a2f..5ffff32a 100644 --- a/src/elevenlabs/types/keep_context_alive.py +++ b/src/elevenlabs/types/keep_context_alive.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class KeepContextAlive(UncheckedBaseModel): diff --git a/src/elevenlabs/types/knowledge_base_document_chunk_response_model.py b/src/elevenlabs/types/knowledge_base_document_chunk_response_model.py index 37534c3a..61b317d2 100644 --- a/src/elevenlabs/types/knowledge_base_document_chunk_response_model.py +++ b/src/elevenlabs/types/knowledge_base_document_chunk_response_model.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class KnowledgeBaseDocumentChunkResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/knowledge_base_document_metadata_response_model.py b/src/elevenlabs/types/knowledge_base_document_metadata_response_model.py index 702060e7..883f83cd 100644 --- a/src/elevenlabs/types/knowledge_base_document_metadata_response_model.py +++ b/src/elevenlabs/types/knowledge_base_document_metadata_response_model.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class KnowledgeBaseDocumentMetadataResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/knowledge_base_locator.py b/src/elevenlabs/types/knowledge_base_locator.py index df8f0599..f7c23635 100644 --- a/src/elevenlabs/types/knowledge_base_locator.py +++ b/src/elevenlabs/types/knowledge_base_locator.py @@ -1,11 +1,12 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from .knowledge_base_document_type import KnowledgeBaseDocumentType -import pydantic import typing -from .document_usage_mode_enum import DocumentUsageModeEnum + +import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .document_usage_mode_enum import DocumentUsageModeEnum +from .knowledge_base_document_type import KnowledgeBaseDocumentType class KnowledgeBaseLocator(UncheckedBaseModel): diff --git a/src/elevenlabs/types/language_added_response.py b/src/elevenlabs/types/language_added_response.py index 7611ef95..c689f04e 100644 --- a/src/elevenlabs/types/language_added_response.py +++ b/src/elevenlabs/types/language_added_response.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class LanguageAddedResponse(UncheckedBaseModel): diff --git a/src/elevenlabs/types/language_detection_tool_config.py b/src/elevenlabs/types/language_detection_tool_config.py index 248c0084..5c00bcf4 100644 --- a/src/elevenlabs/types/language_detection_tool_config.py +++ b/src/elevenlabs/types/language_detection_tool_config.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class LanguageDetectionToolConfig(UncheckedBaseModel): diff --git a/src/elevenlabs/types/language_preset_input.py b/src/elevenlabs/types/language_preset_input.py index b5961c60..9559254d 100644 --- a/src/elevenlabs/types/language_preset_input.py +++ b/src/elevenlabs/types/language_preset_input.py @@ -1,13 +1,12 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from .conversation_config_client_override_input import ( - ConversationConfigClientOverrideInput, -) -import pydantic import typing -from .language_preset_translation import LanguagePresetTranslation + +import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .conversation_config_client_override_input import ConversationConfigClientOverrideInput +from .language_preset_translation import LanguagePresetTranslation class LanguagePresetInput(UncheckedBaseModel): diff --git a/src/elevenlabs/types/language_preset_output.py b/src/elevenlabs/types/language_preset_output.py index 1826251b..86ce3934 100644 --- a/src/elevenlabs/types/language_preset_output.py +++ b/src/elevenlabs/types/language_preset_output.py @@ -1,13 +1,12 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from .conversation_config_client_override_output import ( - ConversationConfigClientOverrideOutput, -) -import pydantic import typing -from .language_preset_translation import LanguagePresetTranslation + +import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .conversation_config_client_override_output import ConversationConfigClientOverrideOutput +from .language_preset_translation import LanguagePresetTranslation class LanguagePresetOutput(UncheckedBaseModel): diff --git a/src/elevenlabs/types/language_preset_translation.py b/src/elevenlabs/types/language_preset_translation.py index a7367bd5..644a9174 100644 --- a/src/elevenlabs/types/language_preset_translation.py +++ b/src/elevenlabs/types/language_preset_translation.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class LanguagePresetTranslation(UncheckedBaseModel): diff --git a/src/elevenlabs/types/language_response.py b/src/elevenlabs/types/language_response.py index ae2648b9..c6db2cf6 100644 --- a/src/elevenlabs/types/language_response.py +++ b/src/elevenlabs/types/language_response.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel +import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import typing +from ..core.unchecked_base_model import UncheckedBaseModel class LanguageResponse(UncheckedBaseModel): diff --git a/src/elevenlabs/types/library_voice_response.py b/src/elevenlabs/types/library_voice_response.py index 31411724..fb5b71e7 100644 --- a/src/elevenlabs/types/library_voice_response.py +++ b/src/elevenlabs/types/library_voice_response.py @@ -1,13 +1,14 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -import pydantic -from .library_voice_response_model_category import LibraryVoiceResponseModelCategory import typing + +import pydantic import typing_extensions +from ..core.pydantic_utilities import IS_PYDANTIC_V2 from ..core.serialization import FieldMetadata +from ..core.unchecked_base_model import UncheckedBaseModel +from .library_voice_response_model_category import LibraryVoiceResponseModelCategory from .verified_voice_language_response_model import VerifiedVoiceLanguageResponseModel -from ..core.pydantic_utilities import IS_PYDANTIC_V2 class LibraryVoiceResponse(UncheckedBaseModel): @@ -109,7 +110,12 @@ class LibraryVoiceResponse(UncheckedBaseModel): rate: typing.Optional[float] = pydantic.Field(default=None) """ - The rate of the voice. + The rate multiplier of the voice. + """ + + fiat_rate: typing.Optional[float] = pydantic.Field(default=None) + """ + The rate of the voice in USD per 1000 credits. null if default """ free_users_allowed: bool = pydantic.Field() diff --git a/src/elevenlabs/types/library_voice_response_model_category.py b/src/elevenlabs/types/library_voice_response_model_category.py index 4af8147c..7d3d40fe 100644 --- a/src/elevenlabs/types/library_voice_response_model_category.py +++ b/src/elevenlabs/types/library_voice_response_model_category.py @@ -3,6 +3,5 @@ import typing LibraryVoiceResponseModelCategory = typing.Union[ - typing.Literal["generated", "cloned", "premade", "professional", "famous", "high_quality"], - typing.Any, + typing.Literal["generated", "cloned", "premade", "professional", "famous", "high_quality"], typing.Any ] diff --git a/src/elevenlabs/types/literal_json_schema_property.py b/src/elevenlabs/types/literal_json_schema_property.py index c3ce7679..6d45c31d 100644 --- a/src/elevenlabs/types/literal_json_schema_property.py +++ b/src/elevenlabs/types/literal_json_schema_property.py @@ -1,13 +1,12 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from .literal_json_schema_property_type import LiteralJsonSchemaPropertyType import typing + import pydantic -from .literal_json_schema_property_constant_value import ( - LiteralJsonSchemaPropertyConstantValue, -) from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .literal_json_schema_property_constant_value import LiteralJsonSchemaPropertyConstantValue +from .literal_json_schema_property_type import LiteralJsonSchemaPropertyType class LiteralJsonSchemaProperty(UncheckedBaseModel): diff --git a/src/elevenlabs/types/llm_category_usage.py b/src/elevenlabs/types/llm_category_usage.py index 0ead264f..715de809 100644 --- a/src/elevenlabs/types/llm_category_usage.py +++ b/src/elevenlabs/types/llm_category_usage.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .llm_usage_output import LlmUsageOutput -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .llm_usage_output import LlmUsageOutput class LlmCategoryUsage(UncheckedBaseModel): diff --git a/src/elevenlabs/types/llm_input_output_tokens_usage.py b/src/elevenlabs/types/llm_input_output_tokens_usage.py index fd6179ed..009b9151 100644 --- a/src/elevenlabs/types/llm_input_output_tokens_usage.py +++ b/src/elevenlabs/types/llm_input_output_tokens_usage.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .llm_tokens_category_usage import LlmTokensCategoryUsage -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .llm_tokens_category_usage import LlmTokensCategoryUsage class LlmInputOutputTokensUsage(UncheckedBaseModel): diff --git a/src/elevenlabs/types/llm_tokens_category_usage.py b/src/elevenlabs/types/llm_tokens_category_usage.py index ebc78548..823d6e22 100644 --- a/src/elevenlabs/types/llm_tokens_category_usage.py +++ b/src/elevenlabs/types/llm_tokens_category_usage.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class LlmTokensCategoryUsage(UncheckedBaseModel): diff --git a/src/elevenlabs/types/llm_usage_input.py b/src/elevenlabs/types/llm_usage_input.py index 07b5b155..8ab42b20 100644 --- a/src/elevenlabs/types/llm_usage_input.py +++ b/src/elevenlabs/types/llm_usage_input.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .llm_input_output_tokens_usage import LlmInputOutputTokensUsage -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .llm_input_output_tokens_usage import LlmInputOutputTokensUsage class LlmUsageInput(UncheckedBaseModel): diff --git a/src/elevenlabs/types/llm_usage_output.py b/src/elevenlabs/types/llm_usage_output.py index d36cf769..80f93404 100644 --- a/src/elevenlabs/types/llm_usage_output.py +++ b/src/elevenlabs/types/llm_usage_output.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .llm_input_output_tokens_usage import LlmInputOutputTokensUsage -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .llm_input_output_tokens_usage import LlmInputOutputTokensUsage class LlmUsageOutput(UncheckedBaseModel): diff --git a/src/elevenlabs/types/manual_verification_file_response.py b/src/elevenlabs/types/manual_verification_file_response.py index 6fee3ecd..62a667d7 100644 --- a/src/elevenlabs/types/manual_verification_file_response.py +++ b/src/elevenlabs/types/manual_verification_file_response.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel +import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import typing +from ..core.unchecked_base_model import UncheckedBaseModel class ManualVerificationFileResponse(UncheckedBaseModel): diff --git a/src/elevenlabs/types/manual_verification_response.py b/src/elevenlabs/types/manual_verification_response.py index a85e4d92..524c7ffd 100644 --- a/src/elevenlabs/types/manual_verification_response.py +++ b/src/elevenlabs/types/manual_verification_response.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -import pydantic import typing -from .manual_verification_file_response import ManualVerificationFileResponse + +import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .manual_verification_file_response import ManualVerificationFileResponse class ManualVerificationResponse(UncheckedBaseModel): diff --git a/src/elevenlabs/types/mcp_tool_config_input.py b/src/elevenlabs/types/mcp_tool_config_input.py index a8b9e71c..453f31fe 100644 --- a/src/elevenlabs/types/mcp_tool_config_input.py +++ b/src/elevenlabs/types/mcp_tool_config_input.py @@ -1,11 +1,12 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from .array_json_schema_property_input import ArrayJsonSchemaPropertyInput -from .object_json_schema_property_input import ObjectJsonSchemaPropertyInput +from __future__ import annotations + import typing + import pydantic -from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.pydantic_utilities import IS_PYDANTIC_V2, update_forward_refs +from ..core.unchecked_base_model import UncheckedBaseModel class McpToolConfigInput(UncheckedBaseModel): @@ -21,7 +22,7 @@ class McpToolConfigInput(UncheckedBaseModel): The maximum time in seconds to wait for the tool call to complete. """ - parameters: typing.Optional[ObjectJsonSchemaPropertyInput] = pydantic.Field(default=None) + parameters: typing.Optional["ObjectJsonSchemaPropertyInput"] = pydantic.Field(default=None) """ Schema for any parameters the LLM needs to provide to the MCP tool. """ @@ -44,3 +45,9 @@ class Config: frozen = True smart_union = True extra = pydantic.Extra.allow + + +from .array_json_schema_property_input import ArrayJsonSchemaPropertyInput # noqa: E402, F401, I001 +from .object_json_schema_property_input import ObjectJsonSchemaPropertyInput # noqa: E402, F401, I001 + +update_forward_refs(McpToolConfigInput) diff --git a/src/elevenlabs/types/mcp_tool_config_output.py b/src/elevenlabs/types/mcp_tool_config_output.py index 57964a2f..d347aec2 100644 --- a/src/elevenlabs/types/mcp_tool_config_output.py +++ b/src/elevenlabs/types/mcp_tool_config_output.py @@ -1,11 +1,12 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from .array_json_schema_property_output import ArrayJsonSchemaPropertyOutput -from .object_json_schema_property_output import ObjectJsonSchemaPropertyOutput +from __future__ import annotations + import typing + import pydantic -from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.pydantic_utilities import IS_PYDANTIC_V2, update_forward_refs +from ..core.unchecked_base_model import UncheckedBaseModel class McpToolConfigOutput(UncheckedBaseModel): @@ -21,7 +22,7 @@ class McpToolConfigOutput(UncheckedBaseModel): The maximum time in seconds to wait for the tool call to complete. """ - parameters: typing.Optional[ObjectJsonSchemaPropertyOutput] = pydantic.Field(default=None) + parameters: typing.Optional["ObjectJsonSchemaPropertyOutput"] = pydantic.Field(default=None) """ Schema for any parameters the LLM needs to provide to the MCP tool. """ @@ -44,3 +45,9 @@ class Config: frozen = True smart_union = True extra = pydantic.Extra.allow + + +from .array_json_schema_property_output import ArrayJsonSchemaPropertyOutput # noqa: E402, F401, I001 +from .object_json_schema_property_output import ObjectJsonSchemaPropertyOutput # noqa: E402, F401, I001 + +update_forward_refs(McpToolConfigOutput) diff --git a/src/elevenlabs/types/metric_record.py b/src/elevenlabs/types/metric_record.py index b7da1126..96a2af6a 100644 --- a/src/elevenlabs/types/metric_record.py +++ b/src/elevenlabs/types/metric_record.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class MetricRecord(UncheckedBaseModel): diff --git a/src/elevenlabs/types/metric_type.py b/src/elevenlabs/types/metric_type.py index 0e70895d..5263d4b3 100644 --- a/src/elevenlabs/types/metric_type.py +++ b/src/elevenlabs/types/metric_type.py @@ -3,13 +3,5 @@ import typing MetricType = typing.Union[ - typing.Literal[ - "credits", - "minutes_used", - "request_count", - "ttfb_avg", - "ttfb_p95", - "fiat_units_spent", - ], - typing.Any, + typing.Literal["credits", "minutes_used", "request_count", "ttfb_avg", "ttfb_p95", "fiat_units_spent"], typing.Any ] diff --git a/src/elevenlabs/types/model.py b/src/elevenlabs/types/model.py index 41fbb0df..9148279f 100644 --- a/src/elevenlabs/types/model.py +++ b/src/elevenlabs/types/model.py @@ -1,12 +1,13 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -import pydantic import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel from .language_response import LanguageResponse from .model_rates_response_model import ModelRatesResponseModel from .model_response_model_concurrency_group import ModelResponseModelConcurrencyGroup -from ..core.pydantic_utilities import IS_PYDANTIC_V2 class Model(UncheckedBaseModel): diff --git a/src/elevenlabs/types/model_rates_response_model.py b/src/elevenlabs/types/model_rates_response_model.py index fe0403f0..ea537201 100644 --- a/src/elevenlabs/types/model_rates_response_model.py +++ b/src/elevenlabs/types/model_rates_response_model.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel +import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import typing +from ..core.unchecked_base_model import UncheckedBaseModel class ModelRatesResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/moderation_status_response_model.py b/src/elevenlabs/types/moderation_status_response_model.py index ddff105b..e3522896 100644 --- a/src/elevenlabs/types/moderation_status_response_model.py +++ b/src/elevenlabs/types/moderation_status_response_model.py @@ -1,15 +1,12 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -import pydantic import typing -from .moderation_status_response_model_safety_status import ( - ModerationStatusResponseModelSafetyStatus, -) -from .moderation_status_response_model_warning_status import ( - ModerationStatusResponseModelWarningStatus, -) + +import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .moderation_status_response_model_safety_status import ModerationStatusResponseModelSafetyStatus +from .moderation_status_response_model_warning_status import ModerationStatusResponseModelWarningStatus class ModerationStatusResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/normalized_alignment.py b/src/elevenlabs/types/normalized_alignment.py index 080e09b8..0ff62b8e 100644 --- a/src/elevenlabs/types/normalized_alignment.py +++ b/src/elevenlabs/types/normalized_alignment.py @@ -1,11 +1,12 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -import typing_extensions import typing -from ..core.serialization import FieldMetadata + import pydantic +import typing_extensions from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.serialization import FieldMetadata +from ..core.unchecked_base_model import UncheckedBaseModel class NormalizedAlignment(UncheckedBaseModel): diff --git a/src/elevenlabs/types/object_json_schema_property_input.py b/src/elevenlabs/types/object_json_schema_property_input.py index 4ae2b0cf..5e23b6f4 100644 --- a/src/elevenlabs/types/object_json_schema_property_input.py +++ b/src/elevenlabs/types/object_json_schema_property_input.py @@ -1,11 +1,12 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -from ..core.unchecked_base_model import UncheckedBaseModel + import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic -from ..core.pydantic_utilities import update_forward_refs +from ..core.pydantic_utilities import IS_PYDANTIC_V2, update_forward_refs +from ..core.unchecked_base_model import UncheckedBaseModel class ObjectJsonSchemaPropertyInput(UncheckedBaseModel): @@ -24,8 +25,6 @@ class Config: extra = pydantic.Extra.allow -from .object_json_schema_property_input_properties_value import ( - ObjectJsonSchemaPropertyInputPropertiesValue, -) # noqa: E402 +from .object_json_schema_property_input_properties_value import ObjectJsonSchemaPropertyInputPropertiesValue # noqa: E402, F401, I001 update_forward_refs(ObjectJsonSchemaPropertyInput) diff --git a/src/elevenlabs/types/object_json_schema_property_input_properties_value.py b/src/elevenlabs/types/object_json_schema_property_input_properties_value.py index bc19e900..c423b0ae 100644 --- a/src/elevenlabs/types/object_json_schema_property_input_properties_value.py +++ b/src/elevenlabs/types/object_json_schema_property_input_properties_value.py @@ -1,15 +1,14 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations + import typing + from .literal_json_schema_property import LiteralJsonSchemaProperty -import typing if typing.TYPE_CHECKING: - from .object_json_schema_property_input import ObjectJsonSchemaPropertyInput from .array_json_schema_property_input import ArrayJsonSchemaPropertyInput + from .object_json_schema_property_input import ObjectJsonSchemaPropertyInput ObjectJsonSchemaPropertyInputPropertiesValue = typing.Union[ - LiteralJsonSchemaProperty, - "ObjectJsonSchemaPropertyInput", - "ArrayJsonSchemaPropertyInput", + LiteralJsonSchemaProperty, "ObjectJsonSchemaPropertyInput", "ArrayJsonSchemaPropertyInput" ] diff --git a/src/elevenlabs/types/object_json_schema_property_output.py b/src/elevenlabs/types/object_json_schema_property_output.py index fccd366f..0786bccb 100644 --- a/src/elevenlabs/types/object_json_schema_property_output.py +++ b/src/elevenlabs/types/object_json_schema_property_output.py @@ -1,11 +1,12 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -from ..core.unchecked_base_model import UncheckedBaseModel + import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic -from ..core.pydantic_utilities import update_forward_refs +from ..core.pydantic_utilities import IS_PYDANTIC_V2, update_forward_refs +from ..core.unchecked_base_model import UncheckedBaseModel class ObjectJsonSchemaPropertyOutput(UncheckedBaseModel): @@ -24,8 +25,6 @@ class Config: extra = pydantic.Extra.allow -from .object_json_schema_property_output_properties_value import ( - ObjectJsonSchemaPropertyOutputPropertiesValue, -) # noqa: E402 +from .object_json_schema_property_output_properties_value import ObjectJsonSchemaPropertyOutputPropertiesValue # noqa: E402, F401, I001 update_forward_refs(ObjectJsonSchemaPropertyOutput) diff --git a/src/elevenlabs/types/object_json_schema_property_output_properties_value.py b/src/elevenlabs/types/object_json_schema_property_output_properties_value.py index 1eca157e..bb463ec9 100644 --- a/src/elevenlabs/types/object_json_schema_property_output_properties_value.py +++ b/src/elevenlabs/types/object_json_schema_property_output_properties_value.py @@ -1,15 +1,14 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations + import typing + from .literal_json_schema_property import LiteralJsonSchemaProperty -import typing if typing.TYPE_CHECKING: - from .object_json_schema_property_output import ObjectJsonSchemaPropertyOutput from .array_json_schema_property_output import ArrayJsonSchemaPropertyOutput + from .object_json_schema_property_output import ObjectJsonSchemaPropertyOutput ObjectJsonSchemaPropertyOutputPropertiesValue = typing.Union[ - LiteralJsonSchemaProperty, - "ObjectJsonSchemaPropertyOutput", - "ArrayJsonSchemaPropertyOutput", + LiteralJsonSchemaProperty, "ObjectJsonSchemaPropertyOutput", "ArrayJsonSchemaPropertyOutput" ] diff --git a/src/elevenlabs/types/orb_avatar.py b/src/elevenlabs/types/orb_avatar.py index 7b2f9af0..d2d1bdff 100644 --- a/src/elevenlabs/types/orb_avatar.py +++ b/src/elevenlabs/types/orb_avatar.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class OrbAvatar(UncheckedBaseModel): diff --git a/src/elevenlabs/types/outbound_call_recipient.py b/src/elevenlabs/types/outbound_call_recipient.py new file mode 100644 index 00000000..34a1cdd1 --- /dev/null +++ b/src/elevenlabs/types/outbound_call_recipient.py @@ -0,0 +1,23 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .conversation_initiation_client_data_request_input import ConversationInitiationClientDataRequestInput + + +class OutboundCallRecipient(UncheckedBaseModel): + id: typing.Optional[str] = None + phone_number: str + conversation_initiation_client_data: typing.Optional[ConversationInitiationClientDataRequestInput] = None + + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 + else: + + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/elevenlabs/types/outbound_call_recipient_response_model.py b/src/elevenlabs/types/outbound_call_recipient_response_model.py index 192ebf80..d29bec68 100644 --- a/src/elevenlabs/types/outbound_call_recipient_response_model.py +++ b/src/elevenlabs/types/outbound_call_recipient_response_model.py @@ -1,13 +1,12 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from .batch_call_recipient_status import BatchCallRecipientStatus import typing -from .conversation_initiation_client_data_internal import ( - ConversationInitiationClientDataInternal, -) -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .batch_call_recipient_status import BatchCallRecipientStatus +from .conversation_initiation_client_data_internal import ConversationInitiationClientDataInternal class OutboundCallRecipientResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/pdf_export_options.py b/src/elevenlabs/types/pdf_export_options.py index d80f4514..bdebc7dc 100644 --- a/src/elevenlabs/types/pdf_export_options.py +++ b/src/elevenlabs/types/pdf_export_options.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class PdfExportOptions(UncheckedBaseModel): diff --git a/src/elevenlabs/types/phone_number_agent_info.py b/src/elevenlabs/types/phone_number_agent_info.py index c531d981..555f898d 100644 --- a/src/elevenlabs/types/phone_number_agent_info.py +++ b/src/elevenlabs/types/phone_number_agent_info.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel +import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import typing +from ..core.unchecked_base_model import UncheckedBaseModel class PhoneNumberAgentInfo(UncheckedBaseModel): diff --git a/src/elevenlabs/types/phone_number_transfer.py b/src/elevenlabs/types/phone_number_transfer.py index b1e84c56..74258c17 100644 --- a/src/elevenlabs/types/phone_number_transfer.py +++ b/src/elevenlabs/types/phone_number_transfer.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class PhoneNumberTransfer(UncheckedBaseModel): diff --git a/src/elevenlabs/types/podcast_bulletin_mode.py b/src/elevenlabs/types/podcast_bulletin_mode.py index 270f8490..0679d343 100644 --- a/src/elevenlabs/types/podcast_bulletin_mode.py +++ b/src/elevenlabs/types/podcast_bulletin_mode.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from .podcast_bulletin_mode_data import PodcastBulletinModeData +import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import typing +from ..core.unchecked_base_model import UncheckedBaseModel +from .podcast_bulletin_mode_data import PodcastBulletinModeData class PodcastBulletinMode(UncheckedBaseModel): diff --git a/src/elevenlabs/types/podcast_bulletin_mode_data.py b/src/elevenlabs/types/podcast_bulletin_mode_data.py index 2bd0766c..d2f0d3eb 100644 --- a/src/elevenlabs/types/podcast_bulletin_mode_data.py +++ b/src/elevenlabs/types/podcast_bulletin_mode_data.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel +import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import typing +from ..core.unchecked_base_model import UncheckedBaseModel class PodcastBulletinModeData(UncheckedBaseModel): diff --git a/src/elevenlabs/types/podcast_conversation_mode.py b/src/elevenlabs/types/podcast_conversation_mode.py index ed013a27..2b9d2b1a 100644 --- a/src/elevenlabs/types/podcast_conversation_mode.py +++ b/src/elevenlabs/types/podcast_conversation_mode.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from .podcast_conversation_mode_data import PodcastConversationModeData +import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import typing +from ..core.unchecked_base_model import UncheckedBaseModel +from .podcast_conversation_mode_data import PodcastConversationModeData class PodcastConversationMode(UncheckedBaseModel): diff --git a/src/elevenlabs/types/podcast_conversation_mode_data.py b/src/elevenlabs/types/podcast_conversation_mode_data.py index 2273f5f9..96d8940a 100644 --- a/src/elevenlabs/types/podcast_conversation_mode_data.py +++ b/src/elevenlabs/types/podcast_conversation_mode_data.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel +import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import typing +from ..core.unchecked_base_model import UncheckedBaseModel class PodcastConversationModeData(UncheckedBaseModel): diff --git a/src/elevenlabs/types/podcast_project_response_model.py b/src/elevenlabs/types/podcast_project_response_model.py index 53f028a7..7f8792dd 100644 --- a/src/elevenlabs/types/podcast_project_response_model.py +++ b/src/elevenlabs/types/podcast_project_response_model.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from .project_response import ProjectResponse +import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import typing +from ..core.unchecked_base_model import UncheckedBaseModel +from .project_response import ProjectResponse class PodcastProjectResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/podcast_text_source.py b/src/elevenlabs/types/podcast_text_source.py index b6f0d077..de555cf8 100644 --- a/src/elevenlabs/types/podcast_text_source.py +++ b/src/elevenlabs/types/podcast_text_source.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel +import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import typing +from ..core.unchecked_base_model import UncheckedBaseModel class PodcastTextSource(UncheckedBaseModel): diff --git a/src/elevenlabs/types/podcast_url_source.py b/src/elevenlabs/types/podcast_url_source.py index c49abedd..add47a4f 100644 --- a/src/elevenlabs/types/podcast_url_source.py +++ b/src/elevenlabs/types/podcast_url_source.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel +import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import typing +from ..core.unchecked_base_model import UncheckedBaseModel class PodcastUrlSource(UncheckedBaseModel): diff --git a/src/elevenlabs/types/post_agent_avatar_response_model.py b/src/elevenlabs/types/post_agent_avatar_response_model.py index 3b56a774..59f06c1d 100644 --- a/src/elevenlabs/types/post_agent_avatar_response_model.py +++ b/src/elevenlabs/types/post_agent_avatar_response_model.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class PostAgentAvatarResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/post_workspace_secret_response_model.py b/src/elevenlabs/types/post_workspace_secret_response_model.py index abae6225..e85d673b 100644 --- a/src/elevenlabs/types/post_workspace_secret_response_model.py +++ b/src/elevenlabs/types/post_workspace_secret_response_model.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class PostWorkspaceSecretResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/privacy_config.py b/src/elevenlabs/types/privacy_config.py index 36a63e3a..3148e93e 100644 --- a/src/elevenlabs/types/privacy_config.py +++ b/src/elevenlabs/types/privacy_config.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class PrivacyConfig(UncheckedBaseModel): diff --git a/src/elevenlabs/types/project_creation_meta_response_model.py b/src/elevenlabs/types/project_creation_meta_response_model.py index 3d16bb64..0163bd65 100644 --- a/src/elevenlabs/types/project_creation_meta_response_model.py +++ b/src/elevenlabs/types/project_creation_meta_response_model.py @@ -1,15 +1,12 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel +import typing + import pydantic -from .project_creation_meta_response_model_status import ( - ProjectCreationMetaResponseModelStatus, -) -from .project_creation_meta_response_model_type import ( - ProjectCreationMetaResponseModelType, -) from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import typing +from ..core.unchecked_base_model import UncheckedBaseModel +from .project_creation_meta_response_model_status import ProjectCreationMetaResponseModelStatus +from .project_creation_meta_response_model_type import ProjectCreationMetaResponseModelType class ProjectCreationMetaResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/project_extended_response.py b/src/elevenlabs/types/project_extended_response.py index 99a96a4e..bd795ac8 100644 --- a/src/elevenlabs/types/project_extended_response.py +++ b/src/elevenlabs/types/project_extended_response.py @@ -1,34 +1,21 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -import pydantic import typing -from .project_extended_response_model_target_audience import ( - ProjectExtendedResponseModelTargetAudience, -) -from .project_state import ProjectState -from .project_extended_response_model_access_level import ( - ProjectExtendedResponseModelAccessLevel, -) -from .project_extended_response_model_fiction import ProjectExtendedResponseModelFiction -from .project_creation_meta_response_model import ProjectCreationMetaResponseModel -from .project_extended_response_model_source_type import ( - ProjectExtendedResponseModelSourceType, -) -from .project_extended_response_model_quality_preset import ( - ProjectExtendedResponseModelQualityPreset, -) -from .chapter_response import ChapterResponse -from .pronunciation_dictionary_version_response_model import ( - PronunciationDictionaryVersionResponseModel, -) -from .pronunciation_dictionary_locator_response_model import ( - PronunciationDictionaryLocatorResponseModel, -) -from .project_extended_response_model_apply_text_normalization import ( - ProjectExtendedResponseModelApplyTextNormalization, -) + +import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .chapter_response import ChapterResponse +from .project_creation_meta_response_model import ProjectCreationMetaResponseModel +from .project_extended_response_model_access_level import ProjectExtendedResponseModelAccessLevel +from .project_extended_response_model_apply_text_normalization import ProjectExtendedResponseModelApplyTextNormalization +from .project_extended_response_model_fiction import ProjectExtendedResponseModelFiction +from .project_extended_response_model_quality_preset import ProjectExtendedResponseModelQualityPreset +from .project_extended_response_model_source_type import ProjectExtendedResponseModelSourceType +from .project_extended_response_model_target_audience import ProjectExtendedResponseModelTargetAudience +from .project_state import ProjectState +from .pronunciation_dictionary_locator_response_model import PronunciationDictionaryLocatorResponseModel +from .pronunciation_dictionary_version_response_model import PronunciationDictionaryVersionResponseModel class ProjectExtendedResponse(UncheckedBaseModel): diff --git a/src/elevenlabs/types/project_response.py b/src/elevenlabs/types/project_response.py index 28b4710f..d77e05c2 100644 --- a/src/elevenlabs/types/project_response.py +++ b/src/elevenlabs/types/project_response.py @@ -1,15 +1,16 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -import pydantic import typing -from .project_response_model_target_audience import ProjectResponseModelTargetAudience -from .project_state import ProjectState + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .project_creation_meta_response_model import ProjectCreationMetaResponseModel from .project_response_model_access_level import ProjectResponseModelAccessLevel from .project_response_model_fiction import ProjectResponseModelFiction -from .project_creation_meta_response_model import ProjectCreationMetaResponseModel from .project_response_model_source_type import ProjectResponseModelSourceType -from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from .project_response_model_target_audience import ProjectResponseModelTargetAudience +from .project_state import ProjectState class ProjectResponse(UncheckedBaseModel): diff --git a/src/elevenlabs/types/project_snapshot_extended_response_model.py b/src/elevenlabs/types/project_snapshot_extended_response_model.py index 23f693d7..7e71977c 100644 --- a/src/elevenlabs/types/project_snapshot_extended_response_model.py +++ b/src/elevenlabs/types/project_snapshot_extended_response_model.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -import pydantic import typing -from .character_alignment_model import CharacterAlignmentModel + +import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .character_alignment_model import CharacterAlignmentModel class ProjectSnapshotExtendedResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/project_snapshot_response.py b/src/elevenlabs/types/project_snapshot_response.py index df7374f6..da74a85e 100644 --- a/src/elevenlabs/types/project_snapshot_response.py +++ b/src/elevenlabs/types/project_snapshot_response.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -import pydantic import typing + +import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class ProjectSnapshotResponse(UncheckedBaseModel): diff --git a/src/elevenlabs/types/project_snapshots_response.py b/src/elevenlabs/types/project_snapshots_response.py index c7d61724..71f59bab 100644 --- a/src/elevenlabs/types/project_snapshots_response.py +++ b/src/elevenlabs/types/project_snapshots_response.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .project_snapshot_response import ProjectSnapshotResponse + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .project_snapshot_response import ProjectSnapshotResponse class ProjectSnapshotsResponse(UncheckedBaseModel): diff --git a/src/elevenlabs/types/prompt_agent.py b/src/elevenlabs/types/prompt_agent.py index a8a7ff19..b74828bd 100644 --- a/src/elevenlabs/types/prompt_agent.py +++ b/src/elevenlabs/types/prompt_agent.py @@ -1,16 +1,17 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from .array_json_schema_property_output import ArrayJsonSchemaPropertyOutput -from .object_json_schema_property_output import ObjectJsonSchemaPropertyOutput +from __future__ import annotations + import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, update_forward_refs +from ..core.unchecked_base_model import UncheckedBaseModel +from .custom_llm import CustomLlm +from .knowledge_base_locator import KnowledgeBaseLocator from .llm import Llm from .prompt_agent_output_tools_item import PromptAgentOutputToolsItem -from .knowledge_base_locator import KnowledgeBaseLocator -from .custom_llm import CustomLlm from .rag_config import RagConfig -from ..core.pydantic_utilities import IS_PYDANTIC_V2, update_forward_refs class PromptAgent(UncheckedBaseModel): @@ -44,6 +45,11 @@ class PromptAgent(UncheckedBaseModel): A list of IDs of tools used by the agent """ + mcp_server_ids: typing.Optional[typing.List[str]] = pydantic.Field(default=None) + """ + A list of MCP server ids to be used by the agent + """ + knowledge_base: typing.Optional[typing.List[KnowledgeBaseLocator]] = pydantic.Field(default=None) """ A list of knowledge bases to be used by the agent @@ -73,9 +79,8 @@ class Config: smart_union = True extra = pydantic.Extra.allow -from .array_json_schema_property_output import ArrayJsonSchemaPropertyOutput # noqa: E402 -update_forward_refs(ArrayJsonSchemaPropertyOutput) +from .array_json_schema_property_output import ArrayJsonSchemaPropertyOutput # noqa: E402, F401, I001 +from .object_json_schema_property_output import ObjectJsonSchemaPropertyOutput # noqa: E402, F401, I001 -if IS_PYDANTIC_V2: - PromptAgent.model_rebuild() +update_forward_refs(PromptAgent) diff --git a/src/elevenlabs/types/prompt_agent_db_model.py b/src/elevenlabs/types/prompt_agent_db_model.py index eab7c27a..5b04d3c3 100644 --- a/src/elevenlabs/types/prompt_agent_db_model.py +++ b/src/elevenlabs/types/prompt_agent_db_model.py @@ -1,16 +1,17 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from .array_json_schema_property_input import ArrayJsonSchemaPropertyInput -from .object_json_schema_property_input import ObjectJsonSchemaPropertyInput +from __future__ import annotations + import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, update_forward_refs +from ..core.unchecked_base_model import UncheckedBaseModel +from .custom_llm import CustomLlm +from .knowledge_base_locator import KnowledgeBaseLocator from .llm import Llm from .prompt_agent_db_model_tools_item import PromptAgentDbModelToolsItem -from .knowledge_base_locator import KnowledgeBaseLocator -from .custom_llm import CustomLlm from .rag_config import RagConfig -from ..core.pydantic_utilities import IS_PYDANTIC_V2 class PromptAgentDbModel(UncheckedBaseModel): @@ -79,3 +80,9 @@ class Config: frozen = True smart_union = True extra = pydantic.Extra.allow + + +from .array_json_schema_property_input import ArrayJsonSchemaPropertyInput # noqa: E402, F401, I001 +from .object_json_schema_property_input import ObjectJsonSchemaPropertyInput # noqa: E402, F401, I001 + +update_forward_refs(PromptAgentDbModel) diff --git a/src/elevenlabs/types/prompt_agent_db_model_tools_item.py b/src/elevenlabs/types/prompt_agent_db_model_tools_item.py index 19d83d7d..8095aa13 100644 --- a/src/elevenlabs/types/prompt_agent_db_model_tools_item.py +++ b/src/elevenlabs/types/prompt_agent_db_model_tools_item.py @@ -1,17 +1,16 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -from ..core.unchecked_base_model import UncheckedBaseModel -from .array_json_schema_property_input import ArrayJsonSchemaPropertyInput -from .object_json_schema_property_input import ObjectJsonSchemaPropertyInput + import typing -from .dynamic_variables_config import DynamicVariablesConfig -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +import typing_extensions +from ..core.pydantic_utilities import IS_PYDANTIC_V2, update_forward_refs +from ..core.unchecked_base_model import UncheckedBaseModel, UnionMetadata +from .dynamic_variables_config import DynamicVariablesConfig from .system_tool_config_input_params import SystemToolConfigInputParams from .webhook_tool_api_schema_config_input import WebhookToolApiSchemaConfigInput -import typing_extensions -from ..core.unchecked_base_model import UnionMetadata class PromptAgentDbModelToolsItem_Client(UncheckedBaseModel): @@ -24,7 +23,7 @@ class PromptAgentDbModelToolsItem_Client(UncheckedBaseModel): name: str description: str response_timeout_secs: typing.Optional[int] = None - parameters: typing.Optional[ObjectJsonSchemaPropertyInput] = None + parameters: typing.Optional["ObjectJsonSchemaPropertyInput"] = None expects_response: typing.Optional[bool] = None dynamic_variables: typing.Optional[DynamicVariablesConfig] = None @@ -48,7 +47,7 @@ class PromptAgentDbModelToolsItem_Mcp(UncheckedBaseModel): name: str description: str response_timeout_secs: typing.Optional[int] = None - parameters: typing.Optional[ObjectJsonSchemaPropertyInput] = None + parameters: typing.Optional["ObjectJsonSchemaPropertyInput"] = None mcp_tool_name: str mcp_server_id: str @@ -107,6 +106,9 @@ class Config: extra = pydantic.Extra.allow +from .array_json_schema_property_input import ArrayJsonSchemaPropertyInput # noqa: E402, F401, I001 +from .object_json_schema_property_input import ObjectJsonSchemaPropertyInput # noqa: E402, F401, I001 + PromptAgentDbModelToolsItem = typing_extensions.Annotated[ typing.Union[ PromptAgentDbModelToolsItem_Client, @@ -116,3 +118,6 @@ class Config: ], UnionMetadata(discriminant="type"), ] +update_forward_refs(PromptAgentDbModelToolsItem_Client) +update_forward_refs(PromptAgentDbModelToolsItem_Mcp) +update_forward_refs(PromptAgentDbModelToolsItem_Webhook) diff --git a/src/elevenlabs/types/prompt_agent_input_tools_item.py b/src/elevenlabs/types/prompt_agent_input_tools_item.py index 9da04cbc..8237ce95 100644 --- a/src/elevenlabs/types/prompt_agent_input_tools_item.py +++ b/src/elevenlabs/types/prompt_agent_input_tools_item.py @@ -1,17 +1,16 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -from ..core.unchecked_base_model import UncheckedBaseModel -from .array_json_schema_property_input import ArrayJsonSchemaPropertyInput -from .object_json_schema_property_input import ObjectJsonSchemaPropertyInput + import typing -from .dynamic_variables_config import DynamicVariablesConfig -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +import typing_extensions +from ..core.pydantic_utilities import IS_PYDANTIC_V2, update_forward_refs +from ..core.unchecked_base_model import UncheckedBaseModel, UnionMetadata +from .dynamic_variables_config import DynamicVariablesConfig from .system_tool_config_input_params import SystemToolConfigInputParams from .webhook_tool_api_schema_config_input import WebhookToolApiSchemaConfigInput -import typing_extensions -from ..core.unchecked_base_model import UnionMetadata class PromptAgentInputToolsItem_Client(UncheckedBaseModel): @@ -24,7 +23,7 @@ class PromptAgentInputToolsItem_Client(UncheckedBaseModel): name: str description: str response_timeout_secs: typing.Optional[int] = None - parameters: typing.Optional[ObjectJsonSchemaPropertyInput] = None + parameters: typing.Optional["ObjectJsonSchemaPropertyInput"] = None expects_response: typing.Optional[bool] = None dynamic_variables: typing.Optional[DynamicVariablesConfig] = None @@ -48,7 +47,7 @@ class PromptAgentInputToolsItem_Mcp(UncheckedBaseModel): name: str description: str response_timeout_secs: typing.Optional[int] = None - parameters: typing.Optional[ObjectJsonSchemaPropertyInput] = None + parameters: typing.Optional["ObjectJsonSchemaPropertyInput"] = None mcp_tool_name: str mcp_server_id: str @@ -107,6 +106,9 @@ class Config: extra = pydantic.Extra.allow +from .array_json_schema_property_input import ArrayJsonSchemaPropertyInput # noqa: E402, F401, I001 +from .object_json_schema_property_input import ObjectJsonSchemaPropertyInput # noqa: E402, F401, I001 + PromptAgentInputToolsItem = typing_extensions.Annotated[ typing.Union[ PromptAgentInputToolsItem_Client, @@ -116,3 +118,6 @@ class Config: ], UnionMetadata(discriminant="type"), ] +update_forward_refs(PromptAgentInputToolsItem_Client) +update_forward_refs(PromptAgentInputToolsItem_Mcp) +update_forward_refs(PromptAgentInputToolsItem_Webhook) diff --git a/src/elevenlabs/types/prompt_agent_output_tools_item.py b/src/elevenlabs/types/prompt_agent_output_tools_item.py index 695fbc45..73f915da 100644 --- a/src/elevenlabs/types/prompt_agent_output_tools_item.py +++ b/src/elevenlabs/types/prompt_agent_output_tools_item.py @@ -1,17 +1,16 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -from ..core.unchecked_base_model import UncheckedBaseModel -from .array_json_schema_property_output import ArrayJsonSchemaPropertyOutput -from .object_json_schema_property_output import ObjectJsonSchemaPropertyOutput + import typing -from .dynamic_variables_config import DynamicVariablesConfig -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +import typing_extensions +from ..core.pydantic_utilities import IS_PYDANTIC_V2, update_forward_refs +from ..core.unchecked_base_model import UncheckedBaseModel, UnionMetadata +from .dynamic_variables_config import DynamicVariablesConfig from .system_tool_config_output_params import SystemToolConfigOutputParams from .webhook_tool_api_schema_config_output import WebhookToolApiSchemaConfigOutput -import typing_extensions -from ..core.unchecked_base_model import UnionMetadata class PromptAgentOutputToolsItem_Client(UncheckedBaseModel): @@ -24,7 +23,7 @@ class PromptAgentOutputToolsItem_Client(UncheckedBaseModel): name: str description: str response_timeout_secs: typing.Optional[int] = None - parameters: typing.Optional[ObjectJsonSchemaPropertyOutput] = None + parameters: typing.Optional["ObjectJsonSchemaPropertyOutput"] = None expects_response: typing.Optional[bool] = None dynamic_variables: typing.Optional[DynamicVariablesConfig] = None @@ -48,7 +47,7 @@ class PromptAgentOutputToolsItem_Mcp(UncheckedBaseModel): name: str description: str response_timeout_secs: typing.Optional[int] = None - parameters: typing.Optional[ObjectJsonSchemaPropertyOutput] = None + parameters: typing.Optional["ObjectJsonSchemaPropertyOutput"] = None mcp_tool_name: str mcp_server_id: str @@ -107,6 +106,9 @@ class Config: extra = pydantic.Extra.allow +from .array_json_schema_property_output import ArrayJsonSchemaPropertyOutput # noqa: E402, F401, I001 +from .object_json_schema_property_output import ObjectJsonSchemaPropertyOutput # noqa: E402, F401, I001 + PromptAgentOutputToolsItem = typing_extensions.Annotated[ typing.Union[ PromptAgentOutputToolsItem_Client, @@ -116,3 +118,6 @@ class Config: ], UnionMetadata(discriminant="type"), ] +update_forward_refs(PromptAgentOutputToolsItem_Client) +update_forward_refs(PromptAgentOutputToolsItem_Mcp) +update_forward_refs(PromptAgentOutputToolsItem_Webhook) diff --git a/src/elevenlabs/types/prompt_agent_override.py b/src/elevenlabs/types/prompt_agent_override.py index 051a7f79..db86bb6a 100644 --- a/src/elevenlabs/types/prompt_agent_override.py +++ b/src/elevenlabs/types/prompt_agent_override.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class PromptAgentOverride(UncheckedBaseModel): diff --git a/src/elevenlabs/types/prompt_agent_override_config.py b/src/elevenlabs/types/prompt_agent_override_config.py index 05795977..28e2da2c 100644 --- a/src/elevenlabs/types/prompt_agent_override_config.py +++ b/src/elevenlabs/types/prompt_agent_override_config.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class PromptAgentOverrideConfig(UncheckedBaseModel): diff --git a/src/elevenlabs/types/prompt_evaluation_criteria.py b/src/elevenlabs/types/prompt_evaluation_criteria.py index 50ac3025..c1e6cab9 100644 --- a/src/elevenlabs/types/prompt_evaluation_criteria.py +++ b/src/elevenlabs/types/prompt_evaluation_criteria.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -import pydantic import typing + +import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class PromptEvaluationCriteria(UncheckedBaseModel): diff --git a/src/elevenlabs/types/pronunciation_dictionary_alias_rule_request_model.py b/src/elevenlabs/types/pronunciation_dictionary_alias_rule_request_model.py index 1d324c3a..c377d4fc 100644 --- a/src/elevenlabs/types/pronunciation_dictionary_alias_rule_request_model.py +++ b/src/elevenlabs/types/pronunciation_dictionary_alias_rule_request_model.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel +import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import typing +from ..core.unchecked_base_model import UncheckedBaseModel class PronunciationDictionaryAliasRuleRequestModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/pronunciation_dictionary_locator.py b/src/elevenlabs/types/pronunciation_dictionary_locator.py index 27218112..ccf41299 100644 --- a/src/elevenlabs/types/pronunciation_dictionary_locator.py +++ b/src/elevenlabs/types/pronunciation_dictionary_locator.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel +import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import typing +from ..core.unchecked_base_model import UncheckedBaseModel class PronunciationDictionaryLocator(UncheckedBaseModel): diff --git a/src/elevenlabs/types/pronunciation_dictionary_locator_response_model.py b/src/elevenlabs/types/pronunciation_dictionary_locator_response_model.py index b1156046..f02fd905 100644 --- a/src/elevenlabs/types/pronunciation_dictionary_locator_response_model.py +++ b/src/elevenlabs/types/pronunciation_dictionary_locator_response_model.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class PronunciationDictionaryLocatorResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/pronunciation_dictionary_phoneme_rule_request_model.py b/src/elevenlabs/types/pronunciation_dictionary_phoneme_rule_request_model.py index 273495ff..a0bcc4a6 100644 --- a/src/elevenlabs/types/pronunciation_dictionary_phoneme_rule_request_model.py +++ b/src/elevenlabs/types/pronunciation_dictionary_phoneme_rule_request_model.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel +import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import typing +from ..core.unchecked_base_model import UncheckedBaseModel class PronunciationDictionaryPhonemeRuleRequestModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/pronunciation_dictionary_rules_response_model.py b/src/elevenlabs/types/pronunciation_dictionary_rules_response_model.py index 59b7a5c6..d1331550 100644 --- a/src/elevenlabs/types/pronunciation_dictionary_rules_response_model.py +++ b/src/elevenlabs/types/pronunciation_dictionary_rules_response_model.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel +import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import typing +from ..core.unchecked_base_model import UncheckedBaseModel class PronunciationDictionaryRulesResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/pronunciation_dictionary_version_locator.py b/src/elevenlabs/types/pronunciation_dictionary_version_locator.py index 55fff7fe..ad6a32d8 100644 --- a/src/elevenlabs/types/pronunciation_dictionary_version_locator.py +++ b/src/elevenlabs/types/pronunciation_dictionary_version_locator.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -import pydantic import typing + +import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class PronunciationDictionaryVersionLocator(UncheckedBaseModel): diff --git a/src/elevenlabs/types/pronunciation_dictionary_version_response_model.py b/src/elevenlabs/types/pronunciation_dictionary_version_response_model.py index 4d6a9fc4..33e30318 100644 --- a/src/elevenlabs/types/pronunciation_dictionary_version_response_model.py +++ b/src/elevenlabs/types/pronunciation_dictionary_version_response_model.py @@ -1,12 +1,13 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel from .pronunciation_dictionary_version_response_model_permission_on_resource import ( PronunciationDictionaryVersionResponseModelPermissionOnResource, ) -from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import pydantic class PronunciationDictionaryVersionResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/pydantic_pronunciation_dictionary_version_locator.py b/src/elevenlabs/types/pydantic_pronunciation_dictionary_version_locator.py index 40917474..b060210e 100644 --- a/src/elevenlabs/types/pydantic_pronunciation_dictionary_version_locator.py +++ b/src/elevenlabs/types/pydantic_pronunciation_dictionary_version_locator.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -import pydantic import typing + +import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class PydanticPronunciationDictionaryVersionLocator(UncheckedBaseModel): diff --git a/src/elevenlabs/types/query_params_json_schema.py b/src/elevenlabs/types/query_params_json_schema.py index 0de3881a..66f1ca03 100644 --- a/src/elevenlabs/types/query_params_json_schema.py +++ b/src/elevenlabs/types/query_params_json_schema.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .literal_json_schema_property import LiteralJsonSchemaProperty -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .literal_json_schema_property import LiteralJsonSchemaProperty class QueryParamsJsonSchema(UncheckedBaseModel): diff --git a/src/elevenlabs/types/rag_chunk_metadata.py b/src/elevenlabs/types/rag_chunk_metadata.py index 4daa4e81..e6345190 100644 --- a/src/elevenlabs/types/rag_chunk_metadata.py +++ b/src/elevenlabs/types/rag_chunk_metadata.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class RagChunkMetadata(UncheckedBaseModel): diff --git a/src/elevenlabs/types/rag_config.py b/src/elevenlabs/types/rag_config.py index 30716bdf..374d3531 100644 --- a/src/elevenlabs/types/rag_config.py +++ b/src/elevenlabs/types/rag_config.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .embedding_model_enum import EmbeddingModelEnum + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .embedding_model_enum import EmbeddingModelEnum class RagConfig(UncheckedBaseModel): diff --git a/src/elevenlabs/types/rag_index_response_model.py b/src/elevenlabs/types/rag_index_response_model.py index 22416b17..d08648cd 100644 --- a/src/elevenlabs/types/rag_index_response_model.py +++ b/src/elevenlabs/types/rag_index_response_model.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from .rag_index_status import RagIndexStatus -from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .rag_index_status import RagIndexStatus class RagIndexResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/rag_retrieval_info.py b/src/elevenlabs/types/rag_retrieval_info.py index f074dfc0..e58db453 100644 --- a/src/elevenlabs/types/rag_retrieval_info.py +++ b/src/elevenlabs/types/rag_retrieval_info.py @@ -1,11 +1,12 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .rag_chunk_metadata import RagChunkMetadata -from .embedding_model_enum import EmbeddingModelEnum -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .embedding_model_enum import EmbeddingModelEnum +from .rag_chunk_metadata import RagChunkMetadata class RagRetrievalInfo(UncheckedBaseModel): diff --git a/src/elevenlabs/types/reader_resource_response_model.py b/src/elevenlabs/types/reader_resource_response_model.py index 705ccbb8..5f09128e 100644 --- a/src/elevenlabs/types/reader_resource_response_model.py +++ b/src/elevenlabs/types/reader_resource_response_model.py @@ -1,12 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from .reader_resource_response_model_resource_type import ( - ReaderResourceResponseModelResourceType, -) +import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import typing +from ..core.unchecked_base_model import UncheckedBaseModel +from .reader_resource_response_model_resource_type import ReaderResourceResponseModelResourceType class ReaderResourceResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/realtime_voice_settings.py b/src/elevenlabs/types/realtime_voice_settings.py index eaf3445f..f34a82dc 100644 --- a/src/elevenlabs/types/realtime_voice_settings.py +++ b/src/elevenlabs/types/realtime_voice_settings.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class RealtimeVoiceSettings(UncheckedBaseModel): diff --git a/src/elevenlabs/types/recording_response.py b/src/elevenlabs/types/recording_response.py index b53de91a..60bc2371 100644 --- a/src/elevenlabs/types/recording_response.py +++ b/src/elevenlabs/types/recording_response.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel +import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import typing +from ..core.unchecked_base_model import UncheckedBaseModel class RecordingResponse(UncheckedBaseModel): diff --git a/src/elevenlabs/types/render.py b/src/elevenlabs/types/render.py index 993f7c9c..056db8fa 100644 --- a/src/elevenlabs/types/render.py +++ b/src/elevenlabs/types/render.py @@ -1,12 +1,13 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .render_type import RenderType + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel from .dubbing_media_reference import DubbingMediaReference from .render_status import RenderStatus -from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import pydantic +from .render_type import RenderType class Render(UncheckedBaseModel): diff --git a/src/elevenlabs/types/render_type.py b/src/elevenlabs/types/render_type.py index c83bdbc6..1d313587 100644 --- a/src/elevenlabs/types/render_type.py +++ b/src/elevenlabs/types/render_type.py @@ -2,7 +2,4 @@ import typing -RenderType = typing.Union[ - typing.Literal["mp4", "aac", "mp3", "wav", "aaf", "tracks_zip", "clips_zip"], - typing.Any, -] +RenderType = typing.Union[typing.Literal["mp4", "aac", "mp3", "wav", "aaf", "tracks_zip", "clips_zip"], typing.Any] diff --git a/src/elevenlabs/types/request_pvc_manual_verification_response_model.py b/src/elevenlabs/types/request_pvc_manual_verification_response_model.py index 5a2c45c9..22c31c37 100644 --- a/src/elevenlabs/types/request_pvc_manual_verification_response_model.py +++ b/src/elevenlabs/types/request_pvc_manual_verification_response_model.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel +import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import typing +from ..core.unchecked_base_model import UncheckedBaseModel class RequestPvcManualVerificationResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/resource_access_info.py b/src/elevenlabs/types/resource_access_info.py index 8d2a5a31..2bfdead5 100644 --- a/src/elevenlabs/types/resource_access_info.py +++ b/src/elevenlabs/types/resource_access_info.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel +import typing + import pydantic -from .resource_access_info_role import ResourceAccessInfoRole from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import typing +from ..core.unchecked_base_model import UncheckedBaseModel +from .resource_access_info_role import ResourceAccessInfoRole class ResourceAccessInfo(UncheckedBaseModel): diff --git a/src/elevenlabs/types/resource_metadata_response_model.py b/src/elevenlabs/types/resource_metadata_response_model.py index 8262ec77..d7be4a2d 100644 --- a/src/elevenlabs/types/resource_metadata_response_model.py +++ b/src/elevenlabs/types/resource_metadata_response_model.py @@ -1,11 +1,12 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -import pydantic -from .workspace_resource_type import WorkspaceResourceType import typing -from .share_option_response_model import ShareOptionResponseModel + +import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .share_option_response_model import ShareOptionResponseModel +from .workspace_resource_type import WorkspaceResourceType class ResourceMetadataResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/review_status.py b/src/elevenlabs/types/review_status.py index 9b626c08..4e7d2437 100644 --- a/src/elevenlabs/types/review_status.py +++ b/src/elevenlabs/types/review_status.py @@ -3,6 +3,5 @@ import typing ReviewStatus = typing.Union[ - typing.Literal["not_requested", "pending", "declined", "allowed", "allowed_with_changes"], - typing.Any, + typing.Literal["not_requested", "pending", "declined", "allowed", "allowed_with_changes"], typing.Any ] diff --git a/src/elevenlabs/types/safety_common_model.py b/src/elevenlabs/types/safety_common_model.py index 3cb0287b..6cf658f5 100644 --- a/src/elevenlabs/types/safety_common_model.py +++ b/src/elevenlabs/types/safety_common_model.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .safety_evaluation import SafetyEvaluation -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .safety_evaluation import SafetyEvaluation class SafetyCommonModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/safety_evaluation.py b/src/elevenlabs/types/safety_evaluation.py index 0ac8cfc7..563988ac 100644 --- a/src/elevenlabs/types/safety_evaluation.py +++ b/src/elevenlabs/types/safety_evaluation.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .safety_rule import SafetyRule -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .safety_rule import SafetyRule class SafetyEvaluation(UncheckedBaseModel): diff --git a/src/elevenlabs/types/safety_response_model.py b/src/elevenlabs/types/safety_response_model.py index 97847ffd..8422f28b 100644 --- a/src/elevenlabs/types/safety_response_model.py +++ b/src/elevenlabs/types/safety_response_model.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class SafetyResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/segment_create_response.py b/src/elevenlabs/types/segment_create_response.py index 13084f21..15fadd4e 100644 --- a/src/elevenlabs/types/segment_create_response.py +++ b/src/elevenlabs/types/segment_create_response.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class SegmentCreateResponse(UncheckedBaseModel): diff --git a/src/elevenlabs/types/segment_delete_response.py b/src/elevenlabs/types/segment_delete_response.py index 4f3642ee..aa2693c2 100644 --- a/src/elevenlabs/types/segment_delete_response.py +++ b/src/elevenlabs/types/segment_delete_response.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class SegmentDeleteResponse(UncheckedBaseModel): diff --git a/src/elevenlabs/types/segment_dub_response.py b/src/elevenlabs/types/segment_dub_response.py index 97c09f7e..50139b9c 100644 --- a/src/elevenlabs/types/segment_dub_response.py +++ b/src/elevenlabs/types/segment_dub_response.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class SegmentDubResponse(UncheckedBaseModel): diff --git a/src/elevenlabs/types/segment_transcription_response.py b/src/elevenlabs/types/segment_transcription_response.py index de02ca22..46b69d1d 100644 --- a/src/elevenlabs/types/segment_transcription_response.py +++ b/src/elevenlabs/types/segment_transcription_response.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class SegmentTranscriptionResponse(UncheckedBaseModel): diff --git a/src/elevenlabs/types/segment_translation_response.py b/src/elevenlabs/types/segment_translation_response.py index c88724c9..2e0fa9eb 100644 --- a/src/elevenlabs/types/segment_translation_response.py +++ b/src/elevenlabs/types/segment_translation_response.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class SegmentTranslationResponse(UncheckedBaseModel): diff --git a/src/elevenlabs/types/segment_update_response.py b/src/elevenlabs/types/segment_update_response.py index 1fba5bd5..41789c94 100644 --- a/src/elevenlabs/types/segment_update_response.py +++ b/src/elevenlabs/types/segment_update_response.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class SegmentUpdateResponse(UncheckedBaseModel): diff --git a/src/elevenlabs/types/segmented_json_export_options.py b/src/elevenlabs/types/segmented_json_export_options.py index 711b3531..da084539 100644 --- a/src/elevenlabs/types/segmented_json_export_options.py +++ b/src/elevenlabs/types/segmented_json_export_options.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class SegmentedJsonExportOptions(UncheckedBaseModel): diff --git a/src/elevenlabs/types/send_text.py b/src/elevenlabs/types/send_text.py index ecc2d309..6ff0234e 100644 --- a/src/elevenlabs/types/send_text.py +++ b/src/elevenlabs/types/send_text.py @@ -1,11 +1,12 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -import pydantic import typing -from .realtime_voice_settings import RealtimeVoiceSettings -from .generation_config import GenerationConfig + +import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .generation_config import GenerationConfig +from .realtime_voice_settings import RealtimeVoiceSettings class SendText(UncheckedBaseModel): diff --git a/src/elevenlabs/types/send_text_multi.py b/src/elevenlabs/types/send_text_multi.py index 78a1ba05..8d76838d 100644 --- a/src/elevenlabs/types/send_text_multi.py +++ b/src/elevenlabs/types/send_text_multi.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -import pydantic import typing + +import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class SendTextMulti(UncheckedBaseModel): diff --git a/src/elevenlabs/types/share_option_response_model.py b/src/elevenlabs/types/share_option_response_model.py index 352d74eb..8ec0d6e1 100644 --- a/src/elevenlabs/types/share_option_response_model.py +++ b/src/elevenlabs/types/share_option_response_model.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel +import typing + import pydantic -from .share_option_response_model_type import ShareOptionResponseModelType from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import typing +from ..core.unchecked_base_model import UncheckedBaseModel +from .share_option_response_model_type import ShareOptionResponseModelType class ShareOptionResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/similar_voice.py b/src/elevenlabs/types/similar_voice.py index 70207e86..2f01d956 100644 --- a/src/elevenlabs/types/similar_voice.py +++ b/src/elevenlabs/types/similar_voice.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from .similar_voice_category import SimilarVoiceCategory import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .similar_voice_category import SimilarVoiceCategory class SimilarVoice(UncheckedBaseModel): diff --git a/src/elevenlabs/types/similar_voice_category.py b/src/elevenlabs/types/similar_voice_category.py index f7e79602..dac4fac8 100644 --- a/src/elevenlabs/types/similar_voice_category.py +++ b/src/elevenlabs/types/similar_voice_category.py @@ -3,6 +3,5 @@ import typing SimilarVoiceCategory = typing.Union[ - typing.Literal["premade", "cloned", "generated", "professional", "famous"], - typing.Any, + typing.Literal["premade", "cloned", "generated", "professional", "famous"], typing.Any ] diff --git a/src/elevenlabs/types/similar_voices_for_speaker_response.py b/src/elevenlabs/types/similar_voices_for_speaker_response.py index a14a09c8..388969a0 100644 --- a/src/elevenlabs/types/similar_voices_for_speaker_response.py +++ b/src/elevenlabs/types/similar_voices_for_speaker_response.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .similar_voice import SimilarVoice -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .similar_voice import SimilarVoice class SimilarVoicesForSpeakerResponse(UncheckedBaseModel): diff --git a/src/elevenlabs/types/sip_trunk_config_response_model.py b/src/elevenlabs/types/sip_trunk_config_response_model.py index 27322cb4..159faf5d 100644 --- a/src/elevenlabs/types/sip_trunk_config_response_model.py +++ b/src/elevenlabs/types/sip_trunk_config_response_model.py @@ -1,11 +1,12 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -import pydantic -from .sip_trunk_transport_enum import SipTrunkTransportEnum -from .sip_media_encryption_enum import SipMediaEncryptionEnum import typing + +import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .sip_media_encryption_enum import SipMediaEncryptionEnum +from .sip_trunk_transport_enum import SipTrunkTransportEnum class SipTrunkConfigResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/sip_trunk_credentials.py b/src/elevenlabs/types/sip_trunk_credentials.py index 8aa1e071..173eb6e9 100644 --- a/src/elevenlabs/types/sip_trunk_credentials.py +++ b/src/elevenlabs/types/sip_trunk_credentials.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel +import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import typing +from ..core.unchecked_base_model import UncheckedBaseModel class SipTrunkCredentials(UncheckedBaseModel): diff --git a/src/elevenlabs/types/sip_trunk_outbound_call_response.py b/src/elevenlabs/types/sip_trunk_outbound_call_response.py index dad551ac..915413b2 100644 --- a/src/elevenlabs/types/sip_trunk_outbound_call_response.py +++ b/src/elevenlabs/types/sip_trunk_outbound_call_response.py @@ -1,14 +1,16 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class SipTrunkOutboundCallResponse(UncheckedBaseModel): success: bool message: str + conversation_id: typing.Optional[str] = None sip_call_id: typing.Optional[str] = None if IS_PYDANTIC_V2: diff --git a/src/elevenlabs/types/speaker_audio_response_model.py b/src/elevenlabs/types/speaker_audio_response_model.py index 81987a95..aeedb824 100644 --- a/src/elevenlabs/types/speaker_audio_response_model.py +++ b/src/elevenlabs/types/speaker_audio_response_model.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel +import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import typing +from ..core.unchecked_base_model import UncheckedBaseModel class SpeakerAudioResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/speaker_response_model.py b/src/elevenlabs/types/speaker_response_model.py index bcb858cb..da352050 100644 --- a/src/elevenlabs/types/speaker_response_model.py +++ b/src/elevenlabs/types/speaker_response_model.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -import pydantic import typing -from .utterance_response_model import UtteranceResponseModel + +import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .utterance_response_model import UtteranceResponseModel class SpeakerResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/speaker_segment.py b/src/elevenlabs/types/speaker_segment.py index 9a147dfa..db4e5000 100644 --- a/src/elevenlabs/types/speaker_segment.py +++ b/src/elevenlabs/types/speaker_segment.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .dubbed_segment import DubbedSegment -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .dubbed_segment import DubbedSegment class SpeakerSegment(UncheckedBaseModel): diff --git a/src/elevenlabs/types/speaker_separation_response_model.py b/src/elevenlabs/types/speaker_separation_response_model.py index ebc8d7cf..66f85b13 100644 --- a/src/elevenlabs/types/speaker_separation_response_model.py +++ b/src/elevenlabs/types/speaker_separation_response_model.py @@ -1,13 +1,12 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -import pydantic -from .speaker_separation_response_model_status import ( - SpeakerSeparationResponseModelStatus, -) import typing -from .speaker_response_model import SpeakerResponseModel + +import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .speaker_response_model import SpeakerResponseModel +from .speaker_separation_response_model_status import SpeakerSeparationResponseModelStatus class SpeakerSeparationResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/speaker_track.py b/src/elevenlabs/types/speaker_track.py index 9b2ab867..9463d97e 100644 --- a/src/elevenlabs/types/speaker_track.py +++ b/src/elevenlabs/types/speaker_track.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from .dubbing_media_reference import DubbingMediaReference import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .dubbing_media_reference import DubbingMediaReference class SpeakerTrack(UncheckedBaseModel): diff --git a/src/elevenlabs/types/speaker_updated_response.py b/src/elevenlabs/types/speaker_updated_response.py index 8cf7d098..fa8423f2 100644 --- a/src/elevenlabs/types/speaker_updated_response.py +++ b/src/elevenlabs/types/speaker_updated_response.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class SpeakerUpdatedResponse(UncheckedBaseModel): diff --git a/src/elevenlabs/types/speech_history_item_response.py b/src/elevenlabs/types/speech_history_item_response.py index ecc7c346..bade4f67 100644 --- a/src/elevenlabs/types/speech_history_item_response.py +++ b/src/elevenlabs/types/speech_history_item_response.py @@ -1,17 +1,14 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -import pydantic import typing -from .speech_history_item_response_model_voice_category import ( - SpeechHistoryItemResponseModelVoiceCategory, -) + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel from .feedback_item import FeedbackItem -from .speech_history_item_response_model_source import ( - SpeechHistoryItemResponseModelSource, -) from .history_alignments_response_model import HistoryAlignmentsResponseModel -from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from .speech_history_item_response_model_source import SpeechHistoryItemResponseModelSource +from .speech_history_item_response_model_voice_category import SpeechHistoryItemResponseModelVoiceCategory class SpeechHistoryItemResponse(UncheckedBaseModel): diff --git a/src/elevenlabs/types/speech_history_item_response_model_source.py b/src/elevenlabs/types/speech_history_item_response_model_source.py index 747b6643..ce3689bf 100644 --- a/src/elevenlabs/types/speech_history_item_response_model_source.py +++ b/src/elevenlabs/types/speech_history_item_response_model_source.py @@ -3,6 +3,5 @@ import typing SpeechHistoryItemResponseModelSource = typing.Union[ - typing.Literal["TTS", "STS", "Projects", "PD", "AN", "Dubbing", "PlayAPI", "ConvAI"], - typing.Any, + typing.Literal["TTS", "STS", "Projects", "PD", "AN", "Dubbing", "PlayAPI", "ConvAI"], typing.Any ] diff --git a/src/elevenlabs/types/speech_to_text_character_response_model.py b/src/elevenlabs/types/speech_to_text_character_response_model.py index 5fd02a66..41ae5f6c 100644 --- a/src/elevenlabs/types/speech_to_text_character_response_model.py +++ b/src/elevenlabs/types/speech_to_text_character_response_model.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -import pydantic import typing + +import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class SpeechToTextCharacterResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/speech_to_text_chunk_response_model.py b/src/elevenlabs/types/speech_to_text_chunk_response_model.py index 94fd10da..fdcb4357 100644 --- a/src/elevenlabs/types/speech_to_text_chunk_response_model.py +++ b/src/elevenlabs/types/speech_to_text_chunk_response_model.py @@ -1,11 +1,12 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -import pydantic import typing -from .speech_to_text_word_response_model import SpeechToTextWordResponseModel -from .additional_format_response_model import AdditionalFormatResponseModel + +import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .additional_format_response_model import AdditionalFormatResponseModel +from .speech_to_text_word_response_model import SpeechToTextWordResponseModel class SpeechToTextChunkResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/speech_to_text_word_response_model.py b/src/elevenlabs/types/speech_to_text_word_response_model.py index b0a83e0e..1d30daa0 100644 --- a/src/elevenlabs/types/speech_to_text_word_response_model.py +++ b/src/elevenlabs/types/speech_to_text_word_response_model.py @@ -1,11 +1,12 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -import pydantic import typing -from .speech_to_text_word_response_model_type import SpeechToTextWordResponseModelType -from .speech_to_text_character_response_model import SpeechToTextCharacterResponseModel + +import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .speech_to_text_character_response_model import SpeechToTextCharacterResponseModel +from .speech_to_text_word_response_model_type import SpeechToTextWordResponseModelType class SpeechToTextWordResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/srt_export_options.py b/src/elevenlabs/types/srt_export_options.py index dbe6b974..a74dd177 100644 --- a/src/elevenlabs/types/srt_export_options.py +++ b/src/elevenlabs/types/srt_export_options.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class SrtExportOptions(UncheckedBaseModel): diff --git a/src/elevenlabs/types/start_pvc_voice_training_response_model.py b/src/elevenlabs/types/start_pvc_voice_training_response_model.py index 34d2d854..2645bf37 100644 --- a/src/elevenlabs/types/start_pvc_voice_training_response_model.py +++ b/src/elevenlabs/types/start_pvc_voice_training_response_model.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel +import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import typing +from ..core.unchecked_base_model import UncheckedBaseModel class StartPvcVoiceTrainingResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/start_speaker_separation_response_model.py b/src/elevenlabs/types/start_speaker_separation_response_model.py index 9e8c118f..089791b7 100644 --- a/src/elevenlabs/types/start_speaker_separation_response_model.py +++ b/src/elevenlabs/types/start_speaker_separation_response_model.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel +import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import typing +from ..core.unchecked_base_model import UncheckedBaseModel class StartSpeakerSeparationResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/stream_input_query_parameters.py b/src/elevenlabs/types/stream_input_query_parameters.py deleted file mode 100644 index cefaea4a..00000000 --- a/src/elevenlabs/types/stream_input_query_parameters.py +++ /dev/null @@ -1,73 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -from ..core.unchecked_base_model import UncheckedBaseModel -import typing -import pydantic -from .stream_input_query_parameters_optimize_streaming_latency import ( - StreamInputQueryParametersOptimizeStreamingLatency, -) -from .text_to_speech_output_format_enum import TextToSpeechOutputFormatEnum -from .text_to_speech_apply_text_normalization_enum import ( - TextToSpeechApplyTextNormalizationEnum, -) -from ..core.pydantic_utilities import IS_PYDANTIC_V2 - - -class StreamInputQueryParameters(UncheckedBaseModel): - model_id: typing.Optional[str] = pydantic.Field(default=None) - """ - The model ID to use - """ - - language_code: typing.Optional[str] = pydantic.Field(default=None) - """ - The ISO 639-1 language code (for Turbo v2.5 and Flash v2.5 models only) - """ - - enable_logging: typing.Optional[str] = pydantic.Field(default=None) - """ - Whether to enable logging of the request - """ - - enable_ssml_parsing: typing.Optional[bool] = pydantic.Field(default=None) - """ - Whether to enable SSML parsing - """ - - optimize_streaming_latency: typing.Optional[StreamInputQueryParametersOptimizeStreamingLatency] = pydantic.Field( - default=None - ) - """ - Latency optimization level (deprecated) - """ - - output_format: typing.Optional[TextToSpeechOutputFormatEnum] = None - inactivity_timeout: typing.Optional[float] = pydantic.Field(default=None) - """ - Timeout for inactivity before connection is closed - """ - - sync_alignment: typing.Optional[bool] = pydantic.Field(default=None) - """ - Whether to include timing data with every audio chunk - """ - - auto_mode: typing.Optional[bool] = pydantic.Field(default=None) - """ - This parameter focuses on reducing the latency by disabling the chunk schedule and all buffers. It is only recommended when sending full sentences or phrases, sending partial phrases will result in highly reduced quality. By default it's set to false. - """ - - apply_text_normalization: typing.Optional[TextToSpeechApplyTextNormalizationEnum] = None - seed: typing.Optional[int] = pydantic.Field(default=None) - """ - If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same seed and parameters should return the same result. Determinism is not guaranteed. Must be an integer between 0 and 4294967295. - """ - - if IS_PYDANTIC_V2: - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 - else: - - class Config: - frozen = True - smart_union = True - extra = pydantic.Extra.allow diff --git a/src/elevenlabs/types/stream_input_query_parameters_optimize_streaming_latency.py b/src/elevenlabs/types/stream_input_query_parameters_optimize_streaming_latency.py deleted file mode 100644 index 7465b75b..00000000 --- a/src/elevenlabs/types/stream_input_query_parameters_optimize_streaming_latency.py +++ /dev/null @@ -1,5 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import typing - -StreamInputQueryParametersOptimizeStreamingLatency = typing.Union[typing.Literal["0", "1", "2", "3", "4"], typing.Any] diff --git a/src/elevenlabs/types/streaming_audio_chunk_with_timestamps_response.py b/src/elevenlabs/types/streaming_audio_chunk_with_timestamps_response.py index ea238d1e..00de6c1e 100644 --- a/src/elevenlabs/types/streaming_audio_chunk_with_timestamps_response.py +++ b/src/elevenlabs/types/streaming_audio_chunk_with_timestamps_response.py @@ -1,12 +1,13 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel +import typing + +import pydantic import typing_extensions +from ..core.pydantic_utilities import IS_PYDANTIC_V2 from ..core.serialization import FieldMetadata -import pydantic -import typing +from ..core.unchecked_base_model import UncheckedBaseModel from .character_alignment_response_model import CharacterAlignmentResponseModel -from ..core.pydantic_utilities import IS_PYDANTIC_V2 class StreamingAudioChunkWithTimestampsResponse(UncheckedBaseModel): diff --git a/src/elevenlabs/types/subscription.py b/src/elevenlabs/types/subscription.py index 12261181..f629cd1e 100644 --- a/src/elevenlabs/types/subscription.py +++ b/src/elevenlabs/types/subscription.py @@ -1,22 +1,17 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -import pydantic import typing -from .extended_subscription_response_model_currency import ( - ExtendedSubscriptionResponseModelCurrency, -) -from .extended_subscription_response_model_status import ( - ExtendedSubscriptionResponseModelStatus, -) -from .extended_subscription_response_model_billing_period import ( - ExtendedSubscriptionResponseModelBillingPeriod, -) + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .extended_subscription_response_model_billing_period import ExtendedSubscriptionResponseModelBillingPeriod from .extended_subscription_response_model_character_refresh_period import ( ExtendedSubscriptionResponseModelCharacterRefreshPeriod, ) +from .extended_subscription_response_model_currency import ExtendedSubscriptionResponseModelCurrency +from .extended_subscription_response_model_status import ExtendedSubscriptionResponseModelStatus from .invoice_response import InvoiceResponse -from ..core.pydantic_utilities import IS_PYDANTIC_V2 class Subscription(UncheckedBaseModel): diff --git a/src/elevenlabs/types/subscription_extras_response_model.py b/src/elevenlabs/types/subscription_extras_response_model.py index cdf20265..96e45165 100644 --- a/src/elevenlabs/types/subscription_extras_response_model.py +++ b/src/elevenlabs/types/subscription_extras_response_model.py @@ -1,11 +1,12 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -import pydantic import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel from .moderation_status_response_model import ModerationStatusResponseModel from .subscription_usage_response_model import SubscriptionUsageResponseModel -from ..core.pydantic_utilities import IS_PYDANTIC_V2 class SubscriptionExtrasResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/subscription_response.py b/src/elevenlabs/types/subscription_response.py index 58faab9e..93a935e6 100644 --- a/src/elevenlabs/types/subscription_response.py +++ b/src/elevenlabs/types/subscription_response.py @@ -1,17 +1,14 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -import pydantic import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .subscription_response_model_billing_period import SubscriptionResponseModelBillingPeriod +from .subscription_response_model_character_refresh_period import SubscriptionResponseModelCharacterRefreshPeriod from .subscription_response_model_currency import SubscriptionResponseModelCurrency from .subscription_status import SubscriptionStatus -from .subscription_response_model_billing_period import ( - SubscriptionResponseModelBillingPeriod, -) -from .subscription_response_model_character_refresh_period import ( - SubscriptionResponseModelCharacterRefreshPeriod, -) -from ..core.pydantic_utilities import IS_PYDANTIC_V2 class SubscriptionResponse(UncheckedBaseModel): diff --git a/src/elevenlabs/types/subscription_status.py b/src/elevenlabs/types/subscription_status.py index bc9fc462..9fbd5131 100644 --- a/src/elevenlabs/types/subscription_status.py +++ b/src/elevenlabs/types/subscription_status.py @@ -3,15 +3,6 @@ import typing SubscriptionStatus = typing.Union[ - typing.Literal[ - "trialing", - "active", - "incomplete", - "incomplete_expired", - "past_due", - "canceled", - "unpaid", - "free", - ], + typing.Literal["trialing", "active", "incomplete", "incomplete_expired", "past_due", "canceled", "unpaid", "free"], typing.Any, ] diff --git a/src/elevenlabs/types/subscription_usage_response_model.py b/src/elevenlabs/types/subscription_usage_response_model.py index 0ebf0aa4..e3b67395 100644 --- a/src/elevenlabs/types/subscription_usage_response_model.py +++ b/src/elevenlabs/types/subscription_usage_response_model.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel +import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import typing +from ..core.unchecked_base_model import UncheckedBaseModel class SubscriptionUsageResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/system_tool_config_input.py b/src/elevenlabs/types/system_tool_config_input.py index 92bcf902..cb0373ce 100644 --- a/src/elevenlabs/types/system_tool_config_input.py +++ b/src/elevenlabs/types/system_tool_config_input.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing + import pydantic -from .system_tool_config_input_params import SystemToolConfigInputParams from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .system_tool_config_input_params import SystemToolConfigInputParams class SystemToolConfigInput(UncheckedBaseModel): diff --git a/src/elevenlabs/types/system_tool_config_input_params.py b/src/elevenlabs/types/system_tool_config_input_params.py index c067712a..c00ce41e 100644 --- a/src/elevenlabs/types/system_tool_config_input_params.py +++ b/src/elevenlabs/types/system_tool_config_input_params.py @@ -1,14 +1,15 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -from ..core.unchecked_base_model import UncheckedBaseModel + import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +import typing_extensions +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel, UnionMetadata from .agent_transfer import AgentTransfer from .phone_number_transfer import PhoneNumberTransfer -import typing_extensions -from ..core.unchecked_base_model import UnionMetadata class SystemToolConfigInputParams_EndCall(UncheckedBaseModel): diff --git a/src/elevenlabs/types/system_tool_config_output.py b/src/elevenlabs/types/system_tool_config_output.py index 2316f86c..e86d6a5d 100644 --- a/src/elevenlabs/types/system_tool_config_output.py +++ b/src/elevenlabs/types/system_tool_config_output.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing + import pydantic -from .system_tool_config_output_params import SystemToolConfigOutputParams from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .system_tool_config_output_params import SystemToolConfigOutputParams class SystemToolConfigOutput(UncheckedBaseModel): diff --git a/src/elevenlabs/types/system_tool_config_output_params.py b/src/elevenlabs/types/system_tool_config_output_params.py index 7f6f0101..db35f6d2 100644 --- a/src/elevenlabs/types/system_tool_config_output_params.py +++ b/src/elevenlabs/types/system_tool_config_output_params.py @@ -1,14 +1,15 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -from ..core.unchecked_base_model import UncheckedBaseModel + import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +import typing_extensions +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel, UnionMetadata from .agent_transfer import AgentTransfer from .phone_number_transfer import PhoneNumberTransfer -import typing_extensions -from ..core.unchecked_base_model import UnionMetadata class SystemToolConfigOutputParams_EndCall(UncheckedBaseModel): diff --git a/src/elevenlabs/types/tool_mock_config.py b/src/elevenlabs/types/tool_mock_config.py index 26f68fd2..22b0ec6d 100644 --- a/src/elevenlabs/types/tool_mock_config.py +++ b/src/elevenlabs/types/tool_mock_config.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class ToolMockConfig(UncheckedBaseModel): diff --git a/src/elevenlabs/types/transfer_to_agent_tool_config.py b/src/elevenlabs/types/transfer_to_agent_tool_config.py index a018982d..63cb8763 100644 --- a/src/elevenlabs/types/transfer_to_agent_tool_config.py +++ b/src/elevenlabs/types/transfer_to_agent_tool_config.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .agent_transfer import AgentTransfer -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .agent_transfer import AgentTransfer class TransferToAgentToolConfig(UncheckedBaseModel): diff --git a/src/elevenlabs/types/transfer_to_number_tool_config.py b/src/elevenlabs/types/transfer_to_number_tool_config.py index 0f0098c2..bf61b8ad 100644 --- a/src/elevenlabs/types/transfer_to_number_tool_config.py +++ b/src/elevenlabs/types/transfer_to_number_tool_config.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .phone_number_transfer import PhoneNumberTransfer -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .phone_number_transfer import PhoneNumberTransfer class TransferToNumberToolConfig(UncheckedBaseModel): diff --git a/src/elevenlabs/types/tts_conversational_config.py b/src/elevenlabs/types/tts_conversational_config.py index ed8672d6..67f17ca1 100644 --- a/src/elevenlabs/types/tts_conversational_config.py +++ b/src/elevenlabs/types/tts_conversational_config.py @@ -1,15 +1,14 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .tts_conversational_model import TtsConversationalModel + import pydantic -from .tts_output_format import TtsOutputFormat -from .tts_optimize_streaming_latency import TtsOptimizeStreamingLatency -from .pydantic_pronunciation_dictionary_version_locator import ( - PydanticPronunciationDictionaryVersionLocator, -) from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .pydantic_pronunciation_dictionary_version_locator import PydanticPronunciationDictionaryVersionLocator +from .tts_conversational_model import TtsConversationalModel +from .tts_optimize_streaming_latency import TtsOptimizeStreamingLatency +from .tts_output_format import TtsOutputFormat class TtsConversationalConfig(UncheckedBaseModel): diff --git a/src/elevenlabs/types/tts_conversational_config_override.py b/src/elevenlabs/types/tts_conversational_config_override.py index db600b89..7107e3b5 100644 --- a/src/elevenlabs/types/tts_conversational_config_override.py +++ b/src/elevenlabs/types/tts_conversational_config_override.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class TtsConversationalConfigOverride(UncheckedBaseModel): diff --git a/src/elevenlabs/types/tts_conversational_config_override_config.py b/src/elevenlabs/types/tts_conversational_config_override_config.py index 64247fec..fc473fbe 100644 --- a/src/elevenlabs/types/tts_conversational_config_override_config.py +++ b/src/elevenlabs/types/tts_conversational_config_override_config.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class TtsConversationalConfigOverrideConfig(UncheckedBaseModel): diff --git a/src/elevenlabs/types/tts_conversational_model.py b/src/elevenlabs/types/tts_conversational_model.py index 6ad39fe4..76638646 100644 --- a/src/elevenlabs/types/tts_conversational_model.py +++ b/src/elevenlabs/types/tts_conversational_model.py @@ -3,6 +3,5 @@ import typing TtsConversationalModel = typing.Union[ - typing.Literal["eleven_turbo_v2", "eleven_turbo_v2_5", "eleven_flash_v2", "eleven_flash_v2_5"], - typing.Any, + typing.Literal["eleven_turbo_v2", "eleven_turbo_v2_5", "eleven_flash_v2", "eleven_flash_v2_5"], typing.Any ] diff --git a/src/elevenlabs/types/tts_output_format.py b/src/elevenlabs/types/tts_output_format.py index 440b500a..d1bb069b 100644 --- a/src/elevenlabs/types/tts_output_format.py +++ b/src/elevenlabs/types/tts_output_format.py @@ -3,14 +3,5 @@ import typing TtsOutputFormat = typing.Union[ - typing.Literal[ - "pcm_8000", - "pcm_16000", - "pcm_22050", - "pcm_24000", - "pcm_44100", - "pcm_48000", - "ulaw_8000", - ], - typing.Any, + typing.Literal["pcm_8000", "pcm_16000", "pcm_22050", "pcm_24000", "pcm_44100", "pcm_48000", "ulaw_8000"], typing.Any ] diff --git a/src/elevenlabs/types/turn_config.py b/src/elevenlabs/types/turn_config.py index 1ad712d9..8e3ad153 100644 --- a/src/elevenlabs/types/turn_config.py +++ b/src/elevenlabs/types/turn_config.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing + import pydantic -from .turn_mode import TurnMode from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .turn_mode import TurnMode class TurnConfig(UncheckedBaseModel): diff --git a/src/elevenlabs/types/twilio_outbound_call_response.py b/src/elevenlabs/types/twilio_outbound_call_response.py index 806296ab..feb9423d 100644 --- a/src/elevenlabs/types/twilio_outbound_call_response.py +++ b/src/elevenlabs/types/twilio_outbound_call_response.py @@ -1,16 +1,18 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -import typing_extensions import typing -from ..core.serialization import FieldMetadata -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +import typing_extensions +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.serialization import FieldMetadata +from ..core.unchecked_base_model import UncheckedBaseModel class TwilioOutboundCallResponse(UncheckedBaseModel): success: bool message: str + conversation_id: typing.Optional[str] = None call_sid: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="callSid")] = None if IS_PYDANTIC_V2: diff --git a/src/elevenlabs/types/txt_export_options.py b/src/elevenlabs/types/txt_export_options.py index c5eead77..914a768d 100644 --- a/src/elevenlabs/types/txt_export_options.py +++ b/src/elevenlabs/types/txt_export_options.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class TxtExportOptions(UncheckedBaseModel): diff --git a/src/elevenlabs/types/update_pronunciation_dictionaries_request.py b/src/elevenlabs/types/update_pronunciation_dictionaries_request.py index 7e87c140..967441fe 100644 --- a/src/elevenlabs/types/update_pronunciation_dictionaries_request.py +++ b/src/elevenlabs/types/update_pronunciation_dictionaries_request.py @@ -1,12 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .pronunciation_dictionary_version_locator import ( - PronunciationDictionaryVersionLocator, -) + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .pronunciation_dictionary_version_locator import PronunciationDictionaryVersionLocator class UpdatePronunciationDictionariesRequest(UncheckedBaseModel): diff --git a/src/elevenlabs/types/update_workspace_member_response_model.py b/src/elevenlabs/types/update_workspace_member_response_model.py index 3041005f..4f5f94e5 100644 --- a/src/elevenlabs/types/update_workspace_member_response_model.py +++ b/src/elevenlabs/types/update_workspace_member_response_model.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel +import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import typing +from ..core.unchecked_base_model import UncheckedBaseModel class UpdateWorkspaceMemberResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/url_avatar.py b/src/elevenlabs/types/url_avatar.py index e6feafec..e0031367 100644 --- a/src/elevenlabs/types/url_avatar.py +++ b/src/elevenlabs/types/url_avatar.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class UrlAvatar(UncheckedBaseModel): diff --git a/src/elevenlabs/types/usage_characters_response_model.py b/src/elevenlabs/types/usage_characters_response_model.py index fb128866..5404ccd4 100644 --- a/src/elevenlabs/types/usage_characters_response_model.py +++ b/src/elevenlabs/types/usage_characters_response_model.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class UsageCharactersResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/user.py b/src/elevenlabs/types/user.py index 8259e3fa..a556ab9d 100644 --- a/src/elevenlabs/types/user.py +++ b/src/elevenlabs/types/user.py @@ -1,11 +1,12 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -import pydantic -from .subscription_response import SubscriptionResponse import typing -from .subscription_extras_response_model import SubscriptionExtrasResponseModel + +import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .subscription_extras_response_model import SubscriptionExtrasResponseModel +from .subscription_response import SubscriptionResponse class User(UncheckedBaseModel): diff --git a/src/elevenlabs/types/user_feedback.py b/src/elevenlabs/types/user_feedback.py index 47abecae..bd9762c9 100644 --- a/src/elevenlabs/types/user_feedback.py +++ b/src/elevenlabs/types/user_feedback.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from .user_feedback_score import UserFeedbackScore -from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .user_feedback_score import UserFeedbackScore class UserFeedback(UncheckedBaseModel): diff --git a/src/elevenlabs/types/utterance_response_model.py b/src/elevenlabs/types/utterance_response_model.py index 5c10cb78..c3fc7fda 100644 --- a/src/elevenlabs/types/utterance_response_model.py +++ b/src/elevenlabs/types/utterance_response_model.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel +import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import typing +from ..core.unchecked_base_model import UncheckedBaseModel class UtteranceResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/validation_error.py b/src/elevenlabs/types/validation_error.py index 72b616e6..0438bc05 100644 --- a/src/elevenlabs/types/validation_error.py +++ b/src/elevenlabs/types/validation_error.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .validation_error_loc_item import ValidationErrorLocItem -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .validation_error_loc_item import ValidationErrorLocItem class ValidationError(UncheckedBaseModel): diff --git a/src/elevenlabs/types/verification_attempt_response.py b/src/elevenlabs/types/verification_attempt_response.py index 756916da..29764227 100644 --- a/src/elevenlabs/types/verification_attempt_response.py +++ b/src/elevenlabs/types/verification_attempt_response.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -import pydantic import typing -from .recording_response import RecordingResponse + +import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .recording_response import RecordingResponse class VerificationAttemptResponse(UncheckedBaseModel): diff --git a/src/elevenlabs/types/verified_voice_language_response_model.py b/src/elevenlabs/types/verified_voice_language_response_model.py index dcfdb3f2..d5f5bdae 100644 --- a/src/elevenlabs/types/verified_voice_language_response_model.py +++ b/src/elevenlabs/types/verified_voice_language_response_model.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -import pydantic import typing + +import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class VerifiedVoiceLanguageResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/verify_pvc_voice_captcha_response_model.py b/src/elevenlabs/types/verify_pvc_voice_captcha_response_model.py index 00a49009..67abea0f 100644 --- a/src/elevenlabs/types/verify_pvc_voice_captcha_response_model.py +++ b/src/elevenlabs/types/verify_pvc_voice_captcha_response_model.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel +import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 -import typing +from ..core.unchecked_base_model import UncheckedBaseModel class VerifyPvcVoiceCaptchaResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/voice.py b/src/elevenlabs/types/voice.py index 24d3fbf6..08a8d0a4 100644 --- a/src/elevenlabs/types/voice.py +++ b/src/elevenlabs/types/voice.py @@ -1,17 +1,18 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -import pydantic import typing -from .voice_sample import VoiceSample -from .voice_response_model_category import VoiceResponseModelCategory + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel from .fine_tuning_response import FineTuningResponse -from .voice_settings import VoiceSettings -from .voice_sharing_response import VoiceSharingResponse from .verified_voice_language_response_model import VerifiedVoiceLanguageResponseModel +from .voice_response_model_category import VoiceResponseModelCategory from .voice_response_model_safety_control import VoiceResponseModelSafetyControl +from .voice_sample import VoiceSample +from .voice_settings import VoiceSettings +from .voice_sharing_response import VoiceSharingResponse from .voice_verification_response import VoiceVerificationResponse -from ..core.pydantic_utilities import IS_PYDANTIC_V2 class Voice(UncheckedBaseModel): diff --git a/src/elevenlabs/types/voice_design_preview_response.py b/src/elevenlabs/types/voice_design_preview_response.py index c82bcbe8..b0acdf8a 100644 --- a/src/elevenlabs/types/voice_design_preview_response.py +++ b/src/elevenlabs/types/voice_design_preview_response.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .voice_preview_response_model import VoicePreviewResponseModel -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .voice_preview_response_model import VoicePreviewResponseModel class VoiceDesignPreviewResponse(UncheckedBaseModel): diff --git a/src/elevenlabs/types/voice_generation_parameter_option_response.py b/src/elevenlabs/types/voice_generation_parameter_option_response.py index d4453190..98154f6c 100644 --- a/src/elevenlabs/types/voice_generation_parameter_option_response.py +++ b/src/elevenlabs/types/voice_generation_parameter_option_response.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class VoiceGenerationParameterOptionResponse(UncheckedBaseModel): diff --git a/src/elevenlabs/types/voice_generation_parameter_response.py b/src/elevenlabs/types/voice_generation_parameter_response.py index 016a5c16..e007ccdd 100644 --- a/src/elevenlabs/types/voice_generation_parameter_response.py +++ b/src/elevenlabs/types/voice_generation_parameter_response.py @@ -1,12 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .voice_generation_parameter_option_response import ( - VoiceGenerationParameterOptionResponse, -) -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .voice_generation_parameter_option_response import VoiceGenerationParameterOptionResponse class VoiceGenerationParameterResponse(UncheckedBaseModel): diff --git a/src/elevenlabs/types/voice_preview_response_model.py b/src/elevenlabs/types/voice_preview_response_model.py index a43c34b4..402c784b 100644 --- a/src/elevenlabs/types/voice_preview_response_model.py +++ b/src/elevenlabs/types/voice_preview_response_model.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from ..core.pydantic_utilities import IS_PYDANTIC_V2 import typing + import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class VoicePreviewResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/voice_response_model_category.py b/src/elevenlabs/types/voice_response_model_category.py index 65da4367..2743db78 100644 --- a/src/elevenlabs/types/voice_response_model_category.py +++ b/src/elevenlabs/types/voice_response_model_category.py @@ -3,6 +3,5 @@ import typing VoiceResponseModelCategory = typing.Union[ - typing.Literal["generated", "cloned", "premade", "professional", "famous", "high_quality"], - typing.Any, + typing.Literal["generated", "cloned", "premade", "professional", "famous", "high_quality"], typing.Any ] diff --git a/src/elevenlabs/types/voice_response_model_safety_control.py b/src/elevenlabs/types/voice_response_model_safety_control.py index 0417a478..8c887cd5 100644 --- a/src/elevenlabs/types/voice_response_model_safety_control.py +++ b/src/elevenlabs/types/voice_response_model_safety_control.py @@ -3,13 +3,6 @@ import typing VoiceResponseModelSafetyControl = typing.Union[ - typing.Literal[ - "NONE", - "BAN", - "CAPTCHA", - "CAPTCHA_AND_MODERATION", - "ENTERPRISE_BAN", - "ENTERPRISE_CAPTCHA", - ], + typing.Literal["NONE", "BAN", "CAPTCHA", "CAPTCHA_AND_MODERATION", "ENTERPRISE_BAN", "ENTERPRISE_CAPTCHA"], typing.Any, ] diff --git a/src/elevenlabs/types/voice_sample.py b/src/elevenlabs/types/voice_sample.py index e8dc42bf..363f04b9 100644 --- a/src/elevenlabs/types/voice_sample.py +++ b/src/elevenlabs/types/voice_sample.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing + import pydantic -from .speaker_separation_response_model import SpeakerSeparationResponseModel from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .speaker_separation_response_model import SpeakerSeparationResponseModel class VoiceSample(UncheckedBaseModel): diff --git a/src/elevenlabs/types/voice_sample_preview_response_model.py b/src/elevenlabs/types/voice_sample_preview_response_model.py index 90b30702..5c8982c5 100644 --- a/src/elevenlabs/types/voice_sample_preview_response_model.py +++ b/src/elevenlabs/types/voice_sample_preview_response_model.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -import pydantic import typing + +import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class VoiceSamplePreviewResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/voice_sample_visual_waveform_response_model.py b/src/elevenlabs/types/voice_sample_visual_waveform_response_model.py index 9ed45fdf..59e0f177 100644 --- a/src/elevenlabs/types/voice_sample_visual_waveform_response_model.py +++ b/src/elevenlabs/types/voice_sample_visual_waveform_response_model.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -import pydantic import typing + +import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class VoiceSampleVisualWaveformResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/voice_settings.py b/src/elevenlabs/types/voice_settings.py index c880d667..8f3e93be 100644 --- a/src/elevenlabs/types/voice_settings.py +++ b/src/elevenlabs/types/voice_settings.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class VoiceSettings(UncheckedBaseModel): diff --git a/src/elevenlabs/types/voice_sharing_moderation_check_response_model.py b/src/elevenlabs/types/voice_sharing_moderation_check_response_model.py index 749bc768..88bc3564 100644 --- a/src/elevenlabs/types/voice_sharing_moderation_check_response_model.py +++ b/src/elevenlabs/types/voice_sharing_moderation_check_response_model.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing + import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class VoiceSharingModerationCheckResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/types/voice_sharing_response.py b/src/elevenlabs/types/voice_sharing_response.py index 3b0444ce..15e52941 100644 --- a/src/elevenlabs/types/voice_sharing_response.py +++ b/src/elevenlabs/types/voice_sharing_response.py @@ -1,16 +1,15 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .voice_sharing_state import VoiceSharingState + import pydantic -from .voice_sharing_response_model_category import VoiceSharingResponseModelCategory -from .review_status import ReviewStatus -from .voice_sharing_moderation_check_response_model import ( - VoiceSharingModerationCheckResponseModel, -) -from .reader_resource_response_model import ReaderResourceResponseModel from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .reader_resource_response_model import ReaderResourceResponseModel +from .review_status import ReviewStatus +from .voice_sharing_moderation_check_response_model import VoiceSharingModerationCheckResponseModel +from .voice_sharing_response_model_category import VoiceSharingResponseModelCategory +from .voice_sharing_state import VoiceSharingState class VoiceSharingResponse(UncheckedBaseModel): @@ -64,6 +63,11 @@ class VoiceSharingResponse(UncheckedBaseModel): The rate of the voice sharing. """ + fiat_rate: typing.Optional[float] = pydantic.Field(default=None) + """ + The rate of the voice sharing in USD per 1000 credits. + """ + notice_period: typing.Optional[int] = pydantic.Field(default=None) """ The notice period of the voice sharing. diff --git a/src/elevenlabs/types/voice_sharing_response_model_category.py b/src/elevenlabs/types/voice_sharing_response_model_category.py index 0da22128..e66678ef 100644 --- a/src/elevenlabs/types/voice_sharing_response_model_category.py +++ b/src/elevenlabs/types/voice_sharing_response_model_category.py @@ -3,6 +3,5 @@ import typing VoiceSharingResponseModelCategory = typing.Union[ - typing.Literal["generated", "cloned", "premade", "professional", "famous", "high_quality"], - typing.Any, + typing.Literal["generated", "cloned", "premade", "professional", "famous", "high_quality"], typing.Any ] diff --git a/src/elevenlabs/types/voice_verification_response.py b/src/elevenlabs/types/voice_verification_response.py index 86c303b7..5928c4cd 100644 --- a/src/elevenlabs/types/voice_verification_response.py +++ b/src/elevenlabs/types/voice_verification_response.py @@ -1,10 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -import pydantic import typing -from .verification_attempt_response import VerificationAttemptResponse + +import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .verification_attempt_response import VerificationAttemptResponse class VoiceVerificationResponse(UncheckedBaseModel): diff --git a/src/elevenlabs/types/webhook_tool_api_schema_config_input.py b/src/elevenlabs/types/webhook_tool_api_schema_config_input.py index bc352d69..a99ef1ed 100644 --- a/src/elevenlabs/types/webhook_tool_api_schema_config_input.py +++ b/src/elevenlabs/types/webhook_tool_api_schema_config_input.py @@ -1,19 +1,18 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from .array_json_schema_property_input import ArrayJsonSchemaPropertyInput -from .object_json_schema_property_input import ObjectJsonSchemaPropertyInput -import pydantic +from __future__ import annotations + import typing -from .webhook_tool_api_schema_config_input_method import ( - WebhookToolApiSchemaConfigInputMethod, -) + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, update_forward_refs +from ..core.unchecked_base_model import UncheckedBaseModel from .literal_json_schema_property import LiteralJsonSchemaProperty from .query_params_json_schema import QueryParamsJsonSchema +from .webhook_tool_api_schema_config_input_method import WebhookToolApiSchemaConfigInputMethod from .webhook_tool_api_schema_config_input_request_headers_value import ( WebhookToolApiSchemaConfigInputRequestHeadersValue, ) -from ..core.pydantic_utilities import IS_PYDANTIC_V2 class WebhookToolApiSchemaConfigInput(UncheckedBaseModel): @@ -41,7 +40,7 @@ class WebhookToolApiSchemaConfigInput(UncheckedBaseModel): Schema for any query params, if any. These will be added to end of the URL as query params. Note: properties in a query param must all be literal types """ - request_body_schema: typing.Optional[ObjectJsonSchemaPropertyInput] = pydantic.Field(default=None) + request_body_schema: typing.Optional["ObjectJsonSchemaPropertyInput"] = pydantic.Field(default=None) """ Schema for the body parameters, if any. Used for POST/PATCH/PUT requests. The schema should be an object which will be sent as the json body """ @@ -61,3 +60,9 @@ class Config: frozen = True smart_union = True extra = pydantic.Extra.allow + + +from .array_json_schema_property_input import ArrayJsonSchemaPropertyInput # noqa: E402, F401, I001 +from .object_json_schema_property_input import ObjectJsonSchemaPropertyInput # noqa: E402, F401, I001 + +update_forward_refs(WebhookToolApiSchemaConfigInput) diff --git a/src/elevenlabs/types/webhook_tool_api_schema_config_input_request_headers_value.py b/src/elevenlabs/types/webhook_tool_api_schema_config_input_request_headers_value.py index 8230d410..0d78a328 100644 --- a/src/elevenlabs/types/webhook_tool_api_schema_config_input_request_headers_value.py +++ b/src/elevenlabs/types/webhook_tool_api_schema_config_input_request_headers_value.py @@ -1,6 +1,8 @@ # This file was auto-generated by Fern from our API Definition. import typing + +from .conv_ai_dynamic_variable import ConvAiDynamicVariable from .conv_ai_secret_locator import ConvAiSecretLocator -WebhookToolApiSchemaConfigInputRequestHeadersValue = typing.Union[str, ConvAiSecretLocator] +WebhookToolApiSchemaConfigInputRequestHeadersValue = typing.Union[str, ConvAiSecretLocator, ConvAiDynamicVariable] diff --git a/src/elevenlabs/types/webhook_tool_api_schema_config_output.py b/src/elevenlabs/types/webhook_tool_api_schema_config_output.py index 03000339..c6558c53 100644 --- a/src/elevenlabs/types/webhook_tool_api_schema_config_output.py +++ b/src/elevenlabs/types/webhook_tool_api_schema_config_output.py @@ -1,19 +1,18 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from .array_json_schema_property_output import ArrayJsonSchemaPropertyOutput -from .object_json_schema_property_output import ObjectJsonSchemaPropertyOutput -import pydantic +from __future__ import annotations + import typing -from .webhook_tool_api_schema_config_output_method import ( - WebhookToolApiSchemaConfigOutputMethod, -) + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2, update_forward_refs +from ..core.unchecked_base_model import UncheckedBaseModel from .literal_json_schema_property import LiteralJsonSchemaProperty from .query_params_json_schema import QueryParamsJsonSchema +from .webhook_tool_api_schema_config_output_method import WebhookToolApiSchemaConfigOutputMethod from .webhook_tool_api_schema_config_output_request_headers_value import ( WebhookToolApiSchemaConfigOutputRequestHeadersValue, ) -from ..core.pydantic_utilities import IS_PYDANTIC_V2 class WebhookToolApiSchemaConfigOutput(UncheckedBaseModel): @@ -41,7 +40,7 @@ class WebhookToolApiSchemaConfigOutput(UncheckedBaseModel): Schema for any query params, if any. These will be added to end of the URL as query params. Note: properties in a query param must all be literal types """ - request_body_schema: typing.Optional[ObjectJsonSchemaPropertyOutput] = pydantic.Field(default=None) + request_body_schema: typing.Optional["ObjectJsonSchemaPropertyOutput"] = pydantic.Field(default=None) """ Schema for the body parameters, if any. Used for POST/PATCH/PUT requests. The schema should be an object which will be sent as the json body """ @@ -61,3 +60,9 @@ class Config: frozen = True smart_union = True extra = pydantic.Extra.allow + + +from .array_json_schema_property_output import ArrayJsonSchemaPropertyOutput # noqa: E402, F401, I001 +from .object_json_schema_property_output import ObjectJsonSchemaPropertyOutput # noqa: E402, F401, I001 + +update_forward_refs(WebhookToolApiSchemaConfigOutput) diff --git a/src/elevenlabs/types/webhook_tool_api_schema_config_output_request_headers_value.py b/src/elevenlabs/types/webhook_tool_api_schema_config_output_request_headers_value.py index f1208dd3..ec66052b 100644 --- a/src/elevenlabs/types/webhook_tool_api_schema_config_output_request_headers_value.py +++ b/src/elevenlabs/types/webhook_tool_api_schema_config_output_request_headers_value.py @@ -1,6 +1,8 @@ # This file was auto-generated by Fern from our API Definition. import typing + +from .conv_ai_dynamic_variable import ConvAiDynamicVariable from .conv_ai_secret_locator import ConvAiSecretLocator -WebhookToolApiSchemaConfigOutputRequestHeadersValue = typing.Union[str, ConvAiSecretLocator] +WebhookToolApiSchemaConfigOutputRequestHeadersValue = typing.Union[str, ConvAiSecretLocator, ConvAiDynamicVariable] diff --git a/src/elevenlabs/types/webhook_tool_config_input.py b/src/elevenlabs/types/webhook_tool_config_input.py index 917e03d1..3fde81e4 100644 --- a/src/elevenlabs/types/webhook_tool_config_input.py +++ b/src/elevenlabs/types/webhook_tool_config_input.py @@ -1,13 +1,14 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from .array_json_schema_property_input import ArrayJsonSchemaPropertyInput -from .object_json_schema_property_input import ObjectJsonSchemaPropertyInput +from __future__ import annotations + import typing + import pydantic -from .webhook_tool_api_schema_config_input import WebhookToolApiSchemaConfigInput +from ..core.pydantic_utilities import IS_PYDANTIC_V2, update_forward_refs +from ..core.unchecked_base_model import UncheckedBaseModel from .dynamic_variables_config import DynamicVariablesConfig -from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from .webhook_tool_api_schema_config_input import WebhookToolApiSchemaConfigInput class WebhookToolConfigInput(UncheckedBaseModel): @@ -41,3 +42,9 @@ class Config: frozen = True smart_union = True extra = pydantic.Extra.allow + + +from .array_json_schema_property_input import ArrayJsonSchemaPropertyInput # noqa: E402, F401, I001 +from .object_json_schema_property_input import ObjectJsonSchemaPropertyInput # noqa: E402, F401, I001 + +update_forward_refs(WebhookToolConfigInput) diff --git a/src/elevenlabs/types/webhook_tool_config_output.py b/src/elevenlabs/types/webhook_tool_config_output.py index 9fae15d3..c28c83c9 100644 --- a/src/elevenlabs/types/webhook_tool_config_output.py +++ b/src/elevenlabs/types/webhook_tool_config_output.py @@ -1,13 +1,14 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -from .array_json_schema_property_output import ArrayJsonSchemaPropertyOutput -from .object_json_schema_property_output import ObjectJsonSchemaPropertyOutput +from __future__ import annotations + import typing + import pydantic -from .webhook_tool_api_schema_config_output import WebhookToolApiSchemaConfigOutput +from ..core.pydantic_utilities import IS_PYDANTIC_V2, update_forward_refs +from ..core.unchecked_base_model import UncheckedBaseModel from .dynamic_variables_config import DynamicVariablesConfig -from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from .webhook_tool_api_schema_config_output import WebhookToolApiSchemaConfigOutput class WebhookToolConfigOutput(UncheckedBaseModel): @@ -41,3 +42,9 @@ class Config: frozen = True smart_union = True extra = pydantic.Extra.allow + + +from .array_json_schema_property_output import ArrayJsonSchemaPropertyOutput # noqa: E402, F401, I001 +from .object_json_schema_property_output import ObjectJsonSchemaPropertyOutput # noqa: E402, F401, I001 + +update_forward_refs(WebhookToolConfigOutput) diff --git a/src/elevenlabs/types/websocket_tts_client_message_multi.py b/src/elevenlabs/types/websocket_tts_client_message_multi.py index 7d0020cc..376cc3e1 100644 --- a/src/elevenlabs/types/websocket_tts_client_message_multi.py +++ b/src/elevenlabs/types/websocket_tts_client_message_multi.py @@ -1,14 +1,15 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing + import pydantic -from .realtime_voice_settings import RealtimeVoiceSettings -from .generation_config import GenerationConfig import typing_extensions +from ..core.pydantic_utilities import IS_PYDANTIC_V2 from ..core.serialization import FieldMetadata +from ..core.unchecked_base_model import UncheckedBaseModel +from .generation_config import GenerationConfig from .pronunciation_dictionary_locator import PronunciationDictionaryLocator -from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from .realtime_voice_settings import RealtimeVoiceSettings class WebsocketTtsClientMessageMulti(UncheckedBaseModel): diff --git a/src/elevenlabs/types/websocket_tts_server_message_multi.py b/src/elevenlabs/types/websocket_tts_server_message_multi.py index f51f2289..1eef82a2 100644 --- a/src/elevenlabs/types/websocket_tts_server_message_multi.py +++ b/src/elevenlabs/types/websocket_tts_server_message_multi.py @@ -1,13 +1,14 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing + import pydantic import typing_extensions -from .normalized_alignment import NormalizedAlignment +from ..core.pydantic_utilities import IS_PYDANTIC_V2 from ..core.serialization import FieldMetadata +from ..core.unchecked_base_model import UncheckedBaseModel from .alignment import Alignment -from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from .normalized_alignment import NormalizedAlignment class WebsocketTtsServerMessageMulti(UncheckedBaseModel): diff --git a/src/elevenlabs/types/widget_config.py b/src/elevenlabs/types/widget_config.py index 028ff7d5..a50cabc1 100644 --- a/src/elevenlabs/types/widget_config.py +++ b/src/elevenlabs/types/widget_config.py @@ -1,13 +1,14 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .embed_variant import EmbedVariant + import pydantic -from .widget_expandable import WidgetExpandable +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .embed_variant import EmbedVariant from .widget_config_avatar import WidgetConfigAvatar +from .widget_expandable import WidgetExpandable from .widget_feedback_mode import WidgetFeedbackMode -from ..core.pydantic_utilities import IS_PYDANTIC_V2 class WidgetConfig(UncheckedBaseModel): @@ -136,6 +137,11 @@ class WidgetConfig(UncheckedBaseModel): Whether to disable the banner """ + override_link: typing.Optional[str] = pydantic.Field(default=None) + """ + The override link for the widget + """ + mic_muting_enabled: typing.Optional[bool] = pydantic.Field(default=None) """ Whether to enable mic muting diff --git a/src/elevenlabs/types/widget_config_avatar.py b/src/elevenlabs/types/widget_config_avatar.py index 19c48c6c..9f25368a 100644 --- a/src/elevenlabs/types/widget_config_avatar.py +++ b/src/elevenlabs/types/widget_config_avatar.py @@ -1,12 +1,13 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -from ..core.unchecked_base_model import UncheckedBaseModel + import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic import typing_extensions -from ..core.unchecked_base_model import UnionMetadata +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel, UnionMetadata class WidgetConfigAvatar_Orb(UncheckedBaseModel): diff --git a/src/elevenlabs/types/widget_config_response_model.py b/src/elevenlabs/types/widget_config_response_model.py index f760b7c1..d7a5649b 100644 --- a/src/elevenlabs/types/widget_config_response_model.py +++ b/src/elevenlabs/types/widget_config_response_model.py @@ -1,13 +1,14 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel import typing -from .embed_variant import EmbedVariant + import pydantic -from .widget_expandable import WidgetExpandable +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .embed_variant import EmbedVariant from .widget_config_response_model_avatar import WidgetConfigResponseModelAvatar +from .widget_expandable import WidgetExpandable from .widget_feedback_mode import WidgetFeedbackMode -from ..core.pydantic_utilities import IS_PYDANTIC_V2 class WidgetConfigResponseModel(UncheckedBaseModel): @@ -136,6 +137,11 @@ class WidgetConfigResponseModel(UncheckedBaseModel): Whether to disable the banner """ + override_link: typing.Optional[str] = pydantic.Field(default=None) + """ + The override link for the widget + """ + mic_muting_enabled: typing.Optional[bool] = pydantic.Field(default=None) """ Whether to enable mic muting diff --git a/src/elevenlabs/types/widget_config_response_model_avatar.py b/src/elevenlabs/types/widget_config_response_model_avatar.py index dad0be4c..bb827b79 100644 --- a/src/elevenlabs/types/widget_config_response_model_avatar.py +++ b/src/elevenlabs/types/widget_config_response_model_avatar.py @@ -1,12 +1,13 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -from ..core.unchecked_base_model import UncheckedBaseModel + import typing -from ..core.pydantic_utilities import IS_PYDANTIC_V2 + import pydantic import typing_extensions -from ..core.unchecked_base_model import UnionMetadata +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel, UnionMetadata class WidgetConfigResponseModelAvatar_Orb(UncheckedBaseModel): @@ -66,9 +67,7 @@ class Config: WidgetConfigResponseModelAvatar = typing_extensions.Annotated[ typing.Union[ - WidgetConfigResponseModelAvatar_Orb, - WidgetConfigResponseModelAvatar_Url, - WidgetConfigResponseModelAvatar_Image, + WidgetConfigResponseModelAvatar_Orb, WidgetConfigResponseModelAvatar_Url, WidgetConfigResponseModelAvatar_Image ], UnionMetadata(discriminant="type"), ] diff --git a/src/elevenlabs/types/workspace_batch_calls_response.py b/src/elevenlabs/types/workspace_batch_calls_response.py new file mode 100644 index 00000000..72c52e2d --- /dev/null +++ b/src/elevenlabs/types/workspace_batch_calls_response.py @@ -0,0 +1,30 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .batch_call_response import BatchCallResponse + + +class WorkspaceBatchCallsResponse(UncheckedBaseModel): + batch_calls: typing.List[BatchCallResponse] + next_doc: typing.Optional[str] = pydantic.Field(default=None) + """ + The next document, used to paginate through the batch calls + """ + + has_more: typing.Optional[bool] = pydantic.Field(default=None) + """ + Whether there are more batch calls to paginate through + """ + + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 + else: + + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/elevenlabs/types/workspace_group_by_name_response_model.py b/src/elevenlabs/types/workspace_group_by_name_response_model.py index 0f83d6f4..5369eeda 100644 --- a/src/elevenlabs/types/workspace_group_by_name_response_model.py +++ b/src/elevenlabs/types/workspace_group_by_name_response_model.py @@ -1,9 +1,10 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.unchecked_base_model import UncheckedBaseModel -import pydantic import typing + +import pydantic from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel class WorkspaceGroupByNameResponseModel(UncheckedBaseModel): diff --git a/src/elevenlabs/usage/__init__.py b/src/elevenlabs/usage/__init__.py index f3ea2659..5cde0202 100644 --- a/src/elevenlabs/usage/__init__.py +++ b/src/elevenlabs/usage/__init__.py @@ -1,2 +1,4 @@ # This file was auto-generated by Fern from our API Definition. +# isort: skip_file + diff --git a/src/elevenlabs/usage/client.py b/src/elevenlabs/usage/client.py index d87b94bd..fb980a51 100644 --- a/src/elevenlabs/usage/client.py +++ b/src/elevenlabs/usage/client.py @@ -1,25 +1,32 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.client_wrapper import SyncClientWrapper import typing + +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ..core.request_options import RequestOptions from ..types.breakdown_types import BreakdownTypes -from ..types.usage_aggregation_interval import UsageAggregationInterval from ..types.metric_type import MetricType -from ..core.request_options import RequestOptions +from ..types.usage_aggregation_interval import UsageAggregationInterval from ..types.usage_characters_response_model import UsageCharactersResponseModel -from ..core.unchecked_base_model import construct_type -from ..errors.unprocessable_entity_error import UnprocessableEntityError -from ..types.http_validation_error import HttpValidationError -from json.decoder import JSONDecodeError -from ..core.api_error import ApiError -from ..core.client_wrapper import AsyncClientWrapper +from .raw_client import AsyncRawUsageClient, RawUsageClient class UsageClient: def __init__(self, *, client_wrapper: SyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = RawUsageClient(client_wrapper=client_wrapper) - def get_characters_usage_metrics( + @property + def with_raw_response(self) -> RawUsageClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawUsageClient + """ + return self._raw_client + + def get( self, *, start_unix: int, @@ -68,55 +75,39 @@ def get_characters_usage_metrics( client = ElevenLabs( api_key="YOUR_API_KEY", ) - client.usage.get_characters_usage_metrics( + client.usage.get( start_unix=1, end_unix=1, ) """ - _response = self._client_wrapper.httpx_client.request( - "v1/usage/character-stats", - base_url=self._client_wrapper.get_environment().base, - method="GET", - params={ - "start_unix": start_unix, - "end_unix": end_unix, - "include_workspace_metrics": include_workspace_metrics, - "breakdown_type": breakdown_type, - "aggregation_interval": aggregation_interval, - "metric": metric, - }, + _response = self._raw_client.get( + start_unix=start_unix, + end_unix=end_unix, + include_workspace_metrics=include_workspace_metrics, + breakdown_type=breakdown_type, + aggregation_interval=aggregation_interval, + metric=metric, request_options=request_options, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - UsageCharactersResponseModel, - construct_type( - type_=UsageCharactersResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + return _response.data class AsyncUsageClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = AsyncRawUsageClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawUsageClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawUsageClient + """ + return self._raw_client - async def get_characters_usage_metrics( + async def get( self, *, start_unix: int, @@ -170,7 +161,7 @@ async def get_characters_usage_metrics( async def main() -> None: - await client.usage.get_characters_usage_metrics( + await client.usage.get( start_unix=1, end_unix=1, ) @@ -178,40 +169,13 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - "v1/usage/character-stats", - base_url=self._client_wrapper.get_environment().base, - method="GET", - params={ - "start_unix": start_unix, - "end_unix": end_unix, - "include_workspace_metrics": include_workspace_metrics, - "breakdown_type": breakdown_type, - "aggregation_interval": aggregation_interval, - "metric": metric, - }, + _response = await self._raw_client.get( + start_unix=start_unix, + end_unix=end_unix, + include_workspace_metrics=include_workspace_metrics, + breakdown_type=breakdown_type, + aggregation_interval=aggregation_interval, + metric=metric, request_options=request_options, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - UsageCharactersResponseModel, - construct_type( - type_=UsageCharactersResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + return _response.data diff --git a/src/elevenlabs/usage/raw_client.py b/src/elevenlabs/usage/raw_client.py new file mode 100644 index 00000000..e716429c --- /dev/null +++ b/src/elevenlabs/usage/raw_client.py @@ -0,0 +1,190 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ..core.api_error import ApiError +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ..core.http_response import AsyncHttpResponse, HttpResponse +from ..core.request_options import RequestOptions +from ..core.unchecked_base_model import construct_type +from ..errors.unprocessable_entity_error import UnprocessableEntityError +from ..types.breakdown_types import BreakdownTypes +from ..types.http_validation_error import HttpValidationError +from ..types.metric_type import MetricType +from ..types.usage_aggregation_interval import UsageAggregationInterval +from ..types.usage_characters_response_model import UsageCharactersResponseModel + + +class RawUsageClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def get( + self, + *, + start_unix: int, + end_unix: int, + include_workspace_metrics: typing.Optional[bool] = None, + breakdown_type: typing.Optional[BreakdownTypes] = None, + aggregation_interval: typing.Optional[UsageAggregationInterval] = None, + metric: typing.Optional[MetricType] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[UsageCharactersResponseModel]: + """ + Returns the usage metrics for the current user or the entire workspace they are part of. The response provides a time axis based on the specified aggregation interval (default: day), with usage values for each interval along that axis. Usage is broken down by the selected breakdown type. For example, breakdown type "voice" will return the usage of each voice for each interval along the time axis. + + Parameters + ---------- + start_unix : int + UTC Unix timestamp for the start of the usage window, in milliseconds. To include the first day of the window, the timestamp should be at 00:00:00 of that day. + + end_unix : int + UTC Unix timestamp for the end of the usage window, in milliseconds. To include the last day of the window, the timestamp should be at 23:59:59 of that day. + + include_workspace_metrics : typing.Optional[bool] + Whether or not to include the statistics of the entire workspace. + + breakdown_type : typing.Optional[BreakdownTypes] + How to break down the information. Cannot be "user" if include_workspace_metrics is False. + + aggregation_interval : typing.Optional[UsageAggregationInterval] + How to aggregate usage data over time. Can be "hour", "day", "week", "month", or "cumulative". + + metric : typing.Optional[MetricType] + Which metric to aggregate. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[UsageCharactersResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + "v1/usage/character-stats", + base_url=self._client_wrapper.get_environment().base, + method="GET", + params={ + "start_unix": start_unix, + "end_unix": end_unix, + "include_workspace_metrics": include_workspace_metrics, + "breakdown_type": breakdown_type, + "aggregation_interval": aggregation_interval, + "metric": metric, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + UsageCharactersResponseModel, + construct_type( + type_=UsageCharactersResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + +class AsyncRawUsageClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def get( + self, + *, + start_unix: int, + end_unix: int, + include_workspace_metrics: typing.Optional[bool] = None, + breakdown_type: typing.Optional[BreakdownTypes] = None, + aggregation_interval: typing.Optional[UsageAggregationInterval] = None, + metric: typing.Optional[MetricType] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[UsageCharactersResponseModel]: + """ + Returns the usage metrics for the current user or the entire workspace they are part of. The response provides a time axis based on the specified aggregation interval (default: day), with usage values for each interval along that axis. Usage is broken down by the selected breakdown type. For example, breakdown type "voice" will return the usage of each voice for each interval along the time axis. + + Parameters + ---------- + start_unix : int + UTC Unix timestamp for the start of the usage window, in milliseconds. To include the first day of the window, the timestamp should be at 00:00:00 of that day. + + end_unix : int + UTC Unix timestamp for the end of the usage window, in milliseconds. To include the last day of the window, the timestamp should be at 23:59:59 of that day. + + include_workspace_metrics : typing.Optional[bool] + Whether or not to include the statistics of the entire workspace. + + breakdown_type : typing.Optional[BreakdownTypes] + How to break down the information. Cannot be "user" if include_workspace_metrics is False. + + aggregation_interval : typing.Optional[UsageAggregationInterval] + How to aggregate usage data over time. Can be "hour", "day", "week", "month", or "cumulative". + + metric : typing.Optional[MetricType] + Which metric to aggregate. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[UsageCharactersResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + "v1/usage/character-stats", + base_url=self._client_wrapper.get_environment().base, + method="GET", + params={ + "start_unix": start_unix, + "end_unix": end_unix, + "include_workspace_metrics": include_workspace_metrics, + "breakdown_type": breakdown_type, + "aggregation_interval": aggregation_interval, + "metric": metric, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + UsageCharactersResponseModel, + construct_type( + type_=UsageCharactersResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/elevenlabs/user/__init__.py b/src/elevenlabs/user/__init__.py index f3ea2659..d07505ef 100644 --- a/src/elevenlabs/user/__init__.py +++ b/src/elevenlabs/user/__init__.py @@ -1,2 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# isort: skip_file + +from . import subscription + +__all__ = ["subscription"] diff --git a/src/elevenlabs/user/client.py b/src/elevenlabs/user/client.py index d9e6f9f6..0dd631f1 100644 --- a/src/elevenlabs/user/client.py +++ b/src/elevenlabs/user/client.py @@ -1,74 +1,29 @@ # This file was auto-generated by Fern from our API Definition. -from ..core.client_wrapper import SyncClientWrapper import typing + +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ..core.request_options import RequestOptions -from ..types.subscription import Subscription -from ..core.unchecked_base_model import construct_type -from ..errors.unprocessable_entity_error import UnprocessableEntityError -from ..types.http_validation_error import HttpValidationError -from json.decoder import JSONDecodeError -from ..core.api_error import ApiError from ..types.user import User -from ..core.client_wrapper import AsyncClientWrapper +from .raw_client import AsyncRawUserClient, RawUserClient +from .subscription.client import AsyncSubscriptionClient, SubscriptionClient class UserClient: def __init__(self, *, client_wrapper: SyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = RawUserClient(client_wrapper=client_wrapper) + self.subscription = SubscriptionClient(client_wrapper=client_wrapper) - def get_subscription(self, *, request_options: typing.Optional[RequestOptions] = None) -> Subscription: + @property + def with_raw_response(self) -> RawUserClient: """ - Gets extended information about the users subscription - - Parameters - ---------- - request_options : typing.Optional[RequestOptions] - Request-specific configuration. + Retrieves a raw implementation of this client that returns raw responses. Returns ------- - Subscription - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.user.get_subscription() + RawUserClient """ - _response = self._client_wrapper.httpx_client.request( - "v1/user/subscription", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - Subscription, - construct_type( - type_=Subscription, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + return self._raw_client def get(self, *, request_options: typing.Optional[RequestOptions] = None) -> User: """ @@ -93,101 +48,25 @@ def get(self, *, request_options: typing.Optional[RequestOptions] = None) -> Use ) client.user.get() """ - _response = self._client_wrapper.httpx_client.request( - "v1/user", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - User, - construct_type( - type_=User, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.get(request_options=request_options) + return _response.data class AsyncUserClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = AsyncRawUserClient(client_wrapper=client_wrapper) + self.subscription = AsyncSubscriptionClient(client_wrapper=client_wrapper) - async def get_subscription(self, *, request_options: typing.Optional[RequestOptions] = None) -> Subscription: + @property + def with_raw_response(self) -> AsyncRawUserClient: """ - Gets extended information about the users subscription - - Parameters - ---------- - request_options : typing.Optional[RequestOptions] - Request-specific configuration. + Retrieves a raw implementation of this client that returns raw responses. Returns ------- - Subscription - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.user.get_subscription() - - - asyncio.run(main()) + AsyncRawUserClient """ - _response = await self._client_wrapper.httpx_client.request( - "v1/user/subscription", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - Subscription, - construct_type( - type_=Subscription, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + return self._raw_client async def get(self, *, request_options: typing.Optional[RequestOptions] = None) -> User: """ @@ -220,32 +99,5 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - "v1/user", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - User, - construct_type( - type_=User, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.get(request_options=request_options) + return _response.data diff --git a/src/elevenlabs/user/raw_client.py b/src/elevenlabs/user/raw_client.py new file mode 100644 index 00000000..9aca6937 --- /dev/null +++ b/src/elevenlabs/user/raw_client.py @@ -0,0 +1,115 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ..core.api_error import ApiError +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ..core.http_response import AsyncHttpResponse, HttpResponse +from ..core.request_options import RequestOptions +from ..core.unchecked_base_model import construct_type +from ..errors.unprocessable_entity_error import UnprocessableEntityError +from ..types.http_validation_error import HttpValidationError +from ..types.user import User + + +class RawUserClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def get(self, *, request_options: typing.Optional[RequestOptions] = None) -> HttpResponse[User]: + """ + Gets information about the user + + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[User] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + "v1/user", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + User, + construct_type( + type_=User, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + +class AsyncRawUserClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def get(self, *, request_options: typing.Optional[RequestOptions] = None) -> AsyncHttpResponse[User]: + """ + Gets information about the user + + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[User] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + "v1/user", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + User, + construct_type( + type_=User, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/elevenlabs/user/subscription/__init__.py b/src/elevenlabs/user/subscription/__init__.py new file mode 100644 index 00000000..5cde0202 --- /dev/null +++ b/src/elevenlabs/user/subscription/__init__.py @@ -0,0 +1,4 @@ +# This file was auto-generated by Fern from our API Definition. + +# isort: skip_file + diff --git a/src/elevenlabs/user/subscription/client.py b/src/elevenlabs/user/subscription/client.py new file mode 100644 index 00000000..060fe368 --- /dev/null +++ b/src/elevenlabs/user/subscription/client.py @@ -0,0 +1,100 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ...core.request_options import RequestOptions +from ...types.subscription import Subscription +from .raw_client import AsyncRawSubscriptionClient, RawSubscriptionClient + + +class SubscriptionClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._raw_client = RawSubscriptionClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawSubscriptionClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawSubscriptionClient + """ + return self._raw_client + + def get(self, *, request_options: typing.Optional[RequestOptions] = None) -> Subscription: + """ + Gets extended information about the users subscription + + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + Subscription + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.user.subscription.get() + """ + _response = self._raw_client.get(request_options=request_options) + return _response.data + + +class AsyncSubscriptionClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawSubscriptionClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawSubscriptionClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawSubscriptionClient + """ + return self._raw_client + + async def get(self, *, request_options: typing.Optional[RequestOptions] = None) -> Subscription: + """ + Gets extended information about the users subscription + + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + Subscription + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.user.subscription.get() + + + asyncio.run(main()) + """ + _response = await self._raw_client.get(request_options=request_options) + return _response.data diff --git a/src/elevenlabs/user/subscription/raw_client.py b/src/elevenlabs/user/subscription/raw_client.py new file mode 100644 index 00000000..3228baf0 --- /dev/null +++ b/src/elevenlabs/user/subscription/raw_client.py @@ -0,0 +1,115 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ...core.api_error import ApiError +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ...core.http_response import AsyncHttpResponse, HttpResponse +from ...core.request_options import RequestOptions +from ...core.unchecked_base_model import construct_type +from ...errors.unprocessable_entity_error import UnprocessableEntityError +from ...types.http_validation_error import HttpValidationError +from ...types.subscription import Subscription + + +class RawSubscriptionClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def get(self, *, request_options: typing.Optional[RequestOptions] = None) -> HttpResponse[Subscription]: + """ + Gets extended information about the users subscription + + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[Subscription] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + "v1/user/subscription", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + Subscription, + construct_type( + type_=Subscription, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + +class AsyncRawSubscriptionClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def get(self, *, request_options: typing.Optional[RequestOptions] = None) -> AsyncHttpResponse[Subscription]: + """ + Gets extended information about the users subscription + + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[Subscription] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + "v1/user/subscription", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + Subscription, + construct_type( + type_=Subscription, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/elevenlabs/v_1_text_to_speech_voice_id_multi_stream_input/__init__.py b/src/elevenlabs/v_1_text_to_speech_voice_id_multi_stream_input/__init__.py index 8b09356a..358eb08b 100644 --- a/src/elevenlabs/v_1_text_to_speech_voice_id_multi_stream_input/__init__.py +++ b/src/elevenlabs/v_1_text_to_speech_voice_id_multi_stream_input/__init__.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. -from .types import ReceiveMessageMulti, SendMessageMulti, TextToSpeechApplyTextNormalization, TextToSpeechOutputFormat +# isort: skip_file -__all__ = ["ReceiveMessageMulti", "SendMessageMulti", "TextToSpeechApplyTextNormalization", "TextToSpeechOutputFormat"] +from .types import ReceiveMessageMulti, SendMessageMulti + +__all__ = ["ReceiveMessageMulti", "SendMessageMulti"] diff --git a/src/elevenlabs/v_1_text_to_speech_voice_id_multi_stream_input/types/__init__.py b/src/elevenlabs/v_1_text_to_speech_voice_id_multi_stream_input/types/__init__.py index c75ab8d2..19eb1be0 100644 --- a/src/elevenlabs/v_1_text_to_speech_voice_id_multi_stream_input/types/__init__.py +++ b/src/elevenlabs/v_1_text_to_speech_voice_id_multi_stream_input/types/__init__.py @@ -1,8 +1,8 @@ # This file was auto-generated by Fern from our API Definition. +# isort: skip_file + from .receive_message_multi import ReceiveMessageMulti from .send_message_multi import SendMessageMulti -from .text_to_speech_apply_text_normalization import TextToSpeechApplyTextNormalization -from .text_to_speech_output_format import TextToSpeechOutputFormat -__all__ = ["ReceiveMessageMulti", "SendMessageMulti", "TextToSpeechApplyTextNormalization", "TextToSpeechOutputFormat"] +__all__ = ["ReceiveMessageMulti", "SendMessageMulti"] diff --git a/src/elevenlabs/v_1_text_to_speech_voice_id_multi_stream_input/types/receive_message_multi.py b/src/elevenlabs/v_1_text_to_speech_voice_id_multi_stream_input/types/receive_message_multi.py index 8b8832fd..d5f2d866 100644 --- a/src/elevenlabs/v_1_text_to_speech_voice_id_multi_stream_input/types/receive_message_multi.py +++ b/src/elevenlabs/v_1_text_to_speech_voice_id_multi_stream_input/types/receive_message_multi.py @@ -1,6 +1,7 @@ # This file was auto-generated by Fern from our API Definition. import typing + from ...types.audio_output_multi import AudioOutputMulti from ...types.final_output_multi import FinalOutputMulti diff --git a/src/elevenlabs/v_1_text_to_speech_voice_id_multi_stream_input/types/send_message_multi.py b/src/elevenlabs/v_1_text_to_speech_voice_id_multi_stream_input/types/send_message_multi.py index dc1b93a9..d06d7d28 100644 --- a/src/elevenlabs/v_1_text_to_speech_voice_id_multi_stream_input/types/send_message_multi.py +++ b/src/elevenlabs/v_1_text_to_speech_voice_id_multi_stream_input/types/send_message_multi.py @@ -1,13 +1,14 @@ # This file was auto-generated by Fern from our API Definition. import typing -from ...types.initialize_connection_multi import InitializeConnectionMulti -from ...types.initialise_context import InitialiseContext -from ...types.send_text_multi import SendTextMulti -from ...types.flush_context import FlushContext + from ...types.close_context import CloseContext from ...types.close_socket import CloseSocket +from ...types.flush_context import FlushContext +from ...types.initialise_context import InitialiseContext +from ...types.initialize_connection_multi import InitializeConnectionMulti from ...types.keep_context_alive import KeepContextAlive +from ...types.send_text_multi import SendTextMulti SendMessageMulti = typing.Union[ InitializeConnectionMulti, diff --git a/src/elevenlabs/v_1_text_to_speech_voice_id_multi_stream_input/types/text_to_speech_apply_text_normalization.py b/src/elevenlabs/v_1_text_to_speech_voice_id_multi_stream_input/types/text_to_speech_apply_text_normalization.py deleted file mode 100644 index 14b9ee34..00000000 --- a/src/elevenlabs/v_1_text_to_speech_voice_id_multi_stream_input/types/text_to_speech_apply_text_normalization.py +++ /dev/null @@ -1,5 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import typing - -TextToSpeechApplyTextNormalization = typing.Union[typing.Literal["auto", "on", "off"], typing.Any] diff --git a/src/elevenlabs/v_1_text_to_speech_voice_id_multi_stream_input/types/text_to_speech_output_format.py b/src/elevenlabs/v_1_text_to_speech_voice_id_multi_stream_input/types/text_to_speech_output_format.py deleted file mode 100644 index cea03a2c..00000000 --- a/src/elevenlabs/v_1_text_to_speech_voice_id_multi_stream_input/types/text_to_speech_output_format.py +++ /dev/null @@ -1,27 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import typing - -TextToSpeechOutputFormat = typing.Union[ - typing.Literal[ - "mp3_22050_32", - "mp3_44100_32", - "mp3_44100_64", - "mp3_44100_96", - "mp3_44100_128", - "mp3_44100_192", - "pcm_8000", - "pcm_16000", - "pcm_22050", - "pcm_24000", - "pcm_44100", - "ulaw_8000", - "alaw_8000", - "opus_48000_32", - "opus_48000_64", - "opus_48000_96", - "opus_48000_128", - "opus_48000_192", - ], - typing.Any, -] diff --git a/src/elevenlabs/v_1_text_to_speech_voice_id_stream_input/__init__.py b/src/elevenlabs/v_1_text_to_speech_voice_id_stream_input/__init__.py index c36b4613..eb078073 100644 --- a/src/elevenlabs/v_1_text_to_speech_voice_id_stream_input/__init__.py +++ b/src/elevenlabs/v_1_text_to_speech_voice_id_stream_input/__init__.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# isort: skip_file + from .types import ReceiveMessage, SendMessage __all__ = ["ReceiveMessage", "SendMessage"] diff --git a/src/elevenlabs/v_1_text_to_speech_voice_id_stream_input/types/__init__.py b/src/elevenlabs/v_1_text_to_speech_voice_id_stream_input/types/__init__.py index 853384c2..5a8a8985 100644 --- a/src/elevenlabs/v_1_text_to_speech_voice_id_stream_input/types/__init__.py +++ b/src/elevenlabs/v_1_text_to_speech_voice_id_stream_input/types/__init__.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# isort: skip_file + from .receive_message import ReceiveMessage from .send_message import SendMessage diff --git a/src/elevenlabs/v_1_text_to_speech_voice_id_stream_input/types/receive_message.py b/src/elevenlabs/v_1_text_to_speech_voice_id_stream_input/types/receive_message.py index 16440a93..813ba867 100644 --- a/src/elevenlabs/v_1_text_to_speech_voice_id_stream_input/types/receive_message.py +++ b/src/elevenlabs/v_1_text_to_speech_voice_id_stream_input/types/receive_message.py @@ -1,6 +1,7 @@ # This file was auto-generated by Fern from our API Definition. import typing + from ...types.audio_output import AudioOutput from ...types.final_output import FinalOutput diff --git a/src/elevenlabs/v_1_text_to_speech_voice_id_stream_input/types/send_message.py b/src/elevenlabs/v_1_text_to_speech_voice_id_stream_input/types/send_message.py index d4d0d409..8ae3c835 100644 --- a/src/elevenlabs/v_1_text_to_speech_voice_id_stream_input/types/send_message.py +++ b/src/elevenlabs/v_1_text_to_speech_voice_id_stream_input/types/send_message.py @@ -1,8 +1,9 @@ # This file was auto-generated by Fern from our API Definition. import typing + +from ...types.close_connection import CloseConnection from ...types.initialize_connection import InitializeConnection from ...types.send_text import SendText -from ...types.close_connection import CloseConnection SendMessage = typing.Union[InitializeConnection, SendText, CloseConnection] diff --git a/src/elevenlabs/voices/__init__.py b/src/elevenlabs/voices/__init__.py index b4422bc9..736abb95 100644 --- a/src/elevenlabs/voices/__init__.py +++ b/src/elevenlabs/voices/__init__.py @@ -1,6 +1,8 @@ # This file was auto-generated by Fern from our API Definition. +# isort: skip_file + from .types import VoicesGetSharedRequestCategory -from . import pvc +from . import ivc, pvc, samples, settings -__all__ = ["VoicesGetSharedRequestCategory", "pvc"] +__all__ = ["VoicesGetSharedRequestCategory", "ivc", "pvc", "samples", "settings"] diff --git a/src/elevenlabs/voices/client.py b/src/elevenlabs/voices/client.py index 7f12c489..93b7e564 100644 --- a/src/elevenlabs/voices/client.py +++ b/src/elevenlabs/voices/client.py @@ -1,30 +1,23 @@ # This file was auto-generated by Fern from our API Definition. import typing -from ..core.client_wrapper import SyncClientWrapper -from .pvc.client import PvcClient + +from .. import core +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ..core.request_options import RequestOptions +from ..types.add_voice_response_model import AddVoiceResponseModel +from ..types.delete_voice_response_model import DeleteVoiceResponseModel +from ..types.edit_voice_response_model import EditVoiceResponseModel +from ..types.get_library_voices_response import GetLibraryVoicesResponse from ..types.get_voices_response import GetVoicesResponse -from ..core.unchecked_base_model import construct_type -from ..errors.unprocessable_entity_error import UnprocessableEntityError -from ..types.http_validation_error import HttpValidationError -from json.decoder import JSONDecodeError -from ..core.api_error import ApiError from ..types.get_voices_v_2_response import GetVoicesV2Response -from ..types.voice_settings import VoiceSettings -from ..core.jsonable_encoder import jsonable_encoder from ..types.voice import Voice -from ..types.delete_voice_response_model import DeleteVoiceResponseModel -from ..types.edit_voice_settings_response_model import EditVoiceSettingsResponseModel -from ..core.serialization import convert_and_respect_annotation_metadata -from .. import core -from ..types.add_voice_ivc_response_model import AddVoiceIvcResponseModel -from ..types.edit_voice_response_model import EditVoiceResponseModel -from ..types.add_voice_response_model import AddVoiceResponseModel +from .ivc.client import AsyncIvcClient, IvcClient +from .pvc.client import AsyncPvcClient, PvcClient +from .raw_client import AsyncRawVoicesClient, RawVoicesClient +from .samples.client import AsyncSamplesClient, SamplesClient +from .settings.client import AsyncSettingsClient, SettingsClient from .types.voices_get_shared_request_category import VoicesGetSharedRequestCategory -from ..types.get_library_voices_response import GetLibraryVoicesResponse -from ..core.client_wrapper import AsyncClientWrapper -from .pvc.client import AsyncPvcClient # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -32,14 +25,28 @@ class VoicesClient: def __init__(self, *, client_wrapper: SyncClientWrapper): - self._client_wrapper = client_wrapper - self.pvc = PvcClient(client_wrapper=self._client_wrapper) + self._raw_client = RawVoicesClient(client_wrapper=client_wrapper) + self.settings = SettingsClient(client_wrapper=client_wrapper) + + self.ivc = IvcClient(client_wrapper=client_wrapper) + + self.pvc = PvcClient(client_wrapper=client_wrapper) + + self.samples = SamplesClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawVoicesClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawVoicesClient + """ + return self._raw_client def get_all( - self, - *, - show_legacy: typing.Optional[bool] = None, - request_options: typing.Optional[RequestOptions] = None, + self, *, show_legacy: typing.Optional[bool] = None, request_options: typing.Optional[RequestOptions] = None ) -> GetVoicesResponse: """ Returns a list of all available voices for a user. @@ -66,38 +73,8 @@ def get_all( ) client.voices.get_all() """ - _response = self._client_wrapper.httpx_client.request( - "v1/voices", - base_url=self._client_wrapper.get_environment().base, - method="GET", - params={ - "show_legacy": show_legacy, - }, - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - GetVoicesResponse, - construct_type( - type_=GetVoicesResponse, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.get_all(show_legacy=show_legacy, request_options=request_options) + return _response.data def search( self, @@ -168,148 +145,20 @@ def search( include_total_count=True, ) """ - _response = self._client_wrapper.httpx_client.request( - "v2/voices", - base_url=self._client_wrapper.get_environment().base, - method="GET", - params={ - "next_page_token": next_page_token, - "page_size": page_size, - "search": search, - "sort": sort, - "sort_direction": sort_direction, - "voice_type": voice_type, - "category": category, - "fine_tuning_state": fine_tuning_state, - "collection_id": collection_id, - "include_total_count": include_total_count, - }, - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - GetVoicesV2Response, - construct_type( - type_=GetVoicesV2Response, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def get_default_settings(self, *, request_options: typing.Optional[RequestOptions] = None) -> VoiceSettings: - """ - Gets the default settings for voices. "similarity_boost" corresponds to"Clarity + Similarity Enhancement" in the web app and "stability" corresponds to "Stability" slider in the web app. - - Parameters - ---------- - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - VoiceSettings - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.voices.get_default_settings() - """ - _response = self._client_wrapper.httpx_client.request( - "v1/voices/settings/default", - base_url=self._client_wrapper.get_environment().base, - method="GET", + _response = self._raw_client.search( + next_page_token=next_page_token, + page_size=page_size, + search=search, + sort=sort, + sort_direction=sort_direction, + voice_type=voice_type, + category=category, + fine_tuning_state=fine_tuning_state, + collection_id=collection_id, + include_total_count=include_total_count, request_options=request_options, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - VoiceSettings, - construct_type( - type_=VoiceSettings, # type: ignore - object_=_response.json(), - ), - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def get_settings(self, voice_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> VoiceSettings: - """ - Returns the settings for a specific voice. "similarity_boost" corresponds to"Clarity + Similarity Enhancement" in the web app and "stability" corresponds to "Stability" slider in the web app. - - Parameters - ---------- - voice_id : str - Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - VoiceSettings - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.voices.get_settings( - voice_id="21m00Tcm4TlvDq8ikWAM", - ) - """ - _response = self._client_wrapper.httpx_client.request( - f"v1/voices/{jsonable_encoder(voice_id)}/settings", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - VoiceSettings, - construct_type( - type_=VoiceSettings, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + return _response.data def get( self, @@ -348,38 +197,8 @@ def get( voice_id="21m00Tcm4TlvDq8ikWAM", ) """ - _response = self._client_wrapper.httpx_client.request( - f"v1/voices/{jsonable_encoder(voice_id)}", - base_url=self._client_wrapper.get_environment().base, - method="GET", - params={ - "with_settings": with_settings, - }, - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - Voice, - construct_type( - type_=Voice, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.get(voice_id, with_settings=with_settings, request_options=request_options) + return _response.data def delete( self, voice_id: str, *, request_options: typing.Optional[RequestOptions] = None @@ -411,201 +230,10 @@ def delete( voice_id="21m00Tcm4TlvDq8ikWAM", ) """ - _response = self._client_wrapper.httpx_client.request( - f"v1/voices/{jsonable_encoder(voice_id)}", - base_url=self._client_wrapper.get_environment().base, - method="DELETE", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - DeleteVoiceResponseModel, - construct_type( - type_=DeleteVoiceResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def edit_settings( - self, - voice_id: str, - *, - request: VoiceSettings, - request_options: typing.Optional[RequestOptions] = None, - ) -> EditVoiceSettingsResponseModel: - """ - Edit your settings for a specific voice. "similarity_boost" corresponds to "Clarity + Similarity Enhancement" in the web app and "stability" corresponds to "Stability" slider in the web app. + _response = self._raw_client.delete(voice_id, request_options=request_options) + return _response.data - Parameters - ---------- - voice_id : str - ID of the voice to be used. You can use the [Get voices](/docs/api-reference/voices/search) endpoint list all the available voices. - - request : VoiceSettings - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - EditVoiceSettingsResponseModel - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs, VoiceSettings - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.voices.edit_settings( - voice_id="21m00Tcm4TlvDq8ikWAM", - request=VoiceSettings( - stability=1.0, - similarity_boost=1.0, - style=0.0, - use_speaker_boost=True, - speed=1.0, - ), - ) - """ - _response = self._client_wrapper.httpx_client.request( - f"v1/voices/{jsonable_encoder(voice_id)}/settings/edit", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json=convert_and_respect_annotation_metadata(object_=request, annotation=VoiceSettings, direction="write"), - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - EditVoiceSettingsResponseModel, - construct_type( - type_=EditVoiceSettingsResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def add( - self, - *, - name: str, - files: typing.List[core.File], - remove_background_noise: typing.Optional[bool] = OMIT, - description: typing.Optional[str] = OMIT, - labels: typing.Optional[str] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> AddVoiceIvcResponseModel: - """ - Create a voice clone and add it to your Voices - - Parameters - ---------- - name : str - The name that identifies this voice. This will be displayed in the dropdown of the website. - - files : typing.List[core.File] - See core.File for more documentation - - remove_background_noise : typing.Optional[bool] - If set will remove background noise for voice samples using our audio isolation model. If the samples do not include background noise, it can make the quality worse. - - description : typing.Optional[str] - A description of the voice. - - labels : typing.Optional[str] - Serialized labels dictionary for the voice. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - AddVoiceIvcResponseModel - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.voices.add( - name="name", - ) - """ - _response = self._client_wrapper.httpx_client.request( - "v1/voices/add", - base_url=self._client_wrapper.get_environment().base, - method="POST", - data={ - "name": name, - "remove_background_noise": remove_background_noise, - "description": description, - "labels": labels, - }, - files={ - "files": files, - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - AddVoiceIvcResponseModel, - construct_type( - type_=AddVoiceIvcResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def edit( + def update( self, voice_id: str, *, @@ -654,52 +282,23 @@ def edit( client = ElevenLabs( api_key="YOUR_API_KEY", ) - client.voices.edit( + client.voices.update( voice_id="21m00Tcm4TlvDq8ikWAM", name="name", ) """ - _response = self._client_wrapper.httpx_client.request( - f"v1/voices/{jsonable_encoder(voice_id)}/edit", - base_url=self._client_wrapper.get_environment().base, - method="POST", - data={ - "name": name, - "remove_background_noise": remove_background_noise, - "description": description, - "labels": labels, - }, - files={ - "files": files, - }, + _response = self._raw_client.update( + voice_id, + name=name, + files=files, + remove_background_noise=remove_background_noise, + description=description, + labels=labels, request_options=request_options, - omit=OMIT, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - EditVoiceResponseModel, - construct_type( - type_=EditVoiceResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def add_sharing_voice( + return _response.data + + def share( self, public_user_id: str, voice_id: str, @@ -736,48 +335,14 @@ def add_sharing_voice( client = ElevenLabs( api_key="YOUR_API_KEY", ) - client.voices.add_sharing_voice( + client.voices.share( public_user_id="63e06b7e7cafdc46be4d2e0b3f045940231ae058d508589653d74d1265a574ca", voice_id="21m00Tcm4TlvDq8ikWAM", new_name="John Smith", ) """ - _response = self._client_wrapper.httpx_client.request( - f"v1/voices/add/{jsonable_encoder(public_user_id)}/{jsonable_encoder(voice_id)}", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "new_name": new_name, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - AddVoiceResponseModel, - construct_type( - type_=AddVoiceResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.share(public_user_id, voice_id, new_name=new_name, request_options=request_options) + return _response.data def get_shared( self, @@ -876,56 +441,29 @@ def get_shared( reader_app_enabled=True, ) """ - _response = self._client_wrapper.httpx_client.request( - "v1/shared-voices", - base_url=self._client_wrapper.get_environment().base, - method="GET", - params={ - "page_size": page_size, - "category": category, - "gender": gender, - "age": age, - "accent": accent, - "language": language, - "locale": locale, - "search": search, - "use_cases": use_cases, - "descriptives": descriptives, - "featured": featured, - "min_notice_period_days": min_notice_period_days, - "include_custom_rates": include_custom_rates, - "reader_app_enabled": reader_app_enabled, - "owner_id": owner_id, - "sort": sort, - "page": page, - }, + _response = self._raw_client.get_shared( + page_size=page_size, + category=category, + gender=gender, + age=age, + accent=accent, + language=language, + locale=locale, + search=search, + use_cases=use_cases, + descriptives=descriptives, + featured=featured, + min_notice_period_days=min_notice_period_days, + include_custom_rates=include_custom_rates, + reader_app_enabled=reader_app_enabled, + owner_id=owner_id, + sort=sort, + page=page, request_options=request_options, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - GetLibraryVoicesResponse, - construct_type( - type_=GetLibraryVoicesResponse, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def get_similar_library_voices( + return _response.data + + def find_similar_voices( self, *, audio_file: typing.Optional[core.File] = OMIT, @@ -962,57 +500,41 @@ def get_similar_library_voices( client = ElevenLabs( api_key="YOUR_API_KEY", ) - client.voices.get_similar_library_voices() + client.voices.find_similar_voices() """ - _response = self._client_wrapper.httpx_client.request( - "v1/similar-voices", - base_url=self._client_wrapper.get_environment().base, - method="POST", - data={ - "similarity_threshold": similarity_threshold, - "top_k": top_k, - }, - files={ - "audio_file": audio_file, - }, + _response = self._raw_client.find_similar_voices( + audio_file=audio_file, + similarity_threshold=similarity_threshold, + top_k=top_k, request_options=request_options, - omit=OMIT, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - GetLibraryVoicesResponse, - construct_type( - type_=GetLibraryVoicesResponse, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + return _response.data class AsyncVoicesClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): - self._client_wrapper = client_wrapper - self.pvc = AsyncPvcClient(client_wrapper=self._client_wrapper) + self._raw_client = AsyncRawVoicesClient(client_wrapper=client_wrapper) + self.settings = AsyncSettingsClient(client_wrapper=client_wrapper) + + self.ivc = AsyncIvcClient(client_wrapper=client_wrapper) + + self.pvc = AsyncPvcClient(client_wrapper=client_wrapper) + + self.samples = AsyncSamplesClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawVoicesClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawVoicesClient + """ + return self._raw_client async def get_all( - self, - *, - show_legacy: typing.Optional[bool] = None, - request_options: typing.Optional[RequestOptions] = None, + self, *, show_legacy: typing.Optional[bool] = None, request_options: typing.Optional[RequestOptions] = None ) -> GetVoicesResponse: """ Returns a list of all available voices for a user. @@ -1047,38 +569,8 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - "v1/voices", - base_url=self._client_wrapper.get_environment().base, - method="GET", - params={ - "show_legacy": show_legacy, - }, - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - GetVoicesResponse, - construct_type( - type_=GetVoicesResponse, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.get_all(show_legacy=show_legacy, request_options=request_options) + return _response.data async def search( self, @@ -1157,166 +649,20 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - "v2/voices", - base_url=self._client_wrapper.get_environment().base, - method="GET", - params={ - "next_page_token": next_page_token, - "page_size": page_size, - "search": search, - "sort": sort, - "sort_direction": sort_direction, - "voice_type": voice_type, - "category": category, - "fine_tuning_state": fine_tuning_state, - "collection_id": collection_id, - "include_total_count": include_total_count, - }, + _response = await self._raw_client.search( + next_page_token=next_page_token, + page_size=page_size, + search=search, + sort=sort, + sort_direction=sort_direction, + voice_type=voice_type, + category=category, + fine_tuning_state=fine_tuning_state, + collection_id=collection_id, + include_total_count=include_total_count, request_options=request_options, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - GetVoicesV2Response, - construct_type( - type_=GetVoicesV2Response, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def get_default_settings(self, *, request_options: typing.Optional[RequestOptions] = None) -> VoiceSettings: - """ - Gets the default settings for voices. "similarity_boost" corresponds to"Clarity + Similarity Enhancement" in the web app and "stability" corresponds to "Stability" slider in the web app. - - Parameters - ---------- - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - VoiceSettings - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.voices.get_default_settings() - - - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - "v1/voices/settings/default", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - VoiceSettings, - construct_type( - type_=VoiceSettings, # type: ignore - object_=_response.json(), - ), - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def get_settings( - self, voice_id: str, *, request_options: typing.Optional[RequestOptions] = None - ) -> VoiceSettings: - """ - Returns the settings for a specific voice. "similarity_boost" corresponds to"Clarity + Similarity Enhancement" in the web app and "stability" corresponds to "Stability" slider in the web app. - - Parameters - ---------- - voice_id : str - Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - VoiceSettings - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.voices.get_settings( - voice_id="21m00Tcm4TlvDq8ikWAM", - ) - - - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/voices/{jsonable_encoder(voice_id)}/settings", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - VoiceSettings, - construct_type( - type_=VoiceSettings, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + return _response.data async def get( self, @@ -1363,38 +709,8 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/voices/{jsonable_encoder(voice_id)}", - base_url=self._client_wrapper.get_environment().base, - method="GET", - params={ - "with_settings": with_settings, - }, - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - Voice, - construct_type( - type_=Voice, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.get(voice_id, with_settings=with_settings, request_options=request_options) + return _response.data async def delete( self, voice_id: str, *, request_options: typing.Optional[RequestOptions] = None @@ -1434,217 +750,10 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/voices/{jsonable_encoder(voice_id)}", - base_url=self._client_wrapper.get_environment().base, - method="DELETE", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - DeleteVoiceResponseModel, - construct_type( - type_=DeleteVoiceResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def edit_settings( - self, - voice_id: str, - *, - request: VoiceSettings, - request_options: typing.Optional[RequestOptions] = None, - ) -> EditVoiceSettingsResponseModel: - """ - Edit your settings for a specific voice. "similarity_boost" corresponds to "Clarity + Similarity Enhancement" in the web app and "stability" corresponds to "Stability" slider in the web app. - - Parameters - ---------- - voice_id : str - ID of the voice to be used. You can use the [Get voices](/docs/api-reference/voices/search) endpoint list all the available voices. - - request : VoiceSettings - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - EditVoiceSettingsResponseModel - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs, VoiceSettings - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.voices.edit_settings( - voice_id="21m00Tcm4TlvDq8ikWAM", - request=VoiceSettings( - stability=1.0, - similarity_boost=1.0, - style=0.0, - use_speaker_boost=True, - speed=1.0, - ), - ) - - - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/voices/{jsonable_encoder(voice_id)}/settings/edit", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json=convert_and_respect_annotation_metadata(object_=request, annotation=VoiceSettings, direction="write"), - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - EditVoiceSettingsResponseModel, - construct_type( - type_=EditVoiceSettingsResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def add( - self, - *, - name: str, - files: typing.List[core.File], - remove_background_noise: typing.Optional[bool] = OMIT, - description: typing.Optional[str] = OMIT, - labels: typing.Optional[str] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> AddVoiceIvcResponseModel: - """ - Create a voice clone and add it to your Voices - - Parameters - ---------- - name : str - The name that identifies this voice. This will be displayed in the dropdown of the website. + _response = await self._raw_client.delete(voice_id, request_options=request_options) + return _response.data - files : typing.List[core.File] - See core.File for more documentation - - remove_background_noise : typing.Optional[bool] - If set will remove background noise for voice samples using our audio isolation model. If the samples do not include background noise, it can make the quality worse. - - description : typing.Optional[str] - A description of the voice. - - labels : typing.Optional[str] - Serialized labels dictionary for the voice. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - AddVoiceIvcResponseModel - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.voices.add( - name="name", - ) - - - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - "v1/voices/add", - base_url=self._client_wrapper.get_environment().base, - method="POST", - data={ - "name": name, - "remove_background_noise": remove_background_noise, - "description": description, - "labels": labels, - }, - files={ - "files": files, - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - AddVoiceIvcResponseModel, - construct_type( - type_=AddVoiceIvcResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def edit( + async def update( self, voice_id: str, *, @@ -1698,7 +807,7 @@ async def edit( async def main() -> None: - await client.voices.edit( + await client.voices.update( voice_id="21m00Tcm4TlvDq8ikWAM", name="name", ) @@ -1706,47 +815,18 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/voices/{jsonable_encoder(voice_id)}/edit", - base_url=self._client_wrapper.get_environment().base, - method="POST", - data={ - "name": name, - "remove_background_noise": remove_background_noise, - "description": description, - "labels": labels, - }, - files={ - "files": files, - }, + _response = await self._raw_client.update( + voice_id, + name=name, + files=files, + remove_background_noise=remove_background_noise, + description=description, + labels=labels, request_options=request_options, - omit=OMIT, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - EditVoiceResponseModel, - construct_type( - type_=EditVoiceResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def add_sharing_voice( + return _response.data + + async def share( self, public_user_id: str, voice_id: str, @@ -1788,7 +868,7 @@ async def add_sharing_voice( async def main() -> None: - await client.voices.add_sharing_voice( + await client.voices.share( public_user_id="63e06b7e7cafdc46be4d2e0b3f045940231ae058d508589653d74d1265a574ca", voice_id="21m00Tcm4TlvDq8ikWAM", new_name="John Smith", @@ -1797,42 +877,10 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/voices/add/{jsonable_encoder(public_user_id)}/{jsonable_encoder(voice_id)}", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "new_name": new_name, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, + _response = await self._raw_client.share( + public_user_id, voice_id, new_name=new_name, request_options=request_options ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - AddVoiceResponseModel, - construct_type( - type_=AddVoiceResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + return _response.data async def get_shared( self, @@ -1939,56 +987,29 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - "v1/shared-voices", - base_url=self._client_wrapper.get_environment().base, - method="GET", - params={ - "page_size": page_size, - "category": category, - "gender": gender, - "age": age, - "accent": accent, - "language": language, - "locale": locale, - "search": search, - "use_cases": use_cases, - "descriptives": descriptives, - "featured": featured, - "min_notice_period_days": min_notice_period_days, - "include_custom_rates": include_custom_rates, - "reader_app_enabled": reader_app_enabled, - "owner_id": owner_id, - "sort": sort, - "page": page, - }, + _response = await self._raw_client.get_shared( + page_size=page_size, + category=category, + gender=gender, + age=age, + accent=accent, + language=language, + locale=locale, + search=search, + use_cases=use_cases, + descriptives=descriptives, + featured=featured, + min_notice_period_days=min_notice_period_days, + include_custom_rates=include_custom_rates, + reader_app_enabled=reader_app_enabled, + owner_id=owner_id, + sort=sort, + page=page, request_options=request_options, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - GetLibraryVoicesResponse, - construct_type( - type_=GetLibraryVoicesResponse, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def get_similar_library_voices( + return _response.data + + async def find_similar_voices( self, *, audio_file: typing.Optional[core.File] = OMIT, @@ -2030,45 +1051,15 @@ async def get_similar_library_voices( async def main() -> None: - await client.voices.get_similar_library_voices() + await client.voices.find_similar_voices() asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - "v1/similar-voices", - base_url=self._client_wrapper.get_environment().base, - method="POST", - data={ - "similarity_threshold": similarity_threshold, - "top_k": top_k, - }, - files={ - "audio_file": audio_file, - }, + _response = await self._raw_client.find_similar_voices( + audio_file=audio_file, + similarity_threshold=similarity_threshold, + top_k=top_k, request_options=request_options, - omit=OMIT, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - GetLibraryVoicesResponse, - construct_type( - type_=GetLibraryVoicesResponse, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + return _response.data diff --git a/src/elevenlabs/voices/ivc/__init__.py b/src/elevenlabs/voices/ivc/__init__.py new file mode 100644 index 00000000..5cde0202 --- /dev/null +++ b/src/elevenlabs/voices/ivc/__init__.py @@ -0,0 +1,4 @@ +# This file was auto-generated by Fern from our API Definition. + +# isort: skip_file + diff --git a/src/elevenlabs/voices/ivc/client.py b/src/elevenlabs/voices/ivc/client.py new file mode 100644 index 00000000..9071fa42 --- /dev/null +++ b/src/elevenlabs/voices/ivc/client.py @@ -0,0 +1,170 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +from ... import core +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ...core.request_options import RequestOptions +from ...types.add_voice_ivc_response_model import AddVoiceIvcResponseModel +from .raw_client import AsyncRawIvcClient, RawIvcClient + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class IvcClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._raw_client = RawIvcClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawIvcClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawIvcClient + """ + return self._raw_client + + def create( + self, + *, + name: str, + files: typing.List[core.File], + remove_background_noise: typing.Optional[bool] = OMIT, + description: typing.Optional[str] = OMIT, + labels: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AddVoiceIvcResponseModel: + """ + Create a voice clone and add it to your Voices + + Parameters + ---------- + name : str + The name that identifies this voice. This will be displayed in the dropdown of the website. + + files : typing.List[core.File] + See core.File for more documentation + + remove_background_noise : typing.Optional[bool] + If set will remove background noise for voice samples using our audio isolation model. If the samples do not include background noise, it can make the quality worse. + + description : typing.Optional[str] + A description of the voice. + + labels : typing.Optional[str] + Serialized labels dictionary for the voice. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AddVoiceIvcResponseModel + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.voices.ivc.create( + name="name", + ) + """ + _response = self._raw_client.create( + name=name, + files=files, + remove_background_noise=remove_background_noise, + description=description, + labels=labels, + request_options=request_options, + ) + return _response.data + + +class AsyncIvcClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawIvcClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawIvcClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawIvcClient + """ + return self._raw_client + + async def create( + self, + *, + name: str, + files: typing.List[core.File], + remove_background_noise: typing.Optional[bool] = OMIT, + description: typing.Optional[str] = OMIT, + labels: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AddVoiceIvcResponseModel: + """ + Create a voice clone and add it to your Voices + + Parameters + ---------- + name : str + The name that identifies this voice. This will be displayed in the dropdown of the website. + + files : typing.List[core.File] + See core.File for more documentation + + remove_background_noise : typing.Optional[bool] + If set will remove background noise for voice samples using our audio isolation model. If the samples do not include background noise, it can make the quality worse. + + description : typing.Optional[str] + A description of the voice. + + labels : typing.Optional[str] + Serialized labels dictionary for the voice. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AddVoiceIvcResponseModel + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.voices.ivc.create( + name="name", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.create( + name=name, + files=files, + remove_background_noise=remove_background_noise, + description=description, + labels=labels, + request_options=request_options, + ) + return _response.data diff --git a/src/elevenlabs/voices/ivc/raw_client.py b/src/elevenlabs/voices/ivc/raw_client.py new file mode 100644 index 00000000..ac8620b7 --- /dev/null +++ b/src/elevenlabs/voices/ivc/raw_client.py @@ -0,0 +1,189 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ... import core +from ...core.api_error import ApiError +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ...core.http_response import AsyncHttpResponse, HttpResponse +from ...core.request_options import RequestOptions +from ...core.unchecked_base_model import construct_type +from ...errors.unprocessable_entity_error import UnprocessableEntityError +from ...types.add_voice_ivc_response_model import AddVoiceIvcResponseModel +from ...types.http_validation_error import HttpValidationError + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RawIvcClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def create( + self, + *, + name: str, + files: typing.List[core.File], + remove_background_noise: typing.Optional[bool] = OMIT, + description: typing.Optional[str] = OMIT, + labels: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[AddVoiceIvcResponseModel]: + """ + Create a voice clone and add it to your Voices + + Parameters + ---------- + name : str + The name that identifies this voice. This will be displayed in the dropdown of the website. + + files : typing.List[core.File] + See core.File for more documentation + + remove_background_noise : typing.Optional[bool] + If set will remove background noise for voice samples using our audio isolation model. If the samples do not include background noise, it can make the quality worse. + + description : typing.Optional[str] + A description of the voice. + + labels : typing.Optional[str] + Serialized labels dictionary for the voice. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[AddVoiceIvcResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + "v1/voices/add", + base_url=self._client_wrapper.get_environment().base, + method="POST", + data={ + "name": name, + "remove_background_noise": remove_background_noise, + "description": description, + "labels": labels, + }, + files={ + "files": files, + }, + request_options=request_options, + omit=OMIT, + force_multipart=True, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + AddVoiceIvcResponseModel, + construct_type( + type_=AddVoiceIvcResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + +class AsyncRawIvcClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def create( + self, + *, + name: str, + files: typing.List[core.File], + remove_background_noise: typing.Optional[bool] = OMIT, + description: typing.Optional[str] = OMIT, + labels: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[AddVoiceIvcResponseModel]: + """ + Create a voice clone and add it to your Voices + + Parameters + ---------- + name : str + The name that identifies this voice. This will be displayed in the dropdown of the website. + + files : typing.List[core.File] + See core.File for more documentation + + remove_background_noise : typing.Optional[bool] + If set will remove background noise for voice samples using our audio isolation model. If the samples do not include background noise, it can make the quality worse. + + description : typing.Optional[str] + A description of the voice. + + labels : typing.Optional[str] + Serialized labels dictionary for the voice. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[AddVoiceIvcResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + "v1/voices/add", + base_url=self._client_wrapper.get_environment().base, + method="POST", + data={ + "name": name, + "remove_background_noise": remove_background_noise, + "description": description, + "labels": labels, + }, + files={ + "files": files, + }, + request_options=request_options, + omit=OMIT, + force_multipart=True, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + AddVoiceIvcResponseModel, + construct_type( + type_=AddVoiceIvcResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/elevenlabs/voices/pvc/__init__.py b/src/elevenlabs/voices/pvc/__init__.py index 2adb2771..bf59eb01 100644 --- a/src/elevenlabs/voices/pvc/__init__.py +++ b/src/elevenlabs/voices/pvc/__init__.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# isort: skip_file + from . import samples, verification __all__ = ["samples", "verification"] diff --git a/src/elevenlabs/voices/pvc/client.py b/src/elevenlabs/voices/pvc/client.py index 076482da..ceabf56f 100644 --- a/src/elevenlabs/voices/pvc/client.py +++ b/src/elevenlabs/voices/pvc/client.py @@ -1,23 +1,14 @@ # This file was auto-generated by Fern from our API Definition. import typing -from ...core.client_wrapper import SyncClientWrapper -from .samples.client import SamplesClient -from .verification.client import VerificationClient + +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ...core.request_options import RequestOptions from ...types.add_voice_response_model import AddVoiceResponseModel -from ...core.unchecked_base_model import construct_type -from ...errors.unprocessable_entity_error import UnprocessableEntityError -from ...types.http_validation_error import HttpValidationError -from json.decoder import JSONDecodeError -from ...core.api_error import ApiError -from ...core.jsonable_encoder import jsonable_encoder -from ...types.start_pvc_voice_training_response_model import ( - StartPvcVoiceTrainingResponseModel, -) -from ...core.client_wrapper import AsyncClientWrapper -from .samples.client import AsyncSamplesClient -from .verification.client import AsyncVerificationClient +from ...types.start_pvc_voice_training_response_model import StartPvcVoiceTrainingResponseModel +from .raw_client import AsyncRawPvcClient, RawPvcClient +from .samples.client import AsyncSamplesClient, SamplesClient +from .verification.client import AsyncVerificationClient, VerificationClient # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -25,9 +16,21 @@ class PvcClient: def __init__(self, *, client_wrapper: SyncClientWrapper): - self._client_wrapper = client_wrapper - self.samples = SamplesClient(client_wrapper=self._client_wrapper) - self.verification = VerificationClient(client_wrapper=self._client_wrapper) + self._raw_client = RawPvcClient(client_wrapper=client_wrapper) + self.samples = SamplesClient(client_wrapper=client_wrapper) + + self.verification = VerificationClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawPvcClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawPvcClient + """ + return self._raw_client def create( self, @@ -75,45 +78,10 @@ def create( language="en", ) """ - _response = self._client_wrapper.httpx_client.request( - "v1/voices/pvc", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "name": name, - "language": language, - "description": description, - "labels": labels, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, + _response = self._raw_client.create( + name=name, language=language, description=description, labels=labels, request_options=request_options ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - AddVoiceResponseModel, - construct_type( - type_=AddVoiceResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + return _response.data def update( self, @@ -164,45 +132,15 @@ def update( voice_id="21m00Tcm4TlvDq8ikWAM", ) """ - _response = self._client_wrapper.httpx_client.request( - f"v1/voices/pvc/{jsonable_encoder(voice_id)}", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "name": name, - "language": language, - "description": description, - "labels": labels, - }, - headers={ - "content-type": "application/json", - }, + _response = self._raw_client.update( + voice_id, + name=name, + language=language, + description=description, + labels=labels, request_options=request_options, - omit=OMIT, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - AddVoiceResponseModel, - construct_type( - type_=AddVoiceResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + return _response.data def train( self, @@ -241,49 +179,27 @@ def train( voice_id="21m00Tcm4TlvDq8ikWAM", ) """ - _response = self._client_wrapper.httpx_client.request( - f"v1/voices/pvc/{jsonable_encoder(voice_id)}/train", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "model_id": model_id, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - StartPvcVoiceTrainingResponseModel, - construct_type( - type_=StartPvcVoiceTrainingResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.train(voice_id, model_id=model_id, request_options=request_options) + return _response.data class AsyncPvcClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): - self._client_wrapper = client_wrapper - self.samples = AsyncSamplesClient(client_wrapper=self._client_wrapper) - self.verification = AsyncVerificationClient(client_wrapper=self._client_wrapper) + self._raw_client = AsyncRawPvcClient(client_wrapper=client_wrapper) + self.samples = AsyncSamplesClient(client_wrapper=client_wrapper) + + self.verification = AsyncVerificationClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawPvcClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawPvcClient + """ + return self._raw_client async def create( self, @@ -339,45 +255,10 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - "v1/voices/pvc", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "name": name, - "language": language, - "description": description, - "labels": labels, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, + _response = await self._raw_client.create( + name=name, language=language, description=description, labels=labels, request_options=request_options ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - AddVoiceResponseModel, - construct_type( - type_=AddVoiceResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + return _response.data async def update( self, @@ -436,45 +317,15 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/voices/pvc/{jsonable_encoder(voice_id)}", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "name": name, - "language": language, - "description": description, - "labels": labels, - }, - headers={ - "content-type": "application/json", - }, + _response = await self._raw_client.update( + voice_id, + name=name, + language=language, + description=description, + labels=labels, request_options=request_options, - omit=OMIT, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - AddVoiceResponseModel, - construct_type( - type_=AddVoiceResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + return _response.data async def train( self, @@ -521,39 +372,5 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/voices/pvc/{jsonable_encoder(voice_id)}/train", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "model_id": model_id, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - StartPvcVoiceTrainingResponseModel, - construct_type( - type_=StartPvcVoiceTrainingResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.train(voice_id, model_id=model_id, request_options=request_options) + return _response.data diff --git a/src/elevenlabs/voices/pvc/raw_client.py b/src/elevenlabs/voices/pvc/raw_client.py new file mode 100644 index 00000000..68a57c68 --- /dev/null +++ b/src/elevenlabs/voices/pvc/raw_client.py @@ -0,0 +1,470 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ...core.api_error import ApiError +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ...core.http_response import AsyncHttpResponse, HttpResponse +from ...core.jsonable_encoder import jsonable_encoder +from ...core.request_options import RequestOptions +from ...core.unchecked_base_model import construct_type +from ...errors.unprocessable_entity_error import UnprocessableEntityError +from ...types.add_voice_response_model import AddVoiceResponseModel +from ...types.http_validation_error import HttpValidationError +from ...types.start_pvc_voice_training_response_model import StartPvcVoiceTrainingResponseModel + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RawPvcClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def create( + self, + *, + name: str, + language: str, + description: typing.Optional[str] = OMIT, + labels: typing.Optional[typing.Dict[str, typing.Optional[str]]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[AddVoiceResponseModel]: + """ + Creates a new PVC voice with metadata but no samples + + Parameters + ---------- + name : str + The name that identifies this voice. This will be displayed in the dropdown of the website. + + language : str + Language used in the samples. + + description : typing.Optional[str] + Description to use for the created voice. + + labels : typing.Optional[typing.Dict[str, typing.Optional[str]]] + Serialized labels dictionary for the voice. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[AddVoiceResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + "v1/voices/pvc", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "name": name, + "language": language, + "description": description, + "labels": labels, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + AddVoiceResponseModel, + construct_type( + type_=AddVoiceResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def update( + self, + voice_id: str, + *, + name: typing.Optional[str] = OMIT, + language: typing.Optional[str] = OMIT, + description: typing.Optional[str] = OMIT, + labels: typing.Optional[typing.Dict[str, typing.Optional[str]]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[AddVoiceResponseModel]: + """ + Edit PVC voice metadata + + Parameters + ---------- + voice_id : str + Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices. + + name : typing.Optional[str] + The name that identifies this voice. This will be displayed in the dropdown of the website. + + language : typing.Optional[str] + Language used in the samples. + + description : typing.Optional[str] + Description to use for the created voice. + + labels : typing.Optional[typing.Dict[str, typing.Optional[str]]] + Serialized labels dictionary for the voice. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[AddVoiceResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/voices/pvc/{jsonable_encoder(voice_id)}", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "name": name, + "language": language, + "description": description, + "labels": labels, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + AddVoiceResponseModel, + construct_type( + type_=AddVoiceResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def train( + self, + voice_id: str, + *, + model_id: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[StartPvcVoiceTrainingResponseModel]: + """ + Start PVC training process for a voice. + + Parameters + ---------- + voice_id : str + Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices. + + model_id : typing.Optional[str] + The model ID to use for the conversion. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[StartPvcVoiceTrainingResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/voices/pvc/{jsonable_encoder(voice_id)}/train", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "model_id": model_id, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + StartPvcVoiceTrainingResponseModel, + construct_type( + type_=StartPvcVoiceTrainingResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + +class AsyncRawPvcClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def create( + self, + *, + name: str, + language: str, + description: typing.Optional[str] = OMIT, + labels: typing.Optional[typing.Dict[str, typing.Optional[str]]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[AddVoiceResponseModel]: + """ + Creates a new PVC voice with metadata but no samples + + Parameters + ---------- + name : str + The name that identifies this voice. This will be displayed in the dropdown of the website. + + language : str + Language used in the samples. + + description : typing.Optional[str] + Description to use for the created voice. + + labels : typing.Optional[typing.Dict[str, typing.Optional[str]]] + Serialized labels dictionary for the voice. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[AddVoiceResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + "v1/voices/pvc", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "name": name, + "language": language, + "description": description, + "labels": labels, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + AddVoiceResponseModel, + construct_type( + type_=AddVoiceResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def update( + self, + voice_id: str, + *, + name: typing.Optional[str] = OMIT, + language: typing.Optional[str] = OMIT, + description: typing.Optional[str] = OMIT, + labels: typing.Optional[typing.Dict[str, typing.Optional[str]]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[AddVoiceResponseModel]: + """ + Edit PVC voice metadata + + Parameters + ---------- + voice_id : str + Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices. + + name : typing.Optional[str] + The name that identifies this voice. This will be displayed in the dropdown of the website. + + language : typing.Optional[str] + Language used in the samples. + + description : typing.Optional[str] + Description to use for the created voice. + + labels : typing.Optional[typing.Dict[str, typing.Optional[str]]] + Serialized labels dictionary for the voice. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[AddVoiceResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/voices/pvc/{jsonable_encoder(voice_id)}", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "name": name, + "language": language, + "description": description, + "labels": labels, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + AddVoiceResponseModel, + construct_type( + type_=AddVoiceResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def train( + self, + voice_id: str, + *, + model_id: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[StartPvcVoiceTrainingResponseModel]: + """ + Start PVC training process for a voice. + + Parameters + ---------- + voice_id : str + Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices. + + model_id : typing.Optional[str] + The model ID to use for the conversion. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[StartPvcVoiceTrainingResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/voices/pvc/{jsonable_encoder(voice_id)}/train", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "model_id": model_id, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + StartPvcVoiceTrainingResponseModel, + construct_type( + type_=StartPvcVoiceTrainingResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/elevenlabs/voices/pvc/samples/__init__.py b/src/elevenlabs/voices/pvc/samples/__init__.py index cb8d7557..3115b6f0 100644 --- a/src/elevenlabs/voices/pvc/samples/__init__.py +++ b/src/elevenlabs/voices/pvc/samples/__init__.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# isort: skip_file + from . import audio, speakers, waveform __all__ = ["audio", "speakers", "waveform"] diff --git a/src/elevenlabs/voices/pvc/samples/audio/__init__.py b/src/elevenlabs/voices/pvc/samples/audio/__init__.py index f3ea2659..5cde0202 100644 --- a/src/elevenlabs/voices/pvc/samples/audio/__init__.py +++ b/src/elevenlabs/voices/pvc/samples/audio/__init__.py @@ -1,2 +1,4 @@ # This file was auto-generated by Fern from our API Definition. +# isort: skip_file + diff --git a/src/elevenlabs/voices/pvc/samples/audio/client.py b/src/elevenlabs/voices/pvc/samples/audio/client.py index 5957d28b..e9b91787 100644 --- a/src/elevenlabs/voices/pvc/samples/audio/client.py +++ b/src/elevenlabs/voices/pvc/samples/audio/client.py @@ -1,30 +1,30 @@ # This file was auto-generated by Fern from our API Definition. -from .....core.client_wrapper import SyncClientWrapper import typing + +from .....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from .....core.request_options import RequestOptions -from .....types.voice_sample_preview_response_model import ( - VoiceSamplePreviewResponseModel, -) -from .....core.jsonable_encoder import jsonable_encoder -from .....core.unchecked_base_model import construct_type -from .....errors.unprocessable_entity_error import UnprocessableEntityError -from .....types.http_validation_error import HttpValidationError -from json.decoder import JSONDecodeError -from .....core.api_error import ApiError -from .....core.client_wrapper import AsyncClientWrapper +from .....types.voice_sample_preview_response_model import VoiceSamplePreviewResponseModel +from .raw_client import AsyncRawAudioClient, RawAudioClient class AudioClient: def __init__(self, *, client_wrapper: SyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = RawAudioClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawAudioClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawAudioClient + """ + return self._raw_client def get( - self, - voice_id: str, - sample_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, + self, voice_id: str, sample_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> VoiceSamplePreviewResponseModel: """ Retrieve the first 30 seconds of voice sample audio with or without noise removal. @@ -57,47 +57,27 @@ def get( sample_id="VW7YKqPnjY4h39yTbx2L", ) """ - _response = self._client_wrapper.httpx_client.request( - f"v1/voices/pvc/{jsonable_encoder(voice_id)}/samples/{jsonable_encoder(sample_id)}/audio", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - VoiceSamplePreviewResponseModel, - construct_type( - type_=VoiceSamplePreviewResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.get(voice_id, sample_id, request_options=request_options) + return _response.data class AsyncAudioClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = AsyncRawAudioClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawAudioClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawAudioClient + """ + return self._raw_client async def get( - self, - voice_id: str, - sample_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, + self, voice_id: str, sample_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> VoiceSamplePreviewResponseModel: """ Retrieve the first 30 seconds of voice sample audio with or without noise removal. @@ -138,32 +118,5 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/voices/pvc/{jsonable_encoder(voice_id)}/samples/{jsonable_encoder(sample_id)}/audio", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - VoiceSamplePreviewResponseModel, - construct_type( - type_=VoiceSamplePreviewResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.get(voice_id, sample_id, request_options=request_options) + return _response.data diff --git a/src/elevenlabs/voices/pvc/samples/audio/raw_client.py b/src/elevenlabs/voices/pvc/samples/audio/raw_client.py new file mode 100644 index 00000000..6b8558a8 --- /dev/null +++ b/src/elevenlabs/voices/pvc/samples/audio/raw_client.py @@ -0,0 +1,132 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from .....core.api_error import ApiError +from .....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from .....core.http_response import AsyncHttpResponse, HttpResponse +from .....core.jsonable_encoder import jsonable_encoder +from .....core.request_options import RequestOptions +from .....core.unchecked_base_model import construct_type +from .....errors.unprocessable_entity_error import UnprocessableEntityError +from .....types.http_validation_error import HttpValidationError +from .....types.voice_sample_preview_response_model import VoiceSamplePreviewResponseModel + + +class RawAudioClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def get( + self, voice_id: str, sample_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[VoiceSamplePreviewResponseModel]: + """ + Retrieve the first 30 seconds of voice sample audio with or without noise removal. + + Parameters + ---------- + voice_id : str + Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices. + + sample_id : str + Sample ID to be used + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[VoiceSamplePreviewResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/voices/pvc/{jsonable_encoder(voice_id)}/samples/{jsonable_encoder(sample_id)}/audio", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + VoiceSamplePreviewResponseModel, + construct_type( + type_=VoiceSamplePreviewResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + +class AsyncRawAudioClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def get( + self, voice_id: str, sample_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[VoiceSamplePreviewResponseModel]: + """ + Retrieve the first 30 seconds of voice sample audio with or without noise removal. + + Parameters + ---------- + voice_id : str + Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices. + + sample_id : str + Sample ID to be used + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[VoiceSamplePreviewResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/voices/pvc/{jsonable_encoder(voice_id)}/samples/{jsonable_encoder(sample_id)}/audio", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + VoiceSamplePreviewResponseModel, + construct_type( + type_=VoiceSamplePreviewResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/elevenlabs/voices/pvc/samples/client.py b/src/elevenlabs/voices/pvc/samples/client.py index c60ad420..a36f98c3 100644 --- a/src/elevenlabs/voices/pvc/samples/client.py +++ b/src/elevenlabs/voices/pvc/samples/client.py @@ -1,25 +1,17 @@ # This file was auto-generated by Fern from our API Definition. import typing -from ....core.client_wrapper import SyncClientWrapper -from .audio.client import AudioClient -from .waveform.client import WaveformClient -from .speakers.client import SpeakersClient + from .... import core +from ....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ....core.request_options import RequestOptions -from ....types.voice_sample import VoiceSample -from ....core.jsonable_encoder import jsonable_encoder -from ....core.unchecked_base_model import construct_type -from ....errors.unprocessable_entity_error import UnprocessableEntityError -from ....types.http_validation_error import HttpValidationError -from json.decoder import JSONDecodeError -from ....core.api_error import ApiError from ....types.add_voice_response_model import AddVoiceResponseModel from ....types.delete_voice_sample_response_model import DeleteVoiceSampleResponseModel -from ....core.client_wrapper import AsyncClientWrapper -from .audio.client import AsyncAudioClient -from .waveform.client import AsyncWaveformClient -from .speakers.client import AsyncSpeakersClient +from ....types.voice_sample import VoiceSample +from .audio.client import AsyncAudioClient, AudioClient +from .raw_client import AsyncRawSamplesClient, RawSamplesClient +from .speakers.client import AsyncSpeakersClient, SpeakersClient +from .waveform.client import AsyncWaveformClient, WaveformClient # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -27,10 +19,23 @@ class SamplesClient: def __init__(self, *, client_wrapper: SyncClientWrapper): - self._client_wrapper = client_wrapper - self.audio = AudioClient(client_wrapper=self._client_wrapper) - self.waveform = WaveformClient(client_wrapper=self._client_wrapper) - self.speakers = SpeakersClient(client_wrapper=self._client_wrapper) + self._raw_client = RawSamplesClient(client_wrapper=client_wrapper) + self.audio = AudioClient(client_wrapper=client_wrapper) + + self.waveform = WaveformClient(client_wrapper=client_wrapper) + + self.speakers = SpeakersClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawSamplesClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawSamplesClient + """ + return self._raw_client def create( self, @@ -73,42 +78,10 @@ def create( voice_id="21m00Tcm4TlvDq8ikWAM", ) """ - _response = self._client_wrapper.httpx_client.request( - f"v1/voices/pvc/{jsonable_encoder(voice_id)}/samples", - base_url=self._client_wrapper.get_environment().base, - method="POST", - data={ - "remove_background_noise": remove_background_noise, - }, - files={ - "files": files, - }, - request_options=request_options, - omit=OMIT, + _response = self._raw_client.create( + voice_id, files=files, remove_background_noise=remove_background_noise, request_options=request_options ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - typing.List[VoiceSample], - construct_type( - type_=typing.List[VoiceSample], # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + return _response.data def update( self, @@ -164,52 +137,19 @@ def update( sample_id="VW7YKqPnjY4h39yTbx2L", ) """ - _response = self._client_wrapper.httpx_client.request( - f"v1/voices/pvc/{jsonable_encoder(voice_id)}/samples/{jsonable_encoder(sample_id)}", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "remove_background_noise": remove_background_noise, - "selected_speaker_ids": selected_speaker_ids, - "trim_start_time": trim_start_time, - "trim_end_time": trim_end_time, - }, - headers={ - "content-type": "application/json", - }, + _response = self._raw_client.update( + voice_id, + sample_id, + remove_background_noise=remove_background_noise, + selected_speaker_ids=selected_speaker_ids, + trim_start_time=trim_start_time, + trim_end_time=trim_end_time, request_options=request_options, - omit=OMIT, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - AddVoiceResponseModel, - construct_type( - type_=AddVoiceResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + return _response.data def delete( - self, - voice_id: str, - sample_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, + self, voice_id: str, sample_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> DeleteVoiceSampleResponseModel: """ Delete a sample from a PVC voice. @@ -242,43 +182,29 @@ def delete( sample_id="VW7YKqPnjY4h39yTbx2L", ) """ - _response = self._client_wrapper.httpx_client.request( - f"v1/voices/pvc/{jsonable_encoder(voice_id)}/samples/{jsonable_encoder(sample_id)}", - base_url=self._client_wrapper.get_environment().base, - method="DELETE", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - DeleteVoiceSampleResponseModel, - construct_type( - type_=DeleteVoiceSampleResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.delete(voice_id, sample_id, request_options=request_options) + return _response.data class AsyncSamplesClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): - self._client_wrapper = client_wrapper - self.audio = AsyncAudioClient(client_wrapper=self._client_wrapper) - self.waveform = AsyncWaveformClient(client_wrapper=self._client_wrapper) - self.speakers = AsyncSpeakersClient(client_wrapper=self._client_wrapper) + self._raw_client = AsyncRawSamplesClient(client_wrapper=client_wrapper) + self.audio = AsyncAudioClient(client_wrapper=client_wrapper) + + self.waveform = AsyncWaveformClient(client_wrapper=client_wrapper) + + self.speakers = AsyncSpeakersClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawSamplesClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawSamplesClient + """ + return self._raw_client async def create( self, @@ -329,42 +255,10 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/voices/pvc/{jsonable_encoder(voice_id)}/samples", - base_url=self._client_wrapper.get_environment().base, - method="POST", - data={ - "remove_background_noise": remove_background_noise, - }, - files={ - "files": files, - }, - request_options=request_options, - omit=OMIT, + _response = await self._raw_client.create( + voice_id, files=files, remove_background_noise=remove_background_noise, request_options=request_options ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - typing.List[VoiceSample], - construct_type( - type_=typing.List[VoiceSample], # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + return _response.data async def update( self, @@ -428,52 +322,19 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/voices/pvc/{jsonable_encoder(voice_id)}/samples/{jsonable_encoder(sample_id)}", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "remove_background_noise": remove_background_noise, - "selected_speaker_ids": selected_speaker_ids, - "trim_start_time": trim_start_time, - "trim_end_time": trim_end_time, - }, - headers={ - "content-type": "application/json", - }, + _response = await self._raw_client.update( + voice_id, + sample_id, + remove_background_noise=remove_background_noise, + selected_speaker_ids=selected_speaker_ids, + trim_start_time=trim_start_time, + trim_end_time=trim_end_time, request_options=request_options, - omit=OMIT, ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - AddVoiceResponseModel, - construct_type( - type_=AddVoiceResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + return _response.data async def delete( - self, - voice_id: str, - sample_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, + self, voice_id: str, sample_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> DeleteVoiceSampleResponseModel: """ Delete a sample from a PVC voice. @@ -514,32 +375,5 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/voices/pvc/{jsonable_encoder(voice_id)}/samples/{jsonable_encoder(sample_id)}", - base_url=self._client_wrapper.get_environment().base, - method="DELETE", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - DeleteVoiceSampleResponseModel, - construct_type( - type_=DeleteVoiceSampleResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.delete(voice_id, sample_id, request_options=request_options) + return _response.data diff --git a/src/elevenlabs/voices/pvc/samples/raw_client.py b/src/elevenlabs/voices/pvc/samples/raw_client.py new file mode 100644 index 00000000..ab22b249 --- /dev/null +++ b/src/elevenlabs/voices/pvc/samples/raw_client.py @@ -0,0 +1,446 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from .... import core +from ....core.api_error import ApiError +from ....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ....core.http_response import AsyncHttpResponse, HttpResponse +from ....core.jsonable_encoder import jsonable_encoder +from ....core.request_options import RequestOptions +from ....core.unchecked_base_model import construct_type +from ....errors.unprocessable_entity_error import UnprocessableEntityError +from ....types.add_voice_response_model import AddVoiceResponseModel +from ....types.delete_voice_sample_response_model import DeleteVoiceSampleResponseModel +from ....types.http_validation_error import HttpValidationError +from ....types.voice_sample import VoiceSample + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RawSamplesClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def create( + self, + voice_id: str, + *, + files: typing.List[core.File], + remove_background_noise: typing.Optional[bool] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[typing.List[VoiceSample]]: + """ + Add audio samples to a PVC voice + + Parameters + ---------- + voice_id : str + Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices. + + files : typing.List[core.File] + See core.File for more documentation + + remove_background_noise : typing.Optional[bool] + If set will remove background noise for voice samples using our audio isolation model. If the samples do not include background noise, it can make the quality worse. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[typing.List[VoiceSample]] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/voices/pvc/{jsonable_encoder(voice_id)}/samples", + base_url=self._client_wrapper.get_environment().base, + method="POST", + data={ + "remove_background_noise": remove_background_noise, + }, + files={ + "files": files, + }, + request_options=request_options, + omit=OMIT, + force_multipart=True, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + typing.List[VoiceSample], + construct_type( + type_=typing.List[VoiceSample], # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def update( + self, + voice_id: str, + sample_id: str, + *, + remove_background_noise: typing.Optional[bool] = OMIT, + selected_speaker_ids: typing.Optional[typing.Sequence[str]] = OMIT, + trim_start_time: typing.Optional[int] = OMIT, + trim_end_time: typing.Optional[int] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[AddVoiceResponseModel]: + """ + Update a PVC voice sample - apply noise removal, or select speaker. + + Parameters + ---------- + voice_id : str + Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices. + + sample_id : str + Sample ID to be used + + remove_background_noise : typing.Optional[bool] + If set will remove background noise for voice samples using our audio isolation model. If the samples do not include background noise, it can make the quality worse. + + selected_speaker_ids : typing.Optional[typing.Sequence[str]] + Speaker IDs to be used for PVC training. Make sure you send all the speaker IDs you want to use for PVC training in one request because the last request will override the previous ones. + + trim_start_time : typing.Optional[int] + The start time of the audio to be used for PVC training. Time should be in milliseconds + + trim_end_time : typing.Optional[int] + The end time of the audio to be used for PVC training. Time should be in milliseconds + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[AddVoiceResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/voices/pvc/{jsonable_encoder(voice_id)}/samples/{jsonable_encoder(sample_id)}", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "remove_background_noise": remove_background_noise, + "selected_speaker_ids": selected_speaker_ids, + "trim_start_time": trim_start_time, + "trim_end_time": trim_end_time, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + AddVoiceResponseModel, + construct_type( + type_=AddVoiceResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def delete( + self, voice_id: str, sample_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[DeleteVoiceSampleResponseModel]: + """ + Delete a sample from a PVC voice. + + Parameters + ---------- + voice_id : str + Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices. + + sample_id : str + Sample ID to be used + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[DeleteVoiceSampleResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/voices/pvc/{jsonable_encoder(voice_id)}/samples/{jsonable_encoder(sample_id)}", + base_url=self._client_wrapper.get_environment().base, + method="DELETE", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + DeleteVoiceSampleResponseModel, + construct_type( + type_=DeleteVoiceSampleResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + +class AsyncRawSamplesClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def create( + self, + voice_id: str, + *, + files: typing.List[core.File], + remove_background_noise: typing.Optional[bool] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[typing.List[VoiceSample]]: + """ + Add audio samples to a PVC voice + + Parameters + ---------- + voice_id : str + Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices. + + files : typing.List[core.File] + See core.File for more documentation + + remove_background_noise : typing.Optional[bool] + If set will remove background noise for voice samples using our audio isolation model. If the samples do not include background noise, it can make the quality worse. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[typing.List[VoiceSample]] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/voices/pvc/{jsonable_encoder(voice_id)}/samples", + base_url=self._client_wrapper.get_environment().base, + method="POST", + data={ + "remove_background_noise": remove_background_noise, + }, + files={ + "files": files, + }, + request_options=request_options, + omit=OMIT, + force_multipart=True, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + typing.List[VoiceSample], + construct_type( + type_=typing.List[VoiceSample], # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def update( + self, + voice_id: str, + sample_id: str, + *, + remove_background_noise: typing.Optional[bool] = OMIT, + selected_speaker_ids: typing.Optional[typing.Sequence[str]] = OMIT, + trim_start_time: typing.Optional[int] = OMIT, + trim_end_time: typing.Optional[int] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[AddVoiceResponseModel]: + """ + Update a PVC voice sample - apply noise removal, or select speaker. + + Parameters + ---------- + voice_id : str + Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices. + + sample_id : str + Sample ID to be used + + remove_background_noise : typing.Optional[bool] + If set will remove background noise for voice samples using our audio isolation model. If the samples do not include background noise, it can make the quality worse. + + selected_speaker_ids : typing.Optional[typing.Sequence[str]] + Speaker IDs to be used for PVC training. Make sure you send all the speaker IDs you want to use for PVC training in one request because the last request will override the previous ones. + + trim_start_time : typing.Optional[int] + The start time of the audio to be used for PVC training. Time should be in milliseconds + + trim_end_time : typing.Optional[int] + The end time of the audio to be used for PVC training. Time should be in milliseconds + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[AddVoiceResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/voices/pvc/{jsonable_encoder(voice_id)}/samples/{jsonable_encoder(sample_id)}", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "remove_background_noise": remove_background_noise, + "selected_speaker_ids": selected_speaker_ids, + "trim_start_time": trim_start_time, + "trim_end_time": trim_end_time, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + AddVoiceResponseModel, + construct_type( + type_=AddVoiceResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def delete( + self, voice_id: str, sample_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[DeleteVoiceSampleResponseModel]: + """ + Delete a sample from a PVC voice. + + Parameters + ---------- + voice_id : str + Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices. + + sample_id : str + Sample ID to be used + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[DeleteVoiceSampleResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/voices/pvc/{jsonable_encoder(voice_id)}/samples/{jsonable_encoder(sample_id)}", + base_url=self._client_wrapper.get_environment().base, + method="DELETE", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + DeleteVoiceSampleResponseModel, + construct_type( + type_=DeleteVoiceSampleResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/elevenlabs/voices/pvc/samples/speakers/__init__.py b/src/elevenlabs/voices/pvc/samples/speakers/__init__.py index 012a17ea..9b59d547 100644 --- a/src/elevenlabs/voices/pvc/samples/speakers/__init__.py +++ b/src/elevenlabs/voices/pvc/samples/speakers/__init__.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# isort: skip_file + from . import audio __all__ = ["audio"] diff --git a/src/elevenlabs/voices/pvc/samples/speakers/audio/__init__.py b/src/elevenlabs/voices/pvc/samples/speakers/audio/__init__.py index f3ea2659..5cde0202 100644 --- a/src/elevenlabs/voices/pvc/samples/speakers/audio/__init__.py +++ b/src/elevenlabs/voices/pvc/samples/speakers/audio/__init__.py @@ -1,2 +1,4 @@ # This file was auto-generated by Fern from our API Definition. +# isort: skip_file + diff --git a/src/elevenlabs/voices/pvc/samples/speakers/audio/client.py b/src/elevenlabs/voices/pvc/samples/speakers/audio/client.py index c656fc00..ce0e75e4 100644 --- a/src/elevenlabs/voices/pvc/samples/speakers/audio/client.py +++ b/src/elevenlabs/voices/pvc/samples/speakers/audio/client.py @@ -1,29 +1,30 @@ # This file was auto-generated by Fern from our API Definition. -from ......core.client_wrapper import SyncClientWrapper import typing + +from ......core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ......core.request_options import RequestOptions from ......types.speaker_audio_response_model import SpeakerAudioResponseModel -from ......core.jsonable_encoder import jsonable_encoder -from ......core.unchecked_base_model import construct_type -from ......errors.unprocessable_entity_error import UnprocessableEntityError -from ......types.http_validation_error import HttpValidationError -from json.decoder import JSONDecodeError -from ......core.api_error import ApiError -from ......core.client_wrapper import AsyncClientWrapper +from .raw_client import AsyncRawAudioClient, RawAudioClient class AudioClient: def __init__(self, *, client_wrapper: SyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = RawAudioClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawAudioClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawAudioClient + """ + return self._raw_client def get( - self, - voice_id: str, - sample_id: str, - speaker_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, + self, voice_id: str, sample_id: str, speaker_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> SpeakerAudioResponseModel: """ Retrieve the separated audio for a specific speaker. @@ -60,48 +61,27 @@ def get( speaker_id="VW7YKqPnjY4h39yTbx2L", ) """ - _response = self._client_wrapper.httpx_client.request( - f"v1/voices/pvc/{jsonable_encoder(voice_id)}/samples/{jsonable_encoder(sample_id)}/speakers/{jsonable_encoder(speaker_id)}/audio", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - SpeakerAudioResponseModel, - construct_type( - type_=SpeakerAudioResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.get(voice_id, sample_id, speaker_id, request_options=request_options) + return _response.data class AsyncAudioClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = AsyncRawAudioClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawAudioClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawAudioClient + """ + return self._raw_client async def get( - self, - voice_id: str, - sample_id: str, - speaker_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, + self, voice_id: str, sample_id: str, speaker_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> SpeakerAudioResponseModel: """ Retrieve the separated audio for a specific speaker. @@ -146,32 +126,5 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/voices/pvc/{jsonable_encoder(voice_id)}/samples/{jsonable_encoder(sample_id)}/speakers/{jsonable_encoder(speaker_id)}/audio", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - SpeakerAudioResponseModel, - construct_type( - type_=SpeakerAudioResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.get(voice_id, sample_id, speaker_id, request_options=request_options) + return _response.data diff --git a/src/elevenlabs/voices/pvc/samples/speakers/audio/raw_client.py b/src/elevenlabs/voices/pvc/samples/speakers/audio/raw_client.py new file mode 100644 index 00000000..cbfc676d --- /dev/null +++ b/src/elevenlabs/voices/pvc/samples/speakers/audio/raw_client.py @@ -0,0 +1,138 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ......core.api_error import ApiError +from ......core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ......core.http_response import AsyncHttpResponse, HttpResponse +from ......core.jsonable_encoder import jsonable_encoder +from ......core.request_options import RequestOptions +from ......core.unchecked_base_model import construct_type +from ......errors.unprocessable_entity_error import UnprocessableEntityError +from ......types.http_validation_error import HttpValidationError +from ......types.speaker_audio_response_model import SpeakerAudioResponseModel + + +class RawAudioClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def get( + self, voice_id: str, sample_id: str, speaker_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[SpeakerAudioResponseModel]: + """ + Retrieve the separated audio for a specific speaker. + + Parameters + ---------- + voice_id : str + Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices. + + sample_id : str + Sample ID to be used + + speaker_id : str + Speaker ID to be used, you can use GET https://api.elevenlabs.io/v1/voices/{voice_id}/samples/{sample_id}/speakers to list all the available speakers for a sample. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[SpeakerAudioResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/voices/pvc/{jsonable_encoder(voice_id)}/samples/{jsonable_encoder(sample_id)}/speakers/{jsonable_encoder(speaker_id)}/audio", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + SpeakerAudioResponseModel, + construct_type( + type_=SpeakerAudioResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + +class AsyncRawAudioClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def get( + self, voice_id: str, sample_id: str, speaker_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[SpeakerAudioResponseModel]: + """ + Retrieve the separated audio for a specific speaker. + + Parameters + ---------- + voice_id : str + Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices. + + sample_id : str + Sample ID to be used + + speaker_id : str + Speaker ID to be used, you can use GET https://api.elevenlabs.io/v1/voices/{voice_id}/samples/{sample_id}/speakers to list all the available speakers for a sample. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[SpeakerAudioResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/voices/pvc/{jsonable_encoder(voice_id)}/samples/{jsonable_encoder(sample_id)}/speakers/{jsonable_encoder(speaker_id)}/audio", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + SpeakerAudioResponseModel, + construct_type( + type_=SpeakerAudioResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/elevenlabs/voices/pvc/samples/speakers/client.py b/src/elevenlabs/voices/pvc/samples/speakers/client.py index a5d43fbb..0eb44b48 100644 --- a/src/elevenlabs/voices/pvc/samples/speakers/client.py +++ b/src/elevenlabs/voices/pvc/samples/speakers/client.py @@ -1,34 +1,33 @@ # This file was auto-generated by Fern from our API Definition. -from .....core.client_wrapper import SyncClientWrapper -from .audio.client import AudioClient import typing + +from .....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from .....core.request_options import RequestOptions from .....types.speaker_separation_response_model import SpeakerSeparationResponseModel -from .....core.jsonable_encoder import jsonable_encoder -from .....core.unchecked_base_model import construct_type -from .....errors.unprocessable_entity_error import UnprocessableEntityError -from .....types.http_validation_error import HttpValidationError -from json.decoder import JSONDecodeError -from .....core.api_error import ApiError -from .....types.start_speaker_separation_response_model import ( - StartSpeakerSeparationResponseModel, -) -from .....core.client_wrapper import AsyncClientWrapper -from .audio.client import AsyncAudioClient +from .....types.start_speaker_separation_response_model import StartSpeakerSeparationResponseModel +from .audio.client import AsyncAudioClient, AudioClient +from .raw_client import AsyncRawSpeakersClient, RawSpeakersClient class SpeakersClient: def __init__(self, *, client_wrapper: SyncClientWrapper): - self._client_wrapper = client_wrapper - self.audio = AudioClient(client_wrapper=self._client_wrapper) + self._raw_client = RawSpeakersClient(client_wrapper=client_wrapper) + self.audio = AudioClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawSpeakersClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawSpeakersClient + """ + return self._raw_client def get( - self, - voice_id: str, - sample_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, + self, voice_id: str, sample_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> SpeakerSeparationResponseModel: """ Retrieve the status of the speaker separation process and the list of detected speakers if complete. @@ -61,42 +60,11 @@ def get( sample_id="VW7YKqPnjY4h39yTbx2L", ) """ - _response = self._client_wrapper.httpx_client.request( - f"v1/voices/pvc/{jsonable_encoder(voice_id)}/samples/{jsonable_encoder(sample_id)}/speakers", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - SpeakerSeparationResponseModel, - construct_type( - type_=SpeakerSeparationResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.get(voice_id, sample_id, request_options=request_options) + return _response.data def separate( - self, - voice_id: str, - sample_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, + self, voice_id: str, sample_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> StartSpeakerSeparationResponseModel: """ Start speaker separation process for a sample @@ -129,48 +97,28 @@ def separate( sample_id="VW7YKqPnjY4h39yTbx2L", ) """ - _response = self._client_wrapper.httpx_client.request( - f"v1/voices/pvc/{jsonable_encoder(voice_id)}/samples/{jsonable_encoder(sample_id)}/separate-speakers", - base_url=self._client_wrapper.get_environment().base, - method="POST", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - StartSpeakerSeparationResponseModel, - construct_type( - type_=StartSpeakerSeparationResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.separate(voice_id, sample_id, request_options=request_options) + return _response.data class AsyncSpeakersClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): - self._client_wrapper = client_wrapper - self.audio = AsyncAudioClient(client_wrapper=self._client_wrapper) + self._raw_client = AsyncRawSpeakersClient(client_wrapper=client_wrapper) + self.audio = AsyncAudioClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawSpeakersClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawSpeakersClient + """ + return self._raw_client async def get( - self, - voice_id: str, - sample_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, + self, voice_id: str, sample_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> SpeakerSeparationResponseModel: """ Retrieve the status of the speaker separation process and the list of detected speakers if complete. @@ -211,42 +159,11 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/voices/pvc/{jsonable_encoder(voice_id)}/samples/{jsonable_encoder(sample_id)}/speakers", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - SpeakerSeparationResponseModel, - construct_type( - type_=SpeakerSeparationResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.get(voice_id, sample_id, request_options=request_options) + return _response.data async def separate( - self, - voice_id: str, - sample_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, + self, voice_id: str, sample_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> StartSpeakerSeparationResponseModel: """ Start speaker separation process for a sample @@ -287,32 +204,5 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/voices/pvc/{jsonable_encoder(voice_id)}/samples/{jsonable_encoder(sample_id)}/separate-speakers", - base_url=self._client_wrapper.get_environment().base, - method="POST", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - StartSpeakerSeparationResponseModel, - construct_type( - type_=StartSpeakerSeparationResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.separate(voice_id, sample_id, request_options=request_options) + return _response.data diff --git a/src/elevenlabs/voices/pvc/samples/speakers/raw_client.py b/src/elevenlabs/voices/pvc/samples/speakers/raw_client.py new file mode 100644 index 00000000..a6c892a4 --- /dev/null +++ b/src/elevenlabs/voices/pvc/samples/speakers/raw_client.py @@ -0,0 +1,241 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from .....core.api_error import ApiError +from .....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from .....core.http_response import AsyncHttpResponse, HttpResponse +from .....core.jsonable_encoder import jsonable_encoder +from .....core.request_options import RequestOptions +from .....core.unchecked_base_model import construct_type +from .....errors.unprocessable_entity_error import UnprocessableEntityError +from .....types.http_validation_error import HttpValidationError +from .....types.speaker_separation_response_model import SpeakerSeparationResponseModel +from .....types.start_speaker_separation_response_model import StartSpeakerSeparationResponseModel + + +class RawSpeakersClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def get( + self, voice_id: str, sample_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[SpeakerSeparationResponseModel]: + """ + Retrieve the status of the speaker separation process and the list of detected speakers if complete. + + Parameters + ---------- + voice_id : str + Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices. + + sample_id : str + Sample ID to be used + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[SpeakerSeparationResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/voices/pvc/{jsonable_encoder(voice_id)}/samples/{jsonable_encoder(sample_id)}/speakers", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + SpeakerSeparationResponseModel, + construct_type( + type_=SpeakerSeparationResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def separate( + self, voice_id: str, sample_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[StartSpeakerSeparationResponseModel]: + """ + Start speaker separation process for a sample + + Parameters + ---------- + voice_id : str + Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices. + + sample_id : str + Sample ID to be used + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[StartSpeakerSeparationResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/voices/pvc/{jsonable_encoder(voice_id)}/samples/{jsonable_encoder(sample_id)}/separate-speakers", + base_url=self._client_wrapper.get_environment().base, + method="POST", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + StartSpeakerSeparationResponseModel, + construct_type( + type_=StartSpeakerSeparationResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + +class AsyncRawSpeakersClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def get( + self, voice_id: str, sample_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[SpeakerSeparationResponseModel]: + """ + Retrieve the status of the speaker separation process and the list of detected speakers if complete. + + Parameters + ---------- + voice_id : str + Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices. + + sample_id : str + Sample ID to be used + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[SpeakerSeparationResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/voices/pvc/{jsonable_encoder(voice_id)}/samples/{jsonable_encoder(sample_id)}/speakers", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + SpeakerSeparationResponseModel, + construct_type( + type_=SpeakerSeparationResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def separate( + self, voice_id: str, sample_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[StartSpeakerSeparationResponseModel]: + """ + Start speaker separation process for a sample + + Parameters + ---------- + voice_id : str + Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices. + + sample_id : str + Sample ID to be used + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[StartSpeakerSeparationResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/voices/pvc/{jsonable_encoder(voice_id)}/samples/{jsonable_encoder(sample_id)}/separate-speakers", + base_url=self._client_wrapper.get_environment().base, + method="POST", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + StartSpeakerSeparationResponseModel, + construct_type( + type_=StartSpeakerSeparationResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/elevenlabs/voices/pvc/samples/waveform/__init__.py b/src/elevenlabs/voices/pvc/samples/waveform/__init__.py index f3ea2659..5cde0202 100644 --- a/src/elevenlabs/voices/pvc/samples/waveform/__init__.py +++ b/src/elevenlabs/voices/pvc/samples/waveform/__init__.py @@ -1,2 +1,4 @@ # This file was auto-generated by Fern from our API Definition. +# isort: skip_file + diff --git a/src/elevenlabs/voices/pvc/samples/waveform/client.py b/src/elevenlabs/voices/pvc/samples/waveform/client.py index beb96132..a649ecdf 100644 --- a/src/elevenlabs/voices/pvc/samples/waveform/client.py +++ b/src/elevenlabs/voices/pvc/samples/waveform/client.py @@ -1,30 +1,30 @@ # This file was auto-generated by Fern from our API Definition. -from .....core.client_wrapper import SyncClientWrapper import typing + +from .....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from .....core.request_options import RequestOptions -from .....types.voice_sample_visual_waveform_response_model import ( - VoiceSampleVisualWaveformResponseModel, -) -from .....core.jsonable_encoder import jsonable_encoder -from .....core.unchecked_base_model import construct_type -from .....errors.unprocessable_entity_error import UnprocessableEntityError -from .....types.http_validation_error import HttpValidationError -from json.decoder import JSONDecodeError -from .....core.api_error import ApiError -from .....core.client_wrapper import AsyncClientWrapper +from .....types.voice_sample_visual_waveform_response_model import VoiceSampleVisualWaveformResponseModel +from .raw_client import AsyncRawWaveformClient, RawWaveformClient class WaveformClient: def __init__(self, *, client_wrapper: SyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = RawWaveformClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawWaveformClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawWaveformClient + """ + return self._raw_client def get( - self, - voice_id: str, - sample_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, + self, voice_id: str, sample_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> VoiceSampleVisualWaveformResponseModel: """ Retrieve the visual waveform of a voice sample. @@ -57,47 +57,27 @@ def get( sample_id="VW7YKqPnjY4h39yTbx2L", ) """ - _response = self._client_wrapper.httpx_client.request( - f"v1/voices/pvc/{jsonable_encoder(voice_id)}/samples/{jsonable_encoder(sample_id)}/waveform", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - VoiceSampleVisualWaveformResponseModel, - construct_type( - type_=VoiceSampleVisualWaveformResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.get(voice_id, sample_id, request_options=request_options) + return _response.data class AsyncWaveformClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = AsyncRawWaveformClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawWaveformClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawWaveformClient + """ + return self._raw_client async def get( - self, - voice_id: str, - sample_id: str, - *, - request_options: typing.Optional[RequestOptions] = None, + self, voice_id: str, sample_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> VoiceSampleVisualWaveformResponseModel: """ Retrieve the visual waveform of a voice sample. @@ -138,32 +118,5 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/voices/pvc/{jsonable_encoder(voice_id)}/samples/{jsonable_encoder(sample_id)}/waveform", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - VoiceSampleVisualWaveformResponseModel, - construct_type( - type_=VoiceSampleVisualWaveformResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.get(voice_id, sample_id, request_options=request_options) + return _response.data diff --git a/src/elevenlabs/voices/pvc/samples/waveform/raw_client.py b/src/elevenlabs/voices/pvc/samples/waveform/raw_client.py new file mode 100644 index 00000000..1904b644 --- /dev/null +++ b/src/elevenlabs/voices/pvc/samples/waveform/raw_client.py @@ -0,0 +1,132 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from .....core.api_error import ApiError +from .....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from .....core.http_response import AsyncHttpResponse, HttpResponse +from .....core.jsonable_encoder import jsonable_encoder +from .....core.request_options import RequestOptions +from .....core.unchecked_base_model import construct_type +from .....errors.unprocessable_entity_error import UnprocessableEntityError +from .....types.http_validation_error import HttpValidationError +from .....types.voice_sample_visual_waveform_response_model import VoiceSampleVisualWaveformResponseModel + + +class RawWaveformClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def get( + self, voice_id: str, sample_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[VoiceSampleVisualWaveformResponseModel]: + """ + Retrieve the visual waveform of a voice sample. + + Parameters + ---------- + voice_id : str + Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices. + + sample_id : str + Sample ID to be used + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[VoiceSampleVisualWaveformResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/voices/pvc/{jsonable_encoder(voice_id)}/samples/{jsonable_encoder(sample_id)}/waveform", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + VoiceSampleVisualWaveformResponseModel, + construct_type( + type_=VoiceSampleVisualWaveformResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + +class AsyncRawWaveformClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def get( + self, voice_id: str, sample_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[VoiceSampleVisualWaveformResponseModel]: + """ + Retrieve the visual waveform of a voice sample. + + Parameters + ---------- + voice_id : str + Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices. + + sample_id : str + Sample ID to be used + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[VoiceSampleVisualWaveformResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/voices/pvc/{jsonable_encoder(voice_id)}/samples/{jsonable_encoder(sample_id)}/waveform", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + VoiceSampleVisualWaveformResponseModel, + construct_type( + type_=VoiceSampleVisualWaveformResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/elevenlabs/voices/pvc/verification/__init__.py b/src/elevenlabs/voices/pvc/verification/__init__.py index 3daecd34..024d6433 100644 --- a/src/elevenlabs/voices/pvc/verification/__init__.py +++ b/src/elevenlabs/voices/pvc/verification/__init__.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# isort: skip_file + from . import captcha __all__ = ["captcha"] diff --git a/src/elevenlabs/voices/pvc/verification/captcha/__init__.py b/src/elevenlabs/voices/pvc/verification/captcha/__init__.py index f3ea2659..5cde0202 100644 --- a/src/elevenlabs/voices/pvc/verification/captcha/__init__.py +++ b/src/elevenlabs/voices/pvc/verification/captcha/__init__.py @@ -1,2 +1,4 @@ # This file was auto-generated by Fern from our API Definition. +# isort: skip_file + diff --git a/src/elevenlabs/voices/pvc/verification/captcha/client.py b/src/elevenlabs/voices/pvc/verification/captcha/client.py index 295aaec0..ab56689c 100644 --- a/src/elevenlabs/voices/pvc/verification/captcha/client.py +++ b/src/elevenlabs/voices/pvc/verification/captcha/client.py @@ -1,19 +1,12 @@ # This file was auto-generated by Fern from our API Definition. import typing -from .....core.client_wrapper import SyncClientWrapper -from .....core.request_options import RequestOptions -from .....core.jsonable_encoder import jsonable_encoder -from .....errors.unprocessable_entity_error import UnprocessableEntityError -from .....types.http_validation_error import HttpValidationError -from .....core.unchecked_base_model import construct_type -from json.decoder import JSONDecodeError -from .....core.api_error import ApiError + from ..... import core -from .....types.verify_pvc_voice_captcha_response_model import ( - VerifyPvcVoiceCaptchaResponseModel, -) -from .....core.client_wrapper import AsyncClientWrapper +from .....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from .....core.request_options import RequestOptions +from .....types.verify_pvc_voice_captcha_response_model import VerifyPvcVoiceCaptchaResponseModel +from .raw_client import AsyncRawCaptchaClient, RawCaptchaClient # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -21,7 +14,18 @@ class CaptchaClient: def __init__(self, *, client_wrapper: SyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = RawCaptchaClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawCaptchaClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawCaptchaClient + """ + return self._raw_client def get(self, voice_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None: """ @@ -50,36 +54,11 @@ def get(self, voice_id: str, *, request_options: typing.Optional[RequestOptions] voice_id="21m00Tcm4TlvDq8ikWAM", ) """ - _response = self._client_wrapper.httpx_client.request( - f"v1/voices/pvc/{jsonable_encoder(voice_id)}/captcha", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.get(voice_id, request_options=request_options) + return _response.data def verify( - self, - voice_id: str, - *, - recording: core.File, - request_options: typing.Optional[RequestOptions] = None, + self, voice_id: str, *, recording: core.File, request_options: typing.Optional[RequestOptions] = None ) -> VerifyPvcVoiceCaptchaResponseModel: """ Submit captcha verification for PVC voice. @@ -111,45 +90,24 @@ def verify( voice_id="21m00Tcm4TlvDq8ikWAM", ) """ - _response = self._client_wrapper.httpx_client.request( - f"v1/voices/pvc/{jsonable_encoder(voice_id)}/captcha", - base_url=self._client_wrapper.get_environment().base, - method="POST", - data={}, - files={ - "recording": recording, - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - VerifyPvcVoiceCaptchaResponseModel, - construct_type( - type_=VerifyPvcVoiceCaptchaResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + _response = self._raw_client.verify(voice_id, recording=recording, request_options=request_options) + return _response.data class AsyncCaptchaClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): - self._client_wrapper = client_wrapper + self._raw_client = AsyncRawCaptchaClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawCaptchaClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawCaptchaClient + """ + return self._raw_client async def get(self, voice_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None: """ @@ -186,36 +144,11 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/voices/pvc/{jsonable_encoder(voice_id)}/captcha", - base_url=self._client_wrapper.get_environment().base, - method="GET", - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.get(voice_id, request_options=request_options) + return _response.data async def verify( - self, - voice_id: str, - *, - recording: core.File, - request_options: typing.Optional[RequestOptions] = None, + self, voice_id: str, *, recording: core.File, request_options: typing.Optional[RequestOptions] = None ) -> VerifyPvcVoiceCaptchaResponseModel: """ Submit captcha verification for PVC voice. @@ -255,37 +188,5 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/voices/pvc/{jsonable_encoder(voice_id)}/captcha", - base_url=self._client_wrapper.get_environment().base, - method="POST", - data={}, - files={ - "recording": recording, - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - VerifyPvcVoiceCaptchaResponseModel, - construct_type( - type_=VerifyPvcVoiceCaptchaResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + _response = await self._raw_client.verify(voice_id, recording=recording, request_options=request_options) + return _response.data diff --git a/src/elevenlabs/voices/pvc/verification/captcha/raw_client.py b/src/elevenlabs/voices/pvc/verification/captcha/raw_client.py new file mode 100644 index 00000000..b534bb8b --- /dev/null +++ b/src/elevenlabs/voices/pvc/verification/captcha/raw_client.py @@ -0,0 +1,232 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ..... import core +from .....core.api_error import ApiError +from .....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from .....core.http_response import AsyncHttpResponse, HttpResponse +from .....core.jsonable_encoder import jsonable_encoder +from .....core.request_options import RequestOptions +from .....core.unchecked_base_model import construct_type +from .....errors.unprocessable_entity_error import UnprocessableEntityError +from .....types.http_validation_error import HttpValidationError +from .....types.verify_pvc_voice_captcha_response_model import VerifyPvcVoiceCaptchaResponseModel + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RawCaptchaClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def get(self, voice_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> HttpResponse[None]: + """ + Get captcha for PVC voice verification. + + Parameters + ---------- + voice_id : str + Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[None] + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/voices/pvc/{jsonable_encoder(voice_id)}/captcha", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return HttpResponse(response=_response, data=None) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def verify( + self, voice_id: str, *, recording: core.File, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[VerifyPvcVoiceCaptchaResponseModel]: + """ + Submit captcha verification for PVC voice. + + Parameters + ---------- + voice_id : str + Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices. + + recording : core.File + See core.File for more documentation + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[VerifyPvcVoiceCaptchaResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/voices/pvc/{jsonable_encoder(voice_id)}/captcha", + base_url=self._client_wrapper.get_environment().base, + method="POST", + data={}, + files={ + "recording": recording, + }, + request_options=request_options, + omit=OMIT, + force_multipart=True, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + VerifyPvcVoiceCaptchaResponseModel, + construct_type( + type_=VerifyPvcVoiceCaptchaResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + +class AsyncRawCaptchaClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def get( + self, voice_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[None]: + """ + Get captcha for PVC voice verification. + + Parameters + ---------- + voice_id : str + Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[None] + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/voices/pvc/{jsonable_encoder(voice_id)}/captcha", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return AsyncHttpResponse(response=_response, data=None) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def verify( + self, voice_id: str, *, recording: core.File, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[VerifyPvcVoiceCaptchaResponseModel]: + """ + Submit captcha verification for PVC voice. + + Parameters + ---------- + voice_id : str + Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices. + + recording : core.File + See core.File for more documentation + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[VerifyPvcVoiceCaptchaResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/voices/pvc/{jsonable_encoder(voice_id)}/captcha", + base_url=self._client_wrapper.get_environment().base, + method="POST", + data={}, + files={ + "recording": recording, + }, + request_options=request_options, + omit=OMIT, + force_multipart=True, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + VerifyPvcVoiceCaptchaResponseModel, + construct_type( + type_=VerifyPvcVoiceCaptchaResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/elevenlabs/voices/pvc/verification/client.py b/src/elevenlabs/voices/pvc/verification/client.py index 56438b47..d0fa1e31 100644 --- a/src/elevenlabs/voices/pvc/verification/client.py +++ b/src/elevenlabs/voices/pvc/verification/client.py @@ -1,21 +1,13 @@ # This file was auto-generated by Fern from our API Definition. import typing -from ....core.client_wrapper import SyncClientWrapper -from .captcha.client import CaptchaClient + from .... import core +from ....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ....core.request_options import RequestOptions -from ....types.request_pvc_manual_verification_response_model import ( - RequestPvcManualVerificationResponseModel, -) -from ....core.jsonable_encoder import jsonable_encoder -from ....core.unchecked_base_model import construct_type -from ....errors.unprocessable_entity_error import UnprocessableEntityError -from ....types.http_validation_error import HttpValidationError -from json.decoder import JSONDecodeError -from ....core.api_error import ApiError -from ....core.client_wrapper import AsyncClientWrapper -from .captcha.client import AsyncCaptchaClient +from ....types.request_pvc_manual_verification_response_model import RequestPvcManualVerificationResponseModel +from .captcha.client import AsyncCaptchaClient, CaptchaClient +from .raw_client import AsyncRawVerificationClient, RawVerificationClient # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -23,8 +15,19 @@ class VerificationClient: def __init__(self, *, client_wrapper: SyncClientWrapper): - self._client_wrapper = client_wrapper - self.captcha = CaptchaClient(client_wrapper=self._client_wrapper) + self._raw_client = RawVerificationClient(client_wrapper=client_wrapper) + self.captcha = CaptchaClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawVerificationClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawVerificationClient + """ + return self._raw_client def request( self, @@ -67,48 +70,27 @@ def request( voice_id="21m00Tcm4TlvDq8ikWAM", ) """ - _response = self._client_wrapper.httpx_client.request( - f"v1/voices/pvc/{jsonable_encoder(voice_id)}/verification", - base_url=self._client_wrapper.get_environment().base, - method="POST", - data={ - "extra_text": extra_text, - }, - files={ - "files": files, - }, - request_options=request_options, - omit=OMIT, + _response = self._raw_client.request( + voice_id, files=files, extra_text=extra_text, request_options=request_options ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - RequestPvcManualVerificationResponseModel, - construct_type( - type_=RequestPvcManualVerificationResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + return _response.data class AsyncVerificationClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): - self._client_wrapper = client_wrapper - self.captcha = AsyncCaptchaClient(client_wrapper=self._client_wrapper) + self._raw_client = AsyncRawVerificationClient(client_wrapper=client_wrapper) + self.captcha = AsyncCaptchaClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawVerificationClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawVerificationClient + """ + return self._raw_client async def request( self, @@ -159,39 +141,7 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/voices/pvc/{jsonable_encoder(voice_id)}/verification", - base_url=self._client_wrapper.get_environment().base, - method="POST", - data={ - "extra_text": extra_text, - }, - files={ - "files": files, - }, - request_options=request_options, - omit=OMIT, + _response = await self._raw_client.request( + voice_id, files=files, extra_text=extra_text, request_options=request_options ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - RequestPvcManualVerificationResponseModel, - construct_type( - type_=RequestPvcManualVerificationResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + return _response.data diff --git a/src/elevenlabs/voices/pvc/verification/raw_client.py b/src/elevenlabs/voices/pvc/verification/raw_client.py new file mode 100644 index 00000000..5a5715d5 --- /dev/null +++ b/src/elevenlabs/voices/pvc/verification/raw_client.py @@ -0,0 +1,168 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from .... import core +from ....core.api_error import ApiError +from ....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ....core.http_response import AsyncHttpResponse, HttpResponse +from ....core.jsonable_encoder import jsonable_encoder +from ....core.request_options import RequestOptions +from ....core.unchecked_base_model import construct_type +from ....errors.unprocessable_entity_error import UnprocessableEntityError +from ....types.http_validation_error import HttpValidationError +from ....types.request_pvc_manual_verification_response_model import RequestPvcManualVerificationResponseModel + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RawVerificationClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def request( + self, + voice_id: str, + *, + files: typing.List[core.File], + extra_text: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[RequestPvcManualVerificationResponseModel]: + """ + Request manual verification for a PVC voice. + + Parameters + ---------- + voice_id : str + Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices. + + files : typing.List[core.File] + See core.File for more documentation + + extra_text : typing.Optional[str] + Extra text to be used in the manual verification process. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[RequestPvcManualVerificationResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/voices/pvc/{jsonable_encoder(voice_id)}/verification", + base_url=self._client_wrapper.get_environment().base, + method="POST", + data={ + "extra_text": extra_text, + }, + files={ + "files": files, + }, + request_options=request_options, + omit=OMIT, + force_multipart=True, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + RequestPvcManualVerificationResponseModel, + construct_type( + type_=RequestPvcManualVerificationResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + +class AsyncRawVerificationClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def request( + self, + voice_id: str, + *, + files: typing.List[core.File], + extra_text: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[RequestPvcManualVerificationResponseModel]: + """ + Request manual verification for a PVC voice. + + Parameters + ---------- + voice_id : str + Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices. + + files : typing.List[core.File] + See core.File for more documentation + + extra_text : typing.Optional[str] + Extra text to be used in the manual verification process. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[RequestPvcManualVerificationResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/voices/pvc/{jsonable_encoder(voice_id)}/verification", + base_url=self._client_wrapper.get_environment().base, + method="POST", + data={ + "extra_text": extra_text, + }, + files={ + "files": files, + }, + request_options=request_options, + omit=OMIT, + force_multipart=True, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + RequestPvcManualVerificationResponseModel, + construct_type( + type_=RequestPvcManualVerificationResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/elevenlabs/voices/raw_client.py b/src/elevenlabs/voices/raw_client.py new file mode 100644 index 00000000..8fbda6c8 --- /dev/null +++ b/src/elevenlabs/voices/raw_client.py @@ -0,0 +1,1293 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from .. import core +from ..core.api_error import ApiError +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ..core.http_response import AsyncHttpResponse, HttpResponse +from ..core.jsonable_encoder import jsonable_encoder +from ..core.request_options import RequestOptions +from ..core.unchecked_base_model import construct_type +from ..errors.unprocessable_entity_error import UnprocessableEntityError +from ..types.add_voice_response_model import AddVoiceResponseModel +from ..types.delete_voice_response_model import DeleteVoiceResponseModel +from ..types.edit_voice_response_model import EditVoiceResponseModel +from ..types.get_library_voices_response import GetLibraryVoicesResponse +from ..types.get_voices_response import GetVoicesResponse +from ..types.get_voices_v_2_response import GetVoicesV2Response +from ..types.http_validation_error import HttpValidationError +from ..types.voice import Voice +from .types.voices_get_shared_request_category import VoicesGetSharedRequestCategory + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RawVoicesClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def get_all( + self, *, show_legacy: typing.Optional[bool] = None, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[GetVoicesResponse]: + """ + Returns a list of all available voices for a user. + + Parameters + ---------- + show_legacy : typing.Optional[bool] + If set to true, legacy premade voices will be included in responses from /v1/voices + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[GetVoicesResponse] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + "v1/voices", + base_url=self._client_wrapper.get_environment().base, + method="GET", + params={ + "show_legacy": show_legacy, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetVoicesResponse, + construct_type( + type_=GetVoicesResponse, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def search( + self, + *, + next_page_token: typing.Optional[str] = None, + page_size: typing.Optional[int] = None, + search: typing.Optional[str] = None, + sort: typing.Optional[str] = None, + sort_direction: typing.Optional[str] = None, + voice_type: typing.Optional[str] = None, + category: typing.Optional[str] = None, + fine_tuning_state: typing.Optional[str] = None, + collection_id: typing.Optional[str] = None, + include_total_count: typing.Optional[bool] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[GetVoicesV2Response]: + """ + Gets a list of all available voices for a user with search, filtering and pagination. + + Parameters + ---------- + next_page_token : typing.Optional[str] + The next page token to use for pagination. Returned from the previous request. + + page_size : typing.Optional[int] + How many voices to return at maximum. Can not exceed 100, defaults to 10. Page 0 may include more voices due to default voices being included. + + search : typing.Optional[str] + Search term to filter voices by. Searches in name, description, labels, category. + + sort : typing.Optional[str] + Which field to sort by, one of 'created_at_unix' or 'name'. 'created_at_unix' may not be available for older voices. + + sort_direction : typing.Optional[str] + Which direction to sort the voices in. 'asc' or 'desc'. + + voice_type : typing.Optional[str] + Type of the voice to filter by. One of 'personal', 'community', 'default', 'workspace', 'non-default'. 'non-default' is equal to 'personal' plus 'community'. + + category : typing.Optional[str] + Category of the voice to filter by. One of 'premade', 'cloned', 'generated', 'professional' + + fine_tuning_state : typing.Optional[str] + State of the voice's fine tuning to filter by. Applicable only to professional voices clones. One of 'draft', 'not_verified', 'not_started', 'queued', 'fine_tuning', 'fine_tuned', 'failed', 'delayed' + + collection_id : typing.Optional[str] + Collection ID to filter voices by. + + include_total_count : typing.Optional[bool] + Whether to include the total count of voices found in the response. Incurs a performance cost. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[GetVoicesV2Response] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + "v2/voices", + base_url=self._client_wrapper.get_environment().base, + method="GET", + params={ + "next_page_token": next_page_token, + "page_size": page_size, + "search": search, + "sort": sort, + "sort_direction": sort_direction, + "voice_type": voice_type, + "category": category, + "fine_tuning_state": fine_tuning_state, + "collection_id": collection_id, + "include_total_count": include_total_count, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetVoicesV2Response, + construct_type( + type_=GetVoicesV2Response, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def get( + self, + voice_id: str, + *, + with_settings: typing.Optional[bool] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[Voice]: + """ + Returns metadata about a specific voice. + + Parameters + ---------- + voice_id : str + ID of the voice to be used. You can use the [Get voices](/docs/api-reference/voices/search) endpoint list all the available voices. + + with_settings : typing.Optional[bool] + This parameter is now deprecated. It is ignored and will be removed in a future version. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[Voice] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/voices/{jsonable_encoder(voice_id)}", + base_url=self._client_wrapper.get_environment().base, + method="GET", + params={ + "with_settings": with_settings, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + Voice, + construct_type( + type_=Voice, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def delete( + self, voice_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[DeleteVoiceResponseModel]: + """ + Deletes a voice by its ID. + + Parameters + ---------- + voice_id : str + ID of the voice to be used. You can use the [Get voices](/docs/api-reference/voices/search) endpoint list all the available voices. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[DeleteVoiceResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/voices/{jsonable_encoder(voice_id)}", + base_url=self._client_wrapper.get_environment().base, + method="DELETE", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + DeleteVoiceResponseModel, + construct_type( + type_=DeleteVoiceResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def update( + self, + voice_id: str, + *, + name: str, + files: typing.Optional[typing.List[core.File]] = OMIT, + remove_background_noise: typing.Optional[bool] = OMIT, + description: typing.Optional[str] = OMIT, + labels: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[EditVoiceResponseModel]: + """ + Edit a voice created by you. + + Parameters + ---------- + voice_id : str + ID of the voice to be used. You can use the [Get voices](/docs/api-reference/voices/search) endpoint list all the available voices. + + name : str + The name that identifies this voice. This will be displayed in the dropdown of the website. + + files : typing.Optional[typing.List[core.File]] + See core.File for more documentation + + remove_background_noise : typing.Optional[bool] + If set will remove background noise for voice samples using our audio isolation model. If the samples do not include background noise, it can make the quality worse. + + description : typing.Optional[str] + A description of the voice. + + labels : typing.Optional[str] + Serialized labels dictionary for the voice. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[EditVoiceResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/voices/{jsonable_encoder(voice_id)}/edit", + base_url=self._client_wrapper.get_environment().base, + method="POST", + data={ + "name": name, + "remove_background_noise": remove_background_noise, + "description": description, + "labels": labels, + }, + files={ + **({"files": files} if files is not None else {}), + }, + request_options=request_options, + omit=OMIT, + force_multipart=True, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + EditVoiceResponseModel, + construct_type( + type_=EditVoiceResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def share( + self, + public_user_id: str, + voice_id: str, + *, + new_name: str, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[AddVoiceResponseModel]: + """ + Add a shared voice to your collection of Voices + + Parameters + ---------- + public_user_id : str + Public user ID used to publicly identify ElevenLabs users. + + voice_id : str + ID of the voice to be used. You can use the [Get voices](/docs/api-reference/voices/search) endpoint list all the available voices. + + new_name : str + The name that identifies this voice. This will be displayed in the dropdown of the website. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[AddVoiceResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/voices/add/{jsonable_encoder(public_user_id)}/{jsonable_encoder(voice_id)}", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "new_name": new_name, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + AddVoiceResponseModel, + construct_type( + type_=AddVoiceResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def get_shared( + self, + *, + page_size: typing.Optional[int] = None, + category: typing.Optional[VoicesGetSharedRequestCategory] = None, + gender: typing.Optional[str] = None, + age: typing.Optional[str] = None, + accent: typing.Optional[str] = None, + language: typing.Optional[str] = None, + locale: typing.Optional[str] = None, + search: typing.Optional[str] = None, + use_cases: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, + descriptives: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, + featured: typing.Optional[bool] = None, + min_notice_period_days: typing.Optional[int] = None, + include_custom_rates: typing.Optional[bool] = None, + reader_app_enabled: typing.Optional[bool] = None, + owner_id: typing.Optional[str] = None, + sort: typing.Optional[str] = None, + page: typing.Optional[int] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[GetLibraryVoicesResponse]: + """ + Retrieves a list of shared voices. + + Parameters + ---------- + page_size : typing.Optional[int] + How many shared voices to return at maximum. Can not exceed 100, defaults to 30. + + category : typing.Optional[VoicesGetSharedRequestCategory] + Voice category used for filtering + + gender : typing.Optional[str] + Gender used for filtering + + age : typing.Optional[str] + Age used for filtering + + accent : typing.Optional[str] + Accent used for filtering + + language : typing.Optional[str] + Language used for filtering + + locale : typing.Optional[str] + Locale used for filtering + + search : typing.Optional[str] + Search term used for filtering + + use_cases : typing.Optional[typing.Union[str, typing.Sequence[str]]] + Use-case used for filtering + + descriptives : typing.Optional[typing.Union[str, typing.Sequence[str]]] + Search term used for filtering + + featured : typing.Optional[bool] + Filter featured voices + + min_notice_period_days : typing.Optional[int] + Filter voices with a minimum notice period of the given number of days. + + include_custom_rates : typing.Optional[bool] + Include/exclude voices with custom rates + + reader_app_enabled : typing.Optional[bool] + Filter voices that are enabled for the reader app + + owner_id : typing.Optional[str] + Filter voices by public owner ID + + sort : typing.Optional[str] + Sort criteria + + page : typing.Optional[int] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[GetLibraryVoicesResponse] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + "v1/shared-voices", + base_url=self._client_wrapper.get_environment().base, + method="GET", + params={ + "page_size": page_size, + "category": category, + "gender": gender, + "age": age, + "accent": accent, + "language": language, + "locale": locale, + "search": search, + "use_cases": use_cases, + "descriptives": descriptives, + "featured": featured, + "min_notice_period_days": min_notice_period_days, + "include_custom_rates": include_custom_rates, + "reader_app_enabled": reader_app_enabled, + "owner_id": owner_id, + "sort": sort, + "page": page, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetLibraryVoicesResponse, + construct_type( + type_=GetLibraryVoicesResponse, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def find_similar_voices( + self, + *, + audio_file: typing.Optional[core.File] = OMIT, + similarity_threshold: typing.Optional[float] = OMIT, + top_k: typing.Optional[int] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[GetLibraryVoicesResponse]: + """ + Returns a list of shared voices similar to the provided audio sample. If neither similarity_threshold nor top_k is provided, we will apply default values. + + Parameters + ---------- + audio_file : typing.Optional[core.File] + See core.File for more documentation + + similarity_threshold : typing.Optional[float] + Threshold for voice similarity between provided sample and library voices. Values range from 0 to 2. The smaller the value the more similar voices will be returned. + + top_k : typing.Optional[int] + Number of most similar voices to return. If similarity_threshold is provided, less than this number of voices may be returned. Values range from 1 to 100. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[GetLibraryVoicesResponse] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + "v1/similar-voices", + base_url=self._client_wrapper.get_environment().base, + method="POST", + data={ + "similarity_threshold": similarity_threshold, + "top_k": top_k, + }, + files={ + **({"audio_file": audio_file} if audio_file is not None else {}), + }, + request_options=request_options, + omit=OMIT, + force_multipart=True, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetLibraryVoicesResponse, + construct_type( + type_=GetLibraryVoicesResponse, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + +class AsyncRawVoicesClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def get_all( + self, *, show_legacy: typing.Optional[bool] = None, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[GetVoicesResponse]: + """ + Returns a list of all available voices for a user. + + Parameters + ---------- + show_legacy : typing.Optional[bool] + If set to true, legacy premade voices will be included in responses from /v1/voices + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[GetVoicesResponse] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + "v1/voices", + base_url=self._client_wrapper.get_environment().base, + method="GET", + params={ + "show_legacy": show_legacy, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetVoicesResponse, + construct_type( + type_=GetVoicesResponse, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def search( + self, + *, + next_page_token: typing.Optional[str] = None, + page_size: typing.Optional[int] = None, + search: typing.Optional[str] = None, + sort: typing.Optional[str] = None, + sort_direction: typing.Optional[str] = None, + voice_type: typing.Optional[str] = None, + category: typing.Optional[str] = None, + fine_tuning_state: typing.Optional[str] = None, + collection_id: typing.Optional[str] = None, + include_total_count: typing.Optional[bool] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[GetVoicesV2Response]: + """ + Gets a list of all available voices for a user with search, filtering and pagination. + + Parameters + ---------- + next_page_token : typing.Optional[str] + The next page token to use for pagination. Returned from the previous request. + + page_size : typing.Optional[int] + How many voices to return at maximum. Can not exceed 100, defaults to 10. Page 0 may include more voices due to default voices being included. + + search : typing.Optional[str] + Search term to filter voices by. Searches in name, description, labels, category. + + sort : typing.Optional[str] + Which field to sort by, one of 'created_at_unix' or 'name'. 'created_at_unix' may not be available for older voices. + + sort_direction : typing.Optional[str] + Which direction to sort the voices in. 'asc' or 'desc'. + + voice_type : typing.Optional[str] + Type of the voice to filter by. One of 'personal', 'community', 'default', 'workspace', 'non-default'. 'non-default' is equal to 'personal' plus 'community'. + + category : typing.Optional[str] + Category of the voice to filter by. One of 'premade', 'cloned', 'generated', 'professional' + + fine_tuning_state : typing.Optional[str] + State of the voice's fine tuning to filter by. Applicable only to professional voices clones. One of 'draft', 'not_verified', 'not_started', 'queued', 'fine_tuning', 'fine_tuned', 'failed', 'delayed' + + collection_id : typing.Optional[str] + Collection ID to filter voices by. + + include_total_count : typing.Optional[bool] + Whether to include the total count of voices found in the response. Incurs a performance cost. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[GetVoicesV2Response] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + "v2/voices", + base_url=self._client_wrapper.get_environment().base, + method="GET", + params={ + "next_page_token": next_page_token, + "page_size": page_size, + "search": search, + "sort": sort, + "sort_direction": sort_direction, + "voice_type": voice_type, + "category": category, + "fine_tuning_state": fine_tuning_state, + "collection_id": collection_id, + "include_total_count": include_total_count, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetVoicesV2Response, + construct_type( + type_=GetVoicesV2Response, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def get( + self, + voice_id: str, + *, + with_settings: typing.Optional[bool] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[Voice]: + """ + Returns metadata about a specific voice. + + Parameters + ---------- + voice_id : str + ID of the voice to be used. You can use the [Get voices](/docs/api-reference/voices/search) endpoint list all the available voices. + + with_settings : typing.Optional[bool] + This parameter is now deprecated. It is ignored and will be removed in a future version. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[Voice] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/voices/{jsonable_encoder(voice_id)}", + base_url=self._client_wrapper.get_environment().base, + method="GET", + params={ + "with_settings": with_settings, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + Voice, + construct_type( + type_=Voice, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def delete( + self, voice_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[DeleteVoiceResponseModel]: + """ + Deletes a voice by its ID. + + Parameters + ---------- + voice_id : str + ID of the voice to be used. You can use the [Get voices](/docs/api-reference/voices/search) endpoint list all the available voices. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[DeleteVoiceResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/voices/{jsonable_encoder(voice_id)}", + base_url=self._client_wrapper.get_environment().base, + method="DELETE", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + DeleteVoiceResponseModel, + construct_type( + type_=DeleteVoiceResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def update( + self, + voice_id: str, + *, + name: str, + files: typing.Optional[typing.List[core.File]] = OMIT, + remove_background_noise: typing.Optional[bool] = OMIT, + description: typing.Optional[str] = OMIT, + labels: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[EditVoiceResponseModel]: + """ + Edit a voice created by you. + + Parameters + ---------- + voice_id : str + ID of the voice to be used. You can use the [Get voices](/docs/api-reference/voices/search) endpoint list all the available voices. + + name : str + The name that identifies this voice. This will be displayed in the dropdown of the website. + + files : typing.Optional[typing.List[core.File]] + See core.File for more documentation + + remove_background_noise : typing.Optional[bool] + If set will remove background noise for voice samples using our audio isolation model. If the samples do not include background noise, it can make the quality worse. + + description : typing.Optional[str] + A description of the voice. + + labels : typing.Optional[str] + Serialized labels dictionary for the voice. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[EditVoiceResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/voices/{jsonable_encoder(voice_id)}/edit", + base_url=self._client_wrapper.get_environment().base, + method="POST", + data={ + "name": name, + "remove_background_noise": remove_background_noise, + "description": description, + "labels": labels, + }, + files={ + **({"files": files} if files is not None else {}), + }, + request_options=request_options, + omit=OMIT, + force_multipart=True, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + EditVoiceResponseModel, + construct_type( + type_=EditVoiceResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def share( + self, + public_user_id: str, + voice_id: str, + *, + new_name: str, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[AddVoiceResponseModel]: + """ + Add a shared voice to your collection of Voices + + Parameters + ---------- + public_user_id : str + Public user ID used to publicly identify ElevenLabs users. + + voice_id : str + ID of the voice to be used. You can use the [Get voices](/docs/api-reference/voices/search) endpoint list all the available voices. + + new_name : str + The name that identifies this voice. This will be displayed in the dropdown of the website. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[AddVoiceResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/voices/add/{jsonable_encoder(public_user_id)}/{jsonable_encoder(voice_id)}", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "new_name": new_name, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + AddVoiceResponseModel, + construct_type( + type_=AddVoiceResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def get_shared( + self, + *, + page_size: typing.Optional[int] = None, + category: typing.Optional[VoicesGetSharedRequestCategory] = None, + gender: typing.Optional[str] = None, + age: typing.Optional[str] = None, + accent: typing.Optional[str] = None, + language: typing.Optional[str] = None, + locale: typing.Optional[str] = None, + search: typing.Optional[str] = None, + use_cases: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, + descriptives: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, + featured: typing.Optional[bool] = None, + min_notice_period_days: typing.Optional[int] = None, + include_custom_rates: typing.Optional[bool] = None, + reader_app_enabled: typing.Optional[bool] = None, + owner_id: typing.Optional[str] = None, + sort: typing.Optional[str] = None, + page: typing.Optional[int] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[GetLibraryVoicesResponse]: + """ + Retrieves a list of shared voices. + + Parameters + ---------- + page_size : typing.Optional[int] + How many shared voices to return at maximum. Can not exceed 100, defaults to 30. + + category : typing.Optional[VoicesGetSharedRequestCategory] + Voice category used for filtering + + gender : typing.Optional[str] + Gender used for filtering + + age : typing.Optional[str] + Age used for filtering + + accent : typing.Optional[str] + Accent used for filtering + + language : typing.Optional[str] + Language used for filtering + + locale : typing.Optional[str] + Locale used for filtering + + search : typing.Optional[str] + Search term used for filtering + + use_cases : typing.Optional[typing.Union[str, typing.Sequence[str]]] + Use-case used for filtering + + descriptives : typing.Optional[typing.Union[str, typing.Sequence[str]]] + Search term used for filtering + + featured : typing.Optional[bool] + Filter featured voices + + min_notice_period_days : typing.Optional[int] + Filter voices with a minimum notice period of the given number of days. + + include_custom_rates : typing.Optional[bool] + Include/exclude voices with custom rates + + reader_app_enabled : typing.Optional[bool] + Filter voices that are enabled for the reader app + + owner_id : typing.Optional[str] + Filter voices by public owner ID + + sort : typing.Optional[str] + Sort criteria + + page : typing.Optional[int] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[GetLibraryVoicesResponse] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + "v1/shared-voices", + base_url=self._client_wrapper.get_environment().base, + method="GET", + params={ + "page_size": page_size, + "category": category, + "gender": gender, + "age": age, + "accent": accent, + "language": language, + "locale": locale, + "search": search, + "use_cases": use_cases, + "descriptives": descriptives, + "featured": featured, + "min_notice_period_days": min_notice_period_days, + "include_custom_rates": include_custom_rates, + "reader_app_enabled": reader_app_enabled, + "owner_id": owner_id, + "sort": sort, + "page": page, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetLibraryVoicesResponse, + construct_type( + type_=GetLibraryVoicesResponse, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def find_similar_voices( + self, + *, + audio_file: typing.Optional[core.File] = OMIT, + similarity_threshold: typing.Optional[float] = OMIT, + top_k: typing.Optional[int] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[GetLibraryVoicesResponse]: + """ + Returns a list of shared voices similar to the provided audio sample. If neither similarity_threshold nor top_k is provided, we will apply default values. + + Parameters + ---------- + audio_file : typing.Optional[core.File] + See core.File for more documentation + + similarity_threshold : typing.Optional[float] + Threshold for voice similarity between provided sample and library voices. Values range from 0 to 2. The smaller the value the more similar voices will be returned. + + top_k : typing.Optional[int] + Number of most similar voices to return. If similarity_threshold is provided, less than this number of voices may be returned. Values range from 1 to 100. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[GetLibraryVoicesResponse] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + "v1/similar-voices", + base_url=self._client_wrapper.get_environment().base, + method="POST", + data={ + "similarity_threshold": similarity_threshold, + "top_k": top_k, + }, + files={ + **({"audio_file": audio_file} if audio_file is not None else {}), + }, + request_options=request_options, + omit=OMIT, + force_multipart=True, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetLibraryVoicesResponse, + construct_type( + type_=GetLibraryVoicesResponse, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/elevenlabs/voices/samples/__init__.py b/src/elevenlabs/voices/samples/__init__.py new file mode 100644 index 00000000..9b59d547 --- /dev/null +++ b/src/elevenlabs/voices/samples/__init__.py @@ -0,0 +1,7 @@ +# This file was auto-generated by Fern from our API Definition. + +# isort: skip_file + +from . import audio + +__all__ = ["audio"] diff --git a/src/elevenlabs/voices/samples/audio/__init__.py b/src/elevenlabs/voices/samples/audio/__init__.py new file mode 100644 index 00000000..5cde0202 --- /dev/null +++ b/src/elevenlabs/voices/samples/audio/__init__.py @@ -0,0 +1,4 @@ +# This file was auto-generated by Fern from our API Definition. + +# isort: skip_file + diff --git a/src/elevenlabs/voices/samples/audio/client.py b/src/elevenlabs/voices/samples/audio/client.py new file mode 100644 index 00000000..97a7349b --- /dev/null +++ b/src/elevenlabs/voices/samples/audio/client.py @@ -0,0 +1,90 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +from ....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ....core.request_options import RequestOptions +from .raw_client import AsyncRawAudioClient, RawAudioClient + + +class AudioClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._raw_client = RawAudioClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawAudioClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawAudioClient + """ + return self._raw_client + + def get( + self, voice_id: str, sample_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> typing.Iterator[bytes]: + """ + Returns the audio corresponding to a sample attached to a voice. + + Parameters + ---------- + voice_id : str + ID of the voice to be used. You can use the [Get voices](/docs/api-reference/voices/search) endpoint list all the available voices. + + sample_id : str + ID of the sample to be used. You can use the [Get voices](/docs/api-reference/voices/get) endpoint list all the available samples for a voice. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. + + Returns + ------- + typing.Iterator[bytes] + Successful Response + """ + with self._raw_client.get(voice_id, sample_id, request_options=request_options) as r: + yield from r.data + + +class AsyncAudioClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawAudioClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawAudioClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawAudioClient + """ + return self._raw_client + + async def get( + self, voice_id: str, sample_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> typing.AsyncIterator[bytes]: + """ + Returns the audio corresponding to a sample attached to a voice. + + Parameters + ---------- + voice_id : str + ID of the voice to be used. You can use the [Get voices](/docs/api-reference/voices/search) endpoint list all the available voices. + + sample_id : str + ID of the sample to be used. You can use the [Get voices](/docs/api-reference/voices/get) endpoint list all the available samples for a voice. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. + + Returns + ------- + typing.AsyncIterator[bytes] + Successful Response + """ + async with self._raw_client.get(voice_id, sample_id, request_options=request_options) as r: + async for _chunk in r.data: + yield _chunk diff --git a/src/elevenlabs/voices/samples/audio/raw_client.py b/src/elevenlabs/voices/samples/audio/raw_client.py new file mode 100644 index 00000000..d39dd0bb --- /dev/null +++ b/src/elevenlabs/voices/samples/audio/raw_client.py @@ -0,0 +1,141 @@ +# This file was auto-generated by Fern from our API Definition. + +import contextlib +import typing +from json.decoder import JSONDecodeError + +from ....core.api_error import ApiError +from ....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ....core.http_response import AsyncHttpResponse, HttpResponse +from ....core.jsonable_encoder import jsonable_encoder +from ....core.request_options import RequestOptions +from ....core.unchecked_base_model import construct_type +from ....errors.unprocessable_entity_error import UnprocessableEntityError +from ....types.http_validation_error import HttpValidationError + + +class RawAudioClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + @contextlib.contextmanager + def get( + self, voice_id: str, sample_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> typing.Iterator[HttpResponse[typing.Iterator[bytes]]]: + """ + Returns the audio corresponding to a sample attached to a voice. + + Parameters + ---------- + voice_id : str + ID of the voice to be used. You can use the [Get voices](/docs/api-reference/voices/search) endpoint list all the available voices. + + sample_id : str + ID of the sample to be used. You can use the [Get voices](/docs/api-reference/voices/get) endpoint list all the available samples for a voice. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. + + Returns + ------- + typing.Iterator[HttpResponse[typing.Iterator[bytes]]] + Successful Response + """ + with self._client_wrapper.httpx_client.stream( + f"v1/voices/{jsonable_encoder(voice_id)}/samples/{jsonable_encoder(sample_id)}/audio", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) as _response: + + def _stream() -> HttpResponse[typing.Iterator[bytes]]: + try: + if 200 <= _response.status_code < 300: + _chunk_size = request_options.get("chunk_size", 1024) if request_options is not None else 1024 + return HttpResponse( + response=_response, data=(_chunk for _chunk in _response.iter_bytes(chunk_size=_chunk_size)) + ) + _response.read() + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + yield _stream() + + +class AsyncRawAudioClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + @contextlib.asynccontextmanager + async def get( + self, voice_id: str, sample_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> typing.AsyncIterator[AsyncHttpResponse[typing.AsyncIterator[bytes]]]: + """ + Returns the audio corresponding to a sample attached to a voice. + + Parameters + ---------- + voice_id : str + ID of the voice to be used. You can use the [Get voices](/docs/api-reference/voices/search) endpoint list all the available voices. + + sample_id : str + ID of the sample to be used. You can use the [Get voices](/docs/api-reference/voices/get) endpoint list all the available samples for a voice. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response. + + Returns + ------- + typing.AsyncIterator[AsyncHttpResponse[typing.AsyncIterator[bytes]]] + Successful Response + """ + async with self._client_wrapper.httpx_client.stream( + f"v1/voices/{jsonable_encoder(voice_id)}/samples/{jsonable_encoder(sample_id)}/audio", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) as _response: + + async def _stream() -> AsyncHttpResponse[typing.AsyncIterator[bytes]]: + try: + if 200 <= _response.status_code < 300: + _chunk_size = request_options.get("chunk_size", 1024) if request_options is not None else 1024 + return AsyncHttpResponse( + response=_response, + data=(_chunk async for _chunk in _response.aiter_bytes(chunk_size=_chunk_size)), + ) + await _response.aread() + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + yield await _stream() diff --git a/src/elevenlabs/voices/samples/client.py b/src/elevenlabs/voices/samples/client.py new file mode 100644 index 00000000..798f5c77 --- /dev/null +++ b/src/elevenlabs/voices/samples/client.py @@ -0,0 +1,39 @@ +# This file was auto-generated by Fern from our API Definition. + +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from .audio.client import AsyncAudioClient, AudioClient +from .raw_client import AsyncRawSamplesClient, RawSamplesClient + + +class SamplesClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._raw_client = RawSamplesClient(client_wrapper=client_wrapper) + self.audio = AudioClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawSamplesClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawSamplesClient + """ + return self._raw_client + + +class AsyncSamplesClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawSamplesClient(client_wrapper=client_wrapper) + self.audio = AsyncAudioClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawSamplesClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawSamplesClient + """ + return self._raw_client diff --git a/src/elevenlabs/voices/samples/raw_client.py b/src/elevenlabs/voices/samples/raw_client.py new file mode 100644 index 00000000..0e04d98f --- /dev/null +++ b/src/elevenlabs/voices/samples/raw_client.py @@ -0,0 +1,13 @@ +# This file was auto-generated by Fern from our API Definition. + +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper + + +class RawSamplesClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + +class AsyncRawSamplesClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper diff --git a/src/elevenlabs/voices/settings/__init__.py b/src/elevenlabs/voices/settings/__init__.py new file mode 100644 index 00000000..5cde0202 --- /dev/null +++ b/src/elevenlabs/voices/settings/__init__.py @@ -0,0 +1,4 @@ +# This file was auto-generated by Fern from our API Definition. + +# isort: skip_file + diff --git a/src/elevenlabs/voices/settings/client.py b/src/elevenlabs/voices/settings/client.py new file mode 100644 index 00000000..c347775a --- /dev/null +++ b/src/elevenlabs/voices/settings/client.py @@ -0,0 +1,266 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ...core.request_options import RequestOptions +from ...types.edit_voice_settings_response_model import EditVoiceSettingsResponseModel +from ...types.voice_settings import VoiceSettings +from .raw_client import AsyncRawSettingsClient, RawSettingsClient + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class SettingsClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._raw_client = RawSettingsClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawSettingsClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawSettingsClient + """ + return self._raw_client + + def get_default(self, *, request_options: typing.Optional[RequestOptions] = None) -> VoiceSettings: + """ + Gets the default settings for voices. "similarity_boost" corresponds to"Clarity + Similarity Enhancement" in the web app and "stability" corresponds to "Stability" slider in the web app. + + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + VoiceSettings + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.voices.settings.get_default() + """ + _response = self._raw_client.get_default(request_options=request_options) + return _response.data + + def get(self, voice_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> VoiceSettings: + """ + Returns the settings for a specific voice. "similarity_boost" corresponds to"Clarity + Similarity Enhancement" in the web app and "stability" corresponds to "Stability" slider in the web app. + + Parameters + ---------- + voice_id : str + Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + VoiceSettings + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.voices.settings.get( + voice_id="21m00Tcm4TlvDq8ikWAM", + ) + """ + _response = self._raw_client.get(voice_id, request_options=request_options) + return _response.data + + def update( + self, voice_id: str, *, request: VoiceSettings, request_options: typing.Optional[RequestOptions] = None + ) -> EditVoiceSettingsResponseModel: + """ + Edit your settings for a specific voice. "similarity_boost" corresponds to "Clarity + Similarity Enhancement" in the web app and "stability" corresponds to "Stability" slider in the web app. + + Parameters + ---------- + voice_id : str + ID of the voice to be used. You can use the [Get voices](/docs/api-reference/voices/search) endpoint list all the available voices. + + request : VoiceSettings + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + EditVoiceSettingsResponseModel + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs, VoiceSettings + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.voices.settings.update( + voice_id="21m00Tcm4TlvDq8ikWAM", + request=VoiceSettings( + stability=1.0, + similarity_boost=1.0, + style=0.0, + use_speaker_boost=True, + speed=1.0, + ), + ) + """ + _response = self._raw_client.update(voice_id, request=request, request_options=request_options) + return _response.data + + +class AsyncSettingsClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawSettingsClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawSettingsClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawSettingsClient + """ + return self._raw_client + + async def get_default(self, *, request_options: typing.Optional[RequestOptions] = None) -> VoiceSettings: + """ + Gets the default settings for voices. "similarity_boost" corresponds to"Clarity + Similarity Enhancement" in the web app and "stability" corresponds to "Stability" slider in the web app. + + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + VoiceSettings + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.voices.settings.get_default() + + + asyncio.run(main()) + """ + _response = await self._raw_client.get_default(request_options=request_options) + return _response.data + + async def get(self, voice_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> VoiceSettings: + """ + Returns the settings for a specific voice. "similarity_boost" corresponds to"Clarity + Similarity Enhancement" in the web app and "stability" corresponds to "Stability" slider in the web app. + + Parameters + ---------- + voice_id : str + Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + VoiceSettings + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.voices.settings.get( + voice_id="21m00Tcm4TlvDq8ikWAM", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.get(voice_id, request_options=request_options) + return _response.data + + async def update( + self, voice_id: str, *, request: VoiceSettings, request_options: typing.Optional[RequestOptions] = None + ) -> EditVoiceSettingsResponseModel: + """ + Edit your settings for a specific voice. "similarity_boost" corresponds to "Clarity + Similarity Enhancement" in the web app and "stability" corresponds to "Stability" slider in the web app. + + Parameters + ---------- + voice_id : str + ID of the voice to be used. You can use the [Get voices](/docs/api-reference/voices/search) endpoint list all the available voices. + + request : VoiceSettings + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + EditVoiceSettingsResponseModel + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs, VoiceSettings + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.voices.settings.update( + voice_id="21m00Tcm4TlvDq8ikWAM", + request=VoiceSettings( + stability=1.0, + similarity_boost=1.0, + style=0.0, + use_speaker_boost=True, + speed=1.0, + ), + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.update(voice_id, request=request, request_options=request_options) + return _response.data diff --git a/src/elevenlabs/voices/settings/raw_client.py b/src/elevenlabs/voices/settings/raw_client.py new file mode 100644 index 00000000..bd059855 --- /dev/null +++ b/src/elevenlabs/voices/settings/raw_client.py @@ -0,0 +1,319 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ...core.api_error import ApiError +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ...core.http_response import AsyncHttpResponse, HttpResponse +from ...core.jsonable_encoder import jsonable_encoder +from ...core.request_options import RequestOptions +from ...core.serialization import convert_and_respect_annotation_metadata +from ...core.unchecked_base_model import construct_type +from ...errors.unprocessable_entity_error import UnprocessableEntityError +from ...types.edit_voice_settings_response_model import EditVoiceSettingsResponseModel +from ...types.http_validation_error import HttpValidationError +from ...types.voice_settings import VoiceSettings + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RawSettingsClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def get_default(self, *, request_options: typing.Optional[RequestOptions] = None) -> HttpResponse[VoiceSettings]: + """ + Gets the default settings for voices. "similarity_boost" corresponds to"Clarity + Similarity Enhancement" in the web app and "stability" corresponds to "Stability" slider in the web app. + + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[VoiceSettings] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + "v1/voices/settings/default", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + VoiceSettings, + construct_type( + type_=VoiceSettings, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def get( + self, voice_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[VoiceSettings]: + """ + Returns the settings for a specific voice. "similarity_boost" corresponds to"Clarity + Similarity Enhancement" in the web app and "stability" corresponds to "Stability" slider in the web app. + + Parameters + ---------- + voice_id : str + Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[VoiceSettings] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/voices/{jsonable_encoder(voice_id)}/settings", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + VoiceSettings, + construct_type( + type_=VoiceSettings, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def update( + self, voice_id: str, *, request: VoiceSettings, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[EditVoiceSettingsResponseModel]: + """ + Edit your settings for a specific voice. "similarity_boost" corresponds to "Clarity + Similarity Enhancement" in the web app and "stability" corresponds to "Stability" slider in the web app. + + Parameters + ---------- + voice_id : str + ID of the voice to be used. You can use the [Get voices](/docs/api-reference/voices/search) endpoint list all the available voices. + + request : VoiceSettings + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[EditVoiceSettingsResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/voices/{jsonable_encoder(voice_id)}/settings/edit", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json=convert_and_respect_annotation_metadata(object_=request, annotation=VoiceSettings, direction="write"), + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + EditVoiceSettingsResponseModel, + construct_type( + type_=EditVoiceSettingsResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + +class AsyncRawSettingsClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def get_default( + self, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[VoiceSettings]: + """ + Gets the default settings for voices. "similarity_boost" corresponds to"Clarity + Similarity Enhancement" in the web app and "stability" corresponds to "Stability" slider in the web app. + + Parameters + ---------- + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[VoiceSettings] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + "v1/voices/settings/default", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + VoiceSettings, + construct_type( + type_=VoiceSettings, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def get( + self, voice_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[VoiceSettings]: + """ + Returns the settings for a specific voice. "similarity_boost" corresponds to"Clarity + Similarity Enhancement" in the web app and "stability" corresponds to "Stability" slider in the web app. + + Parameters + ---------- + voice_id : str + Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[VoiceSettings] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/voices/{jsonable_encoder(voice_id)}/settings", + base_url=self._client_wrapper.get_environment().base, + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + VoiceSettings, + construct_type( + type_=VoiceSettings, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def update( + self, voice_id: str, *, request: VoiceSettings, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[EditVoiceSettingsResponseModel]: + """ + Edit your settings for a specific voice. "similarity_boost" corresponds to "Clarity + Similarity Enhancement" in the web app and "stability" corresponds to "Stability" slider in the web app. + + Parameters + ---------- + voice_id : str + ID of the voice to be used. You can use the [Get voices](/docs/api-reference/voices/search) endpoint list all the available voices. + + request : VoiceSettings + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[EditVoiceSettingsResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/voices/{jsonable_encoder(voice_id)}/settings/edit", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json=convert_and_respect_annotation_metadata(object_=request, annotation=VoiceSettings, direction="write"), + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + EditVoiceSettingsResponseModel, + construct_type( + type_=EditVoiceSettingsResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/elevenlabs/voices/types/__init__.py b/src/elevenlabs/voices/types/__init__.py index d3930f61..e72fd130 100644 --- a/src/elevenlabs/voices/types/__init__.py +++ b/src/elevenlabs/voices/types/__init__.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# isort: skip_file + from .voices_get_shared_request_category import VoicesGetSharedRequestCategory __all__ = ["VoicesGetSharedRequestCategory"] diff --git a/src/elevenlabs/webhooks.py b/src/elevenlabs/webhooks.py deleted file mode 100644 index dcc707c0..00000000 --- a/src/elevenlabs/webhooks.py +++ /dev/null @@ -1,70 +0,0 @@ -import json -import hmac -import hashlib -import time -from typing import Any, Dict -from .errors import BadRequestError - - -class WebhooksClient: - """ - A client to handle ElevenLabs webhook-related functionality - """ - - def construct_event(self, rawBody: str, sig_header: str, secret: str) -> Dict: - """ - Constructs a webhook event object from a payload and signature. - Verifies the webhook signature to ensure the event came from ElevenLabs. - - Args: - rawBody: The webhook request body. Must be the raw body, not a JSON object - sig_header: The signature header from the request - secret: Your webhook secret - - Returns: - The verified webhook event - - Raises: - BadRequestError: If the signature is invalid or missing - """ - - if not sig_header: - raise BadRequestError(body="Missing signature header") - - if not secret: - raise BadRequestError(body="Webhook secret not configured") - - headers = sig_header.split(',') - timestamp = None - signature = None - - for header in headers: - if header.startswith('t='): - timestamp = header[2:] - elif header.startswith('v0='): - signature = header - - if not timestamp or not signature: - raise BadRequestError(body="No signature hash found with expected scheme v0") - - # Validate timestamp - req_timestamp = int(timestamp) * 1000 - tolerance = int(time.time() * 1000) - 30 * 60 * 1000 - if req_timestamp < tolerance: - raise BadRequestError(body="Timestamp outside the tolerance zone") - - # Validate hash - message = f"{timestamp}.{rawBody}" - - digest = "v0=" + hmac.new( - secret.encode('utf-8'), - message.encode('utf-8'), - hashlib.sha256 - ).hexdigest() - - if signature != digest: - raise BadRequestError( - body="Signature hash does not match the expected signature hash for payload" - ) - - return json.loads(rawBody) diff --git a/src/elevenlabs/workspace/__init__.py b/src/elevenlabs/workspace/__init__.py index 51dde111..1a8f0b67 100644 --- a/src/elevenlabs/workspace/__init__.py +++ b/src/elevenlabs/workspace/__init__.py @@ -1,13 +1,18 @@ # This file was auto-generated by Fern from our API Definition. -from .types import ( - BodyInviteUserV1WorkspaceInvitesAddPostWorkspacePermission, - BodyShareWorkspaceResourceV1WorkspaceResourcesResourceIdSharePostRole, - BodyUpdateMemberV1WorkspaceMembersPostWorkspaceRole, -) +# isort: skip_file + +from .resources import BodyShareWorkspaceResourceV1WorkspaceResourcesResourceIdSharePostRole +from . import groups, invites, members, resources +from .invites import BodyInviteUserV1WorkspaceInvitesAddPostWorkspacePermission +from .members import BodyUpdateMemberV1WorkspaceMembersPostWorkspaceRole __all__ = [ "BodyInviteUserV1WorkspaceInvitesAddPostWorkspacePermission", "BodyShareWorkspaceResourceV1WorkspaceResourcesResourceIdSharePostRole", "BodyUpdateMemberV1WorkspaceMembersPostWorkspaceRole", + "groups", + "invites", + "members", + "resources", ] diff --git a/src/elevenlabs/workspace/client.py b/src/elevenlabs/workspace/client.py index 3f286fe9..e896af3c 100644 --- a/src/elevenlabs/workspace/client.py +++ b/src/elevenlabs/workspace/client.py @@ -1,1821 +1,54 @@ # This file was auto-generated by Fern from our API Definition. -import typing -from ..core.client_wrapper import SyncClientWrapper -from ..core.request_options import RequestOptions -from ..types.workspace_group_by_name_response_model import ( - WorkspaceGroupByNameResponseModel, -) -from ..core.unchecked_base_model import construct_type -from ..errors.unprocessable_entity_error import UnprocessableEntityError -from ..types.http_validation_error import HttpValidationError -from json.decoder import JSONDecodeError -from ..core.api_error import ApiError -from ..types.delete_workspace_group_member_response_model import ( - DeleteWorkspaceGroupMemberResponseModel, -) -from ..core.jsonable_encoder import jsonable_encoder -from ..types.add_workspace_group_member_response_model import ( - AddWorkspaceGroupMemberResponseModel, -) -from .types.body_invite_user_v_1_workspace_invites_add_post_workspace_permission import ( - BodyInviteUserV1WorkspaceInvitesAddPostWorkspacePermission, -) -from ..types.add_workspace_invite_response_model import AddWorkspaceInviteResponseModel -from ..types.delete_workspace_invite_response_model import ( - DeleteWorkspaceInviteResponseModel, -) -from .types.body_update_member_v_1_workspace_members_post_workspace_role import ( - BodyUpdateMemberV1WorkspaceMembersPostWorkspaceRole, -) -from ..types.update_workspace_member_response_model import ( - UpdateWorkspaceMemberResponseModel, -) -from ..types.delete_workspace_member_response_model import ( - DeleteWorkspaceMemberResponseModel, -) -from ..types.workspace_resource_type import WorkspaceResourceType -from ..types.resource_metadata_response_model import ResourceMetadataResponseModel -from .types.body_share_workspace_resource_v_1_workspace_resources_resource_id_share_post_role import ( - BodyShareWorkspaceResourceV1WorkspaceResourcesResourceIdSharePostRole, -) -from ..core.client_wrapper import AsyncClientWrapper - -# this is used as the default value for optional parameters -OMIT = typing.cast(typing.Any, ...) +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from .groups.client import AsyncGroupsClient, GroupsClient +from .invites.client import AsyncInvitesClient, InvitesClient +from .members.client import AsyncMembersClient, MembersClient +from .raw_client import AsyncRawWorkspaceClient, RawWorkspaceClient +from .resources.client import AsyncResourcesClient, ResourcesClient class WorkspaceClient: def __init__(self, *, client_wrapper: SyncClientWrapper): - self._client_wrapper = client_wrapper - - def search_user_groups( - self, *, name: str, request_options: typing.Optional[RequestOptions] = None - ) -> typing.List[WorkspaceGroupByNameResponseModel]: - """ - Searches for user groups in the workspace. Multiple or no groups may be returned. - - Parameters - ---------- - name : str - Name of the target group. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - typing.List[WorkspaceGroupByNameResponseModel] - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.workspace.search_user_groups( - name="name", - ) - """ - _response = self._client_wrapper.httpx_client.request( - "v1/workspace/groups/search", - base_url=self._client_wrapper.get_environment().base, - method="GET", - params={ - "name": name, - }, - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - typing.List[WorkspaceGroupByNameResponseModel], - construct_type( - type_=typing.List[WorkspaceGroupByNameResponseModel], # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def delete_member_from_user_group( - self, - group_id: str, - *, - email: str, - request_options: typing.Optional[RequestOptions] = None, - ) -> DeleteWorkspaceGroupMemberResponseModel: - """ - Removes a member from the specified group. This endpoint may only be called by workspace administrators. - - Parameters - ---------- - group_id : str - The ID of the target group. - - email : str - The email of the target workspace member. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - DeleteWorkspaceGroupMemberResponseModel - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.workspace.delete_member_from_user_group( - group_id="group_id", - email="email", - ) - """ - _response = self._client_wrapper.httpx_client.request( - f"v1/workspace/groups/{jsonable_encoder(group_id)}/members/remove", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "email": email, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - DeleteWorkspaceGroupMemberResponseModel, - construct_type( - type_=DeleteWorkspaceGroupMemberResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def add_member_to_user_group( - self, - group_id: str, - *, - email: str, - request_options: typing.Optional[RequestOptions] = None, - ) -> AddWorkspaceGroupMemberResponseModel: - """ - Adds a member of your workspace to the specified group. This endpoint may only be called by workspace administrators. - - Parameters - ---------- - group_id : str - The ID of the target group. - - email : str - The email of the target workspace member. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - AddWorkspaceGroupMemberResponseModel - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.workspace.add_member_to_user_group( - group_id="group_id", - email="email", - ) - """ - _response = self._client_wrapper.httpx_client.request( - f"v1/workspace/groups/{jsonable_encoder(group_id)}/members", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "email": email, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - AddWorkspaceGroupMemberResponseModel, - construct_type( - type_=AddWorkspaceGroupMemberResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def invite_user( - self, - *, - email: str, - group_ids: typing.Optional[typing.Sequence[str]] = OMIT, - workspace_permission: typing.Optional[BodyInviteUserV1WorkspaceInvitesAddPostWorkspacePermission] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> AddWorkspaceInviteResponseModel: - """ - Sends an email invitation to join your workspace to the provided email. If the user doesn't have an account they will be prompted to create one. If the user accepts this invite they will be added as a user to your workspace and your subscription using one of your seats. This endpoint may only be called by workspace administrators. If the user is already in the workspace a 400 error will be returned. - - Parameters - ---------- - email : str - The email of the customer - - group_ids : typing.Optional[typing.Sequence[str]] - The group ids of the user - - workspace_permission : typing.Optional[BodyInviteUserV1WorkspaceInvitesAddPostWorkspacePermission] - The workspace permission of the user - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - AddWorkspaceInviteResponseModel - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.workspace.invite_user( - email="john.doe@testmail.com", - ) - """ - _response = self._client_wrapper.httpx_client.request( - "v1/workspace/invites/add", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "email": email, - "group_ids": group_ids, - "workspace_permission": workspace_permission, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - AddWorkspaceInviteResponseModel, - construct_type( - type_=AddWorkspaceInviteResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def invite_multiple_users( - self, - *, - emails: typing.Sequence[str], - group_ids: typing.Optional[typing.Sequence[str]] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> AddWorkspaceInviteResponseModel: - """ - Sends email invitations to join your workspace to the provided emails. Requires all email addresses to be part of a verified domain. If the users don't have an account they will be prompted to create one. If the users accept these invites they will be added as users to your workspace and your subscription using one of your seats. This endpoint may only be called by workspace administrators. - - Parameters - ---------- - emails : typing.Sequence[str] - The email of the customer - - group_ids : typing.Optional[typing.Sequence[str]] - The group ids of the user - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - AddWorkspaceInviteResponseModel - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.workspace.invite_multiple_users( - emails=["emails"], - ) - """ - _response = self._client_wrapper.httpx_client.request( - "v1/workspace/invites/add-bulk", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "emails": emails, - "group_ids": group_ids, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - AddWorkspaceInviteResponseModel, - construct_type( - type_=AddWorkspaceInviteResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def delete_existing_invitation( - self, *, email: str, request_options: typing.Optional[RequestOptions] = None - ) -> DeleteWorkspaceInviteResponseModel: - """ - Invalidates an existing email invitation. The invitation will still show up in the inbox it has been delivered to, but activating it to join the workspace won't work. This endpoint may only be called by workspace administrators. - - Parameters - ---------- - email : str - The email of the customer - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - DeleteWorkspaceInviteResponseModel - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.workspace.delete_existing_invitation( - email="john.doe@testmail.com", - ) - """ - _response = self._client_wrapper.httpx_client.request( - "v1/workspace/invites", - base_url=self._client_wrapper.get_environment().base, - method="DELETE", - json={ - "email": email, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - DeleteWorkspaceInviteResponseModel, - construct_type( - type_=DeleteWorkspaceInviteResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def update_member( - self, - *, - email: str, - is_locked: typing.Optional[bool] = OMIT, - workspace_role: typing.Optional[BodyUpdateMemberV1WorkspaceMembersPostWorkspaceRole] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> UpdateWorkspaceMemberResponseModel: - """ - Updates attributes of a workspace member. Apart from the email identifier, all parameters will remain unchanged unless specified. This endpoint may only be called by workspace administrators. - - Parameters - ---------- - email : str - Email of the target user. - - is_locked : typing.Optional[bool] - Whether to lock or unlock the user account. - - workspace_role : typing.Optional[BodyUpdateMemberV1WorkspaceMembersPostWorkspaceRole] - Role dictating permissions in the workspace. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - UpdateWorkspaceMemberResponseModel - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.workspace.update_member( - email="email", - ) - """ - _response = self._client_wrapper.httpx_client.request( - "v1/workspace/members", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "email": email, - "is_locked": is_locked, - "workspace_role": workspace_role, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - UpdateWorkspaceMemberResponseModel, - construct_type( - type_=UpdateWorkspaceMemberResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + self._raw_client = RawWorkspaceClient(client_wrapper=client_wrapper) + self.groups = GroupsClient(client_wrapper=client_wrapper) - def delete_member( - self, *, email: str, request_options: typing.Optional[RequestOptions] = None - ) -> DeleteWorkspaceMemberResponseModel: - """ - Deletes a workspace member. This endpoint may only be called by workspace administrators. - - Parameters - ---------- - email : str - Email of the target user. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. + self.invites = InvitesClient(client_wrapper=client_wrapper) - Returns - ------- - DeleteWorkspaceMemberResponseModel - Successful Response + self.members = MembersClient(client_wrapper=client_wrapper) - Examples - -------- - from elevenlabs import ElevenLabs + self.resources = ResourcesClient(client_wrapper=client_wrapper) - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.workspace.delete_member( - email="email", - ) + @property + def with_raw_response(self) -> RawWorkspaceClient: """ - _response = self._client_wrapper.httpx_client.request( - "v1/workspace/members", - base_url=self._client_wrapper.get_environment().base, - method="DELETE", - json={ - "email": email, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - DeleteWorkspaceMemberResponseModel, - construct_type( - type_=DeleteWorkspaceMemberResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def get_resource( - self, - resource_id: str, - *, - resource_type: WorkspaceResourceType, - request_options: typing.Optional[RequestOptions] = None, - ) -> ResourceMetadataResponseModel: - """ - Gets the metadata of a resource by ID. - - Parameters - ---------- - resource_id : str - The ID of the target resource. - - resource_type : WorkspaceResourceType - Resource type of the target resource. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. + Retrieves a raw implementation of this client that returns raw responses. Returns ------- - ResourceMetadataResponseModel - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.workspace.get_resource( - resource_id="resource_id", - resource_type="voice", - ) - """ - _response = self._client_wrapper.httpx_client.request( - f"v1/workspace/resources/{jsonable_encoder(resource_id)}", - base_url=self._client_wrapper.get_environment().base, - method="GET", - params={ - "resource_type": resource_type, - }, - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ResourceMetadataResponseModel, - construct_type( - type_=ResourceMetadataResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def share_workspace_resource( - self, - resource_id: str, - *, - role: BodyShareWorkspaceResourceV1WorkspaceResourcesResourceIdSharePostRole, - resource_type: WorkspaceResourceType, - user_email: typing.Optional[str] = OMIT, - group_id: typing.Optional[str] = OMIT, - workspace_api_key_id: typing.Optional[str] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> typing.Optional[typing.Any]: + RawWorkspaceClient """ - Grants a role on a workspace resource to a user or a group. It overrides any existing role this user/service account/group/workspace api key has on the resource. To target a user or service account, pass only the user email. The user must be in your workspace. To target a group, pass only the group id. To target a workspace api key, pass the api key id. The resource will be shared with the service account associated with the api key. You must have admin access to the resource to share it. - - Parameters - ---------- - resource_id : str - The ID of the target resource. - - role : BodyShareWorkspaceResourceV1WorkspaceResourcesResourceIdSharePostRole - Role to update the target principal with. - - resource_type : WorkspaceResourceType - Resource type of the target resource. - - user_email : typing.Optional[str] - The email of the user or service account. - - group_id : typing.Optional[str] - The ID of the target group. To target the permissions principals have by default on this resource, use the value 'default'. - - workspace_api_key_id : typing.Optional[str] - The ID of the target workspace API key. This isn't the same as the key itself that would you pass in the header for authentication. Workspace admins can find this in the workspace settings UI. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - typing.Optional[typing.Any] - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.workspace.share_workspace_resource( - resource_id="resource_id", - role="admin", - resource_type="voice", - ) - """ - _response = self._client_wrapper.httpx_client.request( - f"v1/workspace/resources/{jsonable_encoder(resource_id)}/share", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "role": role, - "resource_type": resource_type, - "user_email": user_email, - "group_id": group_id, - "workspace_api_key_id": workspace_api_key_id, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - def unshare_workspace_resource( - self, - resource_id: str, - *, - resource_type: WorkspaceResourceType, - user_email: typing.Optional[str] = OMIT, - group_id: typing.Optional[str] = OMIT, - workspace_api_key_id: typing.Optional[str] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> typing.Optional[typing.Any]: - """ - Removes any existing role on a workspace resource from a user, service account, group or workspace api key. To target a user or service account, pass only the user email. The user must be in your workspace. To target a group, pass only the group id. To target a workspace api key, pass the api key id. The resource will be unshared from the service account associated with the api key. You must have admin access to the resource to unshare it. You cannot remove permissions from the user who created the resource. - - Parameters - ---------- - resource_id : str - The ID of the target resource. - - resource_type : WorkspaceResourceType - Resource type of the target resource. - - user_email : typing.Optional[str] - The email of the user or service account. - - group_id : typing.Optional[str] - The ID of the target group. To target the permissions principals have by default on this resource, use the value 'default'. - - workspace_api_key_id : typing.Optional[str] - The ID of the target workspace API key. This isn't the same as the key itself that would you pass in the header for authentication. Workspace admins can find this in the workspace settings UI. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - typing.Optional[typing.Any] - Successful Response - - Examples - -------- - from elevenlabs import ElevenLabs - - client = ElevenLabs( - api_key="YOUR_API_KEY", - ) - client.workspace.unshare_workspace_resource( - resource_id="resource_id", - resource_type="voice", - ) - """ - _response = self._client_wrapper.httpx_client.request( - f"v1/workspace/resources/{jsonable_encoder(resource_id)}/unshare", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "resource_type": resource_type, - "user_email": user_email, - "group_id": group_id, - "workspace_api_key_id": workspace_api_key_id, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + return self._raw_client class AsyncWorkspaceClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): - self._client_wrapper = client_wrapper - - async def search_user_groups( - self, *, name: str, request_options: typing.Optional[RequestOptions] = None - ) -> typing.List[WorkspaceGroupByNameResponseModel]: - """ - Searches for user groups in the workspace. Multiple or no groups may be returned. - - Parameters - ---------- - name : str - Name of the target group. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - typing.List[WorkspaceGroupByNameResponseModel] - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.workspace.search_user_groups( - name="name", - ) - - - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - "v1/workspace/groups/search", - base_url=self._client_wrapper.get_environment().base, - method="GET", - params={ - "name": name, - }, - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - typing.List[WorkspaceGroupByNameResponseModel], - construct_type( - type_=typing.List[WorkspaceGroupByNameResponseModel], # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def delete_member_from_user_group( - self, - group_id: str, - *, - email: str, - request_options: typing.Optional[RequestOptions] = None, - ) -> DeleteWorkspaceGroupMemberResponseModel: - """ - Removes a member from the specified group. This endpoint may only be called by workspace administrators. - - Parameters - ---------- - group_id : str - The ID of the target group. - - email : str - The email of the target workspace member. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - DeleteWorkspaceGroupMemberResponseModel - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - + self._raw_client = AsyncRawWorkspaceClient(client_wrapper=client_wrapper) + self.groups = AsyncGroupsClient(client_wrapper=client_wrapper) - async def main() -> None: - await client.workspace.delete_member_from_user_group( - group_id="group_id", - email="email", - ) + self.invites = AsyncInvitesClient(client_wrapper=client_wrapper) + self.members = AsyncMembersClient(client_wrapper=client_wrapper) - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/workspace/groups/{jsonable_encoder(group_id)}/members/remove", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "email": email, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - DeleteWorkspaceGroupMemberResponseModel, - construct_type( - type_=DeleteWorkspaceGroupMemberResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def add_member_to_user_group( - self, - group_id: str, - *, - email: str, - request_options: typing.Optional[RequestOptions] = None, - ) -> AddWorkspaceGroupMemberResponseModel: - """ - Adds a member of your workspace to the specified group. This endpoint may only be called by workspace administrators. - - Parameters - ---------- - group_id : str - The ID of the target group. - - email : str - The email of the target workspace member. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - AddWorkspaceGroupMemberResponseModel - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.workspace.add_member_to_user_group( - group_id="group_id", - email="email", - ) - - - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/workspace/groups/{jsonable_encoder(group_id)}/members", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "email": email, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - AddWorkspaceGroupMemberResponseModel, - construct_type( - type_=AddWorkspaceGroupMemberResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def invite_user( - self, - *, - email: str, - group_ids: typing.Optional[typing.Sequence[str]] = OMIT, - workspace_permission: typing.Optional[BodyInviteUserV1WorkspaceInvitesAddPostWorkspacePermission] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> AddWorkspaceInviteResponseModel: - """ - Sends an email invitation to join your workspace to the provided email. If the user doesn't have an account they will be prompted to create one. If the user accepts this invite they will be added as a user to your workspace and your subscription using one of your seats. This endpoint may only be called by workspace administrators. If the user is already in the workspace a 400 error will be returned. - - Parameters - ---------- - email : str - The email of the customer - - group_ids : typing.Optional[typing.Sequence[str]] - The group ids of the user - - workspace_permission : typing.Optional[BodyInviteUserV1WorkspaceInvitesAddPostWorkspacePermission] - The workspace permission of the user - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - AddWorkspaceInviteResponseModel - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.workspace.invite_user( - email="john.doe@testmail.com", - ) - - - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - "v1/workspace/invites/add", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "email": email, - "group_ids": group_ids, - "workspace_permission": workspace_permission, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - AddWorkspaceInviteResponseModel, - construct_type( - type_=AddWorkspaceInviteResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def invite_multiple_users( - self, - *, - emails: typing.Sequence[str], - group_ids: typing.Optional[typing.Sequence[str]] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> AddWorkspaceInviteResponseModel: - """ - Sends email invitations to join your workspace to the provided emails. Requires all email addresses to be part of a verified domain. If the users don't have an account they will be prompted to create one. If the users accept these invites they will be added as users to your workspace and your subscription using one of your seats. This endpoint may only be called by workspace administrators. - - Parameters - ---------- - emails : typing.Sequence[str] - The email of the customer - - group_ids : typing.Optional[typing.Sequence[str]] - The group ids of the user - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - AddWorkspaceInviteResponseModel - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.workspace.invite_multiple_users( - emails=["emails"], - ) - - - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - "v1/workspace/invites/add-bulk", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "emails": emails, - "group_ids": group_ids, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - AddWorkspaceInviteResponseModel, - construct_type( - type_=AddWorkspaceInviteResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def delete_existing_invitation( - self, *, email: str, request_options: typing.Optional[RequestOptions] = None - ) -> DeleteWorkspaceInviteResponseModel: - """ - Invalidates an existing email invitation. The invitation will still show up in the inbox it has been delivered to, but activating it to join the workspace won't work. This endpoint may only be called by workspace administrators. - - Parameters - ---------- - email : str - The email of the customer - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - DeleteWorkspaceInviteResponseModel - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.workspace.delete_existing_invitation( - email="john.doe@testmail.com", - ) - - - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - "v1/workspace/invites", - base_url=self._client_wrapper.get_environment().base, - method="DELETE", - json={ - "email": email, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - DeleteWorkspaceInviteResponseModel, - construct_type( - type_=DeleteWorkspaceInviteResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def update_member( - self, - *, - email: str, - is_locked: typing.Optional[bool] = OMIT, - workspace_role: typing.Optional[BodyUpdateMemberV1WorkspaceMembersPostWorkspaceRole] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> UpdateWorkspaceMemberResponseModel: - """ - Updates attributes of a workspace member. Apart from the email identifier, all parameters will remain unchanged unless specified. This endpoint may only be called by workspace administrators. - - Parameters - ---------- - email : str - Email of the target user. - - is_locked : typing.Optional[bool] - Whether to lock or unlock the user account. - - workspace_role : typing.Optional[BodyUpdateMemberV1WorkspaceMembersPostWorkspaceRole] - Role dictating permissions in the workspace. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - UpdateWorkspaceMemberResponseModel - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - + self.resources = AsyncResourcesClient(client_wrapper=client_wrapper) - async def main() -> None: - await client.workspace.update_member( - email="email", - ) - - - asyncio.run(main()) + @property + def with_raw_response(self) -> AsyncRawWorkspaceClient: """ - _response = await self._client_wrapper.httpx_client.request( - "v1/workspace/members", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "email": email, - "is_locked": is_locked, - "workspace_role": workspace_role, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - UpdateWorkspaceMemberResponseModel, - construct_type( - type_=UpdateWorkspaceMemberResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def delete_member( - self, *, email: str, request_options: typing.Optional[RequestOptions] = None - ) -> DeleteWorkspaceMemberResponseModel: - """ - Deletes a workspace member. This endpoint may only be called by workspace administrators. - - Parameters - ---------- - email : str - Email of the target user. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. + Retrieves a raw implementation of this client that returns raw responses. Returns ------- - DeleteWorkspaceMemberResponseModel - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.workspace.delete_member( - email="email", - ) - - - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - "v1/workspace/members", - base_url=self._client_wrapper.get_environment().base, - method="DELETE", - json={ - "email": email, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - DeleteWorkspaceMemberResponseModel, - construct_type( - type_=DeleteWorkspaceMemberResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def get_resource( - self, - resource_id: str, - *, - resource_type: WorkspaceResourceType, - request_options: typing.Optional[RequestOptions] = None, - ) -> ResourceMetadataResponseModel: - """ - Gets the metadata of a resource by ID. - - Parameters - ---------- - resource_id : str - The ID of the target resource. - - resource_type : WorkspaceResourceType - Resource type of the target resource. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - ResourceMetadataResponseModel - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.workspace.get_resource( - resource_id="resource_id", - resource_type="voice", - ) - - - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/workspace/resources/{jsonable_encoder(resource_id)}", - base_url=self._client_wrapper.get_environment().base, - method="GET", - params={ - "resource_type": resource_type, - }, - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - ResourceMetadataResponseModel, - construct_type( - type_=ResourceMetadataResponseModel, # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def share_workspace_resource( - self, - resource_id: str, - *, - role: BodyShareWorkspaceResourceV1WorkspaceResourcesResourceIdSharePostRole, - resource_type: WorkspaceResourceType, - user_email: typing.Optional[str] = OMIT, - group_id: typing.Optional[str] = OMIT, - workspace_api_key_id: typing.Optional[str] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> typing.Optional[typing.Any]: - """ - Grants a role on a workspace resource to a user or a group. It overrides any existing role this user/service account/group/workspace api key has on the resource. To target a user or service account, pass only the user email. The user must be in your workspace. To target a group, pass only the group id. To target a workspace api key, pass the api key id. The resource will be shared with the service account associated with the api key. You must have admin access to the resource to share it. - - Parameters - ---------- - resource_id : str - The ID of the target resource. - - role : BodyShareWorkspaceResourceV1WorkspaceResourcesResourceIdSharePostRole - Role to update the target principal with. - - resource_type : WorkspaceResourceType - Resource type of the target resource. - - user_email : typing.Optional[str] - The email of the user or service account. - - group_id : typing.Optional[str] - The ID of the target group. To target the permissions principals have by default on this resource, use the value 'default'. - - workspace_api_key_id : typing.Optional[str] - The ID of the target workspace API key. This isn't the same as the key itself that would you pass in the header for authentication. Workspace admins can find this in the workspace settings UI. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - typing.Optional[typing.Any] - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.workspace.share_workspace_resource( - resource_id="resource_id", - role="admin", - resource_type="voice", - ) - - - asyncio.run(main()) - """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/workspace/resources/{jsonable_encoder(resource_id)}/share", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "role": role, - "resource_type": resource_type, - "user_email": user_email, - "group_id": group_id, - "workspace_api_key_id": workspace_api_key_id, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) - - async def unshare_workspace_resource( - self, - resource_id: str, - *, - resource_type: WorkspaceResourceType, - user_email: typing.Optional[str] = OMIT, - group_id: typing.Optional[str] = OMIT, - workspace_api_key_id: typing.Optional[str] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> typing.Optional[typing.Any]: - """ - Removes any existing role on a workspace resource from a user, service account, group or workspace api key. To target a user or service account, pass only the user email. The user must be in your workspace. To target a group, pass only the group id. To target a workspace api key, pass the api key id. The resource will be unshared from the service account associated with the api key. You must have admin access to the resource to unshare it. You cannot remove permissions from the user who created the resource. - - Parameters - ---------- - resource_id : str - The ID of the target resource. - - resource_type : WorkspaceResourceType - Resource type of the target resource. - - user_email : typing.Optional[str] - The email of the user or service account. - - group_id : typing.Optional[str] - The ID of the target group. To target the permissions principals have by default on this resource, use the value 'default'. - - workspace_api_key_id : typing.Optional[str] - The ID of the target workspace API key. This isn't the same as the key itself that would you pass in the header for authentication. Workspace admins can find this in the workspace settings UI. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - typing.Optional[typing.Any] - Successful Response - - Examples - -------- - import asyncio - - from elevenlabs import AsyncElevenLabs - - client = AsyncElevenLabs( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.workspace.unshare_workspace_resource( - resource_id="resource_id", - resource_type="voice", - ) - - - asyncio.run(main()) + AsyncRawWorkspaceClient """ - _response = await self._client_wrapper.httpx_client.request( - f"v1/workspace/resources/{jsonable_encoder(resource_id)}/unshare", - base_url=self._client_wrapper.get_environment().base, - method="POST", - json={ - "resource_type": resource_type, - "user_email": user_email, - "group_id": group_id, - "workspace_api_key_id": workspace_api_key_id, - }, - headers={ - "content-type": "application/json", - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - typing.Optional[typing.Any], - construct_type( - type_=typing.Optional[typing.Any], # type: ignore - object_=_response.json(), - ), - ) - if _response.status_code == 422: - raise UnprocessableEntityError( - typing.cast( - HttpValidationError, - construct_type( - type_=HttpValidationError, # type: ignore - object_=_response.json(), - ), - ) - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError(status_code=_response.status_code, body=_response.text) - raise ApiError(status_code=_response.status_code, body=_response_json) + return self._raw_client diff --git a/src/elevenlabs/workspace/groups/__init__.py b/src/elevenlabs/workspace/groups/__init__.py new file mode 100644 index 00000000..7505a46b --- /dev/null +++ b/src/elevenlabs/workspace/groups/__init__.py @@ -0,0 +1,7 @@ +# This file was auto-generated by Fern from our API Definition. + +# isort: skip_file + +from . import members + +__all__ = ["members"] diff --git a/src/elevenlabs/workspace/groups/client.py b/src/elevenlabs/workspace/groups/client.py new file mode 100644 index 00000000..7840e944 --- /dev/null +++ b/src/elevenlabs/workspace/groups/client.py @@ -0,0 +1,117 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ...core.request_options import RequestOptions +from ...types.workspace_group_by_name_response_model import WorkspaceGroupByNameResponseModel +from .members.client import AsyncMembersClient, MembersClient +from .raw_client import AsyncRawGroupsClient, RawGroupsClient + + +class GroupsClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._raw_client = RawGroupsClient(client_wrapper=client_wrapper) + self.members = MembersClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawGroupsClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawGroupsClient + """ + return self._raw_client + + def search( + self, *, name: str, request_options: typing.Optional[RequestOptions] = None + ) -> typing.List[WorkspaceGroupByNameResponseModel]: + """ + Searches for user groups in the workspace. Multiple or no groups may be returned. + + Parameters + ---------- + name : str + Name of the target group. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + typing.List[WorkspaceGroupByNameResponseModel] + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.workspace.groups.search( + name="name", + ) + """ + _response = self._raw_client.search(name=name, request_options=request_options) + return _response.data + + +class AsyncGroupsClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawGroupsClient(client_wrapper=client_wrapper) + self.members = AsyncMembersClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawGroupsClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawGroupsClient + """ + return self._raw_client + + async def search( + self, *, name: str, request_options: typing.Optional[RequestOptions] = None + ) -> typing.List[WorkspaceGroupByNameResponseModel]: + """ + Searches for user groups in the workspace. Multiple or no groups may be returned. + + Parameters + ---------- + name : str + Name of the target group. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + typing.List[WorkspaceGroupByNameResponseModel] + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.workspace.groups.search( + name="name", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.search(name=name, request_options=request_options) + return _response.data diff --git a/src/elevenlabs/workspace/groups/members/__init__.py b/src/elevenlabs/workspace/groups/members/__init__.py new file mode 100644 index 00000000..5cde0202 --- /dev/null +++ b/src/elevenlabs/workspace/groups/members/__init__.py @@ -0,0 +1,4 @@ +# This file was auto-generated by Fern from our API Definition. + +# isort: skip_file + diff --git a/src/elevenlabs/workspace/groups/members/client.py b/src/elevenlabs/workspace/groups/members/client.py new file mode 100644 index 00000000..0adaa491 --- /dev/null +++ b/src/elevenlabs/workspace/groups/members/client.py @@ -0,0 +1,208 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +from ....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ....core.request_options import RequestOptions +from ....types.add_workspace_group_member_response_model import AddWorkspaceGroupMemberResponseModel +from ....types.delete_workspace_group_member_response_model import DeleteWorkspaceGroupMemberResponseModel +from .raw_client import AsyncRawMembersClient, RawMembersClient + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class MembersClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._raw_client = RawMembersClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawMembersClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawMembersClient + """ + return self._raw_client + + def remove( + self, group_id: str, *, email: str, request_options: typing.Optional[RequestOptions] = None + ) -> DeleteWorkspaceGroupMemberResponseModel: + """ + Removes a member from the specified group. This endpoint may only be called by workspace administrators. + + Parameters + ---------- + group_id : str + The ID of the target group. + + email : str + The email of the target workspace member. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + DeleteWorkspaceGroupMemberResponseModel + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.workspace.groups.members.remove( + group_id="group_id", + email="email", + ) + """ + _response = self._raw_client.remove(group_id, email=email, request_options=request_options) + return _response.data + + def add( + self, group_id: str, *, email: str, request_options: typing.Optional[RequestOptions] = None + ) -> AddWorkspaceGroupMemberResponseModel: + """ + Adds a member of your workspace to the specified group. This endpoint may only be called by workspace administrators. + + Parameters + ---------- + group_id : str + The ID of the target group. + + email : str + The email of the target workspace member. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AddWorkspaceGroupMemberResponseModel + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.workspace.groups.members.add( + group_id="group_id", + email="email", + ) + """ + _response = self._raw_client.add(group_id, email=email, request_options=request_options) + return _response.data + + +class AsyncMembersClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawMembersClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawMembersClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawMembersClient + """ + return self._raw_client + + async def remove( + self, group_id: str, *, email: str, request_options: typing.Optional[RequestOptions] = None + ) -> DeleteWorkspaceGroupMemberResponseModel: + """ + Removes a member from the specified group. This endpoint may only be called by workspace administrators. + + Parameters + ---------- + group_id : str + The ID of the target group. + + email : str + The email of the target workspace member. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + DeleteWorkspaceGroupMemberResponseModel + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.workspace.groups.members.remove( + group_id="group_id", + email="email", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.remove(group_id, email=email, request_options=request_options) + return _response.data + + async def add( + self, group_id: str, *, email: str, request_options: typing.Optional[RequestOptions] = None + ) -> AddWorkspaceGroupMemberResponseModel: + """ + Adds a member of your workspace to the specified group. This endpoint may only be called by workspace administrators. + + Parameters + ---------- + group_id : str + The ID of the target group. + + email : str + The email of the target workspace member. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AddWorkspaceGroupMemberResponseModel + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.workspace.groups.members.add( + group_id="group_id", + email="email", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.add(group_id, email=email, request_options=request_options) + return _response.data diff --git a/src/elevenlabs/workspace/groups/members/raw_client.py b/src/elevenlabs/workspace/groups/members/raw_client.py new file mode 100644 index 00000000..36a4a70f --- /dev/null +++ b/src/elevenlabs/workspace/groups/members/raw_client.py @@ -0,0 +1,272 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ....core.api_error import ApiError +from ....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ....core.http_response import AsyncHttpResponse, HttpResponse +from ....core.jsonable_encoder import jsonable_encoder +from ....core.request_options import RequestOptions +from ....core.unchecked_base_model import construct_type +from ....errors.unprocessable_entity_error import UnprocessableEntityError +from ....types.add_workspace_group_member_response_model import AddWorkspaceGroupMemberResponseModel +from ....types.delete_workspace_group_member_response_model import DeleteWorkspaceGroupMemberResponseModel +from ....types.http_validation_error import HttpValidationError + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RawMembersClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def remove( + self, group_id: str, *, email: str, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[DeleteWorkspaceGroupMemberResponseModel]: + """ + Removes a member from the specified group. This endpoint may only be called by workspace administrators. + + Parameters + ---------- + group_id : str + The ID of the target group. + + email : str + The email of the target workspace member. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[DeleteWorkspaceGroupMemberResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/workspace/groups/{jsonable_encoder(group_id)}/members/remove", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "email": email, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + DeleteWorkspaceGroupMemberResponseModel, + construct_type( + type_=DeleteWorkspaceGroupMemberResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def add( + self, group_id: str, *, email: str, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[AddWorkspaceGroupMemberResponseModel]: + """ + Adds a member of your workspace to the specified group. This endpoint may only be called by workspace administrators. + + Parameters + ---------- + group_id : str + The ID of the target group. + + email : str + The email of the target workspace member. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[AddWorkspaceGroupMemberResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/workspace/groups/{jsonable_encoder(group_id)}/members", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "email": email, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + AddWorkspaceGroupMemberResponseModel, + construct_type( + type_=AddWorkspaceGroupMemberResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + +class AsyncRawMembersClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def remove( + self, group_id: str, *, email: str, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[DeleteWorkspaceGroupMemberResponseModel]: + """ + Removes a member from the specified group. This endpoint may only be called by workspace administrators. + + Parameters + ---------- + group_id : str + The ID of the target group. + + email : str + The email of the target workspace member. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[DeleteWorkspaceGroupMemberResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/workspace/groups/{jsonable_encoder(group_id)}/members/remove", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "email": email, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + DeleteWorkspaceGroupMemberResponseModel, + construct_type( + type_=DeleteWorkspaceGroupMemberResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def add( + self, group_id: str, *, email: str, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[AddWorkspaceGroupMemberResponseModel]: + """ + Adds a member of your workspace to the specified group. This endpoint may only be called by workspace administrators. + + Parameters + ---------- + group_id : str + The ID of the target group. + + email : str + The email of the target workspace member. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[AddWorkspaceGroupMemberResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/workspace/groups/{jsonable_encoder(group_id)}/members", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "email": email, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + AddWorkspaceGroupMemberResponseModel, + construct_type( + type_=AddWorkspaceGroupMemberResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/elevenlabs/workspace/groups/raw_client.py b/src/elevenlabs/workspace/groups/raw_client.py new file mode 100644 index 00000000..9cd197aa --- /dev/null +++ b/src/elevenlabs/workspace/groups/raw_client.py @@ -0,0 +1,131 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ...core.api_error import ApiError +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ...core.http_response import AsyncHttpResponse, HttpResponse +from ...core.request_options import RequestOptions +from ...core.unchecked_base_model import construct_type +from ...errors.unprocessable_entity_error import UnprocessableEntityError +from ...types.http_validation_error import HttpValidationError +from ...types.workspace_group_by_name_response_model import WorkspaceGroupByNameResponseModel + + +class RawGroupsClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def search( + self, *, name: str, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[typing.List[WorkspaceGroupByNameResponseModel]]: + """ + Searches for user groups in the workspace. Multiple or no groups may be returned. + + Parameters + ---------- + name : str + Name of the target group. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[typing.List[WorkspaceGroupByNameResponseModel]] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + "v1/workspace/groups/search", + base_url=self._client_wrapper.get_environment().base, + method="GET", + params={ + "name": name, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + typing.List[WorkspaceGroupByNameResponseModel], + construct_type( + type_=typing.List[WorkspaceGroupByNameResponseModel], # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + +class AsyncRawGroupsClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def search( + self, *, name: str, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[typing.List[WorkspaceGroupByNameResponseModel]]: + """ + Searches for user groups in the workspace. Multiple or no groups may be returned. + + Parameters + ---------- + name : str + Name of the target group. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[typing.List[WorkspaceGroupByNameResponseModel]] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + "v1/workspace/groups/search", + base_url=self._client_wrapper.get_environment().base, + method="GET", + params={ + "name": name, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + typing.List[WorkspaceGroupByNameResponseModel], + construct_type( + type_=typing.List[WorkspaceGroupByNameResponseModel], # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/elevenlabs/workspace/invites/__init__.py b/src/elevenlabs/workspace/invites/__init__.py new file mode 100644 index 00000000..5a900d35 --- /dev/null +++ b/src/elevenlabs/workspace/invites/__init__.py @@ -0,0 +1,7 @@ +# This file was auto-generated by Fern from our API Definition. + +# isort: skip_file + +from .types import BodyInviteUserV1WorkspaceInvitesAddPostWorkspacePermission + +__all__ = ["BodyInviteUserV1WorkspaceInvitesAddPostWorkspacePermission"] diff --git a/src/elevenlabs/workspace/invites/client.py b/src/elevenlabs/workspace/invites/client.py new file mode 100644 index 00000000..66258f90 --- /dev/null +++ b/src/elevenlabs/workspace/invites/client.py @@ -0,0 +1,311 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ...core.request_options import RequestOptions +from ...types.add_workspace_invite_response_model import AddWorkspaceInviteResponseModel +from ...types.delete_workspace_invite_response_model import DeleteWorkspaceInviteResponseModel +from .raw_client import AsyncRawInvitesClient, RawInvitesClient +from .types.body_invite_user_v_1_workspace_invites_add_post_workspace_permission import ( + BodyInviteUserV1WorkspaceInvitesAddPostWorkspacePermission, +) + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class InvitesClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._raw_client = RawInvitesClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawInvitesClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawInvitesClient + """ + return self._raw_client + + def create( + self, + *, + email: str, + group_ids: typing.Optional[typing.Sequence[str]] = OMIT, + workspace_permission: typing.Optional[BodyInviteUserV1WorkspaceInvitesAddPostWorkspacePermission] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AddWorkspaceInviteResponseModel: + """ + Sends an email invitation to join your workspace to the provided email. If the user doesn't have an account they will be prompted to create one. If the user accepts this invite they will be added as a user to your workspace and your subscription using one of your seats. This endpoint may only be called by workspace administrators. If the user is already in the workspace a 400 error will be returned. + + Parameters + ---------- + email : str + The email of the customer + + group_ids : typing.Optional[typing.Sequence[str]] + The group ids of the user + + workspace_permission : typing.Optional[BodyInviteUserV1WorkspaceInvitesAddPostWorkspacePermission] + The workspace permission of the user + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AddWorkspaceInviteResponseModel + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.workspace.invites.create( + email="john.doe@testmail.com", + ) + """ + _response = self._raw_client.create( + email=email, group_ids=group_ids, workspace_permission=workspace_permission, request_options=request_options + ) + return _response.data + + def create_batch( + self, + *, + emails: typing.Sequence[str], + group_ids: typing.Optional[typing.Sequence[str]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AddWorkspaceInviteResponseModel: + """ + Sends email invitations to join your workspace to the provided emails. Requires all email addresses to be part of a verified domain. If the users don't have an account they will be prompted to create one. If the users accept these invites they will be added as users to your workspace and your subscription using one of your seats. This endpoint may only be called by workspace administrators. + + Parameters + ---------- + emails : typing.Sequence[str] + The email of the customer + + group_ids : typing.Optional[typing.Sequence[str]] + The group ids of the user + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AddWorkspaceInviteResponseModel + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.workspace.invites.create_batch( + emails=["emails"], + ) + """ + _response = self._raw_client.create_batch(emails=emails, group_ids=group_ids, request_options=request_options) + return _response.data + + def delete( + self, *, email: str, request_options: typing.Optional[RequestOptions] = None + ) -> DeleteWorkspaceInviteResponseModel: + """ + Invalidates an existing email invitation. The invitation will still show up in the inbox it has been delivered to, but activating it to join the workspace won't work. This endpoint may only be called by workspace administrators. + + Parameters + ---------- + email : str + The email of the customer + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + DeleteWorkspaceInviteResponseModel + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.workspace.invites.delete( + email="john.doe@testmail.com", + ) + """ + _response = self._raw_client.delete(email=email, request_options=request_options) + return _response.data + + +class AsyncInvitesClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawInvitesClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawInvitesClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawInvitesClient + """ + return self._raw_client + + async def create( + self, + *, + email: str, + group_ids: typing.Optional[typing.Sequence[str]] = OMIT, + workspace_permission: typing.Optional[BodyInviteUserV1WorkspaceInvitesAddPostWorkspacePermission] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AddWorkspaceInviteResponseModel: + """ + Sends an email invitation to join your workspace to the provided email. If the user doesn't have an account they will be prompted to create one. If the user accepts this invite they will be added as a user to your workspace and your subscription using one of your seats. This endpoint may only be called by workspace administrators. If the user is already in the workspace a 400 error will be returned. + + Parameters + ---------- + email : str + The email of the customer + + group_ids : typing.Optional[typing.Sequence[str]] + The group ids of the user + + workspace_permission : typing.Optional[BodyInviteUserV1WorkspaceInvitesAddPostWorkspacePermission] + The workspace permission of the user + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AddWorkspaceInviteResponseModel + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.workspace.invites.create( + email="john.doe@testmail.com", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.create( + email=email, group_ids=group_ids, workspace_permission=workspace_permission, request_options=request_options + ) + return _response.data + + async def create_batch( + self, + *, + emails: typing.Sequence[str], + group_ids: typing.Optional[typing.Sequence[str]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AddWorkspaceInviteResponseModel: + """ + Sends email invitations to join your workspace to the provided emails. Requires all email addresses to be part of a verified domain. If the users don't have an account they will be prompted to create one. If the users accept these invites they will be added as users to your workspace and your subscription using one of your seats. This endpoint may only be called by workspace administrators. + + Parameters + ---------- + emails : typing.Sequence[str] + The email of the customer + + group_ids : typing.Optional[typing.Sequence[str]] + The group ids of the user + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AddWorkspaceInviteResponseModel + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.workspace.invites.create_batch( + emails=["emails"], + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.create_batch( + emails=emails, group_ids=group_ids, request_options=request_options + ) + return _response.data + + async def delete( + self, *, email: str, request_options: typing.Optional[RequestOptions] = None + ) -> DeleteWorkspaceInviteResponseModel: + """ + Invalidates an existing email invitation. The invitation will still show up in the inbox it has been delivered to, but activating it to join the workspace won't work. This endpoint may only be called by workspace administrators. + + Parameters + ---------- + email : str + The email of the customer + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + DeleteWorkspaceInviteResponseModel + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.workspace.invites.delete( + email="john.doe@testmail.com", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.delete(email=email, request_options=request_options) + return _response.data diff --git a/src/elevenlabs/workspace/invites/raw_client.py b/src/elevenlabs/workspace/invites/raw_client.py new file mode 100644 index 00000000..a5de9b05 --- /dev/null +++ b/src/elevenlabs/workspace/invites/raw_client.py @@ -0,0 +1,420 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ...core.api_error import ApiError +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ...core.http_response import AsyncHttpResponse, HttpResponse +from ...core.request_options import RequestOptions +from ...core.unchecked_base_model import construct_type +from ...errors.unprocessable_entity_error import UnprocessableEntityError +from ...types.add_workspace_invite_response_model import AddWorkspaceInviteResponseModel +from ...types.delete_workspace_invite_response_model import DeleteWorkspaceInviteResponseModel +from ...types.http_validation_error import HttpValidationError +from .types.body_invite_user_v_1_workspace_invites_add_post_workspace_permission import ( + BodyInviteUserV1WorkspaceInvitesAddPostWorkspacePermission, +) + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RawInvitesClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def create( + self, + *, + email: str, + group_ids: typing.Optional[typing.Sequence[str]] = OMIT, + workspace_permission: typing.Optional[BodyInviteUserV1WorkspaceInvitesAddPostWorkspacePermission] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[AddWorkspaceInviteResponseModel]: + """ + Sends an email invitation to join your workspace to the provided email. If the user doesn't have an account they will be prompted to create one. If the user accepts this invite they will be added as a user to your workspace and your subscription using one of your seats. This endpoint may only be called by workspace administrators. If the user is already in the workspace a 400 error will be returned. + + Parameters + ---------- + email : str + The email of the customer + + group_ids : typing.Optional[typing.Sequence[str]] + The group ids of the user + + workspace_permission : typing.Optional[BodyInviteUserV1WorkspaceInvitesAddPostWorkspacePermission] + The workspace permission of the user + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[AddWorkspaceInviteResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + "v1/workspace/invites/add", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "email": email, + "group_ids": group_ids, + "workspace_permission": workspace_permission, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + AddWorkspaceInviteResponseModel, + construct_type( + type_=AddWorkspaceInviteResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def create_batch( + self, + *, + emails: typing.Sequence[str], + group_ids: typing.Optional[typing.Sequence[str]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[AddWorkspaceInviteResponseModel]: + """ + Sends email invitations to join your workspace to the provided emails. Requires all email addresses to be part of a verified domain. If the users don't have an account they will be prompted to create one. If the users accept these invites they will be added as users to your workspace and your subscription using one of your seats. This endpoint may only be called by workspace administrators. + + Parameters + ---------- + emails : typing.Sequence[str] + The email of the customer + + group_ids : typing.Optional[typing.Sequence[str]] + The group ids of the user + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[AddWorkspaceInviteResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + "v1/workspace/invites/add-bulk", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "emails": emails, + "group_ids": group_ids, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + AddWorkspaceInviteResponseModel, + construct_type( + type_=AddWorkspaceInviteResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def delete( + self, *, email: str, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[DeleteWorkspaceInviteResponseModel]: + """ + Invalidates an existing email invitation. The invitation will still show up in the inbox it has been delivered to, but activating it to join the workspace won't work. This endpoint may only be called by workspace administrators. + + Parameters + ---------- + email : str + The email of the customer + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[DeleteWorkspaceInviteResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + "v1/workspace/invites", + base_url=self._client_wrapper.get_environment().base, + method="DELETE", + json={ + "email": email, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + DeleteWorkspaceInviteResponseModel, + construct_type( + type_=DeleteWorkspaceInviteResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + +class AsyncRawInvitesClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def create( + self, + *, + email: str, + group_ids: typing.Optional[typing.Sequence[str]] = OMIT, + workspace_permission: typing.Optional[BodyInviteUserV1WorkspaceInvitesAddPostWorkspacePermission] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[AddWorkspaceInviteResponseModel]: + """ + Sends an email invitation to join your workspace to the provided email. If the user doesn't have an account they will be prompted to create one. If the user accepts this invite they will be added as a user to your workspace and your subscription using one of your seats. This endpoint may only be called by workspace administrators. If the user is already in the workspace a 400 error will be returned. + + Parameters + ---------- + email : str + The email of the customer + + group_ids : typing.Optional[typing.Sequence[str]] + The group ids of the user + + workspace_permission : typing.Optional[BodyInviteUserV1WorkspaceInvitesAddPostWorkspacePermission] + The workspace permission of the user + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[AddWorkspaceInviteResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + "v1/workspace/invites/add", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "email": email, + "group_ids": group_ids, + "workspace_permission": workspace_permission, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + AddWorkspaceInviteResponseModel, + construct_type( + type_=AddWorkspaceInviteResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def create_batch( + self, + *, + emails: typing.Sequence[str], + group_ids: typing.Optional[typing.Sequence[str]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[AddWorkspaceInviteResponseModel]: + """ + Sends email invitations to join your workspace to the provided emails. Requires all email addresses to be part of a verified domain. If the users don't have an account they will be prompted to create one. If the users accept these invites they will be added as users to your workspace and your subscription using one of your seats. This endpoint may only be called by workspace administrators. + + Parameters + ---------- + emails : typing.Sequence[str] + The email of the customer + + group_ids : typing.Optional[typing.Sequence[str]] + The group ids of the user + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[AddWorkspaceInviteResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + "v1/workspace/invites/add-bulk", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "emails": emails, + "group_ids": group_ids, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + AddWorkspaceInviteResponseModel, + construct_type( + type_=AddWorkspaceInviteResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def delete( + self, *, email: str, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[DeleteWorkspaceInviteResponseModel]: + """ + Invalidates an existing email invitation. The invitation will still show up in the inbox it has been delivered to, but activating it to join the workspace won't work. This endpoint may only be called by workspace administrators. + + Parameters + ---------- + email : str + The email of the customer + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[DeleteWorkspaceInviteResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + "v1/workspace/invites", + base_url=self._client_wrapper.get_environment().base, + method="DELETE", + json={ + "email": email, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + DeleteWorkspaceInviteResponseModel, + construct_type( + type_=DeleteWorkspaceInviteResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/elevenlabs/workspace/invites/types/__init__.py b/src/elevenlabs/workspace/invites/types/__init__.py new file mode 100644 index 00000000..7f25ead5 --- /dev/null +++ b/src/elevenlabs/workspace/invites/types/__init__.py @@ -0,0 +1,9 @@ +# This file was auto-generated by Fern from our API Definition. + +# isort: skip_file + +from .body_invite_user_v_1_workspace_invites_add_post_workspace_permission import ( + BodyInviteUserV1WorkspaceInvitesAddPostWorkspacePermission, +) + +__all__ = ["BodyInviteUserV1WorkspaceInvitesAddPostWorkspacePermission"] diff --git a/src/elevenlabs/workspace/types/body_invite_user_v_1_workspace_invites_add_post_workspace_permission.py b/src/elevenlabs/workspace/invites/types/body_invite_user_v_1_workspace_invites_add_post_workspace_permission.py similarity index 100% rename from src/elevenlabs/workspace/types/body_invite_user_v_1_workspace_invites_add_post_workspace_permission.py rename to src/elevenlabs/workspace/invites/types/body_invite_user_v_1_workspace_invites_add_post_workspace_permission.py diff --git a/src/elevenlabs/workspace/members/__init__.py b/src/elevenlabs/workspace/members/__init__.py new file mode 100644 index 00000000..7c4da821 --- /dev/null +++ b/src/elevenlabs/workspace/members/__init__.py @@ -0,0 +1,7 @@ +# This file was auto-generated by Fern from our API Definition. + +# isort: skip_file + +from .types import BodyUpdateMemberV1WorkspaceMembersPostWorkspaceRole + +__all__ = ["BodyUpdateMemberV1WorkspaceMembersPostWorkspaceRole"] diff --git a/src/elevenlabs/workspace/members/client.py b/src/elevenlabs/workspace/members/client.py new file mode 100644 index 00000000..977ca987 --- /dev/null +++ b/src/elevenlabs/workspace/members/client.py @@ -0,0 +1,221 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ...core.request_options import RequestOptions +from ...types.delete_workspace_member_response_model import DeleteWorkspaceMemberResponseModel +from ...types.update_workspace_member_response_model import UpdateWorkspaceMemberResponseModel +from .raw_client import AsyncRawMembersClient, RawMembersClient +from .types.body_update_member_v_1_workspace_members_post_workspace_role import ( + BodyUpdateMemberV1WorkspaceMembersPostWorkspaceRole, +) + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class MembersClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._raw_client = RawMembersClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawMembersClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawMembersClient + """ + return self._raw_client + + def update( + self, + *, + email: str, + is_locked: typing.Optional[bool] = OMIT, + workspace_role: typing.Optional[BodyUpdateMemberV1WorkspaceMembersPostWorkspaceRole] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> UpdateWorkspaceMemberResponseModel: + """ + Updates attributes of a workspace member. Apart from the email identifier, all parameters will remain unchanged unless specified. This endpoint may only be called by workspace administrators. + + Parameters + ---------- + email : str + Email of the target user. + + is_locked : typing.Optional[bool] + Whether to lock or unlock the user account. + + workspace_role : typing.Optional[BodyUpdateMemberV1WorkspaceMembersPostWorkspaceRole] + Role dictating permissions in the workspace. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + UpdateWorkspaceMemberResponseModel + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.workspace.members.update( + email="email", + ) + """ + _response = self._raw_client.update( + email=email, is_locked=is_locked, workspace_role=workspace_role, request_options=request_options + ) + return _response.data + + def delete( + self, *, email: str, request_options: typing.Optional[RequestOptions] = None + ) -> DeleteWorkspaceMemberResponseModel: + """ + Deletes a workspace member. This endpoint may only be called by workspace administrators. + + Parameters + ---------- + email : str + Email of the target user. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + DeleteWorkspaceMemberResponseModel + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.workspace.members.delete( + email="email", + ) + """ + _response = self._raw_client.delete(email=email, request_options=request_options) + return _response.data + + +class AsyncMembersClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawMembersClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawMembersClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawMembersClient + """ + return self._raw_client + + async def update( + self, + *, + email: str, + is_locked: typing.Optional[bool] = OMIT, + workspace_role: typing.Optional[BodyUpdateMemberV1WorkspaceMembersPostWorkspaceRole] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> UpdateWorkspaceMemberResponseModel: + """ + Updates attributes of a workspace member. Apart from the email identifier, all parameters will remain unchanged unless specified. This endpoint may only be called by workspace administrators. + + Parameters + ---------- + email : str + Email of the target user. + + is_locked : typing.Optional[bool] + Whether to lock or unlock the user account. + + workspace_role : typing.Optional[BodyUpdateMemberV1WorkspaceMembersPostWorkspaceRole] + Role dictating permissions in the workspace. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + UpdateWorkspaceMemberResponseModel + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.workspace.members.update( + email="email", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.update( + email=email, is_locked=is_locked, workspace_role=workspace_role, request_options=request_options + ) + return _response.data + + async def delete( + self, *, email: str, request_options: typing.Optional[RequestOptions] = None + ) -> DeleteWorkspaceMemberResponseModel: + """ + Deletes a workspace member. This endpoint may only be called by workspace administrators. + + Parameters + ---------- + email : str + Email of the target user. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + DeleteWorkspaceMemberResponseModel + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.workspace.members.delete( + email="email", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.delete(email=email, request_options=request_options) + return _response.data diff --git a/src/elevenlabs/workspace/members/raw_client.py b/src/elevenlabs/workspace/members/raw_client.py new file mode 100644 index 00000000..5de0f798 --- /dev/null +++ b/src/elevenlabs/workspace/members/raw_client.py @@ -0,0 +1,288 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ...core.api_error import ApiError +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ...core.http_response import AsyncHttpResponse, HttpResponse +from ...core.request_options import RequestOptions +from ...core.unchecked_base_model import construct_type +from ...errors.unprocessable_entity_error import UnprocessableEntityError +from ...types.delete_workspace_member_response_model import DeleteWorkspaceMemberResponseModel +from ...types.http_validation_error import HttpValidationError +from ...types.update_workspace_member_response_model import UpdateWorkspaceMemberResponseModel +from .types.body_update_member_v_1_workspace_members_post_workspace_role import ( + BodyUpdateMemberV1WorkspaceMembersPostWorkspaceRole, +) + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RawMembersClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def update( + self, + *, + email: str, + is_locked: typing.Optional[bool] = OMIT, + workspace_role: typing.Optional[BodyUpdateMemberV1WorkspaceMembersPostWorkspaceRole] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[UpdateWorkspaceMemberResponseModel]: + """ + Updates attributes of a workspace member. Apart from the email identifier, all parameters will remain unchanged unless specified. This endpoint may only be called by workspace administrators. + + Parameters + ---------- + email : str + Email of the target user. + + is_locked : typing.Optional[bool] + Whether to lock or unlock the user account. + + workspace_role : typing.Optional[BodyUpdateMemberV1WorkspaceMembersPostWorkspaceRole] + Role dictating permissions in the workspace. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[UpdateWorkspaceMemberResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + "v1/workspace/members", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "email": email, + "is_locked": is_locked, + "workspace_role": workspace_role, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + UpdateWorkspaceMemberResponseModel, + construct_type( + type_=UpdateWorkspaceMemberResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def delete( + self, *, email: str, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[DeleteWorkspaceMemberResponseModel]: + """ + Deletes a workspace member. This endpoint may only be called by workspace administrators. + + Parameters + ---------- + email : str + Email of the target user. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[DeleteWorkspaceMemberResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + "v1/workspace/members", + base_url=self._client_wrapper.get_environment().base, + method="DELETE", + json={ + "email": email, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + DeleteWorkspaceMemberResponseModel, + construct_type( + type_=DeleteWorkspaceMemberResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + +class AsyncRawMembersClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def update( + self, + *, + email: str, + is_locked: typing.Optional[bool] = OMIT, + workspace_role: typing.Optional[BodyUpdateMemberV1WorkspaceMembersPostWorkspaceRole] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[UpdateWorkspaceMemberResponseModel]: + """ + Updates attributes of a workspace member. Apart from the email identifier, all parameters will remain unchanged unless specified. This endpoint may only be called by workspace administrators. + + Parameters + ---------- + email : str + Email of the target user. + + is_locked : typing.Optional[bool] + Whether to lock or unlock the user account. + + workspace_role : typing.Optional[BodyUpdateMemberV1WorkspaceMembersPostWorkspaceRole] + Role dictating permissions in the workspace. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[UpdateWorkspaceMemberResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + "v1/workspace/members", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "email": email, + "is_locked": is_locked, + "workspace_role": workspace_role, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + UpdateWorkspaceMemberResponseModel, + construct_type( + type_=UpdateWorkspaceMemberResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def delete( + self, *, email: str, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[DeleteWorkspaceMemberResponseModel]: + """ + Deletes a workspace member. This endpoint may only be called by workspace administrators. + + Parameters + ---------- + email : str + Email of the target user. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[DeleteWorkspaceMemberResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + "v1/workspace/members", + base_url=self._client_wrapper.get_environment().base, + method="DELETE", + json={ + "email": email, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + DeleteWorkspaceMemberResponseModel, + construct_type( + type_=DeleteWorkspaceMemberResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/elevenlabs/workspace/members/types/__init__.py b/src/elevenlabs/workspace/members/types/__init__.py new file mode 100644 index 00000000..b7bc3c10 --- /dev/null +++ b/src/elevenlabs/workspace/members/types/__init__.py @@ -0,0 +1,9 @@ +# This file was auto-generated by Fern from our API Definition. + +# isort: skip_file + +from .body_update_member_v_1_workspace_members_post_workspace_role import ( + BodyUpdateMemberV1WorkspaceMembersPostWorkspaceRole, +) + +__all__ = ["BodyUpdateMemberV1WorkspaceMembersPostWorkspaceRole"] diff --git a/src/elevenlabs/workspace/types/body_update_member_v_1_workspace_members_post_workspace_role.py b/src/elevenlabs/workspace/members/types/body_update_member_v_1_workspace_members_post_workspace_role.py similarity index 100% rename from src/elevenlabs/workspace/types/body_update_member_v_1_workspace_members_post_workspace_role.py rename to src/elevenlabs/workspace/members/types/body_update_member_v_1_workspace_members_post_workspace_role.py diff --git a/src/elevenlabs/workspace/raw_client.py b/src/elevenlabs/workspace/raw_client.py new file mode 100644 index 00000000..b33dafd0 --- /dev/null +++ b/src/elevenlabs/workspace/raw_client.py @@ -0,0 +1,13 @@ +# This file was auto-generated by Fern from our API Definition. + +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper + + +class RawWorkspaceClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + +class AsyncRawWorkspaceClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper diff --git a/src/elevenlabs/workspace/resources/__init__.py b/src/elevenlabs/workspace/resources/__init__.py new file mode 100644 index 00000000..6577c2ae --- /dev/null +++ b/src/elevenlabs/workspace/resources/__init__.py @@ -0,0 +1,7 @@ +# This file was auto-generated by Fern from our API Definition. + +# isort: skip_file + +from .types import BodyShareWorkspaceResourceV1WorkspaceResourcesResourceIdSharePostRole + +__all__ = ["BodyShareWorkspaceResourceV1WorkspaceResourcesResourceIdSharePostRole"] diff --git a/src/elevenlabs/workspace/resources/client.py b/src/elevenlabs/workspace/resources/client.py new file mode 100644 index 00000000..912900f6 --- /dev/null +++ b/src/elevenlabs/workspace/resources/client.py @@ -0,0 +1,407 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ...core.request_options import RequestOptions +from ...types.resource_metadata_response_model import ResourceMetadataResponseModel +from ...types.workspace_resource_type import WorkspaceResourceType +from .raw_client import AsyncRawResourcesClient, RawResourcesClient +from .types.body_share_workspace_resource_v_1_workspace_resources_resource_id_share_post_role import ( + BodyShareWorkspaceResourceV1WorkspaceResourcesResourceIdSharePostRole, +) + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class ResourcesClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._raw_client = RawResourcesClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawResourcesClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawResourcesClient + """ + return self._raw_client + + def get( + self, + resource_id: str, + *, + resource_type: WorkspaceResourceType, + request_options: typing.Optional[RequestOptions] = None, + ) -> ResourceMetadataResponseModel: + """ + Gets the metadata of a resource by ID. + + Parameters + ---------- + resource_id : str + The ID of the target resource. + + resource_type : WorkspaceResourceType + Resource type of the target resource. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ResourceMetadataResponseModel + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.workspace.resources.get( + resource_id="resource_id", + resource_type="voice", + ) + """ + _response = self._raw_client.get(resource_id, resource_type=resource_type, request_options=request_options) + return _response.data + + def share( + self, + resource_id: str, + *, + role: BodyShareWorkspaceResourceV1WorkspaceResourcesResourceIdSharePostRole, + resource_type: WorkspaceResourceType, + user_email: typing.Optional[str] = OMIT, + group_id: typing.Optional[str] = OMIT, + workspace_api_key_id: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> typing.Optional[typing.Any]: + """ + Grants a role on a workspace resource to a user or a group. It overrides any existing role this user/service account/group/workspace api key has on the resource. To target a user or service account, pass only the user email. The user must be in your workspace. To target a group, pass only the group id. To target a workspace api key, pass the api key id. The resource will be shared with the service account associated with the api key. You must have admin access to the resource to share it. + + Parameters + ---------- + resource_id : str + The ID of the target resource. + + role : BodyShareWorkspaceResourceV1WorkspaceResourcesResourceIdSharePostRole + Role to update the target principal with. + + resource_type : WorkspaceResourceType + Resource type of the target resource. + + user_email : typing.Optional[str] + The email of the user or service account. + + group_id : typing.Optional[str] + The ID of the target group. To target the permissions principals have by default on this resource, use the value 'default'. + + workspace_api_key_id : typing.Optional[str] + The ID of the target workspace API key. This isn't the same as the key itself that would you pass in the header for authentication. Workspace admins can find this in the workspace settings UI. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + typing.Optional[typing.Any] + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.workspace.resources.share( + resource_id="resource_id", + role="admin", + resource_type="voice", + ) + """ + _response = self._raw_client.share( + resource_id, + role=role, + resource_type=resource_type, + user_email=user_email, + group_id=group_id, + workspace_api_key_id=workspace_api_key_id, + request_options=request_options, + ) + return _response.data + + def unshare( + self, + resource_id: str, + *, + resource_type: WorkspaceResourceType, + user_email: typing.Optional[str] = OMIT, + group_id: typing.Optional[str] = OMIT, + workspace_api_key_id: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> typing.Optional[typing.Any]: + """ + Removes any existing role on a workspace resource from a user, service account, group or workspace api key. To target a user or service account, pass only the user email. The user must be in your workspace. To target a group, pass only the group id. To target a workspace api key, pass the api key id. The resource will be unshared from the service account associated with the api key. You must have admin access to the resource to unshare it. You cannot remove permissions from the user who created the resource. + + Parameters + ---------- + resource_id : str + The ID of the target resource. + + resource_type : WorkspaceResourceType + Resource type of the target resource. + + user_email : typing.Optional[str] + The email of the user or service account. + + group_id : typing.Optional[str] + The ID of the target group. To target the permissions principals have by default on this resource, use the value 'default'. + + workspace_api_key_id : typing.Optional[str] + The ID of the target workspace API key. This isn't the same as the key itself that would you pass in the header for authentication. Workspace admins can find this in the workspace settings UI. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + typing.Optional[typing.Any] + Successful Response + + Examples + -------- + from elevenlabs import ElevenLabs + + client = ElevenLabs( + api_key="YOUR_API_KEY", + ) + client.workspace.resources.unshare( + resource_id="resource_id", + resource_type="voice", + ) + """ + _response = self._raw_client.unshare( + resource_id, + resource_type=resource_type, + user_email=user_email, + group_id=group_id, + workspace_api_key_id=workspace_api_key_id, + request_options=request_options, + ) + return _response.data + + +class AsyncResourcesClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawResourcesClient(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawResourcesClient: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawResourcesClient + """ + return self._raw_client + + async def get( + self, + resource_id: str, + *, + resource_type: WorkspaceResourceType, + request_options: typing.Optional[RequestOptions] = None, + ) -> ResourceMetadataResponseModel: + """ + Gets the metadata of a resource by ID. + + Parameters + ---------- + resource_id : str + The ID of the target resource. + + resource_type : WorkspaceResourceType + Resource type of the target resource. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ResourceMetadataResponseModel + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.workspace.resources.get( + resource_id="resource_id", + resource_type="voice", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.get( + resource_id, resource_type=resource_type, request_options=request_options + ) + return _response.data + + async def share( + self, + resource_id: str, + *, + role: BodyShareWorkspaceResourceV1WorkspaceResourcesResourceIdSharePostRole, + resource_type: WorkspaceResourceType, + user_email: typing.Optional[str] = OMIT, + group_id: typing.Optional[str] = OMIT, + workspace_api_key_id: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> typing.Optional[typing.Any]: + """ + Grants a role on a workspace resource to a user or a group. It overrides any existing role this user/service account/group/workspace api key has on the resource. To target a user or service account, pass only the user email. The user must be in your workspace. To target a group, pass only the group id. To target a workspace api key, pass the api key id. The resource will be shared with the service account associated with the api key. You must have admin access to the resource to share it. + + Parameters + ---------- + resource_id : str + The ID of the target resource. + + role : BodyShareWorkspaceResourceV1WorkspaceResourcesResourceIdSharePostRole + Role to update the target principal with. + + resource_type : WorkspaceResourceType + Resource type of the target resource. + + user_email : typing.Optional[str] + The email of the user or service account. + + group_id : typing.Optional[str] + The ID of the target group. To target the permissions principals have by default on this resource, use the value 'default'. + + workspace_api_key_id : typing.Optional[str] + The ID of the target workspace API key. This isn't the same as the key itself that would you pass in the header for authentication. Workspace admins can find this in the workspace settings UI. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + typing.Optional[typing.Any] + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.workspace.resources.share( + resource_id="resource_id", + role="admin", + resource_type="voice", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.share( + resource_id, + role=role, + resource_type=resource_type, + user_email=user_email, + group_id=group_id, + workspace_api_key_id=workspace_api_key_id, + request_options=request_options, + ) + return _response.data + + async def unshare( + self, + resource_id: str, + *, + resource_type: WorkspaceResourceType, + user_email: typing.Optional[str] = OMIT, + group_id: typing.Optional[str] = OMIT, + workspace_api_key_id: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> typing.Optional[typing.Any]: + """ + Removes any existing role on a workspace resource from a user, service account, group or workspace api key. To target a user or service account, pass only the user email. The user must be in your workspace. To target a group, pass only the group id. To target a workspace api key, pass the api key id. The resource will be unshared from the service account associated with the api key. You must have admin access to the resource to unshare it. You cannot remove permissions from the user who created the resource. + + Parameters + ---------- + resource_id : str + The ID of the target resource. + + resource_type : WorkspaceResourceType + Resource type of the target resource. + + user_email : typing.Optional[str] + The email of the user or service account. + + group_id : typing.Optional[str] + The ID of the target group. To target the permissions principals have by default on this resource, use the value 'default'. + + workspace_api_key_id : typing.Optional[str] + The ID of the target workspace API key. This isn't the same as the key itself that would you pass in the header for authentication. Workspace admins can find this in the workspace settings UI. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + typing.Optional[typing.Any] + Successful Response + + Examples + -------- + import asyncio + + from elevenlabs import AsyncElevenLabs + + client = AsyncElevenLabs( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.workspace.resources.unshare( + resource_id="resource_id", + resource_type="voice", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.unshare( + resource_id, + resource_type=resource_type, + user_email=user_email, + group_id=group_id, + workspace_api_key_id=workspace_api_key_id, + request_options=request_options, + ) + return _response.data diff --git a/src/elevenlabs/workspace/resources/raw_client.py b/src/elevenlabs/workspace/resources/raw_client.py new file mode 100644 index 00000000..bc0b7f72 --- /dev/null +++ b/src/elevenlabs/workspace/resources/raw_client.py @@ -0,0 +1,483 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ...core.api_error import ApiError +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ...core.http_response import AsyncHttpResponse, HttpResponse +from ...core.jsonable_encoder import jsonable_encoder +from ...core.request_options import RequestOptions +from ...core.unchecked_base_model import construct_type +from ...errors.unprocessable_entity_error import UnprocessableEntityError +from ...types.http_validation_error import HttpValidationError +from ...types.resource_metadata_response_model import ResourceMetadataResponseModel +from ...types.workspace_resource_type import WorkspaceResourceType +from .types.body_share_workspace_resource_v_1_workspace_resources_resource_id_share_post_role import ( + BodyShareWorkspaceResourceV1WorkspaceResourcesResourceIdSharePostRole, +) + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class RawResourcesClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def get( + self, + resource_id: str, + *, + resource_type: WorkspaceResourceType, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[ResourceMetadataResponseModel]: + """ + Gets the metadata of a resource by ID. + + Parameters + ---------- + resource_id : str + The ID of the target resource. + + resource_type : WorkspaceResourceType + Resource type of the target resource. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[ResourceMetadataResponseModel] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/workspace/resources/{jsonable_encoder(resource_id)}", + base_url=self._client_wrapper.get_environment().base, + method="GET", + params={ + "resource_type": resource_type, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ResourceMetadataResponseModel, + construct_type( + type_=ResourceMetadataResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def share( + self, + resource_id: str, + *, + role: BodyShareWorkspaceResourceV1WorkspaceResourcesResourceIdSharePostRole, + resource_type: WorkspaceResourceType, + user_email: typing.Optional[str] = OMIT, + group_id: typing.Optional[str] = OMIT, + workspace_api_key_id: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[typing.Optional[typing.Any]]: + """ + Grants a role on a workspace resource to a user or a group. It overrides any existing role this user/service account/group/workspace api key has on the resource. To target a user or service account, pass only the user email. The user must be in your workspace. To target a group, pass only the group id. To target a workspace api key, pass the api key id. The resource will be shared with the service account associated with the api key. You must have admin access to the resource to share it. + + Parameters + ---------- + resource_id : str + The ID of the target resource. + + role : BodyShareWorkspaceResourceV1WorkspaceResourcesResourceIdSharePostRole + Role to update the target principal with. + + resource_type : WorkspaceResourceType + Resource type of the target resource. + + user_email : typing.Optional[str] + The email of the user or service account. + + group_id : typing.Optional[str] + The ID of the target group. To target the permissions principals have by default on this resource, use the value 'default'. + + workspace_api_key_id : typing.Optional[str] + The ID of the target workspace API key. This isn't the same as the key itself that would you pass in the header for authentication. Workspace admins can find this in the workspace settings UI. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[typing.Optional[typing.Any]] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/workspace/resources/{jsonable_encoder(resource_id)}/share", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "role": role, + "resource_type": resource_type, + "user_email": user_email, + "group_id": group_id, + "workspace_api_key_id": workspace_api_key_id, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + typing.Optional[typing.Any], + construct_type( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def unshare( + self, + resource_id: str, + *, + resource_type: WorkspaceResourceType, + user_email: typing.Optional[str] = OMIT, + group_id: typing.Optional[str] = OMIT, + workspace_api_key_id: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[typing.Optional[typing.Any]]: + """ + Removes any existing role on a workspace resource from a user, service account, group or workspace api key. To target a user or service account, pass only the user email. The user must be in your workspace. To target a group, pass only the group id. To target a workspace api key, pass the api key id. The resource will be unshared from the service account associated with the api key. You must have admin access to the resource to unshare it. You cannot remove permissions from the user who created the resource. + + Parameters + ---------- + resource_id : str + The ID of the target resource. + + resource_type : WorkspaceResourceType + Resource type of the target resource. + + user_email : typing.Optional[str] + The email of the user or service account. + + group_id : typing.Optional[str] + The ID of the target group. To target the permissions principals have by default on this resource, use the value 'default'. + + workspace_api_key_id : typing.Optional[str] + The ID of the target workspace API key. This isn't the same as the key itself that would you pass in the header for authentication. Workspace admins can find this in the workspace settings UI. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[typing.Optional[typing.Any]] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/workspace/resources/{jsonable_encoder(resource_id)}/unshare", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "resource_type": resource_type, + "user_email": user_email, + "group_id": group_id, + "workspace_api_key_id": workspace_api_key_id, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + typing.Optional[typing.Any], + construct_type( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + +class AsyncRawResourcesClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def get( + self, + resource_id: str, + *, + resource_type: WorkspaceResourceType, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[ResourceMetadataResponseModel]: + """ + Gets the metadata of a resource by ID. + + Parameters + ---------- + resource_id : str + The ID of the target resource. + + resource_type : WorkspaceResourceType + Resource type of the target resource. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[ResourceMetadataResponseModel] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/workspace/resources/{jsonable_encoder(resource_id)}", + base_url=self._client_wrapper.get_environment().base, + method="GET", + params={ + "resource_type": resource_type, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + ResourceMetadataResponseModel, + construct_type( + type_=ResourceMetadataResponseModel, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def share( + self, + resource_id: str, + *, + role: BodyShareWorkspaceResourceV1WorkspaceResourcesResourceIdSharePostRole, + resource_type: WorkspaceResourceType, + user_email: typing.Optional[str] = OMIT, + group_id: typing.Optional[str] = OMIT, + workspace_api_key_id: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[typing.Optional[typing.Any]]: + """ + Grants a role on a workspace resource to a user or a group. It overrides any existing role this user/service account/group/workspace api key has on the resource. To target a user or service account, pass only the user email. The user must be in your workspace. To target a group, pass only the group id. To target a workspace api key, pass the api key id. The resource will be shared with the service account associated with the api key. You must have admin access to the resource to share it. + + Parameters + ---------- + resource_id : str + The ID of the target resource. + + role : BodyShareWorkspaceResourceV1WorkspaceResourcesResourceIdSharePostRole + Role to update the target principal with. + + resource_type : WorkspaceResourceType + Resource type of the target resource. + + user_email : typing.Optional[str] + The email of the user or service account. + + group_id : typing.Optional[str] + The ID of the target group. To target the permissions principals have by default on this resource, use the value 'default'. + + workspace_api_key_id : typing.Optional[str] + The ID of the target workspace API key. This isn't the same as the key itself that would you pass in the header for authentication. Workspace admins can find this in the workspace settings UI. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[typing.Optional[typing.Any]] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/workspace/resources/{jsonable_encoder(resource_id)}/share", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "role": role, + "resource_type": resource_type, + "user_email": user_email, + "group_id": group_id, + "workspace_api_key_id": workspace_api_key_id, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + typing.Optional[typing.Any], + construct_type( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def unshare( + self, + resource_id: str, + *, + resource_type: WorkspaceResourceType, + user_email: typing.Optional[str] = OMIT, + group_id: typing.Optional[str] = OMIT, + workspace_api_key_id: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[typing.Optional[typing.Any]]: + """ + Removes any existing role on a workspace resource from a user, service account, group or workspace api key. To target a user or service account, pass only the user email. The user must be in your workspace. To target a group, pass only the group id. To target a workspace api key, pass the api key id. The resource will be unshared from the service account associated with the api key. You must have admin access to the resource to unshare it. You cannot remove permissions from the user who created the resource. + + Parameters + ---------- + resource_id : str + The ID of the target resource. + + resource_type : WorkspaceResourceType + Resource type of the target resource. + + user_email : typing.Optional[str] + The email of the user or service account. + + group_id : typing.Optional[str] + The ID of the target group. To target the permissions principals have by default on this resource, use the value 'default'. + + workspace_api_key_id : typing.Optional[str] + The ID of the target workspace API key. This isn't the same as the key itself that would you pass in the header for authentication. Workspace admins can find this in the workspace settings UI. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[typing.Optional[typing.Any]] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/workspace/resources/{jsonable_encoder(resource_id)}/unshare", + base_url=self._client_wrapper.get_environment().base, + method="POST", + json={ + "resource_type": resource_type, + "user_email": user_email, + "group_id": group_id, + "workspace_api_key_id": workspace_api_key_id, + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + typing.Optional[typing.Any], + construct_type( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + HttpValidationError, + construct_type( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/elevenlabs/workspace/resources/types/__init__.py b/src/elevenlabs/workspace/resources/types/__init__.py new file mode 100644 index 00000000..70e3137e --- /dev/null +++ b/src/elevenlabs/workspace/resources/types/__init__.py @@ -0,0 +1,9 @@ +# This file was auto-generated by Fern from our API Definition. + +# isort: skip_file + +from .body_share_workspace_resource_v_1_workspace_resources_resource_id_share_post_role import ( + BodyShareWorkspaceResourceV1WorkspaceResourcesResourceIdSharePostRole, +) + +__all__ = ["BodyShareWorkspaceResourceV1WorkspaceResourcesResourceIdSharePostRole"] diff --git a/src/elevenlabs/workspace/types/body_share_workspace_resource_v_1_workspace_resources_resource_id_share_post_role.py b/src/elevenlabs/workspace/resources/types/body_share_workspace_resource_v_1_workspace_resources_resource_id_share_post_role.py similarity index 100% rename from src/elevenlabs/workspace/types/body_share_workspace_resource_v_1_workspace_resources_resource_id_share_post_role.py rename to src/elevenlabs/workspace/resources/types/body_share_workspace_resource_v_1_workspace_resources_resource_id_share_post_role.py diff --git a/src/elevenlabs/workspace/types/__init__.py b/src/elevenlabs/workspace/types/__init__.py deleted file mode 100644 index ac36c0f2..00000000 --- a/src/elevenlabs/workspace/types/__init__.py +++ /dev/null @@ -1,17 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -from .body_invite_user_v_1_workspace_invites_add_post_workspace_permission import ( - BodyInviteUserV1WorkspaceInvitesAddPostWorkspacePermission, -) -from .body_share_workspace_resource_v_1_workspace_resources_resource_id_share_post_role import ( - BodyShareWorkspaceResourceV1WorkspaceResourcesResourceIdSharePostRole, -) -from .body_update_member_v_1_workspace_members_post_workspace_role import ( - BodyUpdateMemberV1WorkspaceMembersPostWorkspaceRole, -) - -__all__ = [ - "BodyInviteUserV1WorkspaceInvitesAddPostWorkspacePermission", - "BodyShareWorkspaceResourceV1WorkspaceResourcesResourceIdSharePostRole", - "BodyUpdateMemberV1WorkspaceMembersPostWorkspaceRole", -]