agent-server-sdk 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- agent_server_sdk-1.0.0/PKG-INFO +429 -0
- agent_server_sdk-1.0.0/README.md +399 -0
- agent_server_sdk-1.0.0/pyproject.toml +84 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/__init__.py +81 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agentkit/__init__.py +185 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agentkit/agent.py +562 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agentkit/agent_session.py +579 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agentkit/avatar_types.py +60 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agentkit/constants.py +55 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agentkit/token.py +312 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agentkit/vendors/__init__.py +62 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agentkit/vendors/avatar.py +42 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agentkit/vendors/base.py +60 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agentkit/vendors/llm.py +135 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agentkit/vendors/mllm.py +5 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agentkit/vendors/stt.py +226 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agentkit/vendors/tts.py +307 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/__init__.py +4 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/client.py +1030 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/raw_client.py +961 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/__init__.py +4 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/get_agents_response.py +51 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/get_agents_response_status.py +7 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/get_history_agents_response.py +39 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/get_history_agents_response_contents_item.py +31 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/get_history_agents_response_contents_item_role.py +5 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/interrupt_agents_response.py +33 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/list_agents_request_state.py +5 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/list_agents_response.py +35 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/list_agents_response_data.py +37 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/list_agents_response_data_list_item.py +34 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/list_agents_response_data_list_item_status.py +7 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/list_agents_response_meta.py +32 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/speak_agents_request_priority.py +5 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/speak_agents_response.py +33 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties.py +131 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_advanced_features.py +47 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_asr.py +47 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_asr_vendor.py +10 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_avatar.py +40 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_avatar_vendor.py +5 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_filler_words.py +41 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_filler_words_content.py +38 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_filler_words_content_static_config.py +39 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_filler_words_content_static_config_selection_rule.py +7 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_filler_words_trigger.py +38 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_filler_words_trigger_fixed_time_config.py +27 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_geofence.py +34 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_geofence_area.py +7 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_geofence_exclude_area.py +7 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_llm.py +110 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_llm_greeting_configs.py +32 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_llm_greeting_configs_mode.py +7 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_llm_mcp_servers_item.py +54 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_llm_style.py +5 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_mllm.py +74 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_mllm_vendor.py +5 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_parameters.py +58 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_parameters_data_channel.py +5 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_parameters_farewell_config.py +34 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_parameters_silence_config.py +44 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_parameters_silence_config_action.py +5 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_rtc.py +45 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_sal.py +42 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_sal_sal_mode.py +5 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_turn_detection.py +105 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_turn_detection_config.py +47 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_turn_detection_config_end_of_speech.py +52 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_turn_detection_config_end_of_speech_mode.py +7 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_turn_detection_config_end_of_speech_semantic_config.py +25 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_turn_detection_config_end_of_speech_vad_config.py +24 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_turn_detection_config_start_of_speech.py +63 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_turn_detection_config_start_of_speech_disabled_config.py +34 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_turn_detection_config_start_of_speech_disabled_config_strategy.py +7 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_turn_detection_config_start_of_speech_keywords_config.py +26 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_turn_detection_config_start_of_speech_mode.py +7 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_turn_detection_config_start_of_speech_vad_config.py +26 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_turn_detection_eagerness.py +5 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_turn_detection_interrupt_mode.py +7 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_turn_detection_type.py +7 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_response.py +41 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_response_status.py +7 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/update_agents_request_properties.py +39 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/update_agents_request_properties_llm.py +32 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/update_agents_request_properties_mllm.py +27 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/update_agents_response.py +41 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/update_agents_response_status.py +7 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/client.py +227 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/core/__init__.py +34 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/core/api_error.py +23 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/core/client_wrapper.py +114 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/core/datetime_utils.py +28 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/core/domain.py +204 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/core/file.py +67 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/core/force_multipart.py +18 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/core/http_client.py +543 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/core/http_response.py +55 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/core/http_sse/__init__.py +42 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/core/http_sse/_api.py +112 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/core/http_sse/_decoders.py +61 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/core/http_sse/_exceptions.py +7 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/core/http_sse/_models.py +17 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/core/jsonable_encoder.py +100 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/core/pagination.py +82 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/core/pydantic_utilities.py +260 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/core/query_encoder.py +58 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/core/remove_none_from_dict.py +11 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/core/request_options.py +35 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/core/serialization.py +276 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/core/unchecked_base_model.py +376 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/environment.py +7 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/phone_numbers/__init__.py +4 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/phone_numbers/client.py +589 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/phone_numbers/raw_client.py +554 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/phone_numbers/types/__init__.py +4 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/phone_numbers/types/add_phone_numbers_request_inbound_config.py +27 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/phone_numbers/types/add_phone_numbers_request_outbound_config.py +37 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/phone_numbers/types/add_phone_numbers_request_provider.py +5 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/phone_numbers/types/add_phone_numbers_response.py +49 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/phone_numbers/types/add_phone_numbers_response_associated_pipeline.py +32 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/phone_numbers/types/get_phone_numbers_response.py +62 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/phone_numbers/types/get_phone_numbers_response_associated_pipeline.py +32 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/phone_numbers/types/get_phone_numbers_response_provider.py +5 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/phone_numbers/types/list_phone_numbers_response_item.py +62 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/phone_numbers/types/list_phone_numbers_response_item_associated_pipeline.py +32 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/phone_numbers/types/list_phone_numbers_response_item_provider.py +5 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/phone_numbers/types/update_phone_numbers_request_inbound_config.py +27 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/phone_numbers/types/update_phone_numbers_request_outbound_config.py +27 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/phone_numbers/types/update_phone_numbers_response.py +62 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/phone_numbers/types/update_phone_numbers_response_associated_pipeline.py +32 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/phone_numbers/types/update_phone_numbers_response_provider.py +5 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/pool_client.py +546 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/py.typed +0 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/telephony/__init__.py +4 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/telephony/client.py +554 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/telephony/raw_client.py +557 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/telephony/types/__init__.py +4 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/telephony/types/call_telephony_request_properties.py +44 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/telephony/types/call_telephony_request_sip.py +42 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/telephony/types/call_telephony_response.py +23 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/telephony/types/get_telephony_response.py +78 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/telephony/types/get_telephony_response_reason.py +5 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/telephony/types/get_telephony_response_state.py +5 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/telephony/types/get_telephony_response_type.py +5 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/telephony/types/hangup_telephony_response.py +18 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/telephony/types/list_telephony_request_type.py +5 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/telephony/types/list_telephony_response.py +35 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/telephony/types/list_telephony_response_data.py +37 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/telephony/types/list_telephony_response_data_list_item.py +69 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/telephony/types/list_telephony_response_data_list_item_state.py +5 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/telephony/types/list_telephony_response_data_list_item_type.py +5 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/telephony/types/list_telephony_response_meta.py +32 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/types/__init__.py +4 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/types/amazon_tts.py +29 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/types/amazon_tts_params.py +42 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/types/cartesia_tts.py +29 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/types/cartesia_tts_params.py +42 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/types/eleven_labs_tts.py +29 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/types/eleven_labs_tts_params.py +47 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/types/fish_audio_tts.py +29 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/types/fish_audio_tts_params.py +32 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/types/google_tts.py +29 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/types/google_tts_params.py +42 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/types/hume_ai_tts.py +29 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/types/hume_ai_tts_params.py +32 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/types/microsoft_tts.py +29 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/types/microsoft_tts_params.py +42 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/types/minimax_tts.py +29 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/types/minimax_tts_params.py +44 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/types/minimax_tts_params_voice_setting.py +23 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/types/murf_tts.py +29 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/types/murf_tts_params.py +37 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/types/open_ai_tts.py +29 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/types/open_ai_tts_params.py +37 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/types/rime_tts.py +29 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/types/rime_tts_params.py +37 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/types/sarvam_tts.py +29 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/types/sarvam_tts_params.py +37 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/types/tts.py +221 -0
- agent_server_sdk-1.0.0/src/shengwang_agent/version.py +3 -0
|
@@ -0,0 +1,429 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: agent-server-sdk
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary:
|
|
5
|
+
Requires-Python: >=3.8,<4.0
|
|
6
|
+
Classifier: Intended Audience :: Developers
|
|
7
|
+
Classifier: Operating System :: MacOS
|
|
8
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Classifier: Operating System :: POSIX
|
|
11
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
12
|
+
Classifier: Programming Language :: Python
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
21
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
22
|
+
Classifier: Typing :: Typed
|
|
23
|
+
Requires-Dist: httpx (>=0.21.2)
|
|
24
|
+
Requires-Dist: pydantic (>=1.9.2)
|
|
25
|
+
Requires-Dist: pydantic-core (>=2.18.2)
|
|
26
|
+
Requires-Dist: typing_extensions (>=4.0.0)
|
|
27
|
+
Project-URL: Repository, https://github.com/Shengwang-Community/agent-server-sdk-python
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
|
|
30
|
+
# Agent Server SDK for Python
|
|
31
|
+
|
|
32
|
+
[](https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=https%3A%2F%2Fgithub.com%2FShengwang-Community%2Fagent-server-sdk-python)
|
|
33
|
+
[](https://pypi.python.org/pypi/agent-server-sdk)
|
|
34
|
+
|
|
35
|
+
The Conversational AI SDK provides convenient access to the Conversational AI APIs,
|
|
36
|
+
enabling you to build voice-powered AI agents with support for cascading flows (ASR -> LLM -> TTS).
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
## Table of Contents
|
|
40
|
+
|
|
41
|
+
- [Installation](#installation)
|
|
42
|
+
- [Quick Start](#quick-start)
|
|
43
|
+
- [Documentation](#documentation)
|
|
44
|
+
- [Reference](#reference)
|
|
45
|
+
- [Usage](#usage)
|
|
46
|
+
- [Async Client](#async-client)
|
|
47
|
+
- [Exception Handling](#exception-handling)
|
|
48
|
+
- [Pagination](#pagination)
|
|
49
|
+
- [Advanced](#advanced)
|
|
50
|
+
- [Access Raw Response Data](#access-raw-response-data)
|
|
51
|
+
- [Retries](#retries)
|
|
52
|
+
- [Timeouts](#timeouts)
|
|
53
|
+
- [Custom Client](#custom-client)
|
|
54
|
+
- [Contributing](#contributing)
|
|
55
|
+
|
|
56
|
+
## Installation
|
|
57
|
+
|
|
58
|
+
```sh
|
|
59
|
+
pip install agent-server-sdk
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Quick Start
|
|
63
|
+
|
|
64
|
+
Use the **builder pattern** with `Agent` and `AgentSession`. The SDK auto-generates all required tokens:
|
|
65
|
+
|
|
66
|
+
```python
|
|
67
|
+
from shengwang_agent import AgentClient, Area
|
|
68
|
+
from shengwang_agent.agentkit import Agent, expires_in_hours
|
|
69
|
+
from shengwang_agent.agentkit.vendors import AliyunLLM, MiniMaxTTS, FengmingSTT
|
|
70
|
+
|
|
71
|
+
client = AgentClient(
|
|
72
|
+
area=Area.CN,
|
|
73
|
+
app_id="your-app-id",
|
|
74
|
+
app_certificate="your-app-certificate",
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
agent = (
|
|
78
|
+
Agent(name="support-assistant", instructions="你是一个智能语音助手。")
|
|
79
|
+
# Create Agent: STT → LLM → TTS → (optional) Avatar
|
|
80
|
+
.with_stt(FengmingSTT(language="zh-CN"))
|
|
81
|
+
.with_llm(AliyunLLM(api_key="your-aliyun-key", model="qwen-max"))
|
|
82
|
+
.with_tts(MiniMaxTTS(key="your-minimax-key", voice_id="your-voice-id"))
|
|
83
|
+
# .with_avatar(SensetimeAvatar(...)) # optional
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
session = agent.create_session(
|
|
87
|
+
client,
|
|
88
|
+
channel="support-room-123",
|
|
89
|
+
agent_uid="1",
|
|
90
|
+
remote_uids=["100"],
|
|
91
|
+
expires_in=expires_in_hours(12), # optional — default is 24 h
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
# start() returns a session ID unique to this agent session
|
|
95
|
+
agent_session_id = session.start()
|
|
96
|
+
|
|
97
|
+
# In production, stop is typically called when your client signals the session has ended.
|
|
98
|
+
# Your server receives that request and calls session.stop().
|
|
99
|
+
session.stop()
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
For async usage, use `AsyncAgentClient` and `await session.start()`, etc. See [Quick Start](docs/getting-started/quick-start.md).
|
|
103
|
+
|
|
104
|
+
### Session lifecycle
|
|
105
|
+
|
|
106
|
+
`start()` joins the agent to the channel and returns a **session ID** — a unique identifier for this agent session. The session stays active until `stop()` is called.
|
|
107
|
+
|
|
108
|
+
There are two ways to stop a session depending on how your server is structured:
|
|
109
|
+
|
|
110
|
+
**Option 1 — Hold the session in memory:**
|
|
111
|
+
|
|
112
|
+
```python
|
|
113
|
+
# start-session handler
|
|
114
|
+
agent_session_id = session.start() # unique ID for this session
|
|
115
|
+
# stop-session handler (same process, session still in scope)
|
|
116
|
+
session.stop()
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
**Option 2 — Store the session ID and stop by ID (stateless servers):**
|
|
120
|
+
|
|
121
|
+
```python
|
|
122
|
+
# start-session handler: return session ID to your client app
|
|
123
|
+
agent_session_id = session.start()
|
|
124
|
+
# ... return agent_session_id to client ...
|
|
125
|
+
|
|
126
|
+
# stop-session handler: client sends back agent_session_id
|
|
127
|
+
client = AgentClient(area=Area.CN, app_id="...", app_certificate="...")
|
|
128
|
+
client.stop_agent(agent_session_id)
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Manual tokens (for debugging)
|
|
132
|
+
|
|
133
|
+
Generate tokens yourself and pass them in — useful when inspecting or reusing tokens:
|
|
134
|
+
|
|
135
|
+
```python
|
|
136
|
+
from shengwang_agent import AgentClient, Area
|
|
137
|
+
from shengwang_agent.agentkit.token import generate_convo_ai_token, expires_in_hours
|
|
138
|
+
|
|
139
|
+
APP_ID = "your-app-id"
|
|
140
|
+
APP_CERT = "your-app-certificate"
|
|
141
|
+
CHANNEL = "support-room-123"
|
|
142
|
+
AGENT_UID = "1"
|
|
143
|
+
|
|
144
|
+
# Auth header token — used by the SDK to authenticate REST API calls
|
|
145
|
+
auth_token = generate_convo_ai_token(
|
|
146
|
+
app_id=APP_ID, app_certificate=APP_CERT,
|
|
147
|
+
channel_name=CHANNEL, account=AGENT_UID,
|
|
148
|
+
token_expire=expires_in_hours(12),
|
|
149
|
+
)
|
|
150
|
+
|
|
151
|
+
# Channel join token — embedded in the start request so the agent can join the channel
|
|
152
|
+
join_token = generate_convo_ai_token(
|
|
153
|
+
app_id=APP_ID, app_certificate=APP_CERT,
|
|
154
|
+
channel_name=CHANNEL, account=AGENT_UID,
|
|
155
|
+
token_expire=expires_in_hours(12),
|
|
156
|
+
)
|
|
157
|
+
|
|
158
|
+
client = AgentClient(
|
|
159
|
+
area=Area.CN,
|
|
160
|
+
app_id=APP_ID,
|
|
161
|
+
app_certificate=APP_CERT,
|
|
162
|
+
auth_token=auth_token, # SDK sets Authorization: agora token=<auth_token>
|
|
163
|
+
)
|
|
164
|
+
|
|
165
|
+
session = agent.create_session(
|
|
166
|
+
client, channel=CHANNEL, agent_uid=AGENT_UID, remote_uids=["100"],
|
|
167
|
+
token=join_token, # channel join token
|
|
168
|
+
)
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## Documentation
|
|
172
|
+
|
|
173
|
+
API reference documentation is available [here](docs/index.md).
|
|
174
|
+
|
|
175
|
+
## Reference
|
|
176
|
+
|
|
177
|
+
A full reference for this library is available [here](https://github.com/Shengwang-Community/agent-server-sdk-python/blob/HEAD/./reference.md).
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
## Usage
|
|
181
|
+
|
|
182
|
+
Instantiate and use the client with the following:
|
|
183
|
+
|
|
184
|
+
```python
|
|
185
|
+
from shengwang_agent import AgentClient, MicrosoftTtsParams, Tts_Microsoft
|
|
186
|
+
from shengwang_agent.agents import (
|
|
187
|
+
StartAgentsRequestProperties,
|
|
188
|
+
StartAgentsRequestPropertiesAsr,
|
|
189
|
+
StartAgentsRequestPropertiesLlm,
|
|
190
|
+
)
|
|
191
|
+
|
|
192
|
+
client = AgentClient(
|
|
193
|
+
authorization="YOUR_AUTHORIZATION",
|
|
194
|
+
username="YOUR_USERNAME",
|
|
195
|
+
password="YOUR_PASSWORD",
|
|
196
|
+
)
|
|
197
|
+
client.agents.start(
|
|
198
|
+
appid="appid",
|
|
199
|
+
name="unique_name",
|
|
200
|
+
properties=StartAgentsRequestProperties(
|
|
201
|
+
channel="channel_name",
|
|
202
|
+
token="token",
|
|
203
|
+
agent_rtc_uid="1001",
|
|
204
|
+
remote_rtc_uids=["1002"],
|
|
205
|
+
idle_timeout=120,
|
|
206
|
+
asr=StartAgentsRequestPropertiesAsr(
|
|
207
|
+
language="zh-CN",
|
|
208
|
+
),
|
|
209
|
+
tts=Tts_Microsoft(
|
|
210
|
+
params=MicrosoftTtsParams(
|
|
211
|
+
key="key",
|
|
212
|
+
region="eastasia",
|
|
213
|
+
voice_name="zh-CN-XiaoxiaoNeural",
|
|
214
|
+
),
|
|
215
|
+
),
|
|
216
|
+
llm=StartAgentsRequestPropertiesLlm(
|
|
217
|
+
url="https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",
|
|
218
|
+
api_key="<your_llm_key>",
|
|
219
|
+
system_messages=[
|
|
220
|
+
{"role": "system", "content": "你是一个智能助手。"}
|
|
221
|
+
],
|
|
222
|
+
params={"model": "qwen-max"},
|
|
223
|
+
max_history=32,
|
|
224
|
+
greeting_message="你好,有什么可以帮助你的?",
|
|
225
|
+
failure_message="请稍等一下。",
|
|
226
|
+
),
|
|
227
|
+
),
|
|
228
|
+
)
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
## Async Client
|
|
232
|
+
|
|
233
|
+
The SDK also exports an `async` client so that you can make non-blocking calls to our API. Note that if you are constructing an Async httpx client class to pass into this client, use `httpx.AsyncClient()` instead of `httpx.Client()` (e.g. for the `httpx_client` parameter of this client).
|
|
234
|
+
|
|
235
|
+
```python
|
|
236
|
+
import asyncio
|
|
237
|
+
|
|
238
|
+
from shengwang_agent import AsyncAgentClient, MicrosoftTtsParams, Tts_Microsoft
|
|
239
|
+
from shengwang_agent.agents import (
|
|
240
|
+
StartAgentsRequestProperties,
|
|
241
|
+
StartAgentsRequestPropertiesAsr,
|
|
242
|
+
StartAgentsRequestPropertiesLlm,
|
|
243
|
+
)
|
|
244
|
+
|
|
245
|
+
client = AsyncAgentClient(
|
|
246
|
+
authorization="YOUR_AUTHORIZATION",
|
|
247
|
+
username="YOUR_USERNAME",
|
|
248
|
+
password="YOUR_PASSWORD",
|
|
249
|
+
)
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
async def main() -> None:
|
|
253
|
+
await client.agents.start(
|
|
254
|
+
appid="appid",
|
|
255
|
+
name="unique_name",
|
|
256
|
+
properties=StartAgentsRequestProperties(
|
|
257
|
+
channel="channel_name",
|
|
258
|
+
token="token",
|
|
259
|
+
agent_rtc_uid="1001",
|
|
260
|
+
remote_rtc_uids=["1002"],
|
|
261
|
+
idle_timeout=120,
|
|
262
|
+
asr=StartAgentsRequestPropertiesAsr(
|
|
263
|
+
language="zh-CN",
|
|
264
|
+
),
|
|
265
|
+
tts=Tts_Microsoft(
|
|
266
|
+
params=MicrosoftTtsParams(
|
|
267
|
+
key="key",
|
|
268
|
+
region="eastasia",
|
|
269
|
+
voice_name="zh-CN-XiaoxiaoNeural",
|
|
270
|
+
),
|
|
271
|
+
),
|
|
272
|
+
llm=StartAgentsRequestPropertiesLlm(
|
|
273
|
+
url="https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",
|
|
274
|
+
api_key="<your_llm_key>",
|
|
275
|
+
system_messages=[
|
|
276
|
+
{"role": "system", "content": "你是一个智能助手。"}
|
|
277
|
+
],
|
|
278
|
+
params={"model": "qwen-max"},
|
|
279
|
+
max_history=32,
|
|
280
|
+
greeting_message="你好,有什么可以帮助你的?",
|
|
281
|
+
failure_message="请稍等一下。",
|
|
282
|
+
),
|
|
283
|
+
),
|
|
284
|
+
)
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
asyncio.run(main())
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
## Exception Handling
|
|
291
|
+
|
|
292
|
+
When the API returns a non-success status code (4xx or 5xx response), a subclass of the following error
|
|
293
|
+
will be thrown.
|
|
294
|
+
|
|
295
|
+
```python
|
|
296
|
+
from shengwang_agent.core.api_error import ApiError
|
|
297
|
+
|
|
298
|
+
try:
|
|
299
|
+
client.agents.start(...)
|
|
300
|
+
except ApiError as e:
|
|
301
|
+
print(e.status_code)
|
|
302
|
+
print(e.body)
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
## Pagination
|
|
306
|
+
|
|
307
|
+
Paginated requests will return a `SyncPager` or `AsyncPager`, which can be used as generators for the underlying object.
|
|
308
|
+
|
|
309
|
+
```python
|
|
310
|
+
from shengwang_agent import AgentClient
|
|
311
|
+
|
|
312
|
+
client = AgentClient(
|
|
313
|
+
authorization="YOUR_AUTHORIZATION",
|
|
314
|
+
username="YOUR_USERNAME",
|
|
315
|
+
password="YOUR_PASSWORD",
|
|
316
|
+
)
|
|
317
|
+
response = client.agents.list(
|
|
318
|
+
appid="appid",
|
|
319
|
+
)
|
|
320
|
+
for item in response:
|
|
321
|
+
yield item
|
|
322
|
+
# alternatively, you can paginate page-by-page
|
|
323
|
+
for page in response.iter_pages():
|
|
324
|
+
yield page
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
```python
|
|
328
|
+
# You can also iterate through pages and access the typed response per page
|
|
329
|
+
pager = client.agents.list(...)
|
|
330
|
+
for page in pager.iter_pages():
|
|
331
|
+
print(page.response) # access the typed response for each page
|
|
332
|
+
for item in page:
|
|
333
|
+
print(item)
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
## Advanced
|
|
337
|
+
|
|
338
|
+
### Access Raw Response Data
|
|
339
|
+
|
|
340
|
+
The SDK provides access to raw response data, including headers, through the `.with_raw_response` property.
|
|
341
|
+
The `.with_raw_response` property returns a "raw" client that can be used to access the `.headers` and `.data` attributes.
|
|
342
|
+
|
|
343
|
+
```python
|
|
344
|
+
from shengwang_agent import AgentClient
|
|
345
|
+
|
|
346
|
+
client = AgentClient(
|
|
347
|
+
...,
|
|
348
|
+
)
|
|
349
|
+
response = client.agents.with_raw_response.start(...)
|
|
350
|
+
print(response.headers) # access the response headers
|
|
351
|
+
print(response.data) # access the underlying object
|
|
352
|
+
pager = client.agents.list(...)
|
|
353
|
+
print(pager.response) # access the typed response for the first page
|
|
354
|
+
for item in pager:
|
|
355
|
+
print(item) # access the underlying object(s)
|
|
356
|
+
for page in pager.iter_pages():
|
|
357
|
+
print(page.response) # access the typed response for each page
|
|
358
|
+
for item in page:
|
|
359
|
+
print(item) # access the underlying object(s)
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
### Retries
|
|
363
|
+
|
|
364
|
+
The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long
|
|
365
|
+
as the request is deemed retryable and the number of retry attempts has not grown larger than the configured
|
|
366
|
+
retry limit (default: 2).
|
|
367
|
+
|
|
368
|
+
A request is deemed retryable when any of the following HTTP status codes is returned:
|
|
369
|
+
|
|
370
|
+
- [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)
|
|
371
|
+
- [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)
|
|
372
|
+
- [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500) (Internal Server Errors)
|
|
373
|
+
|
|
374
|
+
Use the `max_retries` request option to configure this behavior.
|
|
375
|
+
|
|
376
|
+
```python
|
|
377
|
+
client.agents.start(..., request_options={
|
|
378
|
+
"max_retries": 1
|
|
379
|
+
})
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
### Timeouts
|
|
383
|
+
|
|
384
|
+
The SDK defaults to a 60 second timeout. You can configure this with a timeout option at the client or request level.
|
|
385
|
+
|
|
386
|
+
```python
|
|
387
|
+
|
|
388
|
+
from shengwang_agent import AgentClient
|
|
389
|
+
|
|
390
|
+
client = AgentClient(
|
|
391
|
+
...,
|
|
392
|
+
timeout=20.0,
|
|
393
|
+
)
|
|
394
|
+
|
|
395
|
+
|
|
396
|
+
# Override timeout for a specific method
|
|
397
|
+
client.agents.start(..., request_options={
|
|
398
|
+
"timeout_in_seconds": 1
|
|
399
|
+
})
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
### Custom Client
|
|
403
|
+
|
|
404
|
+
You can override the `httpx` client to customize it for your use-case. Some common use-cases include support for proxies
|
|
405
|
+
and transports.
|
|
406
|
+
|
|
407
|
+
```python
|
|
408
|
+
import httpx
|
|
409
|
+
from shengwang_agent import AgentClient
|
|
410
|
+
|
|
411
|
+
client = AgentClient(
|
|
412
|
+
...,
|
|
413
|
+
httpx_client=httpx.Client(
|
|
414
|
+
proxy="http://my.test.proxy.example.com",
|
|
415
|
+
transport=httpx.HTTPTransport(local_address="0.0.0.0"),
|
|
416
|
+
),
|
|
417
|
+
)
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
## Contributing
|
|
421
|
+
|
|
422
|
+
While we value open-source contributions to this SDK, this library is generated programmatically.
|
|
423
|
+
Additions made directly to this library would have to be moved over to our generation code,
|
|
424
|
+
otherwise they would be overwritten upon the next generated release. Feel free to open a PR as
|
|
425
|
+
a proof of concept, but know that we will not be able to merge it as-is. We suggest opening
|
|
426
|
+
an issue first to discuss with us!
|
|
427
|
+
|
|
428
|
+
On the other hand, contributions to the README are always very welcome!
|
|
429
|
+
|