inputs
Contain classes used to define the inputs of a model.
Audio
dataclass
Contains an audio that can be passed to a multimodal model.
Provide one or several instances of this class along with a text prompt
in a list as the model_input
argument to a model that supports audio
processing.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
audio
|
Any
|
The audio to use in the text generation. |
required |
Source code in outlines/inputs.py
Chat
dataclass
Contains the input for a chat model.
Provide an instance of this class as the model_input
argument to a model
that supports chat.
Each message contained in the messages list must be a dict with 'role' and 'content' keys. The role can be 'user', 'assistant', or 'system'. The content can be a string or a list containing a str and assets (images, videos, audios, etc.) in the case of multimodal models.
Examples:
# Initialize the chat with a system message.
chat_prompt = Chat([
{"role": "system", "content": "You are a helpful assistant."},
])
# Add a user message with an image and call the model (not shown here).
chat_prompt.add_user_message(["Describe the image below", Image(image)])
# Add as an assistant message the response from the model.
chat_prompt.add_assistant_message("The is a black cat sitting on a couch.")
Parameters:
Name | Type | Description | Default |
---|---|---|---|
messages
|
List[Dict[str, Any]]
|
The list of messages that will be provided to the model. |
None
|
Source code in outlines/inputs.py
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
|
add_assistant_message(content)
Add an assistant message to the chat.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
content
|
str | List[Any]
|
The content of the assistant message. |
required |
Source code in outlines/inputs.py
add_system_message(content)
Add a system message to the chat.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
content
|
str | List[Any]
|
The content of the system message. |
required |
add_user_message(content)
Add a user message to the chat.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
content
|
str | List[Any]
|
The content of the user message. |
required |
append(message)
Add a message to the chat.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message
|
Dict[str, Any]
|
The message to add to the chat. |
required |
extend(messages)
Add a list of messages to the chat.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
messages
|
List[Dict[str, Any]]
|
The list of messages to add to the chat. |
required |
pop()
Remove the last message from the chat.
Returns:
Type | Description |
---|---|
message
|
The removed message. |
Image
dataclass
Contains an image that can be passed to a multimodal model.
Provide one or several instances of this class along with a text prompt
in a list as the model_input
argument to a model that supports vision.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
image
|
Image
|
The image to use in the text generation. |
required |
Source code in outlines/inputs.py
Video
dataclass
Contains a video that can be passed to a multimodal model.
Provide one or several instances of this class along with a text prompt
in a list as the model_input
argument to a model that supports video
processing.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
video
|
Any
|
The video to use in the text generation. |
required |