2
2
import json
3
3
import time
4
4
from enum import Enum
5
- from typing import TYPE_CHECKING , AsyncIterator , Dict , List , Optional , Union , overload
5
+ from typing import TYPE_CHECKING , Any , AsyncIterator , Dict , List , Optional , Union , overload
6
6
7
7
import httpx
8
8
from typing_extensions import Literal
@@ -442,6 +442,7 @@ def create(
442
442
custom_variables : Optional [Dict [str , str ]] = None ,
443
443
auto_save_history : bool = True ,
444
444
meta_data : Optional [Dict [str , str ]] = None ,
445
+ parameters : Optional [Dict [str , Any ]] = None ,
445
446
) -> Chat :
446
447
"""
447
448
Call the Chat API with non-streaming to send messages to a published Coze bot.
@@ -458,6 +459,7 @@ def create(
458
459
:param custom_variables: The customized variable in a key-value pair.
459
460
:param auto_save_history: Whether to automatically save the history of conversation records.
460
461
:param meta_data: Additional information, typically used to encapsulate some business-related fields.
462
+ :param parameters: Additional parameters for the chat API. pass through to the workflow.
461
463
:return: chat object
462
464
"""
463
465
return self ._create (
@@ -469,6 +471,7 @@ def create(
469
471
auto_save_history = auto_save_history ,
470
472
meta_data = meta_data ,
471
473
conversation_id = conversation_id ,
474
+ parameters = parameters ,
472
475
)
473
476
474
477
def stream (
@@ -481,6 +484,7 @@ def stream(
481
484
auto_save_history : bool = True ,
482
485
meta_data : Optional [Dict [str , str ]] = None ,
483
486
conversation_id : Optional [str ] = None ,
487
+ parameters : Optional [Dict [str , Any ]] = None ,
484
488
** kwargs ,
485
489
) -> Stream [ChatEvent ]:
486
490
"""
@@ -498,6 +502,7 @@ def stream(
498
502
:param custom_variables: The customized variable in a key-value pair.
499
503
:param auto_save_history: Whether to automatically save the history of conversation records.
500
504
:param meta_data: Additional information, typically used to encapsulate some business-related fields.
505
+ :param parameters: Additional parameters for the chat API. pass through to the workflow.
501
506
:return: iterator of ChatEvent
502
507
"""
503
508
return self ._create (
@@ -509,6 +514,7 @@ def stream(
509
514
auto_save_history = auto_save_history ,
510
515
meta_data = meta_data ,
511
516
conversation_id = conversation_id ,
517
+ parameters = parameters ,
512
518
** kwargs ,
513
519
)
514
520
@@ -523,6 +529,7 @@ def create_and_poll(
523
529
auto_save_history : bool = True ,
524
530
meta_data : Optional [Dict [str , str ]] = None ,
525
531
poll_timeout : Optional [int ] = None ,
532
+ parameters : Optional [Dict [str , Any ]] = None ,
526
533
) -> ChatPoll :
527
534
"""
528
535
Call the Chat API with non-streaming to send messages to a published Coze bot and
@@ -541,6 +548,7 @@ def create_and_poll(
541
548
:param auto_save_history: Whether to automatically save the history of conversation records.
542
549
:param meta_data: Additional information, typically used to encapsulate some business-related fields.
543
550
:param poll_timeout: poll timeout in seconds
551
+ :param parameters: Additional parameters for the chat API. pass through to the workflow.
544
552
:return: chat object
545
553
"""
546
554
chat = self .create (
@@ -551,6 +559,7 @@ def create_and_poll(
551
559
custom_variables = custom_variables ,
552
560
auto_save_history = auto_save_history ,
553
561
meta_data = meta_data ,
562
+ parameters = parameters ,
554
563
)
555
564
556
565
start = int (time .time ())
@@ -579,6 +588,7 @@ def _create(
579
588
auto_save_history : bool = ...,
580
589
meta_data : Optional [Dict [str , str ]] = ...,
581
590
conversation_id : Optional [str ] = ...,
591
+ parameters : Optional [Dict [str , Any ]] = ...,
582
592
) -> Stream [ChatEvent ]: ...
583
593
584
594
@overload
@@ -593,6 +603,7 @@ def _create(
593
603
auto_save_history : bool = ...,
594
604
meta_data : Optional [Dict [str , str ]] = ...,
595
605
conversation_id : Optional [str ] = ...,
606
+ parameters : Optional [Dict [str , Any ]] = ...,
596
607
) -> Chat : ...
597
608
598
609
def _create (
@@ -606,11 +617,11 @@ def _create(
606
617
auto_save_history : bool = True ,
607
618
meta_data : Optional [Dict [str , str ]] = None ,
608
619
conversation_id : Optional [str ] = None ,
620
+ parameters : Optional [Dict [str , Any ]] = None ,
609
621
** kwargs ,
610
622
) -> Union [Chat , Stream [ChatEvent ]]:
611
623
"""
612
- Create a conversation.
613
- Conversation is an interaction between a bot and a user, including one or more messages.
624
+ Create a chat.
614
625
"""
615
626
url = f"{ self ._base_url } /v3/chat"
616
627
params = {
@@ -624,6 +635,7 @@ def _create(
624
635
"custom_variables" : custom_variables ,
625
636
"auto_save_history" : auto_save_history ,
626
637
"meta_data" : meta_data ,
638
+ "parameters" : parameters ,
627
639
}
628
640
headers : Optional [dict ] = kwargs .get ("headers" )
629
641
if not stream :
@@ -777,6 +789,7 @@ async def create(
777
789
custom_variables : Optional [Dict [str , str ]] = None ,
778
790
auto_save_history : bool = True ,
779
791
meta_data : Optional [Dict [str , str ]] = None ,
792
+ parameters : Optional [Dict [str , Any ]] = None ,
780
793
) -> Chat :
781
794
"""
782
795
Call the Chat API with non-streaming to send messages to a published Coze bot.
@@ -793,6 +806,7 @@ async def create(
793
806
:param custom_variables: The customized variable in a key-value pair.
794
807
:param auto_save_history: Whether to automatically save the history of conversation records.
795
808
:param meta_data: Additional information, typically used to encapsulate some business-related fields.
809
+ :param parameters: Additional parameters for the chat API. pass through to the workflow.
796
810
:return: chat object
797
811
"""
798
812
return await self ._create (
@@ -804,6 +818,7 @@ async def create(
804
818
auto_save_history = auto_save_history ,
805
819
meta_data = meta_data ,
806
820
conversation_id = conversation_id ,
821
+ parameters = parameters ,
807
822
)
808
823
809
824
async def stream (
@@ -816,6 +831,7 @@ async def stream(
816
831
auto_save_history : bool = True ,
817
832
meta_data : Optional [Dict [str , str ]] = None ,
818
833
conversation_id : Optional [str ] = None ,
834
+ parameters : Optional [Dict [str , Any ]] = None ,
819
835
) -> AsyncIterator [ChatEvent ]:
820
836
"""
821
837
Call the Chat API with streaming to send messages to a published Coze bot.
@@ -832,6 +848,7 @@ async def stream(
832
848
:param custom_variables: The customized variable in a key-value pair.
833
849
:param auto_save_history: Whether to automatically save the history of conversation records.
834
850
:param meta_data: Additional information, typically used to encapsulate some business-related fields.
851
+ :param parameters: Additional parameters for the chat API. pass through to the workflow.
835
852
:return: iterator of ChatEvent
836
853
"""
837
854
async for item in await self ._create (
@@ -843,6 +860,7 @@ async def stream(
843
860
auto_save_history = auto_save_history ,
844
861
meta_data = meta_data ,
845
862
conversation_id = conversation_id ,
863
+ parameters = parameters ,
846
864
):
847
865
yield item
848
866
@@ -858,6 +876,7 @@ async def _create(
858
876
auto_save_history : bool = ...,
859
877
meta_data : Optional [Dict [str , str ]] = ...,
860
878
conversation_id : Optional [str ] = ...,
879
+ parameters : Optional [Dict [str , Any ]] = ...,
861
880
) -> AsyncStream [ChatEvent ]: ...
862
881
863
882
@overload
@@ -872,6 +891,7 @@ async def _create(
872
891
auto_save_history : bool = ...,
873
892
meta_data : Optional [Dict [str , str ]] = ...,
874
893
conversation_id : Optional [str ] = ...,
894
+ parameters : Optional [Dict [str , Any ]] = ...,
875
895
) -> Chat : ...
876
896
877
897
async def _create (
@@ -885,6 +905,7 @@ async def _create(
885
905
auto_save_history : bool = True ,
886
906
meta_data : Optional [Dict [str , str ]] = None ,
887
907
conversation_id : Optional [str ] = None ,
908
+ parameters : Optional [Dict [str , Any ]] = None ,
888
909
) -> Union [Chat , AsyncStream [ChatEvent ]]:
889
910
"""
890
911
Create a conversation.
@@ -902,6 +923,7 @@ async def _create(
902
923
"custom_variables" : custom_variables ,
903
924
"auto_save_history" : auto_save_history ,
904
925
"meta_data" : meta_data ,
926
+ "parameters" : parameters ,
905
927
}
906
928
if not stream :
907
929
return await self ._requester .arequest (
0 commit comments