diff options
Diffstat (limited to 'frontend-old/node_modules/@firebase/ai/dist/esm/src/methods')
7 files changed, 0 insertions, 544 deletions
diff --git a/frontend-old/node_modules/@firebase/ai/dist/esm/src/methods/chat-session-helpers.d.ts b/frontend-old/node_modules/@firebase/ai/dist/esm/src/methods/chat-session-helpers.d.ts deleted file mode 100644 index 65e4eef..0000000 --- a/frontend-old/node_modules/@firebase/ai/dist/esm/src/methods/chat-session-helpers.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -/** - * @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 } from '../types'; -export declare function validateChatHistory(history: Content[]): void; diff --git a/frontend-old/node_modules/@firebase/ai/dist/esm/src/methods/chat-session.d.ts b/frontend-old/node_modules/@firebase/ai/dist/esm/src/methods/chat-session.d.ts deleted file mode 100644 index 2f2557a..0000000 --- a/frontend-old/node_modules/@firebase/ai/dist/esm/src/methods/chat-session.d.ts +++ /dev/null @@ -1,52 +0,0 @@ -/** - * @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, GenerateContentResult, GenerateContentStreamResult, Part, RequestOptions, StartChatParams } from '../types'; -import { ApiSettings } from '../types/internal'; -import { ChromeAdapter } from '../types/chrome-adapter'; -/** - * ChatSession class that enables sending chat messages and stores - * history of sent and received messages so far. - * - * @public - */ -export declare class ChatSession { - model: string; - private chromeAdapter?; - params?: StartChatParams | undefined; - requestOptions?: RequestOptions | undefined; - private _apiSettings; - private _history; - private _sendPromise; - constructor(apiSettings: ApiSettings, model: string, chromeAdapter?: ChromeAdapter | undefined, params?: StartChatParams | undefined, requestOptions?: RequestOptions | undefined); - /** - * Gets the chat history so far. Blocked prompts are not added to history. - * Neither blocked candidates nor the prompts that generated them are added - * to history. - */ - getHistory(): Promise<Content[]>; - /** - * Sends a chat message and receives a non-streaming - * {@link GenerateContentResult} - */ - sendMessage(request: string | Array<string | Part>): Promise<GenerateContentResult>; - /** - * Sends a chat message and receives the response as a - * {@link GenerateContentStreamResult} containing an iterable stream - * and a response promise. - */ - sendMessageStream(request: string | Array<string | Part>): Promise<GenerateContentStreamResult>; -} diff --git a/frontend-old/node_modules/@firebase/ai/dist/esm/src/methods/chrome-adapter.d.ts b/frontend-old/node_modules/@firebase/ai/dist/esm/src/methods/chrome-adapter.d.ts deleted file mode 100644 index 5bd0a99..0000000 --- a/frontend-old/node_modules/@firebase/ai/dist/esm/src/methods/chrome-adapter.d.ts +++ /dev/null @@ -1,124 +0,0 @@ -/** - * @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 { CountTokensRequest, GenerateContentRequest, InferenceMode, OnDeviceParams } from '../types'; -import { ChromeAdapter } from '../types/chrome-adapter'; -import { LanguageModel } from '../types/language-model'; -/** - * Defines an inference "backend" that uses Chrome's on-device model, - * and encapsulates logic for detecting when on-device inference is - * possible. - */ -export declare class ChromeAdapterImpl implements ChromeAdapter { - languageModelProvider: LanguageModel; - mode: InferenceMode; - static SUPPORTED_MIME_TYPES: string[]; - private isDownloading; - private downloadPromise; - private oldSession; - onDeviceParams: OnDeviceParams; - constructor(languageModelProvider: LanguageModel, mode: InferenceMode, onDeviceParams?: OnDeviceParams); - /** - * Checks if a given request can be made on-device. - * - * Encapsulates a few concerns: - * the mode - * API existence - * prompt formatting - * model availability, including triggering download if necessary - * - * - * Pros: callers needn't be concerned with details of on-device availability.</p> - * Cons: this method spans a few concerns and splits request validation from usage. - * If instance variables weren't already part of the API, we could consider a better - * separation of concerns. - */ - isAvailable(request: GenerateContentRequest): Promise<boolean>; - /** - * Generates content on device. - * - * @remarks - * This is comparable to {@link GenerativeModel.generateContent} for generating content in - * Cloud. - * @param request - a standard Firebase AI {@link GenerateContentRequest} - * @returns {@link Response}, so we can reuse common response formatting. - */ - generateContent(request: GenerateContentRequest): Promise<Response>; - /** - * Generates content stream on device. - * - * @remarks - * This is comparable to {@link GenerativeModel.generateContentStream} for generating content in - * Cloud. - * @param request - a standard Firebase AI {@link GenerateContentRequest} - * @returns {@link Response}, so we can reuse common response formatting. - */ - generateContentStream(request: GenerateContentRequest): Promise<Response>; - countTokens(_request: CountTokensRequest): Promise<Response>; - /** - * Asserts inference for the given request can be performed by an on-device model. - */ - private static isOnDeviceRequest; - /** - * Encapsulates logic to get availability and download a model if one is downloadable. - */ - private downloadIfAvailable; - /** - * Triggers out-of-band download of an on-device model. - * - * Chrome only downloads models as needed. Chrome knows a model is needed when code calls - * LanguageModel.create. - * - * Since Chrome manages the download, the SDK can only avoid redundant download requests by - * tracking if a download has previously been requested. - */ - private download; - /** - * Converts Firebase AI {@link Content} object to a Chrome {@link LanguageModelMessage} object. - */ - private static toLanguageModelMessage; - /** - * Converts a Firebase AI Part object to a Chrome LanguageModelMessageContent object. - */ - private static toLanguageModelMessageContent; - /** - * Converts a Firebase AI {@link Role} string to a {@link LanguageModelMessageRole} string. - */ - private static toLanguageModelMessageRole; - /** - * Abstracts Chrome session creation. - * - * Chrome uses a multi-turn session for all inference. Firebase AI uses single-turn for all - * inference. To map the Firebase AI API to Chrome's API, the SDK creates a new session for all - * inference. - * - * Chrome will remove a model from memory if it's no longer in use, so this method ensures a - * new session is created before an old session is destroyed. - */ - private createSession; - /** - * Formats string returned by Chrome as a {@link Response} returned by Firebase AI. - */ - private static toResponse; - /** - * Formats string stream returned by Chrome as SSE returned by Firebase AI. - */ - private static toStreamResponse; -} -/** - * Creates a ChromeAdapterImpl on demand. - */ -export declare function chromeAdapterFactory(mode: InferenceMode, window?: Window, params?: OnDeviceParams): ChromeAdapterImpl | undefined; diff --git a/frontend-old/node_modules/@firebase/ai/dist/esm/src/methods/count-tokens.d.ts b/frontend-old/node_modules/@firebase/ai/dist/esm/src/methods/count-tokens.d.ts deleted file mode 100644 index 9f94f86..0000000 --- a/frontend-old/node_modules/@firebase/ai/dist/esm/src/methods/count-tokens.d.ts +++ /dev/null @@ -1,21 +0,0 @@ -/** - * @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 { CountTokensRequest, CountTokensResponse, RequestOptions } from '../types'; -import { ApiSettings } from '../types/internal'; -import { ChromeAdapter } from '../types/chrome-adapter'; -export declare function countTokensOnCloud(apiSettings: ApiSettings, model: string, params: CountTokensRequest, requestOptions?: RequestOptions): Promise<CountTokensResponse>; -export declare function countTokens(apiSettings: ApiSettings, model: string, params: CountTokensRequest, chromeAdapter?: ChromeAdapter, requestOptions?: RequestOptions): Promise<CountTokensResponse>; diff --git a/frontend-old/node_modules/@firebase/ai/dist/esm/src/methods/generate-content.d.ts b/frontend-old/node_modules/@firebase/ai/dist/esm/src/methods/generate-content.d.ts deleted file mode 100644 index 96493bd..0000000 --- a/frontend-old/node_modules/@firebase/ai/dist/esm/src/methods/generate-content.d.ts +++ /dev/null @@ -1,21 +0,0 @@ -/** - * @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 { GenerateContentRequest, GenerateContentResult, GenerateContentStreamResult, RequestOptions } from '../types'; -import { ApiSettings } from '../types/internal'; -import { ChromeAdapter } from '../types/chrome-adapter'; -export declare function generateContentStream(apiSettings: ApiSettings, model: string, params: GenerateContentRequest, chromeAdapter?: ChromeAdapter, requestOptions?: RequestOptions): Promise<GenerateContentStreamResult>; -export declare function generateContent(apiSettings: ApiSettings, model: string, params: GenerateContentRequest, chromeAdapter?: ChromeAdapter, requestOptions?: RequestOptions): Promise<GenerateContentResult>; diff --git a/frontend-old/node_modules/@firebase/ai/dist/esm/src/methods/live-session-helpers.d.ts b/frontend-old/node_modules/@firebase/ai/dist/esm/src/methods/live-session-helpers.d.ts deleted file mode 100644 index c6f8dea..0000000 --- a/frontend-old/node_modules/@firebase/ai/dist/esm/src/methods/live-session-helpers.d.ts +++ /dev/null @@ -1,154 +0,0 @@ -/** - * @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 { FunctionCall, FunctionResponse } from '../types'; -import { LiveSession } from './live-session'; -/** - * A controller for managing an active audio conversation. - * - * @beta - */ -export interface AudioConversationController { - /** - * Stops the audio conversation, closes the microphone connection, and - * cleans up resources. Returns a promise that resolves when cleanup is complete. - */ - stop: () => Promise<void>; -} -/** - * Options for {@link startAudioConversation}. - * - * @beta - */ -export interface StartAudioConversationOptions { - /** - * An async handler that is called when the model requests a function to be executed. - * The handler should perform the function call and return the result as a `Part`, - * which will then be sent back to the model. - */ - functionCallingHandler?: (functionCalls: FunctionCall[]) => Promise<FunctionResponse>; -} -/** - * Dependencies needed by the {@link AudioConversationRunner}. - * - * @internal - */ -interface RunnerDependencies { - audioContext: AudioContext; - mediaStream: MediaStream; - sourceNode: MediaStreamAudioSourceNode; - workletNode: AudioWorkletNode; -} -/** - * Encapsulates the core logic of an audio conversation. - * - * @internal - */ -export declare class AudioConversationRunner { - private readonly liveSession; - private readonly options; - private readonly deps; - /** A flag to indicate if the conversation has been stopped. */ - private isStopped; - /** A deferred that contains a promise that is resolved when stop() is called, to unblock the receive loop. */ - private readonly stopDeferred; - /** A promise that tracks the lifecycle of the main `runReceiveLoop`. */ - private readonly receiveLoopPromise; - /** A FIFO queue of 24kHz, 16-bit PCM audio chunks received from the server. */ - private readonly playbackQueue; - /** Tracks scheduled audio sources. Used to cancel scheduled audio when the model is interrupted. */ - private scheduledSources; - /** A high-precision timeline pointer for scheduling gapless audio playback. */ - private nextStartTime; - /** A mutex to prevent the playback processing loop from running multiple times concurrently. */ - private isPlaybackLoopRunning; - constructor(liveSession: LiveSession, options: StartAudioConversationOptions, deps: RunnerDependencies); - /** - * Stops the conversation and unblocks the main receive loop. - */ - stop(): Promise<void>; - /** - * Cleans up all audio resources (nodes, stream tracks, context) and marks the - * session as no longer in a conversation. - */ - private cleanup; - /** - * Adds audio data to the queue and ensures the playback loop is running. - */ - private enqueueAndPlay; - /** - * Stops all current and pending audio playback and clears the queue. This is - * called when the server indicates the model's speech was interrupted with - * `LiveServerContent.modelTurn.interrupted`. - */ - private interruptPlayback; - /** - * Processes the playback queue in a loop, scheduling each chunk in a gapless sequence. - */ - private processPlaybackQueue; - /** - * The main loop that listens for and processes messages from the server. - */ - private runReceiveLoop; -} -/** - * Starts a real-time, bidirectional audio conversation with the model. This helper function manages - * the complexities of microphone access, audio recording, playback, and interruptions. - * - * @remarks Important: This function must be called in response to a user gesture - * (for example, a button click) to comply with {@link https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API/Best_practices#autoplay_policy | browser autoplay policies}. - * - * @example - * ```javascript - * const liveSession = await model.connect(); - * let conversationController; - * - * // This function must be called from within a click handler. - * async function startConversation() { - * try { - * conversationController = await startAudioConversation(liveSession); - * } catch (e) { - * // Handle AI-specific errors - * if (e instanceof AIError) { - * console.error("AI Error:", e.message); - * } - * // Handle microphone permission and hardware errors - * else if (e instanceof DOMException) { - * console.error("Microphone Error:", e.message); - * } - * // Handle other unexpected errors - * else { - * console.error("An unexpected error occurred:", e); - * } - * } - * } - * - * // Later, to stop the conversation: - * // if (conversationController) { - * // await conversationController.stop(); - * // } - * ``` - * - * @param liveSession - An active {@link LiveSession} instance. - * @param options - Configuration options for the audio conversation. - * @returns A `Promise` that resolves with an {@link AudioConversationController}. - * @throws `AIError` if the environment does not support required Web APIs (`UNSUPPORTED`), if a conversation is already active (`REQUEST_ERROR`), the session is closed (`SESSION_CLOSED`), or if an unexpected initialization error occurs (`ERROR`). - * @throws `DOMException` Thrown by `navigator.mediaDevices.getUserMedia()` if issues occur with microphone access, such as permissions being denied (`NotAllowedError`) or no compatible hardware being found (`NotFoundError`). See the {@link https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia#exceptions | MDN documentation} for a full list of exceptions. - * - * @beta - */ -export declare function startAudioConversation(liveSession: LiveSession, options?: StartAudioConversationOptions): Promise<AudioConversationController>; -export {}; diff --git a/frontend-old/node_modules/@firebase/ai/dist/esm/src/methods/live-session.d.ts b/frontend-old/node_modules/@firebase/ai/dist/esm/src/methods/live-session.d.ts deleted file mode 100644 index 92ecbe5..0000000 --- a/frontend-old/node_modules/@firebase/ai/dist/esm/src/methods/live-session.d.ts +++ /dev/null @@ -1,154 +0,0 @@ -/** - * @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 { FunctionResponse, GenerativeContentBlob, LiveServerContent, LiveServerToolCall, LiveServerToolCallCancellation, Part } from '../public-types'; -import { WebSocketHandler } from '../websocket'; -/** - * Represents an active, real-time, bidirectional conversation with the model. - * - * This class should only be instantiated by calling {@link LiveGenerativeModel.connect}. - * - * @beta - */ -export declare class LiveSession { - private webSocketHandler; - private serverMessages; - /** - * Indicates whether this Live session is closed. - * - * @beta - */ - isClosed: boolean; - /** - * Indicates whether this Live session is being controlled by an `AudioConversationController`. - * - * @beta - */ - inConversation: boolean; - /** - * @internal - */ - constructor(webSocketHandler: WebSocketHandler, serverMessages: AsyncGenerator<unknown>); - /** - * Sends content to the server. - * - * @param request - The message to send to the model. - * @param turnComplete - Indicates if the turn is complete. Defaults to false. - * @throws If this session has been closed. - * - * @beta - */ - send(request: string | Array<string | Part>, turnComplete?: boolean): Promise<void>; - /** - * Sends text to the server in realtime. - * - * @example - * ```javascript - * liveSession.sendTextRealtime("Hello, how are you?"); - * ``` - * - * @param text - The text data to send. - * @throws If this session has been closed. - * - * @beta - */ - sendTextRealtime(text: string): Promise<void>; - /** - * Sends audio data to the server in realtime. - * - * @remarks The server requires that the audio data is base64-encoded 16-bit PCM at 16kHz - * little-endian. - * - * @example - * ```javascript - * // const pcmData = ... base64-encoded 16-bit PCM at 16kHz little-endian. - * const blob = { mimeType: "audio/pcm", data: pcmData }; - * liveSession.sendAudioRealtime(blob); - * ``` - * - * @param blob - The base64-encoded PCM data to send to the server in realtime. - * @throws If this session has been closed. - * - * @beta - */ - sendAudioRealtime(blob: GenerativeContentBlob): Promise<void>; - /** - * Sends video data to the server in realtime. - * - * @remarks The server requires that the video is sent as individual video frames at 1 FPS. It - * is recommended to set `mimeType` to `image/jpeg`. - * - * @example - * ```javascript - * // const videoFrame = ... base64-encoded JPEG data - * const blob = { mimeType: "image/jpeg", data: videoFrame }; - * liveSession.sendVideoRealtime(blob); - * ``` - * @param blob - The base64-encoded video data to send to the server in realtime. - * @throws If this session has been closed. - * - * @beta - */ - sendVideoRealtime(blob: GenerativeContentBlob): Promise<void>; - /** - * Sends function responses to the server. - * - * @param functionResponses - The function responses to send. - * @throws If this session has been closed. - * - * @beta - */ - sendFunctionResponses(functionResponses: FunctionResponse[]): Promise<void>; - /** - * Yields messages received from the server. - * This can only be used by one consumer at a time. - * - * @returns An `AsyncGenerator` that yields server messages as they arrive. - * @throws If the session is already closed, or if we receive a response that we don't support. - * - * @beta - */ - receive(): AsyncGenerator<LiveServerContent | LiveServerToolCall | LiveServerToolCallCancellation>; - /** - * Closes this session. - * All methods on this session will throw an error once this resolves. - * - * @beta - */ - close(): Promise<void>; - /** - * Sends realtime input to the server. - * - * @deprecated Use `sendTextRealtime()`, `sendAudioRealtime()`, and `sendVideoRealtime()` instead. - * - * @param mediaChunks - The media chunks to send. - * @throws If this session has been closed. - * - * @beta - */ - sendMediaChunks(mediaChunks: GenerativeContentBlob[]): Promise<void>; - /** - * @deprecated Use `sendTextRealtime()`, `sendAudioRealtime()`, and `sendVideoRealtime()` instead. - * - * Sends a stream of {@link GenerativeContentBlob}. - * - * @param mediaChunkStream - The stream of {@link GenerativeContentBlob} to send. - * @throws If this session has been closed. - * - * @beta - */ - sendMediaStream(mediaChunkStream: ReadableStream<GenerativeContentBlob>): Promise<void>; -} |
