Skip to main content

Manipulate and visualize LLMs conversations

Project description

💬 Dialog

Unittests PyPI version

Library to manipulate and display conversations.

✨ Try it on Colab:

Features

  • Create and manipulate conversations with minimal boilerplate

    conv = dialog.Conversation(
        dialog.User('What is this image ?\n', dialog.Image(data)),
        dialog.Model('This image represent a cat'),
        dialog.User('Thank you.'),
    )
    
  • Round-trip conversions between:

    • Text: conv.as_text()
    • Tokens: conv.as_batch()
  • Pretty Colab display

    • For conversation: conversation
    • For text: conversation
  • Manipulations:

    • conv += dialog.User(): Append the next turn
    • conv += [dialog.User(), dialog.Model()]: Append multiple turns.
    • len(conv)
    • list(conv)
    • conv[-1][-1]: Slicing (last chunk of the last turn)

Thinking

  • dialog.Think(): In the System instruction
  • dialog.Thought('Model thoughts...'): In the model answer
conv = dialog.Conversation(
    dialog.System(dialog.Think()),
    dialog.User('Hello'),
    dialog.Model(
        dialog.Thought('I need to greet the user'),
        'Hello! What can I do for you?',
    )
)

Function calling

Function calling is done through:

  • dialog.Tool: Tool definition in the system instruction
  • dialog.ToolCall
  • dialog.ToolResponse
conv = dialog.Conversation(
    dialog.System(
        dialog.Tool(tool0),
        dialog.Tool(tool1),
    ),
    dialog.User('Turn off the light in my bedroom'),
    dialog.Model(
        dialog.ToolCall(call0),
        dialog.ToolResponse(response0),
        'Lights have been turned off. Good night.',
    )
)

Multi-modalities

  • dialog.Image: Image modality
  • dialog.Audio: Audio modality

Modalities supports anything which can be interpreted as image/audio, including urls, paths, numpy array,...

dialog.User(
    'Describe those images:\n\n',
    dialog.Image(np.zeros((256, 256, 3), np.uint8)),
    dialog.Image('https://example.org/img.png'),
    dialog.Image('/path/to/my_img.jpg'),
),

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

dialog-1.0.0.tar.gz (305.7 kB view details)

Uploaded Source

Built Distribution

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

dialog-1.0.0-py3-none-any.whl (318.4 kB view details)

Uploaded Python 3

File details

Details for the file dialog-1.0.0.tar.gz.

File metadata

  • Download URL: dialog-1.0.0.tar.gz
  • Upload date:
  • Size: 305.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for dialog-1.0.0.tar.gz
Algorithm Hash digest
SHA256 9a0bbc5c48491942433fb2dde5db362f705385d36f975c316c2c9b9d71b999b5
MD5 21a6987d8b839c15eda8fda3c9a19e9e
BLAKE2b-256 6ce667e8e7f14f0ca9396c34ad5d762cf159a1e49fc2e1a1b29566d4132b749a

See more details on using hashes here.

File details

Details for the file dialog-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: dialog-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 318.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for dialog-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ca3abbb059454993180c018e0acd12355365a4bb975d873b636599c7cd8b2d49
MD5 beb1fd0c21b4a16ce135cbff873b6f07
BLAKE2b-256 902cf7034927f6e6a6d97bec0d621674b8e62162f90d06474dd5fa11637b07cd

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