MCPcopy
hub / github.com/minio/minio-go / PromptObject

Method PromptObject

api-prompt-object.go:33–78  ·  view source on GitHub ↗

PromptObject performs language model inference with the prompt and referenced object as context. Inference is performed using a Lambda handler that can process the prompt and object. Currently, this functionality is limited to certain MinIO servers.

(ctx context.Context, bucketName, objectName, prompt string, opts PromptObjectOptions)

Source from the content-addressed store, hash-verified

31// Inference is performed using a Lambda handler that can process the prompt and object.
32// Currently, this functionality is limited to certain MinIO servers.
33func (c *Client) PromptObject(ctx context.Context, bucketName, objectName, prompt string, opts PromptObjectOptions) (io.ReadCloser, error) {
34 // Input validation.
35 if err := s3utils.CheckValidBucketName(bucketName); err != nil {
36 return nil, ErrorResponse{
37 StatusCode: http.StatusBadRequest,
38 Code: InvalidBucketName,
39 Message: err.Error(),
40 }
41 }
42 if err := s3utils.CheckValidObjectName(objectName); err != nil {
43 return nil, ErrorResponse{
44 StatusCode: http.StatusBadRequest,
45 Code: XMinioInvalidObjectName,
46 Message: err.Error(),
47 }
48 }
49
50 opts.AddLambdaArnToReqParams(opts.LambdaArn)
51 opts.SetHeader("Content-Type", "application/json")
52 opts.AddPromptArg("prompt", prompt)
53 promptReqBytes, err := json.Marshal(opts.PromptArgs)
54 if err != nil {
55 return nil, err
56 }
57
58 // Execute POST on bucket/object.
59 resp, err := c.executeMethod(ctx, http.MethodPost, requestMetadata{
60 bucketName: bucketName,
61 objectName: objectName,
62 queryValues: opts.toQueryValues(),
63 customHeader: opts.Header(),
64 contentSHA256Hex: sum256Hex(promptReqBytes),
65 contentBody: bytes.NewReader(promptReqBytes),
66 contentLength: int64(len(promptReqBytes)),
67 })
68 if err != nil {
69 return nil, err
70 }
71
72 if resp.StatusCode != http.StatusOK {
73 defer closeResponse(resp)
74 return nil, httpRespToErrorResponse(resp, bucketName, objectName)
75 }
76
77 return resp.Body, nil
78}

Callers

nothing calls this directly

Calls 13

executeMethodMethod · 0.95
CheckValidBucketNameFunction · 0.92
CheckValidObjectNameFunction · 0.92
sum256HexFunction · 0.85
httpRespToErrorResponseFunction · 0.85
SetHeaderMethod · 0.80
AddPromptArgMethod · 0.80
closeResponseFunction · 0.70
MarshalMethod · 0.65
ErrorMethod · 0.45
toQueryValuesMethod · 0.45

Tested by

no test coverage detected