Skip to main content

Module for using MNN API

Project description

MNNAI

This repository contains an example of how to use the mnnai library.

Prerequisites

  • Python 3.x
  • MNNAI library installed. You can install it using pip:
pip install mnnai

Usage

Non-Streaming Chat

from mnnai import MNN

client = MNN(
    key='MNN API KEY',
    id='MNN ID',
    # max_retries=2, 
    # timeout=60
)

chat_completion = client.chat_create(
    messages=[
        {
            "role": "user",
            "content": "Hi",
        }
    ],
    model="gpt-4o-mini",
)
print(chat_completion)

Image Generation

import base64
import os

response = client.Image_create(
    prompt="Draw a cute red panda",
    model='dall-e-3'
)

image_base64 = response['data'][0]['urls']

os.makedirs('images', exist_ok=True)

for i, image_base64 in enumerate(image_base64):
    image_data = base64.b64decode(image_base64)

    with open(f'images/image_{i}.png', 'wb') as f:
        f.write(image_data)

print("Images have been successfully downloaded!")

Models

print(client.GetModels())

Configuration

Replace the key and id parameters in the MNN client initialization with your own API key and user ID. Adjust the prompt, model, and other parameters as needed for your specific use case.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Discord

https://discord.gg/Ku2haNjFvj

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

mnnai-4.5.0.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mnnai-4.5.0-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file mnnai-4.5.0.tar.gz.

File metadata

  • Download URL: mnnai-4.5.0.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for mnnai-4.5.0.tar.gz
Algorithm Hash digest
SHA256 8c2c44fcde1f6086f1c8f6b8885d0562e63b514b0645de931c5b119cddbc9800
MD5 dbdb5e392da8d2e1b3d8f2a1a3839299
BLAKE2b-256 ced527944554312ae75548a7c19ea394a58ce920821072e97c9e00f926927965

See more details on using hashes here.

File details

Details for the file mnnai-4.5.0-py3-none-any.whl.

File metadata

  • Download URL: mnnai-4.5.0-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for mnnai-4.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8acd71f2097e1145992348f2e870382e1dda4b0bd9aa437a88946bd1e20b62c5
MD5 b3458ae45bcf77bf326c8414f1578d9a
BLAKE2b-256 2b131c1f1eac59d3fe9bbb4e9296c1f102416289b1b6ec50cdb5dc67aad170e3

See more details on using hashes here.

Supported by

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