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.2.tar.gz (4.3 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.2-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mnnai-4.5.2.tar.gz
  • Upload date:
  • Size: 4.3 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.2.tar.gz
Algorithm Hash digest
SHA256 494eae3760b36fc8d5d75fddafa61f026613e2be72f6f286b7f89edaa23afd02
MD5 c8b8172cfe6b3f1147354a039476815d
BLAKE2b-256 0a291cfcaf60258d42e0330831349ce051233c52f7fae7c25c2cf21a5723fa96

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mnnai-4.5.2-py3-none-any.whl
  • Upload date:
  • Size: 4.8 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e50ebd48e9b7b42963de297be09488d4849b64cff3ec7227b193e34d22184e3c
MD5 8e5538903bca94097b40927c928af288
BLAKE2b-256 a1ad487061f8dd22ce71f7b3af10d08f3436af9bd377e37647bb1ec151c694ad

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