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)
| 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. |
| 33 | func (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 | } |
nothing calls this directly
no test coverage detected