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.
Files changed (180) hide show
  1. agent_server_sdk-1.0.0/PKG-INFO +429 -0
  2. agent_server_sdk-1.0.0/README.md +399 -0
  3. agent_server_sdk-1.0.0/pyproject.toml +84 -0
  4. agent_server_sdk-1.0.0/src/shengwang_agent/__init__.py +81 -0
  5. agent_server_sdk-1.0.0/src/shengwang_agent/agentkit/__init__.py +185 -0
  6. agent_server_sdk-1.0.0/src/shengwang_agent/agentkit/agent.py +562 -0
  7. agent_server_sdk-1.0.0/src/shengwang_agent/agentkit/agent_session.py +579 -0
  8. agent_server_sdk-1.0.0/src/shengwang_agent/agentkit/avatar_types.py +60 -0
  9. agent_server_sdk-1.0.0/src/shengwang_agent/agentkit/constants.py +55 -0
  10. agent_server_sdk-1.0.0/src/shengwang_agent/agentkit/token.py +312 -0
  11. agent_server_sdk-1.0.0/src/shengwang_agent/agentkit/vendors/__init__.py +62 -0
  12. agent_server_sdk-1.0.0/src/shengwang_agent/agentkit/vendors/avatar.py +42 -0
  13. agent_server_sdk-1.0.0/src/shengwang_agent/agentkit/vendors/base.py +60 -0
  14. agent_server_sdk-1.0.0/src/shengwang_agent/agentkit/vendors/llm.py +135 -0
  15. agent_server_sdk-1.0.0/src/shengwang_agent/agentkit/vendors/mllm.py +5 -0
  16. agent_server_sdk-1.0.0/src/shengwang_agent/agentkit/vendors/stt.py +226 -0
  17. agent_server_sdk-1.0.0/src/shengwang_agent/agentkit/vendors/tts.py +307 -0
  18. agent_server_sdk-1.0.0/src/shengwang_agent/agents/__init__.py +4 -0
  19. agent_server_sdk-1.0.0/src/shengwang_agent/agents/client.py +1030 -0
  20. agent_server_sdk-1.0.0/src/shengwang_agent/agents/raw_client.py +961 -0
  21. agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/__init__.py +4 -0
  22. agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/get_agents_response.py +51 -0
  23. agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/get_agents_response_status.py +7 -0
  24. agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/get_history_agents_response.py +39 -0
  25. agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/get_history_agents_response_contents_item.py +31 -0
  26. agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/get_history_agents_response_contents_item_role.py +5 -0
  27. agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/interrupt_agents_response.py +33 -0
  28. agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/list_agents_request_state.py +5 -0
  29. agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/list_agents_response.py +35 -0
  30. agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/list_agents_response_data.py +37 -0
  31. agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/list_agents_response_data_list_item.py +34 -0
  32. agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/list_agents_response_data_list_item_status.py +7 -0
  33. agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/list_agents_response_meta.py +32 -0
  34. agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/speak_agents_request_priority.py +5 -0
  35. agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/speak_agents_response.py +33 -0
  36. agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties.py +131 -0
  37. agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_advanced_features.py +47 -0
  38. agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_asr.py +47 -0
  39. agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_asr_vendor.py +10 -0
  40. agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_avatar.py +40 -0
  41. agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_avatar_vendor.py +5 -0
  42. agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_filler_words.py +41 -0
  43. agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_filler_words_content.py +38 -0
  44. agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_filler_words_content_static_config.py +39 -0
  45. 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
  46. agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_filler_words_trigger.py +38 -0
  47. agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_filler_words_trigger_fixed_time_config.py +27 -0
  48. agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_geofence.py +34 -0
  49. agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_geofence_area.py +7 -0
  50. agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_geofence_exclude_area.py +7 -0
  51. agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_llm.py +110 -0
  52. agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_llm_greeting_configs.py +32 -0
  53. agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_llm_greeting_configs_mode.py +7 -0
  54. agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_llm_mcp_servers_item.py +54 -0
  55. agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_llm_style.py +5 -0
  56. agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_mllm.py +74 -0
  57. agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_mllm_vendor.py +5 -0
  58. agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_parameters.py +58 -0
  59. agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_parameters_data_channel.py +5 -0
  60. agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_parameters_farewell_config.py +34 -0
  61. agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_parameters_silence_config.py +44 -0
  62. agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_parameters_silence_config_action.py +5 -0
  63. agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_rtc.py +45 -0
  64. agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_sal.py +42 -0
  65. agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_sal_sal_mode.py +5 -0
  66. agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_turn_detection.py +105 -0
  67. agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_turn_detection_config.py +47 -0
  68. agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_turn_detection_config_end_of_speech.py +52 -0
  69. 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
  70. 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
  71. 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
  72. agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_turn_detection_config_start_of_speech.py +63 -0
  73. 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
  74. 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
  75. 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
  76. 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
  77. 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
  78. agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_turn_detection_eagerness.py +5 -0
  79. agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_turn_detection_interrupt_mode.py +7 -0
  80. agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_request_properties_turn_detection_type.py +7 -0
  81. agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_response.py +41 -0
  82. agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/start_agents_response_status.py +7 -0
  83. agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/update_agents_request_properties.py +39 -0
  84. agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/update_agents_request_properties_llm.py +32 -0
  85. agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/update_agents_request_properties_mllm.py +27 -0
  86. agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/update_agents_response.py +41 -0
  87. agent_server_sdk-1.0.0/src/shengwang_agent/agents/types/update_agents_response_status.py +7 -0
  88. agent_server_sdk-1.0.0/src/shengwang_agent/client.py +227 -0
  89. agent_server_sdk-1.0.0/src/shengwang_agent/core/__init__.py +34 -0
  90. agent_server_sdk-1.0.0/src/shengwang_agent/core/api_error.py +23 -0
  91. agent_server_sdk-1.0.0/src/shengwang_agent/core/client_wrapper.py +114 -0
  92. agent_server_sdk-1.0.0/src/shengwang_agent/core/datetime_utils.py +28 -0
  93. agent_server_sdk-1.0.0/src/shengwang_agent/core/domain.py +204 -0
  94. agent_server_sdk-1.0.0/src/shengwang_agent/core/file.py +67 -0
  95. agent_server_sdk-1.0.0/src/shengwang_agent/core/force_multipart.py +18 -0
  96. agent_server_sdk-1.0.0/src/shengwang_agent/core/http_client.py +543 -0
  97. agent_server_sdk-1.0.0/src/shengwang_agent/core/http_response.py +55 -0
  98. agent_server_sdk-1.0.0/src/shengwang_agent/core/http_sse/__init__.py +42 -0
  99. agent_server_sdk-1.0.0/src/shengwang_agent/core/http_sse/_api.py +112 -0
  100. agent_server_sdk-1.0.0/src/shengwang_agent/core/http_sse/_decoders.py +61 -0
  101. agent_server_sdk-1.0.0/src/shengwang_agent/core/http_sse/_exceptions.py +7 -0
  102. agent_server_sdk-1.0.0/src/shengwang_agent/core/http_sse/_models.py +17 -0
  103. agent_server_sdk-1.0.0/src/shengwang_agent/core/jsonable_encoder.py +100 -0
  104. agent_server_sdk-1.0.0/src/shengwang_agent/core/pagination.py +82 -0
  105. agent_server_sdk-1.0.0/src/shengwang_agent/core/pydantic_utilities.py +260 -0
  106. agent_server_sdk-1.0.0/src/shengwang_agent/core/query_encoder.py +58 -0
  107. agent_server_sdk-1.0.0/src/shengwang_agent/core/remove_none_from_dict.py +11 -0
  108. agent_server_sdk-1.0.0/src/shengwang_agent/core/request_options.py +35 -0
  109. agent_server_sdk-1.0.0/src/shengwang_agent/core/serialization.py +276 -0
  110. agent_server_sdk-1.0.0/src/shengwang_agent/core/unchecked_base_model.py +376 -0
  111. agent_server_sdk-1.0.0/src/shengwang_agent/environment.py +7 -0
  112. agent_server_sdk-1.0.0/src/shengwang_agent/phone_numbers/__init__.py +4 -0
  113. agent_server_sdk-1.0.0/src/shengwang_agent/phone_numbers/client.py +589 -0
  114. agent_server_sdk-1.0.0/src/shengwang_agent/phone_numbers/raw_client.py +554 -0
  115. agent_server_sdk-1.0.0/src/shengwang_agent/phone_numbers/types/__init__.py +4 -0
  116. agent_server_sdk-1.0.0/src/shengwang_agent/phone_numbers/types/add_phone_numbers_request_inbound_config.py +27 -0
  117. agent_server_sdk-1.0.0/src/shengwang_agent/phone_numbers/types/add_phone_numbers_request_outbound_config.py +37 -0
  118. agent_server_sdk-1.0.0/src/shengwang_agent/phone_numbers/types/add_phone_numbers_request_provider.py +5 -0
  119. agent_server_sdk-1.0.0/src/shengwang_agent/phone_numbers/types/add_phone_numbers_response.py +49 -0
  120. agent_server_sdk-1.0.0/src/shengwang_agent/phone_numbers/types/add_phone_numbers_response_associated_pipeline.py +32 -0
  121. agent_server_sdk-1.0.0/src/shengwang_agent/phone_numbers/types/get_phone_numbers_response.py +62 -0
  122. agent_server_sdk-1.0.0/src/shengwang_agent/phone_numbers/types/get_phone_numbers_response_associated_pipeline.py +32 -0
  123. agent_server_sdk-1.0.0/src/shengwang_agent/phone_numbers/types/get_phone_numbers_response_provider.py +5 -0
  124. agent_server_sdk-1.0.0/src/shengwang_agent/phone_numbers/types/list_phone_numbers_response_item.py +62 -0
  125. agent_server_sdk-1.0.0/src/shengwang_agent/phone_numbers/types/list_phone_numbers_response_item_associated_pipeline.py +32 -0
  126. agent_server_sdk-1.0.0/src/shengwang_agent/phone_numbers/types/list_phone_numbers_response_item_provider.py +5 -0
  127. agent_server_sdk-1.0.0/src/shengwang_agent/phone_numbers/types/update_phone_numbers_request_inbound_config.py +27 -0
  128. agent_server_sdk-1.0.0/src/shengwang_agent/phone_numbers/types/update_phone_numbers_request_outbound_config.py +27 -0
  129. agent_server_sdk-1.0.0/src/shengwang_agent/phone_numbers/types/update_phone_numbers_response.py +62 -0
  130. agent_server_sdk-1.0.0/src/shengwang_agent/phone_numbers/types/update_phone_numbers_response_associated_pipeline.py +32 -0
  131. agent_server_sdk-1.0.0/src/shengwang_agent/phone_numbers/types/update_phone_numbers_response_provider.py +5 -0
  132. agent_server_sdk-1.0.0/src/shengwang_agent/pool_client.py +546 -0
  133. agent_server_sdk-1.0.0/src/shengwang_agent/py.typed +0 -0
  134. agent_server_sdk-1.0.0/src/shengwang_agent/telephony/__init__.py +4 -0
  135. agent_server_sdk-1.0.0/src/shengwang_agent/telephony/client.py +554 -0
  136. agent_server_sdk-1.0.0/src/shengwang_agent/telephony/raw_client.py +557 -0
  137. agent_server_sdk-1.0.0/src/shengwang_agent/telephony/types/__init__.py +4 -0
  138. agent_server_sdk-1.0.0/src/shengwang_agent/telephony/types/call_telephony_request_properties.py +44 -0
  139. agent_server_sdk-1.0.0/src/shengwang_agent/telephony/types/call_telephony_request_sip.py +42 -0
  140. agent_server_sdk-1.0.0/src/shengwang_agent/telephony/types/call_telephony_response.py +23 -0
  141. agent_server_sdk-1.0.0/src/shengwang_agent/telephony/types/get_telephony_response.py +78 -0
  142. agent_server_sdk-1.0.0/src/shengwang_agent/telephony/types/get_telephony_response_reason.py +5 -0
  143. agent_server_sdk-1.0.0/src/shengwang_agent/telephony/types/get_telephony_response_state.py +5 -0
  144. agent_server_sdk-1.0.0/src/shengwang_agent/telephony/types/get_telephony_response_type.py +5 -0
  145. agent_server_sdk-1.0.0/src/shengwang_agent/telephony/types/hangup_telephony_response.py +18 -0
  146. agent_server_sdk-1.0.0/src/shengwang_agent/telephony/types/list_telephony_request_type.py +5 -0
  147. agent_server_sdk-1.0.0/src/shengwang_agent/telephony/types/list_telephony_response.py +35 -0
  148. agent_server_sdk-1.0.0/src/shengwang_agent/telephony/types/list_telephony_response_data.py +37 -0
  149. agent_server_sdk-1.0.0/src/shengwang_agent/telephony/types/list_telephony_response_data_list_item.py +69 -0
  150. agent_server_sdk-1.0.0/src/shengwang_agent/telephony/types/list_telephony_response_data_list_item_state.py +5 -0
  151. agent_server_sdk-1.0.0/src/shengwang_agent/telephony/types/list_telephony_response_data_list_item_type.py +5 -0
  152. agent_server_sdk-1.0.0/src/shengwang_agent/telephony/types/list_telephony_response_meta.py +32 -0
  153. agent_server_sdk-1.0.0/src/shengwang_agent/types/__init__.py +4 -0
  154. agent_server_sdk-1.0.0/src/shengwang_agent/types/amazon_tts.py +29 -0
  155. agent_server_sdk-1.0.0/src/shengwang_agent/types/amazon_tts_params.py +42 -0
  156. agent_server_sdk-1.0.0/src/shengwang_agent/types/cartesia_tts.py +29 -0
  157. agent_server_sdk-1.0.0/src/shengwang_agent/types/cartesia_tts_params.py +42 -0
  158. agent_server_sdk-1.0.0/src/shengwang_agent/types/eleven_labs_tts.py +29 -0
  159. agent_server_sdk-1.0.0/src/shengwang_agent/types/eleven_labs_tts_params.py +47 -0
  160. agent_server_sdk-1.0.0/src/shengwang_agent/types/fish_audio_tts.py +29 -0
  161. agent_server_sdk-1.0.0/src/shengwang_agent/types/fish_audio_tts_params.py +32 -0
  162. agent_server_sdk-1.0.0/src/shengwang_agent/types/google_tts.py +29 -0
  163. agent_server_sdk-1.0.0/src/shengwang_agent/types/google_tts_params.py +42 -0
  164. agent_server_sdk-1.0.0/src/shengwang_agent/types/hume_ai_tts.py +29 -0
  165. agent_server_sdk-1.0.0/src/shengwang_agent/types/hume_ai_tts_params.py +32 -0
  166. agent_server_sdk-1.0.0/src/shengwang_agent/types/microsoft_tts.py +29 -0
  167. agent_server_sdk-1.0.0/src/shengwang_agent/types/microsoft_tts_params.py +42 -0
  168. agent_server_sdk-1.0.0/src/shengwang_agent/types/minimax_tts.py +29 -0
  169. agent_server_sdk-1.0.0/src/shengwang_agent/types/minimax_tts_params.py +44 -0
  170. agent_server_sdk-1.0.0/src/shengwang_agent/types/minimax_tts_params_voice_setting.py +23 -0
  171. agent_server_sdk-1.0.0/src/shengwang_agent/types/murf_tts.py +29 -0
  172. agent_server_sdk-1.0.0/src/shengwang_agent/types/murf_tts_params.py +37 -0
  173. agent_server_sdk-1.0.0/src/shengwang_agent/types/open_ai_tts.py +29 -0
  174. agent_server_sdk-1.0.0/src/shengwang_agent/types/open_ai_tts_params.py +37 -0
  175. agent_server_sdk-1.0.0/src/shengwang_agent/types/rime_tts.py +29 -0
  176. agent_server_sdk-1.0.0/src/shengwang_agent/types/rime_tts_params.py +37 -0
  177. agent_server_sdk-1.0.0/src/shengwang_agent/types/sarvam_tts.py +29 -0
  178. agent_server_sdk-1.0.0/src/shengwang_agent/types/sarvam_tts_params.py +37 -0
  179. agent_server_sdk-1.0.0/src/shengwang_agent/types/tts.py +221 -0
  180. 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
+ [![fern shield](https://img.shields.io/badge/%F0%9F%8C%BF-Built%20with%20Fern-brightgreen)](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
+ [![pypi](https://img.shields.io/pypi/v/agent-server-sdk)](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
+