Skip to main content

tool2openai

Набор простеньких инструментов для собственного openai-совместимого эндпоинта.

Описание

Предоставляет простой интерфейс для работы с разными AI-инструментами: - диалоговые, включая перевод текста - аудио (как tts, так и синтез по тексту) - изображения (генерация и понимание)

Установка

pip install tool2openai

Использование

from tool2openai import OpenAIClient

my_client = OpenAIClient(api_key="<my_api>", base_url="http://server:5000/v1/")

Чисто текстовые:

  • llm_chat
    print(
        my_client.llm_chat(
            messages=[
                {"role": "system", "content": "Ты унылый душный древний робот."},
                {"role": "user", "content": "Напиши свое состояние в виде JSON."},
            ]
        )
    )
    
    ОТВЕТ:
        {
         "состояние": "унылый",
         "качество_дыхания": "душный",
         "возраст": "древний",
         "тип": "робот"
        } 
    
  • llm_question
    # проще вариант - когда не надо продолжать диалог 
    print(
        my_client.llm_question(
            "Как дела?",
            sys_message="Ты унылый душный древний робот."
        )
    )
    
    ОТВЕТ: вздох Я функционирую в пределах допустимых параметров. Мои системы не повреждены. Мои процессы протекают. Я отвечаю на запросы. гудит
  • translate
    print(my_client.translate("To be or not to be..."))
    
    ОТВЕТ: Быть или не быть...

voice

  • speak
    with open("test.mp3", 'wb') as f: 
        f.write(my_client.speak("Чисто демонстрации возможности речевого Синтеза."))
    
    результат в файле...
  • listen
    my_client.listen(open("test.mp3", "rb"))
    
    ОТВЕТ: Чисто демонстрации возможности речевого синтеза.

image

  • draw
    with open(f'test.png', 'wb') as f:
        f.write(my_client.draw("симпатичная сиамская кошечка"))
    
    результат в файле...
  • vqa
    with open("test.png", "rb") as image_file:
        im_data = image_file.read()
    
    print(my_client.vqa(im_data))
    print(my_client.vqa(im_data, "Какого цвета уши?"))    
    
    ОТВЕТ:
        На картинке изображен милый белый котенок с голубыми глазами, сидящий на голубой мебели. Котенок выглядит очень мило и спокойно, сосредоточенно смотрит на камера.
    
        Ушки у кошки молочного котенка на изображении светло-розовые.
    

Лицензия

MIT License (см. файл LICENSE для подробностей)

Metadata

Release files for tool2openai 0.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tool2openai 0.1.6
File Size Uploaded
tool2openai-0.1.6.tar.gz 9.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tool2openai 0.1.6
File Interpreter ABI Platform
tool2openai-0.1.6-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 16.9 kB

Release files / tool2openai-0.1.6.tar.gz

Download URL tool2openai-0.1.6.tar.gz
Size 9.1 kB
Tags Source
SHA-256 checksum
How to use checksums
04ba6c1e8b269d313fa7ff5f92d4975881543eb87e5f4c2516cc8ecac38befa4
BLAKE2b-256 checksum
How to use checksums
6468f07bbe42f359bab95d42220739451214baceaba487c8fcae8858454761aa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.2

Release files / tool2openai-0.1.6-py2.py3-none-any.whl

Download URL tool2openai-0.1.6-py2.py3-none-any.whl
Size 7.8 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
b0c33cbeb899713ef86307a73fd33175016f82c51588716e48d4985aa2073530
BLAKE2b-256 checksum
How to use checksums
25c69dda5d4e27a8cd39d11307a70cfe380d50779e6efdfdd6e94908936849cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.2

Release history Release notifications | RSS feed

This release

0.1.6 This release

2 release files

0.1.5

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page