Common types
conatus.utils.common_types
¶
Common types shared across the project.
JSONPrimitives
module-attribute
¶
JSON primitives type alias.
JSONLevel1
module-attribute
¶
JSONLevel1 = (
JSONPrimitives
| dict[str, JSONPrimitives]
| list[JSONPrimitives]
| tuple[JSONPrimitives, ...]
)
JSON level with one level of nesting.
JSONLevel2
module-attribute
¶
JSONLevel2 = (
JSONPrimitives
| dict[str, JSONLevel1]
| list[JSONLevel1]
| tuple[JSONLevel1, ...]
)
JSON level with two levels of nesting.
JSONLevel3
module-attribute
¶
JSONLevel3 = (
JSONPrimitives
| dict[str, JSONLevel2]
| list[JSONLevel2]
| tuple[JSONLevel2, ...]
)
JSON level with three levels of nesting.
JSONLevel4
module-attribute
¶
JSONLevel4 = (
JSONPrimitives
| dict[str, JSONLevel3]
| list[JSONLevel3]
| tuple[JSONLevel3, ...]
)
JSON level with four levels of nesting.
JSONLevel5
module-attribute
¶
JSONLevel5 = (
JSONPrimitives
| dict[str, JSONLevel4]
| list[JSONLevel4]
| tuple[JSONLevel4, ...]
)
JSON level with five levels of nesting.
JSONLevel6
module-attribute
¶
JSONLevel6 = (
JSONPrimitives
| dict[str, JSONLevel5]
| list[JSONLevel5]
| tuple[JSONLevel5, ...]
)
JSON level with six levels of nesting.
JSONLevel7
module-attribute
¶
JSONLevel7 = (
JSONPrimitives
| dict[str, JSONLevel6]
| list[JSONLevel6]
| tuple[JSONLevel6, ...]
)
JSON level with seven levels of nesting.
JSONLevel8
module-attribute
¶
JSONLevel8 = (
JSONPrimitives
| dict[str, JSONLevel7]
| list[JSONLevel7]
| tuple[JSONLevel7, ...]
)
JSON level with eight levels of nesting.
JSONLevel9
module-attribute
¶
JSONLevel9 = (
JSONPrimitives
| dict[str, JSONLevel8]
| list[JSONLevel8]
| tuple[JSONLevel8, ...]
)
JSON level with nine levels of nesting.
JSONLevel10
module-attribute
¶
JSONLevel10 = (
JSONPrimitives
| dict[str, JSONLevel9]
| list[JSONLevel9]
| tuple[JSONLevel9, ...]
)
JSON levels with up to 10 levels of nesting.
DeepConstJSONSchema
module-attribute
¶
DeepConstJSONSchema = (
JSONPrimitives
| dict[str, JSONLevel10]
| list[JSONLevel10]
)
JSON schema with a maximum of 10 levels of nesting.
ConstJSONSchema
module-attribute
¶
ConstJSONSchema = (
JSONPrimitives
| dict[str, JSONLevel2]
| list[JSONLevel2]
)
JSON schema with a maximum of 2 levels of nesting.
JSONType
module-attribute
¶
JSONType = JSONLevel3
Default JSON type alias, with a maximum of 3 levels of nesting.
InvariantJSONDict
module-attribute
¶
Invariant JSON dictionary type alias.
conatus.utils.common_processing
¶
Common processing functions across all modules.
check_name_is_not_reserved
¶
Check if the name of an action or variable is not reserved.
For Action classes and subclasses¶
In general, this function will be called when the name attribute is
set on the class. But if you want to do modifications before the
class is created, you can call this function directly.
For inputs and outputs of Agent¶
This function will be called when the inputs and outputs are normalized.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The name to check.
TYPE:
|
kind
|
The kind of the name. Either "action" or "variable".
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the name is reserved. |
Source code in conatus/utils/common_processing.py
generate_import_statement
¶
Generate an import statement for a given type.
Example
| PARAMETER | DESCRIPTION |
|---|---|
t
|
The type object to generate the import for.
TYPE:
|
skip_if_builtin
|
Whether to skip if the type is a built-in type.
Defaults to
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
The formatted import statement. |
Source code in conatus/utils/common_processing.py
extract_code_blocks
¶
Extracts all fenced code blocks from a Markdown-formatted LLM response.
| PARAMETER | DESCRIPTION |
|---|---|
markdown_text
|
The Markdown content.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[tuple[str, str]]
|
A list of tuples where each tuple contains: (1) The language (empty string if unspecified) (2) The code block content |