-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtask_answer.go
149 lines (121 loc) · 5.01 KB
/
task_answer.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
// go-mirage-api
//
// Copyright 2023, Valerian Saliou
// Author: Valerian Saliou <[email protected]>
package mirage
// AnswerPromptRequest mapping
type AnswerPromptRequest struct {
Prompt string `json:"prompt"`
Answer *AnswerPromptRequestAnswer `json:"answer,omitempty"`
Schema *interface{} `json:"schema,omitempty"`
Model *string `json:"model,omitempty"`
}
// AnswerPromptRequestAnswer mapping
type AnswerPromptRequestAnswer struct {
MaxTokens *uint16 `json:"max_tokens,omitempty"`
Temperature *float32 `json:"temperature,omitempty"`
}
// AnswerQuestionRequest mapping
type AnswerQuestionRequest struct {
Question string `json:"question"`
Answer *AnswerQuestionRequestAnswer `json:"answer,omitempty"`
Locale *AnswerQuestionRequestLocale `json:"locale,omitempty"`
Context AnswerQuestionRequestContext `json:"context"`
Model *string `json:"model,omitempty"`
}
// AnswerQuestionRequestAnswer mapping
type AnswerQuestionRequestAnswer struct {
Start *string `json:"start,omitempty"`
System *string `json:"system,omitempty"`
Quality *uint8 `json:"quality,omitempty"`
MaxTokens *uint16 `json:"max_tokens,omitempty"`
Temperature *float32 `json:"temperature,omitempty"`
}
// AnswerQuestionRequestLocale mapping
type AnswerQuestionRequestLocale struct {
From string `json:"from"`
}
// AnswerQuestionRequestContext mapping
type AnswerQuestionRequestContext struct {
Source *string `json:"source,omitempty"`
PrimaryID string `json:"primary_id"`
Filters *AnswerQuestionRequestContextFilters `json:"filters,omitempty"`
Conversation AnswerQuestionRequestContextConversation `json:"conversation"`
}
// AnswerQuestionRequestContextFilters mapping
type AnswerQuestionRequestContextFilters struct {
SecondaryID *AnswerQuestionRequestContextFiltersFilter `json:"secondary_id,omitempty"`
TertiaryID *AnswerQuestionRequestContextFiltersFilter `json:"tertiary_id,omitempty"`
Source *AnswerQuestionRequestContextFiltersFilter `json:"source,omitempty"`
}
// AnswerQuestionRequestContextFiltersFilter mapping
type AnswerQuestionRequestContextFiltersFilter struct {
Include *[]string `json:"include,omitempty"`
Exclude *[]string `json:"exclude,omitempty"`
}
// AnswerQuestionRequestContextConversation mapping
type AnswerQuestionRequestContextConversation struct {
Messages []AnswerQuestionRequestContextConversationMessage `json:"messages"`
}
// AnswerQuestionRequestContextConversationMessage mapping
type AnswerQuestionRequestContextConversationMessage struct {
From string `json:"from"`
Text string `json:"text"`
}
// AnswerPromptResponseData mapping
type AnswerPromptResponseData struct {
Data *AnswerPromptResponse `json:"data"`
}
// AnswerPromptResponse mapping
type AnswerPromptResponse struct {
Answer string `json:"answer"`
Model string `json:"model"`
}
// AnswerQuestionResponseData mapping
type AnswerQuestionResponseData struct {
Data *AnswerQuestionResponse `json:"data"`
}
// AnswerQuestionResponse mapping
type AnswerQuestionResponse struct {
Answer string `json:"answer"`
Model string `json:"model"`
Sources []AnswerQuestionResponseSource `json:"sources"`
}
// AnswerQuestionResponseSource mapping
type AnswerQuestionResponseSource struct {
Source *string `json:"source,omitempty"`
Score *uint8 `json:"score,omitempty"`
PrimaryID string `json:"primary_id"`
SecondaryID *string `json:"secondary_id,omitempty"`
Excerpt *string `json:"excerpt,omitempty"`
Timestamp *uint64 `json:"timestamp,omitempty"`
Metadata *map[string]string `json:"metadata,omitempty"`
}
// String returns the string representation of AnswerPromptResponse
func (instance AnswerPromptResponse) String() string {
return Stringify(instance)
}
// String returns the string representation of AnswerQuestionResponse
func (instance AnswerQuestionResponse) String() string {
return Stringify(instance)
}
// AnswerPrompt answer a given prompt.
func (service *TaskService) AnswerPrompt(ctx RequestContext, data AnswerPromptRequest) (*AnswerPromptResponse, error) {
req, _ := service.client.NewRequest("POST", "task/answer/prompt", data, ctx)
result := new(AnswerPromptResponseData)
_, err := service.client.Do(req, result)
if err != nil {
return nil, err
}
return result.Data, err
}
// AnswerQuestion answer a given question.
func (service *TaskService) AnswerQuestion(ctx RequestContext, data AnswerQuestionRequest) (*AnswerQuestionResponse, error) {
req, _ := service.client.NewRequest("POST", "task/answer/question", data, ctx)
result := new(AnswerQuestionResponseData)
_, err := service.client.Do(req, result)
if err != nil {
return nil, err
}
return result.Data, err
}