forked from zhouyangtingwen/dify-sdk-go
-
Notifications
You must be signed in to change notification settings - Fork 15
/
api_chat.go
35 lines (30 loc) · 1002 Bytes
/
api_chat.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package dify
import (
"context"
"net/http"
)
type ChatMessageRequest struct {
Inputs map[string]interface{} `json:"inputs"`
Query string `json:"query"`
ResponseMode string `json:"response_mode"`
ConversationID string `json:"conversation_id,omitempty"`
User string `json:"user"`
}
type ChatMessageResponse struct {
ID string `json:"id"`
Answer string `json:"answer"`
ConversationID string `json:"conversation_id"`
CreatedAt int `json:"created_at"`
}
/* Create chat message
* Create a new conversation message or continue an existing dialogue.
*/
func (api *API) ChatMessages(ctx context.Context, req *ChatMessageRequest) (resp *ChatMessageResponse, err error) {
req.ResponseMode = "blocking"
httpReq, err := api.createBaseRequest(ctx, http.MethodPost, "/v1/chat-messages", req)
if err != nil {
return
}
err = api.c.sendJSONRequest(httpReq, &resp)
return
}