import {Meta} from '@storybook/addon-docs/blocks'

<Meta title='@dxtmisha/en/scripts/Classes/AiGoogleLite - Google Gemini AI Integration'/>

# AiGoogleLite Class

A concrete implementation of the `AiAbstract` class for Google's Gemini AI (via the `GoogleGenAI` client). This class provides a streamlined way to interact with Gemini models, handling authentication, context accumulation, and content generation.

## Key Features

- **Google Gemini Integration** — seamlessly connects to Google's generative AI models.
- **Multimodal Support** — supports both text and image inputs for generation requests.
- **Context Accumulation** — inherits a robust mechanics for building complex prompts, including images and multi-part text.
- **Unified Workflow** — provides a consistent interface for model selection and generation, abstracting away low-level client details.

## Initialization

Initialize the `AiGoogleLite` by providing your API key and a target model ID.

**Parameters:**
- `key: string` — your Google AI API key.
- `model: string` — the ID of the Gemini model to use (e.g., `'gemini-1.5-flash'`).

```typescript
import { AiGoogleLite } from '@dxtmisha/scripts'

const ai = new AiGoogleLite('YOUR_API_KEY', 'gemini-1.5-flash')

// Set an optional system prompt prefix
ai.addPrompt('You are a technical writer.')

// Generate a response
const response = await ai.generate('Explain the AiGoogleLite class.')
```

## Methods

### Generation

- `generate(contents: string): Promise<string>` — the main entry point for AI interaction. It combines all accumulated context (prefix, images, parts) and performs the request.

### Configuration

- `setKey(key: string): this` — updates the API key and re-initializes the internal client.
- `setModel(model: string): this` — switches the active model for subsequent requests.

### Context Building

These methods allow you to accumulate data before calling `generate()`:

- `addPrompt(prompt: string): void` — appends a persistent text prefix (useful for system instructions).
- `addContent(content: string): this` — adds a text part to the prompt.
- `addImage(image: AiImageItem): this` — appends an image (base64) to the request.
- `resetPrompt(): void` — clears the persistent prefix.
- `resetContents(): this` — clears all accumulated text parts.
- `resetImages(): this` — clears all accumulated images.

### Information

- `getContents(): string[]` — returns the list of accumulated text parts.
- `getImages(): AiImageList` — returns the list of accumulated images.

## Types

### AiImageItem
Represents an image for multimodal requests.
- `mime: string` — the MIME type of the image (e.g., `'image/png'`).
- `base64: string` — the image data in base64 format.

### AiImageList
An array of `AiImageItem`.
