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: https://colab.research.google.com/github/google-deepmind/dialog/blob/main/colab/dialog.ipynb

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.1.0.tar.gz (35.1 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.1.0-py3-none-any.whl (48.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for dialog-1.1.0.tar.gz
Algorithm Hash digest
SHA256 3739815cb702ae7b95f2f4732d9dbb2e98574764e54c2f2f5f5db6bbe6a04688
MD5 246403a13151d29362f0e5a1ea4cfb4b
BLAKE2b-256 efa5da62d764788bbbab4d313ddba6d84a535b0cb32ffce60901aa15363b9d67

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for dialog-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 179d3742e95c53175790eb728e63702abce52fbfc6dc8502d8e6cffdd4b581aa
MD5 e444abd16371c8e31d2698c4e70f8059
BLAKE2b-256 9038bcfc52b2fec0d1cadfde15b0948864170c7f241b50889673d73c7ed786e2

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