@promptbook/azure-openai
Version:
Promptbook: Run AI apps in plain human language across multiple models and platforms
41 lines (40 loc) • 2.02 kB
TypeScript
import type { ExecutionTools } from '../../execution/ExecutionTools';
import type { PromptbookStorage } from '../_common/PromptbookStorage';
import type { FileCacheStorageOptions } from './FileCacheStorageOptions';
/**
* A storage implementation that caches data in files organized in a directory structure.
* Provides methods for retrieving, storing, and managing cached data on the filesystem.
*
* This class implements the PromptbookStorage interface for filesystem-based caching.
*
* @public exported from `@promptbook/node`
*/
export declare class FileCacheStorage<TItem> implements PromptbookStorage<TItem> {
protected readonly tools: Required<Pick<ExecutionTools, 'fs'>>;
private readonly options;
constructor(tools: Required<Pick<ExecutionTools, 'fs'>>, options: FileCacheStorageOptions);
/**
* Converts a storage key to a filesystem path where the data should be stored.
* Creates a consistent, deterministic file path based on the key string.
*/
private getFilenameForKey;
/**
* Returns the current value associated with the given key, or null if the given key does not exist.
* Retrieves the cached data from the file system storage.
*/
getItem(key: string): Promise<TItem | null>;
/**
* Sets the value of the pair identified by key to value, creating a new key/value pair if none existed for key previously.
* Persists data to the file system, creating necessary directory structure if it doesn't exist.
*/
setItem(key: string, value: TItem): Promise<void>;
/**
* Removes the key/value pair with the given key from the storage, if a key/value pair with the given key exists.
* Deletes the corresponding file from the filesystem.
*/
removeItem(key: string): Promise<void>;
}
/**
* TODO: [🌗] Maybe some checkers, not all valid JSONs are desired and valid values
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
*/