Create a new Program object from a program string. Parameters ---------- text : str The program string to use as a engine template. llm : engine.models.LLM (defaults to engine.llm) The language model to use for executing the program. c
(
self,
text,
llm=None,
cache_seed=0,
logprobs=None,
silent=None,
async_mode=False,
stream=None,
caching=None,
await_missing=False,
log=None,
memory=None,
memory_threshold=1,
memory_llm=None,
**kwargs,
)
| 141 | """ |
| 142 | |
| 143 | def __init__( |
| 144 | self, |
| 145 | text, |
| 146 | llm=None, |
| 147 | cache_seed=0, |
| 148 | logprobs=None, |
| 149 | silent=None, |
| 150 | async_mode=False, |
| 151 | stream=None, |
| 152 | caching=None, |
| 153 | await_missing=False, |
| 154 | log=None, |
| 155 | memory=None, |
| 156 | memory_threshold=1, |
| 157 | memory_llm=None, |
| 158 | **kwargs, |
| 159 | ): |
| 160 | """Create a new Program object from a program string. |
| 161 | |
| 162 | Parameters |
| 163 | ---------- |
| 164 | text : str |
| 165 | The program string to use as a engine template. |
| 166 | llm : engine.models.LLM (defaults to engine.llm) |
| 167 | The language model to use for executing the program. |
| 168 | cache_seed : int (default 0) or None |
| 169 | The seed to use for the cache. If you want to use the same cache for multiple programs |
| 170 | you can set this to the same value for all of them. Set this to None to disable caching. |
| 171 | Caching is enabled by default, and saves calls that have tempurature=0, and also saves |
| 172 | higher temperature calls but uses different seed for each call. |
| 173 | logprobs : int or None (default) |
| 174 | The number of logprobs to return from the language model for each token. (not well supported yet, |
| 175 | since some llms don't support it) |
| 176 | silent : bool (default None) |
| 177 | If True, the program will not display any output. This is useful for programs that are |
| 178 | only used to generate variables for other programs. If None we automatically set this based |
| 179 | on if we are streaming and if we are in interactive mode. |
| 180 | async_mode : bool (default False) |
| 181 | If True, the program will be executed asynchronously. This is useful for programs that |
| 182 | take a long time to run, or that need to be run in parallel. |
| 183 | stream : bool (default None) |
| 184 | If True, the program will try to stream all the results from the LLM token by token. If None |
| 185 | streaming will be enabled if is needed for funtionality. (Warning: this param may change a bit in the future) |
| 186 | caching : bool (default None) |
| 187 | If True, the program will cache the results of the LLM. If False, it will not cache the results. |
| 188 | If None, it will use the default caching setting from the LLM. |
| 189 | await_missing : bool (default False) |
| 190 | If True, the program will automatically await any missing variables. This means the program |
| 191 | will stop executation at that point and return a paritally executed program. This is useful |
| 192 | for executing programs on different machines, for example shipping a program to a GPU machine |
| 193 | then waiting for the results to come back for any local processing, then shipping it back to |
| 194 | the GPU machine to continue execution. |
| 195 | log : bool or Log |
| 196 | If True, the program will log all the commands that are executed into the `program.log` property. |
| 197 | If a Log object is passed in, it will be used as the log instead of creating a new one. |
| 198 | Memory: None or Memory Instance |
| 199 | if None, the program will not utilize memory |
| 200 | if Memory Class Instance is passed, it will be used to store and retrieve conversations |
nothing calls this directly
no test coverage detected