Skip to content

marvin.beta.assistants.formatting

download_temp_file cached

Downloads a file from OpenAI's servers and saves it to a temporary file.

Parameters:

Name Type Description Default
file_id str

The ID of the file to be downloaded.

required

Returns:

Type Description

The file path of the downloaded temporary file.

format_run

Formats a run, which is an object that has both .messages and .steps attributes, each of which is a list of Messages and RunSteps.

Parameters:

Name Type Description Default
run

A Run object

required
include_messages bool

Whether to include messages in the formatted output

True
include_steps bool

Whether to include steps in the formatted output

True

format_timestamp

Outputs timestamp as a string in 12 hour format. Hours are left-padded with space instead of zero.

pprint_message

Pretty-prints a single message using the rich library, highlighting the speaker's role, the message text, any available images, and the message timestamp in a panel format.

Parameters:

Name Type Description Default
message Message

A message object

required

pprint_messages

Iterates over a list of messages and pretty-prints each one.

Messages are pretty-printed using the rich library, highlighting the speaker's role, the message text, any available images, and the message timestamp in a panel format.

Parameters:

Name Type Description Default
messages list[Message]

A list of Message objects to be printed.

required

pprint_run

Pretty-prints a run, which is an object that has both .messages and .steps attributes, each of which is a list of Messages and RunSteps.

Parameters:

Name Type Description Default
run

A Run object

required

pprint_step

Formats and prints a run step with status information.

Parameters:

Name Type Description Default
run_step

A RunStep object containing the details of the run step.

required

pprint_steps

Iterates over a list of run steps and pretty-prints each one.

Parameters:

Name Type Description Default
steps list[RunStep]

A list of RunStep objects to be printed.

required