Skip to content

Blocks

datapizza.type.Block

A class for storing the response from a client.

to_dict abstractmethod

to_dict()

Convert the block to a dictionary for JSON serialization.

datapizza.type.TextBlock

Bases: Block

A class for storing the text response from a client.

__init__

__init__(content, type='text')

Initialize a TextBlock object.

Parameters:

Name Type Description Default
content str

The content of the text block.

required
type str

The type of the text block. Defaults to "text".

'text'

datapizza.type.MediaBlock

Bases: Block

A class for storing the media response from a client.

__init__

__init__(media, type='media')

Initialize a MediaBlock object.

Parameters:

Name Type Description Default
media Media

The media of the media block.

required
type str

The type of the media block. Defaults to "media".

'media'

datapizza.type.ThoughtBlock

Bases: Block

A class for storing the thought from a client.

__init__

__init__(content, type='thought')

Initialize a ThoughtBlock object.

Parameters:

Name Type Description Default
content str

The content of the thought block.

required
type str

The type of the thought block. Defaults to "thought".

'thought'

datapizza.type.FunctionCallBlock

Bases: Block

A class for storing the function call from a client.

__init__

__init__(id, arguments, name, tool, type='function')

Initialize a FunctionCallBlock object.

Parameters:

Name Type Description Default
id str

The id of the function call block.

required
arguments dict[str, Any]

The arguments of the function call block.

required
name str

The name of the function call block.

required
tool Tool

The tool of the function call block.

required

datapizza.type.FunctionCallResultBlock

Bases: Block

A class for storing the function call response from a client.

__init__

__init__(id, tool, result, type='function_call_result')

Initialize a FunctionCallResultBlock object.

Parameters:

Name Type Description Default
id str

The id of the function call result block.

required
tool Tool

The tool of the function call result block.

required
result str

The result of the function call result block.

required

datapizza.type.StructuredBlock

Bases: Block

A class for storing the structured response from a client.

__init__

__init__(content, type='structured')

Initialize a StructuredBlock object.

Parameters:

Name Type Description Default
content BaseModel

The content of the structured block.

required
type str

The type of the structured block. Defaults to "structured".

'structured'