tiny-ai-api
TypeScript icon, indicating that this package has built-in type declarations

1.1.5 • Public • Published

Discord server NPM version NPM downloads Patreon Ko-Fi

npm installnfo

Tiny AI Server Communication API

This class is responsible for managing AI session data, including models, history, and content generation.

The script is designed to interact with the AI API, providing a complete structure for building user interfaces (UI) or AI-powered chatbots.

It implements a session management system to help handle multiple different bots, allowing you to manage various aspects of interactions such as system instructions, file handling, tokens, and more.

Note: This documentation was written by ChatGPT, an AI assistant developed by OpenAI, based on the project structure and descriptions provided by the repository author.
If you find any inaccuracies or need improvements, feel free to contribute or open an issue!


Inspiration

This project was initially a simple AI application from Pony Driland repository. The AI project eventually evolved both during the development that resulted in this project that is now published by the same creator of the Pony Driland repository.


Limitations

⚠️ Not optimized for high-load scenarios
This script is not optimized for efficiently handling multiple AI instances simultaneously.
It may not be suitable for environments that require running several AI instances at once.

⚠️ Token tracking not included
This script does not automatically manage or track token counts for messages.
Developers must implement their own logic to monitor and manage token usage if necessary.


📦 Installation

To install the package, use the following command:

npm install tiny-ai-api

🔧 Usage Example

You can interact with the AI using two methods, both of which are valid.

import { TinyAiInstance, setTinyGoogleAi } from 'tiny-ai-api';

const ai = new TinyAiInstance();
setTinyGoogleAi(ai, 'GEMINI_API_KEY', 'gemini-2.0-flash');

Alternatively, you can use the following shorthand method:

import { TinyGoogleAi } from 'tiny-ai-api';

const ai = new TinyGoogleAi('GEMINI_API_KEY', 'gemini-2.0-flash');

📂 File Structure (After Build)

After building the project, the following files will be available:

dist/
├── index.mjs       → For ESM users (`import`)
├── index.cjs       → For CommonJS users (`require`)
└── index.d.mts     → TypeScript `.d.ts` declaration files

📚 API Reference

Introduction - Getting Started

Learn the basics of initializing a session, setting up models, and understanding the general structure of the API.

Configs - Session Configuration

Learn how to configure session data, including setting up system instructions, models, and file handling.

Content - Content Management

Understand how to manage content like prompts, dialogues, file data, and how to retrieve and modify this content.

Custom - Working with Custom Values

Understand how to implement custom values, including session-specific data and any user-defined parameters.

Dev - Development Tools

For developers looking to extend or debug the API, this section provides tools and guidelines for working with the internal workings of the library.

Models - Model Configuration

Set up models and manage their configurations to interact with the API correctly. This includes handling different types of models and adjusting their parameters.


💡 Features

  • Session Management: Keep track of multiple AI instances with full session history.
  • Content Handling: Easily manage data like user inputs, AI-generated responses, and file handling.
  • Token and Hash Tracking: Monitor token usage for each session and track hash values for specific items.
  • Customizable: Fully configurable session data and model setups for different environments.
  • Error Handling: Built-in error management to ensure robust session handling and prevent crashes.
  • Event-driven: Supports event-driven architecture to handle real-time updates and triggers.

🛠 Development Tools

For advanced users, you can access several development tools to help with debugging and extending the API:

  • Token Tracking: Manually track token usage for specific message categories like prompt, system instruction, or file.
  • Custom Session IDs: Create and manage custom session IDs to differentiate between different AI sessions.
  • File Data Management: Set, get, and remove file data associated with specific sessions, ideal for sending or receiving large data files.

📄 Terms of Use

Please make sure to read the Terms of Use before using this project.
By using this project, you agree to follow the terms described in that document.


📄 License

This project is licensed under the AGPL-3.0 License - see the LICENSE file for details.

/tiny-ai-api/

    Package Sidebar

    Install

    npm i tiny-ai-api

    Weekly Downloads

    83

    Version

    1.1.5

    License

    AGPL-3.0-only

    Unpacked Size

    530 kB

    Total Files

    29

    Last publish

    Collaborators

    • jasmindreasond