# War and Peace Context Caching Test Application
This sample application demonstrates the use of **context caching** with Google's Gemini models via the Google Generative AI plugin in Genkit. The focus is on analyzing content from large texts like _War and Peace_.
## Features
- **Dynamic Content Loading**: Supports loading text from files or fetching default content online.
- **Context Caching**: Reuses previously cached content to optimize performance.
- **Flexible Query Handling**: Allows default and user-defined queries.
## Installation
Ensure you have the necessary dependencies installed.
### Prerequisites
- **Node.js** version 20 or higher
- **npm** or **pnpm** for package management
### Install Dependencies
```bash
npm install
```
or
```bash
pnpm install
```
## Scripts
The following scripts are available:
- **`build`**: Compile TypeScript files.
- **`build:watch`**: Watch for changes and recompile TypeScript files.
- **`start`**: Run the compiled application.
- **`dev`**: Start the application in development mode with environment variable setup.
- **`genkit:dev`**: Run the application with `GENKIT_ENV=dev`.
## Configuration
This application uses the Google Generative AI plugin for Genkit. Ensure you have a valid API key for the Gemini API.
### API Key Setup
You can configure the API key in two ways:
1. **Environment Variable**:
```bash
export GOOGLE_GENAI_API_KEY=your_api_key_here
```
2. **Inline Configuration** (for testing only, not recommended for production):
```ts
googleAI({ apiKey: yourKey });
```
## Usage
### Running the Application
To start the application:
```bash
npm run dev
```
or
```bash
pnpm dev
```
### Sample Flow
The application defines a `warAndPeaceFlow` for analyzing _War and Peace_. You can either provide a local text file path or use the default content fetched online.
Example:
```ts
const defaultQuery =
"Describe Pierre Bezukhov's transformation throughout the novel.";
```
### Output
The output will be generated by the model based on the provided context and query.
## Dependencies
- **@genkit-ai/googleai**: Provides the interface for Google Gemini models.
- **genkit**: Framework for integrating generative models.
- **typescript**: TypeScript support for the application.
- **cross-env**: Cross-platform environment variable setup.
## License
This project is licensed under the ISC License.
---
**Note**: Ensure your API key is managed securely in production environments. Avoid embedding sensitive information directly in your codebase.
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/firebase/genkit'
If you have feedback or need assistance with the MCP directory API, please join our Discord server