22
33from __future__ import annotations
44
5- from typing import Dict , Union , Optional
5+ from typing import Any , Dict , Union , Optional , cast
66
77import httpx
88
9- from ...types import chat_list_params , chat_create_params
9+ from ...types import chat_list_params , chat_create_params , chat_post_message_params
1010from ..._types import NOT_GIVEN , Body , Query , Headers , NoneType , NotGiven
1111from ..._utils import (
1212 maybe_transform ,
3232from ...types .chat import Chat
3333from ..._base_client import AsyncPaginator , make_request_options
3434from ...types .chat_retrieve_response import ChatRetrieveResponse
35+ from ...types .chat_post_message_response import ChatPostMessageResponse
3536
3637__all__ = ["ChatsResource" , "AsyncChatsResource" ]
3738
@@ -231,6 +232,49 @@ def delete(
231232 cast_to = NoneType ,
232233 )
233234
235+ def post_message (
236+ self ,
237+ chat_id : str ,
238+ * ,
239+ question : str ,
240+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
241+ # The extra values given here take precedence over values defined on the client or passed to this method.
242+ extra_headers : Headers | None = None ,
243+ extra_query : Query | None = None ,
244+ extra_body : Body | None = None ,
245+ timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
246+ ) -> ChatPostMessageResponse :
247+ """
248+ 发消息
249+
250+ Args:
251+ extra_headers: Send extra headers
252+
253+ extra_query: Add additional query parameters to the request
254+
255+ extra_body: Add additional JSON properties to the request
256+
257+ timeout: Override the client-level default timeout for this request, in seconds
258+ """
259+ if not chat_id :
260+ raise ValueError (f"Expected a non-empty value for `chat_id` but received { chat_id !r} " )
261+ return cast (
262+ ChatPostMessageResponse ,
263+ self ._post (
264+ f"/chats/{ chat_id } " ,
265+ options = make_request_options (
266+ extra_headers = extra_headers ,
267+ extra_query = extra_query ,
268+ extra_body = extra_body ,
269+ timeout = timeout ,
270+ query = maybe_transform ({"question" : question }, chat_post_message_params .ChatPostMessageParams ),
271+ ),
272+ cast_to = cast (
273+ Any , ChatPostMessageResponse
274+ ), # Union types cannot be passed in as arguments in the type system
275+ ),
276+ )
277+
234278
235279class AsyncChatsResource (AsyncAPIResource ):
236280 @cached_property
@@ -427,6 +471,51 @@ async def delete(
427471 cast_to = NoneType ,
428472 )
429473
474+ async def post_message (
475+ self ,
476+ chat_id : str ,
477+ * ,
478+ question : str ,
479+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
480+ # The extra values given here take precedence over values defined on the client or passed to this method.
481+ extra_headers : Headers | None = None ,
482+ extra_query : Query | None = None ,
483+ extra_body : Body | None = None ,
484+ timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
485+ ) -> ChatPostMessageResponse :
486+ """
487+ 发消息
488+
489+ Args:
490+ extra_headers: Send extra headers
491+
492+ extra_query: Add additional query parameters to the request
493+
494+ extra_body: Add additional JSON properties to the request
495+
496+ timeout: Override the client-level default timeout for this request, in seconds
497+ """
498+ if not chat_id :
499+ raise ValueError (f"Expected a non-empty value for `chat_id` but received { chat_id !r} " )
500+ return cast (
501+ ChatPostMessageResponse ,
502+ await self ._post (
503+ f"/chats/{ chat_id } " ,
504+ options = make_request_options (
505+ extra_headers = extra_headers ,
506+ extra_query = extra_query ,
507+ extra_body = extra_body ,
508+ timeout = timeout ,
509+ query = await async_maybe_transform (
510+ {"question" : question }, chat_post_message_params .ChatPostMessageParams
511+ ),
512+ ),
513+ cast_to = cast (
514+ Any , ChatPostMessageResponse
515+ ), # Union types cannot be passed in as arguments in the type system
516+ ),
517+ )
518+
430519
431520class ChatsResourceWithRawResponse :
432521 def __init__ (self , chats : ChatsResource ) -> None :
@@ -444,6 +533,9 @@ def __init__(self, chats: ChatsResource) -> None:
444533 self .delete = to_raw_response_wrapper (
445534 chats .delete ,
446535 )
536+ self .post_message = to_raw_response_wrapper (
537+ chats .post_message ,
538+ )
447539
448540 @cached_property
449541 def messages (self ) -> MessagesResourceWithRawResponse :
@@ -466,6 +558,9 @@ def __init__(self, chats: AsyncChatsResource) -> None:
466558 self .delete = async_to_raw_response_wrapper (
467559 chats .delete ,
468560 )
561+ self .post_message = async_to_raw_response_wrapper (
562+ chats .post_message ,
563+ )
469564
470565 @cached_property
471566 def messages (self ) -> AsyncMessagesResourceWithRawResponse :
@@ -488,6 +583,9 @@ def __init__(self, chats: ChatsResource) -> None:
488583 self .delete = to_streamed_response_wrapper (
489584 chats .delete ,
490585 )
586+ self .post_message = to_streamed_response_wrapper (
587+ chats .post_message ,
588+ )
491589
492590 @cached_property
493591 def messages (self ) -> MessagesResourceWithStreamingResponse :
@@ -510,6 +608,9 @@ def __init__(self, chats: AsyncChatsResource) -> None:
510608 self .delete = async_to_streamed_response_wrapper (
511609 chats .delete ,
512610 )
611+ self .post_message = async_to_streamed_response_wrapper (
612+ chats .post_message ,
613+ )
513614
514615 @cached_property
515616 def messages (self ) -> AsyncMessagesResourceWithStreamingResponse :
0 commit comments