Metadata-Version: 2.4
Name: dialog
Version: 1.0.0
Summary: Manipulate and visualize LLMs conversations
Keywords: 
Author-email: dialog authors <dialog@google.com>
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Intended Audience :: Science/Research
License-File: LICENSE
Requires-Dist: etils[enp, epath, epy]
Requires-Dist: lark
Requires-Dist: numpy
Requires-Dist: pillow
Requires-Dist: requests
Requires-Dist: anywidget
Requires-Dist: mcp
Requires-Dist: pydub
Requires-Dist: pytest ; extra == "dev"
Requires-Dist: pytest-xdist ; extra == "dev"
Requires-Dist: pylint>=2.6.0 ; extra == "dev"
Requires-Dist: pyink ; extra == "dev"
Project-URL: changelog, https://github.com/google-deepmind/dialog/blob/main/CHANGELOG.md
Project-URL: homepage, https://github.com/google-deepmind/dialog
Project-URL: repository, https://github.com/google-deepmind/dialog
Provides-Extra: dev

# 💬 Dialog

[![Unittests](https://github.com/google-deepmind/dialog/actions/workflows/pytest_and_autopublish.yml/badge.svg)](https://github.com/google-deepmind/dialog/actions/workflows/pytest_and_autopublish.yml)
[![PyPI version](https://badge.fury.io/py/dialog.svg)](https://badge.fury.io/py/dialog)

Library to manipulate and display conversations.

✨ Try it on Colab:

## Features

* Create and manipulate conversations with minimal boilerplate

  ```python
  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](docs/imgs/conversation.png)
    * For text:
      ![conversation](docs/imgs/conversation_str.png)
* 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

```python
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`

```python
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,...

```python
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'),
),
```

