trulens.core.utils.signature¶
trulens.core.utils.signature
¶
Utilities related to guessing inputs and outputs of functions.
Functions¶
_extract_content
¶
_extract_content(value, content_keys=['content'])
Extracts the 'content' from various data types commonly used by libraries like OpenAI, Canopy, LiteLLM, etc. This method navigates nested data structures (pydantic models, dictionaries, lists) to retrieve the 'content' field. If 'content' is not directly available, it attempts to extract from known structures like 'choices' in a ChatResponse. This standardizes extracting relevant text or data from complex API responses or internal data representations.
PARAMETER | DESCRIPTION |
---|---|
value
|
The input data to extract content from. Can be a pydantic model, dictionary, list, or basic data type.
|
RETURNS | DESCRIPTION |
---|---|
The extracted content, which may be a single value, a list of values, |
|
or a nested structure with content extracted from all levels. |
main_input
¶
main_input(
func: Callable, sig: Signature, bindings: BoundArguments
) -> str
Determine (guess) the main input string for a main app call.
PARAMETER | DESCRIPTION |
---|---|
func
|
The main function we are targeting in this determination.
TYPE:
|
sig
|
The signature of the above.
TYPE:
|
bindings
|
The arguments to be passed to the function.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
str
|
The main input string. |