@@ -26,3 +26,29 @@ response format under the `connector` field.
2626 "interactive" : " ChatPanel"
2727}
2828```
29+
30+ ## Advanced example
31+
32+ We used [ JsonPath] ( https://github.com/json-path/JsonPath ) to parse response, If you want to get stream content from Coze
33+ API, you can use ` $[?(@.type == 'answer' && !(@.created_at))].content ` to filter the content.
34+
35+ Here some examples of the request and response format:
36+
37+ ``` bash
38+ event:conversation.message.delta
39+ data:{" id" :" 7490890868547862564" ," conversation_id" :" 7490890868547682340" ," bot_id" :" 7490858512726458380" ," role" :" assistant" ," type" :" answer" ," content" :" All" ," content_type" :" text" ," chat_id" :" 7490890868547698724" ," section_id" :" 7490890868547682340" }
40+
41+ event:conversation.message.delta
42+ data:{" id" :" 7490890868547862564" ," conversation_id" :" 7490890868547682340" ," bot_id" :" 7490858512726458380" ," role" :" assistant" ," type" :" answer" ," content" :" Files" ," content_type" :" text" ," chat_id" :" 7490890868547698724" ," section_id" :" 7490890868547682340" }
43+
44+ event:conversation.message.completed
45+ data:{" id" :" 7490890868547862564" ," conversation_id" :" 7490890868547682340" ," bot_id" :" 7490858512726458380" ," role" :" assistant" ," type" :" answer" ," content" :" listAllFiles" ," content_type" :" text" ," chat_id" :" 7490890868547698724" ," section_id" :" 7490890868547682340" ," created_at" :1744108946}
46+
47+ event:conversation.message.completed
48+ data:{" id" :" 7490890877657923603" ," conversation_id" :" 7490890868547682340" ," bot_id" :" 7490858512726458380" ," role" :" assistant" ," type" :" verbose" ," content" :" {\" msg_type\" :\" generate_answer_finish\" ,\" data\" :\" {\\\" finish_reason\\\" :0,\\\" FinData\\\" :\\\"\\\" }\" ,\" from_module\" :null,\" from_unit\" :null}" ," content_type" :" text" ," chat_id" :" 7490890868547698724" ," section_id" :" 7490890868547682340" ," created_at" :1744108948," updated_at" :1744108948}
49+ ```
50+
51+ explain:
52+
53+ 1 . ` answer ` is the type of the response, which is the content you want to get.
54+ 2 . ` created_at ` is the time when the response is completed, which is not needed in the response.
0 commit comments