forked from zhouyangtingwen/dify-sdk-go
-
Notifications
You must be signed in to change notification settings - Fork 18
/
api_parameters.go
57 lines (49 loc) · 1.62 KB
/
api_parameters.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package dify
import (
"context"
"errors"
"net/http"
)
type ParametersRequest struct {
User string `json:"user"`
}
type ParametersResponse struct {
OpeningStatement string `json:"opening_statement"`
SuggestedQuestions []interface{} `json:"suggested_questions"`
SuggestedQuestionsAfterAnswer struct {
Enabled bool `json:"enabled"`
} `json:"suggested_questions_after_answer"`
MoreLikeThis struct {
Enabled bool `json:"enabled"`
} `json:"more_like_this"`
UserInputForm []map[string]interface{} `json:"user_input_form"`
}
// type ParametersUserInputFormResponse struct {
// TextInput []ParametersTextInputResponse `json:"text-input"`
// }
// type ParametersTextInputResponse struct {
// Label string `json:"label"`
// Variable string `json:"variable"`
// Required bool `json:"required"`
// MaxLength int `json:"max_length"`
// Default string `json:"default"`
// }
/* Obtain application parameter information
* Retrieve configured Input parameters, including variable names, field names, types, and default values.
* Typically used for displaying these fields in a form or filling in default values after the client loads.
*/
func (api *API) Parameters(ctx context.Context, req *ParametersRequest) (resp *ParametersResponse, err error) {
if req.User == "" {
err = errors.New("ParametersRequest.User Illegal")
return
}
httpReq, err := api.createBaseRequest(ctx, http.MethodGet, "/v1/parameters", nil)
if err != nil {
return
}
query := httpReq.URL.Query()
query.Set("user", req.User)
httpReq.URL.RawQuery = query.Encode()
err = api.c.sendJSONRequest(httpReq, &resp)
return
}