Skip to main content

A modular package for interacting with llama.cpp models via a server or CLI, supporting LoRA and JSON configurations.

Project description

TinyAGI

A modular Python package that provides both a Flask API server and a command-line interface (CLI) for interacting with llama.cpp models, including support for LoRA addons and configuration via JSON files.

Features

  • Flask API Server: Serve models via HTTP endpoints.
  • Command-Line Interface (CLI): Interact with models directly from the terminal.
  • LoRA Support: Utilize LoRA adapters with your models.
  • JSON Configuration: Manage settings and parameters via JSON files.
  • Modular Design: Use components independently in your projects.

Installation

Install from PyPI:

pip install TinyAGI

Usage

Configuration

Create a config.json file in your working directory:

{
  "model_path": "path/to/your/model.bin",
  "lora_path": "path/to/your/lora_adapter.bin",
  "model_params": {
    "n_ctx": 2048,
    "n_gpu_layers": 20
  },
  "inference_params": {
    "temperature": 0.7,
    "top_p": 0.95,
    "max_tokens": 512
  }
}

Running the Server

Start the Flask API server:

tinyagi-server

The server will be accessible at http://localhost:5000.

Using the CLI

Generate Text from a Prompt

tinyagi-cli generate --prompt "Why is the sky blue?"

Stream Output

tinyagi-cli generate --prompt "Tell me a story." --stream

Generate Embeddings

tinyagi-cli embed --input "Text to embed"

Reload the Model Configuration

tinyagi-cli reload --config new_config.json

API Endpoints

  • POST /chat: Chat with the model using messages.
  • POST /generate: Generate text from a prompt.
  • POST /embed: Generate embeddings.
  • POST /reload: Reload the model configuration.
  • GET /config: Get the current configuration.

Example: Chat Endpoint

Request:

curl -X POST http://localhost:5000/chat \
  -H 'Content-Type: application/json' \
  -d '{
        "messages": [
            {"role": "user", "content": "Hello! Who are you?"}
        ]
    }'

Response:

{
  "response": "Assistant: I am an AI language model developed to assist with your questions."
}

Contributing

Contributions are welcome! Please open an issue or submit a pull request on GitHub.

License

This project is licensed under the MIT License.

Contact

For any inquiries or support, please contact SullyGreene.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

TinyAGI-0.0.1.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

TinyAGI-0.0.1-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file TinyAGI-0.0.1.tar.gz.

File metadata

  • Download URL: TinyAGI-0.0.1.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for TinyAGI-0.0.1.tar.gz
Algorithm Hash digest
SHA256 c84f0f0ccc08a5915a9ba2b4ed04c66885c69c7358c79052421f63b41b3f0cbf
MD5 3f935de08ac78ad8d6f53e339eb0c332
BLAKE2b-256 05a571410a49e3e7e81ae0c81c9613ba0818af272d01a9e3163d4a20fd864cd5

See more details on using hashes here.

File details

Details for the file TinyAGI-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: TinyAGI-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for TinyAGI-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e52c26f369c326e2a501249ae414b3a7fde839fd6c74ef07b202749449ac1a42
MD5 f217d3e790c923f29bc3a4f414a352f6
BLAKE2b-256 32b3cc915cf897d25739b56988a5a45edddae3b642b279e7c51f0dcb95a4a7fe

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page