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\GoogleCloudAiplatformV1ComputeTokensRequest;
|
---|
21 | use Google\Service\Aiplatform\GoogleCloudAiplatformV1ComputeTokensResponse;
|
---|
22 | use Google\Service\Aiplatform\GoogleCloudAiplatformV1CountTokensRequest;
|
---|
23 | use Google\Service\Aiplatform\GoogleCloudAiplatformV1CountTokensResponse;
|
---|
24 | use Google\Service\Aiplatform\GoogleCloudAiplatformV1GenerateContentRequest;
|
---|
25 | use Google\Service\Aiplatform\GoogleCloudAiplatformV1GenerateContentResponse;
|
---|
26 | use Google\Service\Aiplatform\GoogleCloudAiplatformV1PublisherModel;
|
---|
27 |
|
---|
28 | /**
|
---|
29 | * The "models" collection of methods.
|
---|
30 | * Typical usage is:
|
---|
31 | * <code>
|
---|
32 | * $aiplatformService = new Google\Service\Aiplatform(...);
|
---|
33 | * $models = $aiplatformService->publishers_models;
|
---|
34 | * </code>
|
---|
35 | */
|
---|
36 | class PublishersModels extends \Google\Service\Resource
|
---|
37 | {
|
---|
38 | /**
|
---|
39 | * Return a list of tokens based on the input text. (models.computeTokens)
|
---|
40 | *
|
---|
41 | * @param string $endpoint Required. The name of the Endpoint requested to get
|
---|
42 | * lists of tokens and token ids.
|
---|
43 | * @param GoogleCloudAiplatformV1ComputeTokensRequest $postBody
|
---|
44 | * @param array $optParams Optional parameters.
|
---|
45 | * @return GoogleCloudAiplatformV1ComputeTokensResponse
|
---|
46 | * @throws \Google\Service\Exception
|
---|
47 | */
|
---|
48 | public function computeTokens($endpoint, GoogleCloudAiplatformV1ComputeTokensRequest $postBody, $optParams = [])
|
---|
49 | {
|
---|
50 | $params = ['endpoint' => $endpoint, 'postBody' => $postBody];
|
---|
51 | $params = array_merge($params, $optParams);
|
---|
52 | return $this->call('computeTokens', [$params], GoogleCloudAiplatformV1ComputeTokensResponse::class);
|
---|
53 | }
|
---|
54 | /**
|
---|
55 | * Perform a token counting. (models.countTokens)
|
---|
56 | *
|
---|
57 | * @param string $endpoint Required. The name of the Endpoint requested to
|
---|
58 | * perform token counting. Format:
|
---|
59 | * `projects/{project}/locations/{location}/endpoints/{endpoint}`
|
---|
60 | * @param GoogleCloudAiplatformV1CountTokensRequest $postBody
|
---|
61 | * @param array $optParams Optional parameters.
|
---|
62 | * @return GoogleCloudAiplatformV1CountTokensResponse
|
---|
63 | * @throws \Google\Service\Exception
|
---|
64 | */
|
---|
65 | public function countTokens($endpoint, GoogleCloudAiplatformV1CountTokensRequest $postBody, $optParams = [])
|
---|
66 | {
|
---|
67 | $params = ['endpoint' => $endpoint, 'postBody' => $postBody];
|
---|
68 | $params = array_merge($params, $optParams);
|
---|
69 | return $this->call('countTokens', [$params], GoogleCloudAiplatformV1CountTokensResponse::class);
|
---|
70 | }
|
---|
71 | /**
|
---|
72 | * Generate content with multimodal inputs. (models.generateContent)
|
---|
73 | *
|
---|
74 | * @param string $model Required. The fully qualified name of the publisher
|
---|
75 | * model or tuned model endpoint to use. Publisher model format:
|
---|
76 | * `projects/{project}/locations/{location}/publishers/models` Tuned model
|
---|
77 | * endpoint format:
|
---|
78 | * `projects/{project}/locations/{location}/endpoints/{endpoint}`
|
---|
79 | * @param GoogleCloudAiplatformV1GenerateContentRequest $postBody
|
---|
80 | * @param array $optParams Optional parameters.
|
---|
81 | * @return GoogleCloudAiplatformV1GenerateContentResponse
|
---|
82 | * @throws \Google\Service\Exception
|
---|
83 | */
|
---|
84 | public function generateContent($model, GoogleCloudAiplatformV1GenerateContentRequest $postBody, $optParams = [])
|
---|
85 | {
|
---|
86 | $params = ['model' => $model, 'postBody' => $postBody];
|
---|
87 | $params = array_merge($params, $optParams);
|
---|
88 | return $this->call('generateContent', [$params], GoogleCloudAiplatformV1GenerateContentResponse::class);
|
---|
89 | }
|
---|
90 | /**
|
---|
91 | * Gets a Model Garden publisher model. (models.get)
|
---|
92 | *
|
---|
93 | * @param string $name Required. The name of the PublisherModel resource.
|
---|
94 | * Format: `publishers/{publisher}/models/{publisher_model}`
|
---|
95 | * @param array $optParams Optional parameters.
|
---|
96 | *
|
---|
97 | * @opt_param string huggingFaceToken Optional. Token used to access Hugging
|
---|
98 | * Face gated models.
|
---|
99 | * @opt_param bool isHuggingFaceModel Optional. Boolean indicates whether the
|
---|
100 | * requested model is a Hugging Face model.
|
---|
101 | * @opt_param string languageCode Optional. The IETF BCP-47 language code
|
---|
102 | * representing the language in which the publisher model's text information
|
---|
103 | * should be written in.
|
---|
104 | * @opt_param string view Optional. PublisherModel view specifying which fields
|
---|
105 | * to read.
|
---|
106 | * @return GoogleCloudAiplatformV1PublisherModel
|
---|
107 | * @throws \Google\Service\Exception
|
---|
108 | */
|
---|
109 | public function get($name, $optParams = [])
|
---|
110 | {
|
---|
111 | $params = ['name' => $name];
|
---|
112 | $params = array_merge($params, $optParams);
|
---|
113 | return $this->call('get', [$params], GoogleCloudAiplatformV1PublisherModel::class);
|
---|
114 | }
|
---|
115 | /**
|
---|
116 | * Generate content with multimodal inputs with streaming support.
|
---|
117 | * (models.streamGenerateContent)
|
---|
118 | *
|
---|
119 | * @param string $model Required. The fully qualified name of the publisher
|
---|
120 | * model or tuned model endpoint to use. Publisher model format:
|
---|
121 | * `projects/{project}/locations/{location}/publishers/models` Tuned model
|
---|
122 | * endpoint format:
|
---|
123 | * `projects/{project}/locations/{location}/endpoints/{endpoint}`
|
---|
124 | * @param GoogleCloudAiplatformV1GenerateContentRequest $postBody
|
---|
125 | * @param array $optParams Optional parameters.
|
---|
126 | * @return GoogleCloudAiplatformV1GenerateContentResponse
|
---|
127 | * @throws \Google\Service\Exception
|
---|
128 | */
|
---|
129 | public function streamGenerateContent($model, GoogleCloudAiplatformV1GenerateContentRequest $postBody, $optParams = [])
|
---|
130 | {
|
---|
131 | $params = ['model' => $model, 'postBody' => $postBody];
|
---|
132 | $params = array_merge($params, $optParams);
|
---|
133 | return $this->call('streamGenerateContent', [$params], GoogleCloudAiplatformV1GenerateContentResponse::class);
|
---|
134 | }
|
---|
135 | }
|
---|
136 |
|
---|
137 | // Adding a class alias for backwards compatibility with the previous class name.
|
---|
138 | class_alias(PublishersModels::class, 'Google_Service_Aiplatform_Resource_PublishersModels');
|
---|