Skip to main content

Get structured output from multimodal AI models and integrate them into multitool agents

Project description

OmniModKit

Use convenient multimodal toolkit that operates with structured output.

Easily build agent tools on top of that.

Implementation

This package utilizes the implemented langchain structured output pipelines.

Installation

pip install omnimodkit

Omnimodel Usage

  • Import OmniModel
  • Give it text/image/audio and get text/image/audio
from omnimodkit import OmniModel

# Initialize the model
omni_model = OmniModel()

# Get image
omni_model.run(
    user_input="Give me an image of a cat",
)

# Get just text
omni_model.run(
    user_input="Tell me a joke",
)

# Get audio response
omni_model.run(
    user_input="Tell me a joke with voice",
)

# Get image and text
omni_model.run(
    user_input="Show me a cat and tell me about it",
)

# Stream responses
for response in omni_model.stream(
    user_input="Tell me a joke",
):
    print(response.text_new_chunk, end="|", flush=True)

# Async stream responses with image generation
last_response = None
async for response in omni_model.astream(
    user_input="Draw a cat and provide some text about it",
):
    if response.text_new_chunk:
        print(response.text_new_chunk, end="|", flush=True)
    last_response = response
print("\nFinal response:", last_response)

# Async stream responses
async for response in omni_model.astream(
    user_input="Tell me a joke",
):
    print(response.text_new_chunk, end="|", flush=True)

# Use audio recognition
import io
import requests

url = "https://cdn.openai.com/API/examples/data/ZyntriQix.wav"
audio_bytes = io.BytesIO(requests.get(url, timeout=10).content)
audio_bytes.name = "audio.wav"
omni_model.run(
    user_input="Draw an image based on the audio and tell me about it.",
    in_memory_audio_stream=audio_bytes,
)

# Use image recognition
import io
import requests

url = "https://raw.githubusercontent.com/Flagro/treefeeder/main/logo.png"
image_bytes = io.BytesIO(requests.get(url, timeout=10).content)
image_bytes.name = "image.png"
omni_model.run(
    user_input="Describe this image and generate a related image.",
    in_memory_image_stream=image_bytes,
)

# Estimate price for a model run
import io
import requests

url = "https://raw.githubusercontent.com/Flagro/treefeeder/main/logo.png"
image_bytes = io.BytesIO(requests.get(url, timeout=10).content)
image_bytes.name = "image.png"
omni_model.estimate_price(
    user_input="What is the capital of France?", in_memory_image_stream=image_bytes
)

Modkit Usage

  • Import ModelsToolkit
  • Run appropriate models
  • Get structured output response
from omnimodkit import ModelsToolkit

# Initialize the model toolkit
modkit = ModelsToolkit()

# Run the model synchronously
modkit.text_model.run(
    user_input="What is the capital of France?",
)

# Stream responses from the model
for response in modkit.text_model.stream(
    user_input="What is the capital of France?",
):
    print(response, end="|", flush=True)

# Generate images
modkit.image_generation_model.run(
    user_input="Draw a cat",
)

# Use audio recognition
import io
import requests

url = "https://cdn.openai.com/API/examples/data/ZyntriQix.wav"
audio_bytes = io.BytesIO(requests.get(url, timeout=10).content)
audio_bytes.name = "audio.wav"
modkit.audio_recognition_model.run(
    in_memory_audio_stream=audio_bytes,
)

# Use image recognition
import io
import requests

url = "https://raw.githubusercontent.com/Flagro/treefeeder/main/logo.png"
image_bytes = io.BytesIO(requests.get(url, timeout=10).content)
image_bytes.name = "image.png"
modkit.vision_model.run(
    in_memory_image_stream=image_bytes,
)

# Use audio generation
modkit.audio_generation_model.run(
    user_input="Hello! How can I help you today?",
)

License

MIT license

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

omnimodkit-0.0.7.tar.gz (14.2 kB view details)

Uploaded Source

Built Distribution

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

omnimodkit-0.0.7-py3-none-any.whl (20.3 kB view details)

Uploaded Python 3

File details

Details for the file omnimodkit-0.0.7.tar.gz.

File metadata

  • Download URL: omnimodkit-0.0.7.tar.gz
  • Upload date:
  • Size: 14.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.23

File hashes

Hashes for omnimodkit-0.0.7.tar.gz
Algorithm Hash digest
SHA256 72d8bb8b311ae883e3dfb1393915afdc309c0fa79a0c4b68e651653e83b07701
MD5 f7a0102beff2bde0e6f597ef4d83207b
BLAKE2b-256 0a382e6e0e65d5b9f70c122346a943dac6e61e2b94a095377248af7be303bddf

See more details on using hashes here.

File details

Details for the file omnimodkit-0.0.7-py3-none-any.whl.

File metadata

  • Download URL: omnimodkit-0.0.7-py3-none-any.whl
  • Upload date:
  • Size: 20.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.23

File hashes

Hashes for omnimodkit-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 e3a259430b37216d857648ab34ccdb64eb02b4f1d2dd068c9199dec996cc4b60
MD5 c6d629010b53b2d9d44b748d7cbe2a1f
BLAKE2b-256 96d3361c79f3ae9958518748fa6e53256b9d1099e8c5a2242f8f03562bf4b72b

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