codemode
Class info¶
Classes¶
| Name | Children | Inherits |
|---|---|---|
| CodeModeResourceProvider llmling_agent.resource_providers.codemode.provider Provider that wraps tools into a single Python execution environment. |
||
| RemoteCodeModeResourceProvider llmling_agent.resource_providers.codemode.remote_provider Provider that executes code in secure isolation with tool access via server. |
🛈 DocStrings¶
Meta-resource provider that exposes tools through Python execution.
CodeModeResourceProvider
¶
Bases: AggregatingResourceProvider
Provider that wraps tools into a single Python execution environment.
Source code in src/llmling_agent/resource_providers/codemode/provider.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | |
__init__
¶
__init__(
providers: list[ResourceProvider],
name: str = "meta_tools",
include_docstrings: bool = True,
usage_notes: str = USAGE,
) -> None
Initialize meta provider.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
providers
|
list[ResourceProvider]
|
Providers whose tools to wrap |
required |
name
|
str
|
Provider name |
'meta_tools'
|
include_docstrings
|
bool
|
Include function docstrings in documentation |
True
|
usage_notes
|
str
|
Usage notes for the codemode tool |
USAGE
|
Source code in src/llmling_agent/resource_providers/codemode/provider.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | |
execute
async
¶
execute(ctx: AgentContext, python_code: str) -> Any
Execute Python code with all wrapped tools available as functions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
python_code
|
str
|
Python code to execute |
required |
Returns:
| Type | Description |
|---|---|
Any
|
Result of the last expression or explicit return value |
Source code in src/llmling_agent/resource_providers/codemode/provider.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | |
get_tools
async
¶
Return single meta-tool for Python execution with available tools.
Source code in src/llmling_agent/resource_providers/codemode/provider.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | |
invalidate_cache
¶
invalidate_cache() -> None
Invalidate cached tool when providers change.
Source code in src/llmling_agent/resource_providers/codemode/provider.py
102 103 104 | |
RemoteCodeModeResourceProvider
¶
Bases: CodeModeResourceProvider
Provider that executes code in secure isolation with tool access via server.
Source code in src/llmling_agent/resource_providers/codemode/remote_provider.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | |
__aenter__
async
¶
__aenter__() -> Self
Async context manager entry.
Source code in src/llmling_agent/resource_providers/codemode/remote_provider.py
121 122 123 | |
__aexit__
async
¶
__aexit__(
exc_type: type[BaseException] | None,
exc_val: BaseException | None,
exc_tb: TracebackType | None,
) -> None
Async context manager exit.
Source code in src/llmling_agent/resource_providers/codemode/remote_provider.py
125 126 127 128 129 130 131 132 133 134 135 | |
__init__
¶
__init__(
providers: list[ResourceProvider],
execution_config: ExecutionEnvironmentConfig | None = None,
name: str = "secure_code_executor",
include_docstrings: bool = True,
usage_notes: str = USAGE,
server_host: str = "localhost",
server_port: int = 8000,
) -> None
Initialize secure code execution provider.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
providers
|
list[ResourceProvider]
|
Providers whose tools to expose |
required |
execution_config
|
ExecutionEnvironmentConfig | None
|
Execution environment configuration |
None
|
name
|
str
|
Provider name |
'secure_code_executor'
|
include_docstrings
|
bool
|
Include function docstrings in documentation |
True
|
usage_notes
|
str
|
Usage notes for the provider |
USAGE
|
server_host
|
str
|
Host for tool server |
'localhost'
|
server_port
|
int
|
Port for tool server |
8000
|
Source code in src/llmling_agent/resource_providers/codemode/remote_provider.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | |
execute
async
¶
execute(ctx: AgentContext, python_code: str) -> Any
Execute Python code in secure environment with tools available via HTTP.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
python_code
|
str
|
Python code to execute |
required |
Returns:
| Type | Description |
|---|---|
Any
|
Result of the code execution |
Source code in src/llmling_agent/resource_providers/codemode/remote_provider.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |