MCPcopy
hub / github.com/elastic/go-elasticsearch / Do

Method Do

esapi/api.inference.put_cohere.go:74–189  ·  view source on GitHub ↗

Do executes the request and returns response or error.

(providedCtx context.Context, transport Transport)

Source from the content-addressed store, hash-verified

72
73// Do executes the request and returns response or error.
74func (r InferencePutCohereRequest) Do(providedCtx context.Context, transport Transport) (*Response, error) {
75 var (
76 method string
77 path strings.Builder
78 params map[string]string
79 ctx context.Context
80 )
81
82 if instrument, ok := r.Instrument.(Instrumentation); ok {
83 ctx = instrument.Start(providedCtx, "inference.put_cohere")
84 defer instrument.Close(ctx)
85 }
86 if ctx == nil {
87 ctx = providedCtx
88 }
89
90 method = "PUT"
91
92 path.Grow(7 + 1 + len("_inference") + 1 + len(r.TaskType) + 1 + len(r.CohereInferenceID))
93 path.WriteString("http://")
94 path.WriteString("/")
95 path.WriteString("_inference")
96 path.WriteString("/")
97 path.WriteString(r.TaskType)
98 if instrument, ok := r.Instrument.(Instrumentation); ok {
99 instrument.RecordPathPart(ctx, "task_type", r.TaskType)
100 }
101 path.WriteString("/")
102 path.WriteString(r.CohereInferenceID)
103 if instrument, ok := r.Instrument.(Instrumentation); ok {
104 instrument.RecordPathPart(ctx, "cohere_inference_id", r.CohereInferenceID)
105 }
106
107 params = make(map[string]string)
108
109 if r.Timeout != 0 {
110 params["timeout"] = formatDuration(r.Timeout)
111 }
112
113 if r.Pretty {
114 params["pretty"] = "true"
115 }
116
117 if r.Human {
118 params["human"] = "true"
119 }
120
121 if r.ErrorTrace {
122 params["error_trace"] = "true"
123 }
124
125 if len(r.FilterPath) > 0 {
126 params["filter_path"] = strings.Join(r.FilterPath, ",")
127 }
128
129 req, err := newRequest(method, path.String(), r.Body)
130 if err != nil {
131 if instrument, ok := r.Instrument.(Instrumentation); ok {

Callers

nothing calls this directly

Calls 15

formatDurationFunction · 0.85
newRequestFunction · 0.85
JoinMethod · 0.80
CloseMethod · 0.65
AddMethod · 0.65
PerformMethod · 0.65
StartMethod · 0.45
RecordPathPartMethod · 0.45
StringMethod · 0.45
RecordErrorMethod · 0.45
QueryMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected