|
| 1 | +<?php |
| 2 | + |
| 3 | +/** |
| 4 | + * Elasticsearch PHP Client |
| 5 | + * |
| 6 | + * @link https://github.com/elastic/elasticsearch-php |
| 7 | + * @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co) |
| 8 | + * @license https://opensource.org/licenses/MIT MIT License |
| 9 | + * |
| 10 | + * Licensed to Elasticsearch B.V under one or more agreements. |
| 11 | + * Elasticsearch B.V licenses this file to you under the MIT License. |
| 12 | + * See the LICENSE file in the project root for more information. |
| 13 | + */ |
| 14 | + |
| 15 | +declare(strict_types=1); |
| 16 | + |
| 17 | +namespace Elastic\Elasticsearch\Endpoints; |
| 18 | + |
| 19 | +use Elastic\Elasticsearch\Exception\ClientResponseException; |
| 20 | +use Elastic\Elasticsearch\Exception\MissingParameterException; |
| 21 | +use Elastic\Elasticsearch\Exception\ServerResponseException; |
| 22 | +use Elastic\Elasticsearch\Response\Elasticsearch; |
| 23 | +use Elastic\Transport\Exception\NoNodeAvailableException; |
| 24 | +use Http\Promise\Promise; |
| 25 | + |
| 26 | +/** |
| 27 | + * @generated This file is generated, please do not edit |
| 28 | + */ |
| 29 | +class Inference extends AbstractEndpoint |
| 30 | +{ |
| 31 | + /** |
| 32 | + * Delete model in the Inference API |
| 33 | + * |
| 34 | + * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/delete-inference-api.html |
| 35 | + * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release |
| 36 | + * |
| 37 | + * @param array{ |
| 38 | + * task_type: string, // (REQUIRED) The model task type |
| 39 | + * model_id: string, // (REQUIRED) The model Id |
| 40 | + * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) |
| 41 | + * human: boolean, // Return human readable values for statistics. (DEFAULT: true) |
| 42 | + * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) |
| 43 | + * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. |
| 44 | + * filter_path: list, // A comma-separated list of filters used to reduce the response. |
| 45 | + * } $params |
| 46 | + * |
| 47 | + * @throws MissingParameterException if a required parameter is missing |
| 48 | + * @throws NoNodeAvailableException if all the hosts are offline |
| 49 | + * @throws ClientResponseException if the status code of response is 4xx |
| 50 | + * @throws ServerResponseException if the status code of response is 5xx |
| 51 | + * |
| 52 | + * @return Elasticsearch|Promise |
| 53 | + */ |
| 54 | + public function deleteModel(array $params = []) |
| 55 | + { |
| 56 | + $this->checkRequiredParameters(['task_type','model_id'], $params); |
| 57 | + $url = '/_inference/' . $this->encode($params['task_type']) . '/' . $this->encode($params['model_id']); |
| 58 | + $method = 'DELETE'; |
| 59 | + |
| 60 | + $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); |
| 61 | + $headers = [ |
| 62 | + 'Accept' => 'application/json', |
| 63 | + ]; |
| 64 | + return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); |
| 65 | + } |
| 66 | + |
| 67 | + |
| 68 | + /** |
| 69 | + * Get a model in the Inference API |
| 70 | + * |
| 71 | + * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/get-inference-api.html |
| 72 | + * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release |
| 73 | + * |
| 74 | + * @param array{ |
| 75 | + * task_type: string, // (REQUIRED) The model task type |
| 76 | + * model_id: string, // (REQUIRED) The model Id |
| 77 | + * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) |
| 78 | + * human: boolean, // Return human readable values for statistics. (DEFAULT: true) |
| 79 | + * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) |
| 80 | + * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. |
| 81 | + * filter_path: list, // A comma-separated list of filters used to reduce the response. |
| 82 | + * } $params |
| 83 | + * |
| 84 | + * @throws MissingParameterException if a required parameter is missing |
| 85 | + * @throws NoNodeAvailableException if all the hosts are offline |
| 86 | + * @throws ClientResponseException if the status code of response is 4xx |
| 87 | + * @throws ServerResponseException if the status code of response is 5xx |
| 88 | + * |
| 89 | + * @return Elasticsearch|Promise |
| 90 | + */ |
| 91 | + public function getModel(array $params = []) |
| 92 | + { |
| 93 | + $this->checkRequiredParameters(['task_type','model_id'], $params); |
| 94 | + $url = '/_inference/' . $this->encode($params['task_type']) . '/' . $this->encode($params['model_id']); |
| 95 | + $method = 'GET'; |
| 96 | + |
| 97 | + $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); |
| 98 | + $headers = [ |
| 99 | + 'Accept' => 'application/json', |
| 100 | + ]; |
| 101 | + return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); |
| 102 | + } |
| 103 | + |
| 104 | + |
| 105 | + /** |
| 106 | + * Perform inference on a model |
| 107 | + * |
| 108 | + * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/post-inference-api.html |
| 109 | + * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release |
| 110 | + * |
| 111 | + * @param array{ |
| 112 | + * task_type: string, // (REQUIRED) The model task type |
| 113 | + * model_id: string, // (REQUIRED) The model Id |
| 114 | + * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) |
| 115 | + * human: boolean, // Return human readable values for statistics. (DEFAULT: true) |
| 116 | + * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) |
| 117 | + * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. |
| 118 | + * filter_path: list, // A comma-separated list of filters used to reduce the response. |
| 119 | + * body: array, // The inference payload |
| 120 | + * } $params |
| 121 | + * |
| 122 | + * @throws MissingParameterException if a required parameter is missing |
| 123 | + * @throws NoNodeAvailableException if all the hosts are offline |
| 124 | + * @throws ClientResponseException if the status code of response is 4xx |
| 125 | + * @throws ServerResponseException if the status code of response is 5xx |
| 126 | + * |
| 127 | + * @return Elasticsearch|Promise |
| 128 | + */ |
| 129 | + public function inference(array $params = []) |
| 130 | + { |
| 131 | + $this->checkRequiredParameters(['task_type','model_id'], $params); |
| 132 | + $url = '/_inference/' . $this->encode($params['task_type']) . '/' . $this->encode($params['model_id']); |
| 133 | + $method = 'POST'; |
| 134 | + |
| 135 | + $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); |
| 136 | + $headers = [ |
| 137 | + 'Accept' => 'application/json', |
| 138 | + 'Content-Type' => 'application/json', |
| 139 | + ]; |
| 140 | + return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); |
| 141 | + } |
| 142 | + |
| 143 | + |
| 144 | + /** |
| 145 | + * Configure a model for use in the Inference API |
| 146 | + * |
| 147 | + * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/put-inference-api.html |
| 148 | + * @internal This API is EXPERIMENTAL and may be changed or removed completely in a future release |
| 149 | + * |
| 150 | + * @param array{ |
| 151 | + * task_type: string, // (REQUIRED) The model task type |
| 152 | + * model_id: string, // (REQUIRED) The model Id |
| 153 | + * pretty: boolean, // Pretty format the returned JSON response. (DEFAULT: false) |
| 154 | + * human: boolean, // Return human readable values for statistics. (DEFAULT: true) |
| 155 | + * error_trace: boolean, // Include the stack trace of returned errors. (DEFAULT: false) |
| 156 | + * source: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. |
| 157 | + * filter_path: list, // A comma-separated list of filters used to reduce the response. |
| 158 | + * body: array, // The model's task and service settings |
| 159 | + * } $params |
| 160 | + * |
| 161 | + * @throws MissingParameterException if a required parameter is missing |
| 162 | + * @throws NoNodeAvailableException if all the hosts are offline |
| 163 | + * @throws ClientResponseException if the status code of response is 4xx |
| 164 | + * @throws ServerResponseException if the status code of response is 5xx |
| 165 | + * |
| 166 | + * @return Elasticsearch|Promise |
| 167 | + */ |
| 168 | + public function putModel(array $params = []) |
| 169 | + { |
| 170 | + $this->checkRequiredParameters(['task_type','model_id'], $params); |
| 171 | + $url = '/_inference/' . $this->encode($params['task_type']) . '/' . $this->encode($params['model_id']); |
| 172 | + $method = 'PUT'; |
| 173 | + |
| 174 | + $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); |
| 175 | + $headers = [ |
| 176 | + 'Accept' => 'application/json', |
| 177 | + 'Content-Type' => 'application/json', |
| 178 | + ]; |
| 179 | + return $this->client->sendRequest($this->createRequest($method, $url, $headers, $params['body'] ?? null)); |
| 180 | + } |
| 181 | +} |
0 commit comments