summaryrefslogtreecommitdiff
path: root/frontend-old/node_modules/@firebase/ai/dist/esm/src/requests
diff options
context:
space:
mode:
authoraltaf-creator <dev@altafcreator.com>2025-11-09 11:15:19 +0800
committeraltaf-creator <dev@altafcreator.com>2025-11-09 11:15:19 +0800
commit8eff962cab608341a6f2fedc640a0e32d96f26e2 (patch)
tree05534d1a720ddc3691d346c69b4972555820a061 /frontend-old/node_modules/@firebase/ai/dist/esm/src/requests
pain
Diffstat (limited to 'frontend-old/node_modules/@firebase/ai/dist/esm/src/requests')
-rw-r--r--frontend-old/node_modules/@firebase/ai/dist/esm/src/requests/hybrid-helpers.d.ts33
-rw-r--r--frontend-old/node_modules/@firebase/ai/dist/esm/src/requests/imagen-image-format.d.ts61
-rw-r--r--frontend-old/node_modules/@firebase/ai/dist/esm/src/requests/request-helpers.d.ts28
-rw-r--r--frontend-old/node_modules/@firebase/ai/dist/esm/src/requests/request.d.ts49
-rw-r--r--frontend-old/node_modules/@firebase/ai/dist/esm/src/requests/response-helpers.d.ts57
-rw-r--r--frontend-old/node_modules/@firebase/ai/dist/esm/src/requests/schema-builder.d.ts170
-rw-r--r--frontend-old/node_modules/@firebase/ai/dist/esm/src/requests/stream-reader.d.ts39
7 files changed, 437 insertions, 0 deletions
diff --git a/frontend-old/node_modules/@firebase/ai/dist/esm/src/requests/hybrid-helpers.d.ts b/frontend-old/node_modules/@firebase/ai/dist/esm/src/requests/hybrid-helpers.d.ts
new file mode 100644
index 0000000..b52e6bf
--- /dev/null
+++ b/frontend-old/node_modules/@firebase/ai/dist/esm/src/requests/hybrid-helpers.d.ts
@@ -0,0 +1,33 @@
+/**
+ * @license
+ * Copyright 2025 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import { GenerateContentRequest, ChromeAdapter, InferenceSource } from '../types';
+interface CallResult<Response> {
+ response: Response;
+ inferenceSource: InferenceSource;
+}
+/**
+ * Dispatches a request to the appropriate backend (on-device or in-cloud)
+ * based on the inference mode.
+ *
+ * @param request - The request to be sent.
+ * @param chromeAdapter - The on-device model adapter.
+ * @param onDeviceCall - The function to call for on-device inference.
+ * @param inCloudCall - The function to call for in-cloud inference.
+ * @returns The response from the backend.
+ */
+export declare function callCloudOrDevice<Response>(request: GenerateContentRequest, chromeAdapter: ChromeAdapter | undefined, onDeviceCall: () => Promise<Response>, inCloudCall: () => Promise<Response>): Promise<CallResult<Response>>;
+export {};
diff --git a/frontend-old/node_modules/@firebase/ai/dist/esm/src/requests/imagen-image-format.d.ts b/frontend-old/node_modules/@firebase/ai/dist/esm/src/requests/imagen-image-format.d.ts
new file mode 100644
index 0000000..2f3eddb
--- /dev/null
+++ b/frontend-old/node_modules/@firebase/ai/dist/esm/src/requests/imagen-image-format.d.ts
@@ -0,0 +1,61 @@
+/**
+ * @license
+ * Copyright 2025 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * Defines the image format for images generated by Imagen.
+ *
+ * Use this class to specify the desired format (JPEG or PNG) and compression quality
+ * for images generated by Imagen. This is typically included as part of
+ * {@link ImagenModelParams}.
+ *
+ * @example
+ * ```javascript
+ * const imagenModelParams = {
+ * // ... other ImagenModelParams
+ * imageFormat: ImagenImageFormat.jpeg(75) // JPEG with a compression level of 75.
+ * }
+ * ```
+ *
+ * @public
+ */
+export declare class ImagenImageFormat {
+ /**
+ * The MIME type.
+ */
+ mimeType: string;
+ /**
+ * The level of compression (a number between 0 and 100).
+ */
+ compressionQuality?: number;
+ private constructor();
+ /**
+ * Creates an {@link ImagenImageFormat} for a JPEG image.
+ *
+ * @param compressionQuality - The level of compression (a number between 0 and 100).
+ * @returns An {@link ImagenImageFormat} object for a JPEG image.
+ *
+ * @public
+ */
+ static jpeg(compressionQuality?: number): ImagenImageFormat;
+ /**
+ * Creates an {@link ImagenImageFormat} for a PNG image.
+ *
+ * @returns An {@link ImagenImageFormat} object for a PNG image.
+ *
+ * @public
+ */
+ static png(): ImagenImageFormat;
+}
diff --git a/frontend-old/node_modules/@firebase/ai/dist/esm/src/requests/request-helpers.d.ts b/frontend-old/node_modules/@firebase/ai/dist/esm/src/requests/request-helpers.d.ts
new file mode 100644
index 0000000..fa79626
--- /dev/null
+++ b/frontend-old/node_modules/@firebase/ai/dist/esm/src/requests/request-helpers.d.ts
@@ -0,0 +1,28 @@
+/**
+ * @license
+ * Copyright 2024 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import { Content, GenerateContentRequest, Part } from '../types';
+import { ImagenGenerationParams, PredictRequestBody } from '../types/internal';
+export declare function formatSystemInstruction(input?: string | Part | Content): Content | undefined;
+export declare function formatNewContent(request: string | Array<string | Part>): Content;
+export declare function formatGenerateContentInput(params: GenerateContentRequest | string | Array<string | Part>): GenerateContentRequest;
+/**
+ * Convert the user-defined parameters in {@link ImagenGenerationParams} to the format
+ * that is expected from the REST API.
+ *
+ * @internal
+ */
+export declare function createPredictRequestBody(prompt: string, { gcsURI, imageFormat, addWatermark, numberOfImages, negativePrompt, aspectRatio, safetyFilterLevel, personFilterLevel }: ImagenGenerationParams): PredictRequestBody;
diff --git a/frontend-old/node_modules/@firebase/ai/dist/esm/src/requests/request.d.ts b/frontend-old/node_modules/@firebase/ai/dist/esm/src/requests/request.d.ts
new file mode 100644
index 0000000..b0aed14
--- /dev/null
+++ b/frontend-old/node_modules/@firebase/ai/dist/esm/src/requests/request.d.ts
@@ -0,0 +1,49 @@
+/**
+ * @license
+ * Copyright 2024 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import { RequestOptions } from '../types';
+import { ApiSettings } from '../types/internal';
+export declare enum Task {
+ GENERATE_CONTENT = "generateContent",
+ STREAM_GENERATE_CONTENT = "streamGenerateContent",
+ COUNT_TOKENS = "countTokens",
+ PREDICT = "predict"
+}
+export declare class RequestUrl {
+ model: string;
+ task: Task;
+ apiSettings: ApiSettings;
+ stream: boolean;
+ requestOptions?: RequestOptions | undefined;
+ constructor(model: string, task: Task, apiSettings: ApiSettings, stream: boolean, requestOptions?: RequestOptions | undefined);
+ toString(): string;
+ private get baseUrl();
+ private get apiVersion();
+ private get modelPath();
+ private get queryParams();
+}
+export declare class WebSocketUrl {
+ apiSettings: ApiSettings;
+ constructor(apiSettings: ApiSettings);
+ toString(): string;
+ private get pathname();
+}
+export declare function getHeaders(url: RequestUrl): Promise<Headers>;
+export declare function constructRequest(model: string, task: Task, apiSettings: ApiSettings, stream: boolean, body: string, requestOptions?: RequestOptions): Promise<{
+ url: string;
+ fetchOptions: RequestInit;
+}>;
+export declare function makeRequest(model: string, task: Task, apiSettings: ApiSettings, stream: boolean, body: string, requestOptions?: RequestOptions): Promise<Response>;
diff --git a/frontend-old/node_modules/@firebase/ai/dist/esm/src/requests/response-helpers.d.ts b/frontend-old/node_modules/@firebase/ai/dist/esm/src/requests/response-helpers.d.ts
new file mode 100644
index 0000000..d0aded1
--- /dev/null
+++ b/frontend-old/node_modules/@firebase/ai/dist/esm/src/requests/response-helpers.d.ts
@@ -0,0 +1,57 @@
+/**
+ * @license
+ * Copyright 2024 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import { EnhancedGenerateContentResponse, FunctionCall, GenerateContentResponse, ImagenGCSImage, ImagenInlineImage, InlineDataPart, Part, InferenceSource } from '../types';
+/**
+ * Creates an EnhancedGenerateContentResponse object that has helper functions and
+ * other modifications that improve usability.
+ */
+export declare function createEnhancedContentResponse(response: GenerateContentResponse, inferenceSource?: InferenceSource): EnhancedGenerateContentResponse;
+/**
+ * Adds convenience helper methods to a response object, including stream
+ * chunks (as long as each chunk is a complete GenerateContentResponse JSON).
+ */
+export declare function addHelpers(response: GenerateContentResponse): EnhancedGenerateContentResponse;
+/**
+ * Returns all text from the first candidate's parts, filtering by whether
+ * `partFilter()` returns true.
+ *
+ * @param response - The `GenerateContentResponse` from which to extract text.
+ * @param partFilter - Only return `Part`s for which this returns true
+ */
+export declare function getText(response: GenerateContentResponse, partFilter: (part: Part) => boolean): string;
+/**
+ * Returns every {@link FunctionCall} associated with first candidate.
+ */
+export declare function getFunctionCalls(response: GenerateContentResponse): FunctionCall[] | undefined;
+/**
+ * Returns every {@link InlineDataPart} in the first candidate if present.
+ *
+ * @internal
+ */
+export declare function getInlineDataParts(response: GenerateContentResponse): InlineDataPart[] | undefined;
+export declare function formatBlockErrorMessage(response: GenerateContentResponse): string;
+/**
+ * Convert a generic successful fetch response body to an Imagen response object
+ * that can be returned to the user. This converts the REST APIs response format to our
+ * APIs representation of a response.
+ *
+ * @internal
+ */
+export declare function handlePredictResponse<T extends ImagenInlineImage | ImagenGCSImage>(response: Response): Promise<{
+ images: T[];
+ filteredReason?: string;
+}>;
diff --git a/frontend-old/node_modules/@firebase/ai/dist/esm/src/requests/schema-builder.d.ts b/frontend-old/node_modules/@firebase/ai/dist/esm/src/requests/schema-builder.d.ts
new file mode 100644
index 0000000..e23e74f
--- /dev/null
+++ b/frontend-old/node_modules/@firebase/ai/dist/esm/src/requests/schema-builder.d.ts
@@ -0,0 +1,170 @@
+/**
+ * @license
+ * Copyright 2024 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import { SchemaInterface, SchemaType, SchemaParams, SchemaRequest } from '../types/schema';
+/**
+ * Parent class encompassing all Schema types, with static methods that
+ * allow building specific Schema types. This class can be converted with
+ * `JSON.stringify()` into a JSON string accepted by Vertex AI REST endpoints.
+ * (This string conversion is automatically done when calling SDK methods.)
+ * @public
+ */
+export declare abstract class Schema implements SchemaInterface {
+ /**
+ * Optional. The type of the property.
+ * This can only be undefined when using `anyOf` schemas, which do not have an
+ * explicit type in the {@link https://swagger.io/docs/specification/v3_0/data-models/data-types/#any-type | OpenAPI specification}.
+ */
+ type?: SchemaType;
+ /** Optional. The format of the property.
+ * Supported formats:<br/>
+ * <ul>
+ * <li>for NUMBER type: "float", "double"</li>
+ * <li>for INTEGER type: "int32", "int64"</li>
+ * <li>for STRING type: "email", "byte", etc</li>
+ * </ul>
+ */
+ format?: string;
+ /** Optional. The description of the property. */
+ description?: string;
+ /** Optional. The items of the property. */
+ items?: SchemaInterface;
+ /** The minimum number of items (elements) in a schema of {@link (SchemaType:type)} `array`. */
+ minItems?: number;
+ /** The maximum number of items (elements) in a schema of {@link (SchemaType:type)} `array`. */
+ maxItems?: number;
+ /** Optional. Whether the property is nullable. Defaults to false. */
+ nullable: boolean;
+ /** Optional. The example of the property. */
+ example?: unknown;
+ /**
+ * Allows user to add other schema properties that have not yet
+ * been officially added to the SDK.
+ */
+ [key: string]: unknown;
+ constructor(schemaParams: SchemaInterface);
+ /**
+ * Defines how this Schema should be serialized as JSON.
+ * See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#tojson_behavior
+ * @internal
+ */
+ toJSON(): SchemaRequest;
+ static array(arrayParams: SchemaParams & {
+ items: Schema;
+ }): ArraySchema;
+ static object(objectParams: SchemaParams & {
+ properties: {
+ [k: string]: Schema;
+ };
+ optionalProperties?: string[];
+ }): ObjectSchema;
+ static string(stringParams?: SchemaParams): StringSchema;
+ static enumString(stringParams: SchemaParams & {
+ enum: string[];
+ }): StringSchema;
+ static integer(integerParams?: SchemaParams): IntegerSchema;
+ static number(numberParams?: SchemaParams): NumberSchema;
+ static boolean(booleanParams?: SchemaParams): BooleanSchema;
+ static anyOf(anyOfParams: SchemaParams & {
+ anyOf: TypedSchema[];
+ }): AnyOfSchema;
+}
+/**
+ * A type that includes all specific Schema types.
+ * @public
+ */
+export type TypedSchema = IntegerSchema | NumberSchema | StringSchema | BooleanSchema | ObjectSchema | ArraySchema | AnyOfSchema;
+/**
+ * Schema class for "integer" types.
+ * @public
+ */
+export declare class IntegerSchema extends Schema {
+ constructor(schemaParams?: SchemaParams);
+}
+/**
+ * Schema class for "number" types.
+ * @public
+ */
+export declare class NumberSchema extends Schema {
+ constructor(schemaParams?: SchemaParams);
+}
+/**
+ * Schema class for "boolean" types.
+ * @public
+ */
+export declare class BooleanSchema extends Schema {
+ constructor(schemaParams?: SchemaParams);
+}
+/**
+ * Schema class for "string" types. Can be used with or without
+ * enum values.
+ * @public
+ */
+export declare class StringSchema extends Schema {
+ enum?: string[];
+ constructor(schemaParams?: SchemaParams, enumValues?: string[]);
+ /**
+ * @internal
+ */
+ toJSON(): SchemaRequest;
+}
+/**
+ * Schema class for "array" types.
+ * The `items` param should refer to the type of item that can be a member
+ * of the array.
+ * @public
+ */
+export declare class ArraySchema extends Schema {
+ items: TypedSchema;
+ constructor(schemaParams: SchemaParams, items: TypedSchema);
+ /**
+ * @internal
+ */
+ toJSON(): SchemaRequest;
+}
+/**
+ * Schema class for "object" types.
+ * The `properties` param must be a map of `Schema` objects.
+ * @public
+ */
+export declare class ObjectSchema extends Schema {
+ properties: {
+ [k: string]: TypedSchema;
+ };
+ optionalProperties: string[];
+ constructor(schemaParams: SchemaParams, properties: {
+ [k: string]: TypedSchema;
+ }, optionalProperties?: string[]);
+ /**
+ * @internal
+ */
+ toJSON(): SchemaRequest;
+}
+/**
+ * Schema class representing a value that can conform to any of the provided sub-schemas. This is
+ * useful when a field can accept multiple distinct types or structures.
+ * @public
+ */
+export declare class AnyOfSchema extends Schema {
+ anyOf: TypedSchema[];
+ constructor(schemaParams: SchemaParams & {
+ anyOf: TypedSchema[];
+ });
+ /**
+ * @internal
+ */
+ toJSON(): SchemaRequest;
+}
diff --git a/frontend-old/node_modules/@firebase/ai/dist/esm/src/requests/stream-reader.d.ts b/frontend-old/node_modules/@firebase/ai/dist/esm/src/requests/stream-reader.d.ts
new file mode 100644
index 0000000..4ffb0da
--- /dev/null
+++ b/frontend-old/node_modules/@firebase/ai/dist/esm/src/requests/stream-reader.d.ts
@@ -0,0 +1,39 @@
+/**
+ * @license
+ * Copyright 2024 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import { GenerateContentResponse, GenerateContentStreamResult } from '../types';
+import { ApiSettings } from '../types/internal';
+import { InferenceSource } from '../public-types';
+/**
+ * Process a response.body stream from the backend and return an
+ * iterator that provides one complete GenerateContentResponse at a time
+ * and a promise that resolves with a single aggregated
+ * GenerateContentResponse.
+ *
+ * @param response - Response from a fetch call
+ */
+export declare function processStream(response: Response, apiSettings: ApiSettings, inferenceSource?: InferenceSource): GenerateContentStreamResult;
+/**
+ * Reads a raw stream from the fetch response and join incomplete
+ * chunks, returning a new stream that provides a single complete
+ * GenerateContentResponse in each iteration.
+ */
+export declare function getResponseStream<T>(inputStream: ReadableStream<string>): ReadableStream<T>;
+/**
+ * Aggregates an array of `GenerateContentResponse`s into a single
+ * GenerateContentResponse.
+ */
+export declare function aggregateResponses(responses: GenerateContentResponse[]): GenerateContentResponse;