Skip to main content

Библиотека для использования RuModeratorAI (https://moderator.pysols.ru)

Project description

RuModeratorAI

Библиотека для использования RuModeratorAI API (https://moderator.pysols.ru).

Установка

pip install rumoderatorai

Пример использования

from rumoderatorai import Client

import asyncio

from PIL import Image

import os


async def main():
    async with Client(
        api_key=os.getenv("RUMODERATORAI_API_KEY")
    ) as client:
        text_response = await client.get_text_class("Hello, world!")
        print(text_response)

        profile_response = await client.get_profile_class(
            username="test",
            first_name="test",
            last_name="test",
            description="test",
            is_premium=False,
        )
        print(profile_response)

        image = Image.open("tests/image.png")
        image_response = await client.get_image_class(image)
        print(image_response)

        ocr_response = await client.get_ocr(image)
        print(ocr_response)

        multimodal_text_response = await client.get_multimodal_text_class(
            text="Всем привет!",
            images=[
                "tests/image_spam.png", "tests/image_not_spam.png", "tests/image_spam_2.png"\
            ]
        )
        print(multimodal_text_response)

        stats_response = await client.get_stats()
        print(stats_response)

        key_info_response = await client.get_key_info()
        print(key_info_response)

        prediction_response = await client.get_prediction(unique_id=text_response.unique_id)
        print(prediction_response)

        ips_response = await client.get_ips()
        print(ips_response)

        prices_response = await client.get_prices()
        print(prices_response)


asyncio.run(main())

Или можно использовать без async with:

from rumoderatorai import Client

import asyncio

from PIL import Image

import os


async def main():
    client = Client(
        api_key=os.getenv("RUMODERATORAI_API_KEY"),
    )
    await client.init()

    text_response = await client.get_text_class("Hello, world!")
    print(text_response)

    profile_response = await client.get_profile_class(
        username="test",
        first_name="test",
        last_name="test",
        description="test",
        is_premium=False,
    )
    print(profile_response)

    image = Image.open("tests/image.png")
    image_response = await client.get_image_class(image)
    print(image_response)

    ocr_response = await client.get_ocr(image)
    print(ocr_response)

    multimodal_text_response = await client.get_multimodal_text_class(
        text="Всем привет!",
        images=[
            "tests/image_spam.png", "tests/image_not_spam.png", "tests/image_spam_2.png"\
        ]
    )
    print(multimodal_text_response)

    stats_response = await client.get_stats()
    print(stats_response)

    key_info_response = await client.get_key_info()
    print(key_info_response)

    prediction_response = await client.get_prediction(unique_id=text_response.unique_id)
    print(prediction_response)

    ips_response = await client.get_ips()
    print(ips_response)

    prices_response = await client.get_prices()
    print(prices_response)

    await client.close()


asyncio.run(main())

Примечание: Не забудьте установить переменную окружения RUMODERATORAI_API_KEY перед запуском кода.

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

rumoderatorai-1.0.1.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

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

rumoderatorai-1.0.1-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file rumoderatorai-1.0.1.tar.gz.

File metadata

  • Download URL: rumoderatorai-1.0.1.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.2

File hashes

Hashes for rumoderatorai-1.0.1.tar.gz
Algorithm Hash digest
SHA256 bb6b0bf23c9d8a8340bd82ce961e613321dde1a84f255f7c890121669bd06b87
MD5 202c4c709eb4f341d5c9d50d7e91946e
BLAKE2b-256 76b651032530ab7ed352f0c037df4e4004258bb03d5fdc579431578d3c434bca

See more details on using hashes here.

File details

Details for the file rumoderatorai-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: rumoderatorai-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.2

File hashes

Hashes for rumoderatorai-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 aa0d3dee6a31b1cfb67efeefe4f0cf3b5e26006d289672c76826c083fc640f62
MD5 6843ef533759daf578e93103beeb515c
BLAKE2b-256 bd70a5d35c004ec4afeec96679f3747216a9bf823c5e111dda06b60b4873a3f3

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