Input module
AudioInput(optional=False, name=None)
Instantiate a symbolic multimodal (audio) input for a Program.
The audio sibling of ImageInput: it declares a ChatMessages input
branch into which you put a user ChatMessage whose content mixes the
instruction text with one or more synalinks.Audio parts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
optional
|
bool
|
Whether the input is optional or not.
An optional input can accept |
False
|
name
|
string
|
Optional name string for the module. Should be unique in a program (do not reuse the same name twice). It will be autogenerated if it isn't provided. |
None
|
Returns:
| Type | Description |
|---|---|
SymbolicDataModel
|
A |
Source code in synalinks/src/modules/core/input_module.py
ImageInput(optional=False, name=None)
Instantiate a symbolic multimodal (image) input for a Program.
A modality is a content part of a Message, so an image input is just a
chat input: this declares a ChatMessages input branch into which you put
a user ChatMessage whose content mixes the question text with one or more
synalinks.Image parts.
Example:
import synalinks
inputs = synalinks.ImageInput()
outputs = await synalinks.Generator(
data_model=Answer,
language_model=language_model,
)(inputs)
program = synalinks.Program(inputs=inputs, outputs=outputs)
result = await program(
synalinks.ChatMessages(
messages=[
synalinks.ChatMessage(
role="user",
content=[
"What is in this picture?",
synalinks.Image(url="https://example.com/cat.png"),
],
)
]
)
)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
optional
|
bool
|
Whether the input is optional or not.
An optional input can accept |
False
|
name
|
string
|
Optional name string for the module. Should be unique in a program (do not reuse the same name twice). It will be autogenerated if it isn't provided. |
None
|
Returns:
| Type | Description |
|---|---|
SymbolicDataModel
|
A |
Source code in synalinks/src/modules/core/input_module.py
Input(schema=None, data_model=None, optional=False, name=None)
Used to instantiate a SymbolicDataModel.
A SymbolicDataModel is a symbolic data model-like object, which we augment with
certain attributes that allow us to build a Synalinks Program just by knowing the
inputs and outputs of the program (similar to Keras symbolic tensor).
Example:
import synalinks
class Query(synalinks.DataModel):
query: str
inputs = synalinks.Input(data_model=Query)
# You can also create it using a JSON schema like this:
inputs = synalinks.Input(schema=Query.get_schema())
# Or using a symbolic datamodel:
inputs = synalinks.Input(data_model=Query.to_symbolic_data_model())
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
schema
|
dict
|
A Json schema of the data_model.
If not provided uses the |
None
|
data_model
|
DataModel
|
Optional existing data model to wrap into
the |
None
|
optional
|
bool
|
Whether the input is optional or not.
An optional input can accept |
False
|
name
|
string
|
Optional name string for the module. Should be unique in a program (do not reuse the same name twice). It will be autogenerated if it isn't provided. |
None
|
Returns:
| Type | Description |
|---|---|
SymbolicDataModel
|
The symbolic data model corresponding to the given data model/schema. |