pixano.inference.text_image_conditional_generation
messages_to_prompt(messages, media_dir, image_regex=DEFAULT_IMAGE_REGEX, role_system=DEFAULT_ROLE_SYSTEM, role_user=DEFAULT_ROLE_USER, role_assistant=DEFAULT_ROLE_ASSISTANT)
Convert a list of messages to a prompt.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
messages
|
list[Message]
|
List of messages. |
required |
media_dir
|
Path
|
The directory containing the images. |
required |
image_regex
|
str
|
The tag used to represent an image in the messages. |
DEFAULT_IMAGE_REGEX
|
role_system
|
str
|
The role to use for the system. |
DEFAULT_ROLE_SYSTEM
|
role_user
|
str
|
The role to use for the user. |
DEFAULT_ROLE_USER
|
role_assistant
|
str
|
The role to use for the assistant. |
DEFAULT_ROLE_ASSISTANT
|
Returns:
Type | Description |
---|---|
list[dict[str, Any]]
|
List of dictionaries representing the prompt. |
Source code in pixano/inference/text_image_conditional_generation.py
text_image_conditional_generation(client, source, media_dir, messages, conversation, max_new_tokens=DEFAULT_MAX_NEW_TOKENS, temperature=DEFAULT_TEMPERATURE, image_regex=DEFAULT_IMAGE_REGEX, role_system=DEFAULT_ROLE_SYSTEM, role_user=DEFAULT_ROLE_USER, role_assistant=DEFAULT_ROLE_ASSISTANT, **client_kwargs)
async
Generate text from an image using the Pixano Inference API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
client
|
PixanoInferenceClient
|
The Pixano-Inference client to use. |
required |
source
|
Source
|
The source refering to the model. |
required |
media_dir
|
Path
|
The directory containing the input media files. |
required |
messages
|
list[Message]
|
A list of Message objects representing the input messages. |
required |
conversation
|
Conversation
|
The conversation entity of the messages. |
required |
max_new_tokens
|
int
|
The maximum number of tokens to generate. |
DEFAULT_MAX_NEW_TOKENS
|
temperature
|
float
|
The temperature to use for sampling. |
DEFAULT_TEMPERATURE
|
image_regex
|
str
|
The tag used to represent an image in the messages. |
DEFAULT_IMAGE_REGEX
|
role_system
|
str
|
The role of the system in the prompt. |
DEFAULT_ROLE_SYSTEM
|
role_user
|
str
|
The role of the user in the prompt. |
DEFAULT_ROLE_USER
|
role_assistant
|
str
|
The role of the assistant in the prompt. |
DEFAULT_ROLE_ASSISTANT
|
client_kwargs
|
Any
|
Additional kwargs for the client to be passed. |
{}
|
Returns:
Type | Description |
---|---|
Message
|
The response message and its source. |
Source code in pixano/inference/text_image_conditional_generation.py
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 |
|