Библиотека для использования Omni Antispam API (https://moderator.omni-devel.ru)
Project description
RuModeratorAI
Библиотека для использования Omni Antispam API (https://moderator.omni-devel.ru), в прошлом - RuModeratorAI API.
Установка
pip install rumoderatorai
Пример использования
from rumoderatorai import Client, Context, ChatContext
import asyncio
from PIL import Image
import os
async def main():
async with Client(
api_key=os.getenv("RUMODERATORAI_API_KEY")
) as client:
context = Context(
chat_context=ChatContext(
title="Test group",
topic_title="Test topic"
),
allowed_rules=[
"mutual subscriptions",
"job offers",
"cars selling"
]
)
text_response = await client.get_text_class("Hello, world!", context=context)
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"
],
context=context
)
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, Context, ChatContext
import asyncio
from PIL import Image
import os
async def main():
client = Client(
api_key=os.getenv("RUMODERATORAI_API_KEY"),
)
await client.init()
context = Context(
chat_context=ChatContext(
title="Test group",
topic_title="Test topic"
),
allowed_rules=[
"job offers",
"cars selling"
]
)
text_response = await client.get_text_class("Hello, world!", context=context)
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"
],
context=context
)
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rumoderatorai-1.6.2.tar.gz.
File metadata
- Download URL: rumoderatorai-1.6.2.tar.gz
- Upload date:
- Size: 9.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
23166f40e3e3099ad0d7393b2a2572f1b5a16bf4a79ffff1a16b31abb5d47a3a
|
|
| MD5 |
37154b4fd8a1d8ec933bdb5cfd7c0792
|
|
| BLAKE2b-256 |
c1a03a78f61e9cdfe8b73a3e9a39feabc36a04a4bfc8fdfe62b0723108968957
|
File details
Details for the file rumoderatorai-1.6.2-py3-none-any.whl.
File metadata
- Download URL: rumoderatorai-1.6.2-py3-none-any.whl
- Upload date:
- Size: 9.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
721a9e0d3f6b0eb67576a1f6a9f32c560dd9d141c5c1240c40aecf1b61bd1aef
|
|
| MD5 |
442f5b373a7d698777019c1fe4abd73d
|
|
| BLAKE2b-256 |
2460832808bc0db8ee92ddd920221f175b7678402ed23797ec127b04632f9ff1
|