IOStream - AG2
IOStream
autogen.io.IOStream
A protocol for input/output streams.
set_global_default`staticmethod
set_global_default(stream)
Set the default input/output stream.
| PARAMETER | DESCRIPTION |
|---|---|
stream |
The input/output stream to set as the default. TYPE: IOStream |
Source code in autogen/io/base.py
<br>102<br>103<br>104<br>105<br>106<br>107<br>108<br>109<br> |
<br>@staticmethod<br>def set_global_default(stream: iostream_union) -> None:<br> """Set the default input/output stream.<br> Args:<br> stream (IOStream): The input/output stream to set as the default.<br> """<br> IOStream._global_default = stream<br> |
get_global_default`staticmethod
get_global_default()
Get the default input/output stream.
| RETURNS | DESCRIPTION |
|---|---|
IOStream |
The default input/output stream. TYPE: iostream_union |
Source code in autogen/io/base.py
<br>111<br>112<br>113<br>114<br>115<br>116<br>117<br>118<br>119<br>120<br> |
<br>@staticmethod<br>def get_global_default() -> iostream_union:<br> """Get the default input/output stream.<br> Returns:<br> IOStream: The default input/output stream.<br> """<br> if IOStream._global_default is None:<br> raise RuntimeError("No global default IOStream has been set")<br> return IOStream._global_default<br> |
get_default`staticmethod
get_default()
Get the default input/output stream.
| RETURNS | DESCRIPTION |
|---|---|
IOStream |
The default input/output stream. TYPE: iostream_union |
Source code in autogen/io/base.py
<br>122<br>123<br>124<br>125<br>126<br>127<br>128<br>129<br>130<br>131<br>132<br>133<br>134<br> |
<br>@staticmethod<br>def get_default() -> iostream_union:<br> """Get the default input/output stream.<br> Returns:<br> IOStream: The default input/output stream.<br> """<br> iostream = IOStream._default_io_stream.get()<br> if iostream is None:<br> iostream = IOStream.get_global_default()<br> # Set the default IOStream of the current context (thread/cooroutine)<br> IOStream.set_default(iostream)<br> return iostream<br> |
set_default`staticmethod
set_default(stream)
Set the default input/output stream.
| PARAMETER | DESCRIPTION |
|---|---|
stream |
The input/output stream to set as the default. TYPE: IOStream |
Source code in autogen/io/base.py
<br>136<br>137<br>138<br>139<br>140<br>141<br>142<br>143<br>144<br>145<br>146<br>147<br>148<br>149<br>150<br>151<br> |
<br>@staticmethod<br>@contextmanager<br>def set_default(stream: Optional[iostream_union]) -> Iterator[None]:<br> """Set the default input/output stream.<br> Args:<br> stream (IOStream): The input/output stream to set as the default.<br> """<br> global _default_io_stream<br> try:<br> token = IOStream._default_io_stream.set(stream)<br> yield<br> finally:<br> IOStream._default_io_stream.reset(token)<br> return<br> |