Skip to content

Commit bd8c2ef

Browse files
committed
docs(agent): add advanced example for custom request and response
- Include example of using JsonPath to parse response - Provide sample request and response format - Explain the structure of the response, focusing on 'answer' type and 'created_at' field
1 parent a032538 commit bd8c2ef

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

docs/agent/custom-request-response.md

+26
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)