function
¶
PromptFunc
¶
PromptFunc(
func: Callable,
ctx_method: str = "new",
compositor: Optional[Compositor] = None,
default_return: Optional[Literal["prompt"]] = None,
docstring_as: Optional[str] = None,
new_ctx_func: Callable = PromptContext,
)
A wrapper for an APPL function, can be called as a normal function.
The function contains a prompt context, which could be same as or copied from its caller function, or created from scratch, or resumed from the last run.
Parameters:
-
func
(Callable
) –the function being wrapped
-
ctx_method
(str
, default:'new'
) –the method to deal with the child context, available methods includes:
- (default) "new" or "new_ctx": create a brand new context.
- "copy" or "copy_ctx": copy from the parent's context, the change will not affect the parent's context.
- "same" or "same_ctx": use the same context as the parent's, the change will affect the parent's context.
- "resume" or "resume_ctx": resume its own context from the last run. For the first run, it will copy the parent's context.
-
compositor
(Compositor
, default:None
) –the default compositor to be used. Defaults to None.
-
default_return
(str
, default:None
) –The default return value, "prompt" means return the prompt within the function. Defaults to None.
-
docstring_as
(str
, default:None
) –Include the triple-quoted docstring as a message in the prompt. Options include "user" and "system". Defaults to None.
-
new_ctx_func
(Callable
, default:PromptContext
) –the function to create a new context. Defaults to PromptContext.