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.1.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.1-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mnnai-4.5.1.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.1.tar.gz
Algorithm Hash digest
SHA256 4f1e7c66536d3af5edce11e71be050d3a30d5a126e6fadd66153bad51fccb784
MD5 23887c062c77d6b771b8d0940a66a8ef
BLAKE2b-256 f429f10d42e13d984f771b486b1ade0ea8dbfaefb0c1ca8fadda515461269d77

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mnnai-4.5.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 170ee384f2c8dfdf62bbf76ee442915fcb761a17db470828182e3637d4d6dd44
MD5 045dcf30dcd4b60146a6a30c3d612f8e
BLAKE2b-256 205dbec2039a9f5424e6a2bbf832b05a9ab54d382d61d84860aecc21638cd16b

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