1 | <?php
|
---|
2 | /*
|
---|
3 | * Copyright 2014 Google Inc.
|
---|
4 | *
|
---|
5 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
---|
6 | * use this file except in compliance with the License. You may obtain a copy of
|
---|
7 | * the License at
|
---|
8 | *
|
---|
9 | * http://www.apache.org/licenses/LICENSE-2.0
|
---|
10 | *
|
---|
11 | * Unless required by applicable law or agreed to in writing, software
|
---|
12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
---|
13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
---|
14 | * License for the specific language governing permissions and limitations under
|
---|
15 | * the License.
|
---|
16 | */
|
---|
17 |
|
---|
18 | namespace Google\Service\Aiplatform\Resource;
|
---|
19 |
|
---|
20 | use Google\Service\Aiplatform\GoogleApiHttpBody;
|
---|
21 | use Google\Service\Aiplatform\GoogleCloudAiplatformV1ComputeTokensRequest;
|
---|
22 | use Google\Service\Aiplatform\GoogleCloudAiplatformV1ComputeTokensResponse;
|
---|
23 | use Google\Service\Aiplatform\GoogleCloudAiplatformV1CountTokensRequest;
|
---|
24 | use Google\Service\Aiplatform\GoogleCloudAiplatformV1CountTokensResponse;
|
---|
25 | use Google\Service\Aiplatform\GoogleCloudAiplatformV1FetchPredictOperationRequest;
|
---|
26 | use Google\Service\Aiplatform\GoogleCloudAiplatformV1GenerateContentRequest;
|
---|
27 | use Google\Service\Aiplatform\GoogleCloudAiplatformV1GenerateContentResponse;
|
---|
28 | use Google\Service\Aiplatform\GoogleCloudAiplatformV1PredictLongRunningRequest;
|
---|
29 | use Google\Service\Aiplatform\GoogleCloudAiplatformV1PredictRequest;
|
---|
30 | use Google\Service\Aiplatform\GoogleCloudAiplatformV1PredictResponse;
|
---|
31 | use Google\Service\Aiplatform\GoogleCloudAiplatformV1RawPredictRequest;
|
---|
32 | use Google\Service\Aiplatform\GoogleCloudAiplatformV1StreamRawPredictRequest;
|
---|
33 | use Google\Service\Aiplatform\GoogleCloudAiplatformV1StreamingPredictRequest;
|
---|
34 | use Google\Service\Aiplatform\GoogleCloudAiplatformV1StreamingPredictResponse;
|
---|
35 | use Google\Service\Aiplatform\GoogleLongrunningOperation;
|
---|
36 |
|
---|
37 | /**
|
---|
38 | * The "models" collection of methods.
|
---|
39 | * Typical usage is:
|
---|
40 | * <code>
|
---|
41 | * $aiplatformService = new Google\Service\Aiplatform(...);
|
---|
42 | * $models = $aiplatformService->projects_locations_publishers_models;
|
---|
43 | * </code>
|
---|
44 | */
|
---|
45 | class ProjectsLocationsPublishersModels extends \Google\Service\Resource
|
---|
46 | {
|
---|
47 | /**
|
---|
48 | * Return a list of tokens based on the input text. (models.computeTokens)
|
---|
49 | *
|
---|
50 | * @param string $endpoint Required. The name of the Endpoint requested to get
|
---|
51 | * lists of tokens and token ids.
|
---|
52 | * @param GoogleCloudAiplatformV1ComputeTokensRequest $postBody
|
---|
53 | * @param array $optParams Optional parameters.
|
---|
54 | * @return GoogleCloudAiplatformV1ComputeTokensResponse
|
---|
55 | * @throws \Google\Service\Exception
|
---|
56 | */
|
---|
57 | public function computeTokens($endpoint, GoogleCloudAiplatformV1ComputeTokensRequest $postBody, $optParams = [])
|
---|
58 | {
|
---|
59 | $params = ['endpoint' => $endpoint, 'postBody' => $postBody];
|
---|
60 | $params = array_merge($params, $optParams);
|
---|
61 | return $this->call('computeTokens', [$params], GoogleCloudAiplatformV1ComputeTokensResponse::class);
|
---|
62 | }
|
---|
63 | /**
|
---|
64 | * Perform a token counting. (models.countTokens)
|
---|
65 | *
|
---|
66 | * @param string $endpoint Required. The name of the Endpoint requested to
|
---|
67 | * perform token counting. Format:
|
---|
68 | * `projects/{project}/locations/{location}/endpoints/{endpoint}`
|
---|
69 | * @param GoogleCloudAiplatformV1CountTokensRequest $postBody
|
---|
70 | * @param array $optParams Optional parameters.
|
---|
71 | * @return GoogleCloudAiplatformV1CountTokensResponse
|
---|
72 | * @throws \Google\Service\Exception
|
---|
73 | */
|
---|
74 | public function countTokens($endpoint, GoogleCloudAiplatformV1CountTokensRequest $postBody, $optParams = [])
|
---|
75 | {
|
---|
76 | $params = ['endpoint' => $endpoint, 'postBody' => $postBody];
|
---|
77 | $params = array_merge($params, $optParams);
|
---|
78 | return $this->call('countTokens', [$params], GoogleCloudAiplatformV1CountTokensResponse::class);
|
---|
79 | }
|
---|
80 | /**
|
---|
81 | * Fetch an asynchronous online prediction operation.
|
---|
82 | * (models.fetchPredictOperation)
|
---|
83 | *
|
---|
84 | * @param string $endpoint Required. The name of the Endpoint requested to serve
|
---|
85 | * the prediction. Format:
|
---|
86 | * `projects/{project}/locations/{location}/endpoints/{endpoint}` or `projects/{
|
---|
87 | * project}/locations/{location}/publishers/{publisher}/models/{model}`
|
---|
88 | * @param GoogleCloudAiplatformV1FetchPredictOperationRequest $postBody
|
---|
89 | * @param array $optParams Optional parameters.
|
---|
90 | * @return GoogleLongrunningOperation
|
---|
91 | * @throws \Google\Service\Exception
|
---|
92 | */
|
---|
93 | public function fetchPredictOperation($endpoint, GoogleCloudAiplatformV1FetchPredictOperationRequest $postBody, $optParams = [])
|
---|
94 | {
|
---|
95 | $params = ['endpoint' => $endpoint, 'postBody' => $postBody];
|
---|
96 | $params = array_merge($params, $optParams);
|
---|
97 | return $this->call('fetchPredictOperation', [$params], GoogleLongrunningOperation::class);
|
---|
98 | }
|
---|
99 | /**
|
---|
100 | * Generate content with multimodal inputs. (models.generateContent)
|
---|
101 | *
|
---|
102 | * @param string $model Required. The fully qualified name of the publisher
|
---|
103 | * model or tuned model endpoint to use. Publisher model format:
|
---|
104 | * `projects/{project}/locations/{location}/publishers/models` Tuned model
|
---|
105 | * endpoint format:
|
---|
106 | * `projects/{project}/locations/{location}/endpoints/{endpoint}`
|
---|
107 | * @param GoogleCloudAiplatformV1GenerateContentRequest $postBody
|
---|
108 | * @param array $optParams Optional parameters.
|
---|
109 | * @return GoogleCloudAiplatformV1GenerateContentResponse
|
---|
110 | * @throws \Google\Service\Exception
|
---|
111 | */
|
---|
112 | public function generateContent($model, GoogleCloudAiplatformV1GenerateContentRequest $postBody, $optParams = [])
|
---|
113 | {
|
---|
114 | $params = ['model' => $model, 'postBody' => $postBody];
|
---|
115 | $params = array_merge($params, $optParams);
|
---|
116 | return $this->call('generateContent', [$params], GoogleCloudAiplatformV1GenerateContentResponse::class);
|
---|
117 | }
|
---|
118 | /**
|
---|
119 | * Perform an online prediction. (models.predict)
|
---|
120 | *
|
---|
121 | * @param string $endpoint Required. The name of the Endpoint requested to serve
|
---|
122 | * the prediction. Format:
|
---|
123 | * `projects/{project}/locations/{location}/endpoints/{endpoint}`
|
---|
124 | * @param GoogleCloudAiplatformV1PredictRequest $postBody
|
---|
125 | * @param array $optParams Optional parameters.
|
---|
126 | * @return GoogleCloudAiplatformV1PredictResponse
|
---|
127 | * @throws \Google\Service\Exception
|
---|
128 | */
|
---|
129 | public function predict($endpoint, GoogleCloudAiplatformV1PredictRequest $postBody, $optParams = [])
|
---|
130 | {
|
---|
131 | $params = ['endpoint' => $endpoint, 'postBody' => $postBody];
|
---|
132 | $params = array_merge($params, $optParams);
|
---|
133 | return $this->call('predict', [$params], GoogleCloudAiplatformV1PredictResponse::class);
|
---|
134 | }
|
---|
135 | /**
|
---|
136 | * (models.predictLongRunning)
|
---|
137 | *
|
---|
138 | * @param string $endpoint Required. The name of the Endpoint requested to serve
|
---|
139 | * the prediction. Format:
|
---|
140 | * `projects/{project}/locations/{location}/endpoints/{endpoint}` or `projects/{
|
---|
141 | * project}/locations/{location}/publishers/{publisher}/models/{model}`
|
---|
142 | * @param GoogleCloudAiplatformV1PredictLongRunningRequest $postBody
|
---|
143 | * @param array $optParams Optional parameters.
|
---|
144 | * @return GoogleLongrunningOperation
|
---|
145 | * @throws \Google\Service\Exception
|
---|
146 | */
|
---|
147 | public function predictLongRunning($endpoint, GoogleCloudAiplatformV1PredictLongRunningRequest $postBody, $optParams = [])
|
---|
148 | {
|
---|
149 | $params = ['endpoint' => $endpoint, 'postBody' => $postBody];
|
---|
150 | $params = array_merge($params, $optParams);
|
---|
151 | return $this->call('predictLongRunning', [$params], GoogleLongrunningOperation::class);
|
---|
152 | }
|
---|
153 | /**
|
---|
154 | * Perform an online prediction with an arbitrary HTTP payload. The response
|
---|
155 | * includes the following HTTP headers: * `X-Vertex-AI-Endpoint-Id`: ID of the
|
---|
156 | * Endpoint that served this prediction. * `X-Vertex-AI-Deployed-Model-Id`: ID
|
---|
157 | * of the Endpoint's DeployedModel that served this prediction.
|
---|
158 | * (models.rawPredict)
|
---|
159 | *
|
---|
160 | * @param string $endpoint Required. The name of the Endpoint requested to serve
|
---|
161 | * the prediction. Format:
|
---|
162 | * `projects/{project}/locations/{location}/endpoints/{endpoint}`
|
---|
163 | * @param GoogleCloudAiplatformV1RawPredictRequest $postBody
|
---|
164 | * @param array $optParams Optional parameters.
|
---|
165 | * @return GoogleApiHttpBody
|
---|
166 | * @throws \Google\Service\Exception
|
---|
167 | */
|
---|
168 | public function rawPredict($endpoint, GoogleCloudAiplatformV1RawPredictRequest $postBody, $optParams = [])
|
---|
169 | {
|
---|
170 | $params = ['endpoint' => $endpoint, 'postBody' => $postBody];
|
---|
171 | $params = array_merge($params, $optParams);
|
---|
172 | return $this->call('rawPredict', [$params], GoogleApiHttpBody::class);
|
---|
173 | }
|
---|
174 | /**
|
---|
175 | * Perform a server-side streaming online prediction request for Vertex LLM
|
---|
176 | * streaming. (models.serverStreamingPredict)
|
---|
177 | *
|
---|
178 | * @param string $endpoint Required. The name of the Endpoint requested to serve
|
---|
179 | * the prediction. Format:
|
---|
180 | * `projects/{project}/locations/{location}/endpoints/{endpoint}`
|
---|
181 | * @param GoogleCloudAiplatformV1StreamingPredictRequest $postBody
|
---|
182 | * @param array $optParams Optional parameters.
|
---|
183 | * @return GoogleCloudAiplatformV1StreamingPredictResponse
|
---|
184 | * @throws \Google\Service\Exception
|
---|
185 | */
|
---|
186 | public function serverStreamingPredict($endpoint, GoogleCloudAiplatformV1StreamingPredictRequest $postBody, $optParams = [])
|
---|
187 | {
|
---|
188 | $params = ['endpoint' => $endpoint, 'postBody' => $postBody];
|
---|
189 | $params = array_merge($params, $optParams);
|
---|
190 | return $this->call('serverStreamingPredict', [$params], GoogleCloudAiplatformV1StreamingPredictResponse::class);
|
---|
191 | }
|
---|
192 | /**
|
---|
193 | * Generate content with multimodal inputs with streaming support.
|
---|
194 | * (models.streamGenerateContent)
|
---|
195 | *
|
---|
196 | * @param string $model Required. The fully qualified name of the publisher
|
---|
197 | * model or tuned model endpoint to use. Publisher model format:
|
---|
198 | * `projects/{project}/locations/{location}/publishers/models` Tuned model
|
---|
199 | * endpoint format:
|
---|
200 | * `projects/{project}/locations/{location}/endpoints/{endpoint}`
|
---|
201 | * @param GoogleCloudAiplatformV1GenerateContentRequest $postBody
|
---|
202 | * @param array $optParams Optional parameters.
|
---|
203 | * @return GoogleCloudAiplatformV1GenerateContentResponse
|
---|
204 | * @throws \Google\Service\Exception
|
---|
205 | */
|
---|
206 | public function streamGenerateContent($model, GoogleCloudAiplatformV1GenerateContentRequest $postBody, $optParams = [])
|
---|
207 | {
|
---|
208 | $params = ['model' => $model, 'postBody' => $postBody];
|
---|
209 | $params = array_merge($params, $optParams);
|
---|
210 | return $this->call('streamGenerateContent', [$params], GoogleCloudAiplatformV1GenerateContentResponse::class);
|
---|
211 | }
|
---|
212 | /**
|
---|
213 | * Perform a streaming online prediction with an arbitrary HTTP payload.
|
---|
214 | * (models.streamRawPredict)
|
---|
215 | *
|
---|
216 | * @param string $endpoint Required. The name of the Endpoint requested to serve
|
---|
217 | * the prediction. Format:
|
---|
218 | * `projects/{project}/locations/{location}/endpoints/{endpoint}`
|
---|
219 | * @param GoogleCloudAiplatformV1StreamRawPredictRequest $postBody
|
---|
220 | * @param array $optParams Optional parameters.
|
---|
221 | * @return GoogleApiHttpBody
|
---|
222 | * @throws \Google\Service\Exception
|
---|
223 | */
|
---|
224 | public function streamRawPredict($endpoint, GoogleCloudAiplatformV1StreamRawPredictRequest $postBody, $optParams = [])
|
---|
225 | {
|
---|
226 | $params = ['endpoint' => $endpoint, 'postBody' => $postBody];
|
---|
227 | $params = array_merge($params, $optParams);
|
---|
228 | return $this->call('streamRawPredict', [$params], GoogleApiHttpBody::class);
|
---|
229 | }
|
---|
230 | }
|
---|
231 |
|
---|
232 | // Adding a class alias for backwards compatibility with the previous class name.
|
---|
233 | class_alias(ProjectsLocationsPublishersModels::class, 'Google_Service_Aiplatform_Resource_ProjectsLocationsPublishersModels');
|
---|