Библиотека для использования RuModeratorAI (https://moderator.pysols.ru)
Project description
RuModeratorAI
Библиотека для использования RuModeratorAI API (https://moderator.pysols.ru).
Установка
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"
)
)
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"
)
)
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
rumoderatorai-1.1.0.tar.gz
(8.0 kB
view details)
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.1.0.tar.gz.
File metadata
- Download URL: rumoderatorai-1.1.0.tar.gz
- Upload date:
- Size: 8.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a46c74ad19a10f135f120c11307391023447c2bfcd1bc71b4177b031e7e8c4cc
|
|
| MD5 |
fcead03e1d02c6f7cf69665e5b2b1b01
|
|
| BLAKE2b-256 |
7a3d3a6ce1f683fdc211eb8e31b09d6bf0ce779a213b6bc45ffc9140ade839e1
|
File details
Details for the file rumoderatorai-1.1.0-py3-none-any.whl.
File metadata
- Download URL: rumoderatorai-1.1.0-py3-none-any.whl
- Upload date:
- Size: 7.6 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 |
34a72db32acd0eb57442c0ca22d3bf69c2776cd609760ad70b65c3da436b4b6e
|
|
| MD5 |
c3c529993fc18739ffd2a80f9feb61f8
|
|
| BLAKE2b-256 |
146f8ff718a6393099589d4f8083d6472e9cb9fa0430dd89d90bb517d4e6e340
|