resource_providers
Class info¶
Classes¶
| Name | Children | Inherits |
|---|---|---|
| AggregatingResourceProvider llmling_agent.resource_providers.aggregating Provider that combines resources from multiple providers. |
||
| MCPResourceProvider llmling_agent.resource_providers.mcp_provider Resource provider for a single MCP server. |
||
| ResourceProvider llmling_agent.resource_providers.base Base class for resource providers. |
||
| StaticResourceProvider llmling_agent.resource_providers.static Provider for pre-configured tools, prompts and resources. |
🛈 DocStrings¶
Resource provider implementations.
AggregatingResourceProvider
¶
Bases: ResourceProvider
Provider that combines resources from multiple providers.
Source code in src/llmling_agent/resource_providers/aggregating.py
18 19 20 21 22 23 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 | |
__init__
¶
__init__(providers: list[ResourceProvider], name: str = 'aggregating')
Initialize provider with list of providers to aggregate.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
providers
|
list[ResourceProvider]
|
Resource providers to aggregate (stores reference to list) |
required |
name
|
str
|
Name for this provider |
'aggregating'
|
Source code in src/llmling_agent/resource_providers/aggregating.py
21 22 23 24 25 26 27 28 29 30 | |
get_prompts
async
¶
get_prompts() -> list[BasePrompt]
Get prompts from all providers.
Source code in src/llmling_agent/resource_providers/aggregating.py
36 37 38 | |
get_request_parts
async
¶
Try to get prompt from first provider that has it.
Source code in src/llmling_agent/resource_providers/aggregating.py
44 45 46 47 48 49 50 51 52 53 54 | |
get_resources
async
¶
get_resources() -> list[ResourceInfo]
Get resources from all providers.
Source code in src/llmling_agent/resource_providers/aggregating.py
40 41 42 | |
get_tools
async
¶
Get tools from all providers.
Source code in src/llmling_agent/resource_providers/aggregating.py
32 33 34 | |
MCPResourceProvider
¶
Bases: ResourceProvider
Resource provider for a single MCP server.
Source code in src/llmling_agent/resource_providers/mcp_provider.py
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 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 | |
get_prompts
async
¶
get_prompts() -> list[MCPClientPrompt]
Get cached prompts, refreshing if necessary.
Source code in src/llmling_agent/resource_providers/mcp_provider.py
192 193 194 195 196 197 | |
get_resources
async
¶
get_resources() -> list[ResourceInfo]
Get cached resources, refreshing if necessary.
Source code in src/llmling_agent/resource_providers/mcp_provider.py
221 222 223 224 225 226 | |
get_tools
async
¶
Get cached tools, refreshing if necessary.
Source code in src/llmling_agent/resource_providers/mcp_provider.py
163 164 165 166 167 168 | |
refresh_prompts_cache
async
¶
refresh_prompts_cache() -> None
Refresh the prompts cache by fetching from client.
Source code in src/llmling_agent/resource_providers/mcp_provider.py
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | |
refresh_resources_cache
async
¶
refresh_resources_cache() -> None
Refresh the resources cache by fetching from client.
Source code in src/llmling_agent/resource_providers/mcp_provider.py
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 | |
refresh_tools_cache
async
¶
refresh_tools_cache() -> None
Refresh the tools cache by fetching from client.
Source code in src/llmling_agent/resource_providers/mcp_provider.py
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | |
ResourceProvider
¶
Base class for resource providers.
Provides tools, prompts, and other resources to agents. Default implementations return empty lists - override as needed.
Source code in src/llmling_agent/resource_providers/base.py
23 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 | |
__aenter__
async
¶
__aenter__() -> Self
Async context entry if required.
Source code in src/llmling_agent/resource_providers/base.py
36 37 38 | |
__aexit__
async
¶
__aexit__(
exc_type: type[BaseException] | None,
exc_val: BaseException | None,
exc_tb: TracebackType | None,
)
Async context cleanup if required.
Source code in src/llmling_agent/resource_providers/base.py
40 41 42 43 44 45 46 | |
__init__
¶
Initialize the resource provider.
Source code in src/llmling_agent/resource_providers/base.py
30 31 32 33 34 | |
get_prompts
async
¶
get_prompts() -> list[BasePrompt]
Get available prompts. Override to provide prompts.
Source code in src/llmling_agent/resource_providers/base.py
55 56 57 | |
get_request_parts
async
¶
Get a prompt formatted with arguments.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the prompt to format |
required |
arguments
|
dict[str, str] | None
|
Optional arguments for prompt formatting |
None
|
Returns:
| Type | Description |
|---|---|
list[ModelRequestPart]
|
Single chat message with merged content |
Raises:
| Type | Description |
|---|---|
KeyError
|
If prompt not found |
ValueError
|
If formatting fails |
Source code in src/llmling_agent/resource_providers/base.py
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 | |
get_resources
async
¶
get_resources() -> list[ResourceInfo]
Get available resources. Override to provide resources.
Source code in src/llmling_agent/resource_providers/base.py
59 60 61 | |
StaticResourceProvider
¶
Bases: ResourceProvider
Provider for pre-configured tools, prompts and resources.
Allows creating a provider that serves a fixed set of resources passed during initialization. Useful for converting static configurations to the common ResourceProvider interface.
Source code in src/llmling_agent/resource_providers/static.py
18 19 20 21 22 23 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 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 | |
__init__
¶
__init__(
name: str = "static",
tools: Sequence[Tool] | None = None,
prompts: Sequence[BasePrompt] | None = None,
resources: Sequence[ResourceInfo] | None = None,
)
Initialize provider with static resources.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the provider |
'static'
|
tools
|
Sequence[Tool] | None
|
Optional list of tools to serve |
None
|
prompts
|
Sequence[BasePrompt] | None
|
Optional list of prompts to serve |
None
|
resources
|
Sequence[ResourceInfo] | None
|
Optional list of resources to serve |
None
|
Source code in src/llmling_agent/resource_providers/static.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | |
add_prompt
¶
add_prompt(prompt: BasePrompt) -> None
Add a prompt to this provider.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prompt
|
BasePrompt
|
Prompt to add |
required |
Source code in src/llmling_agent/resource_providers/static.py
85 86 87 88 89 90 91 | |
add_resource
¶
add_resource(resource: ResourceInfo) -> None
Add a resource to this provider.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
resource
|
ResourceInfo
|
Resource to add |
required |
Source code in src/llmling_agent/resource_providers/static.py
108 109 110 111 112 113 114 | |
add_tool
¶
add_tool(tool: Tool) -> None
Add a tool to this provider.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tool
|
Tool
|
Tool to add |
required |
Source code in src/llmling_agent/resource_providers/static.py
62 63 64 65 66 67 68 | |
get_prompts
async
¶
get_prompts() -> list[BasePrompt]
Get pre-configured prompts.
Source code in src/llmling_agent/resource_providers/static.py
54 55 56 | |
get_resources
async
¶
get_resources() -> list[ResourceInfo]
Get pre-configured resources.
Source code in src/llmling_agent/resource_providers/static.py
58 59 60 | |
get_tool
async
¶
Get tool by name.
Source code in src/llmling_agent/resource_providers/static.py
50 51 52 | |
get_tools
async
¶
Get pre-configured tools.
Source code in src/llmling_agent/resource_providers/static.py
46 47 48 | |
remove_prompt
¶
Remove a prompt by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of prompt to remove |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if prompt was found and removed, False otherwise |
Source code in src/llmling_agent/resource_providers/static.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 | |
remove_resource
¶
Remove a resource by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of resource to remove |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if resource was found and removed, False otherwise |
Source code in src/llmling_agent/resource_providers/static.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 | |
remove_tool
¶
Remove a tool by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of tool to remove |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if tool was found and removed, False otherwise |
Source code in src/llmling_agent/resource_providers/static.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 | |
tool
¶
tool(
func: Callable[..., Any] | None = None,
*,
name: str | None = None,
description: str | None = None,
enabled: bool = True,
requires_confirmation: bool = False,
metadata: dict[str, str] | None = None,
**kwargs: Any
) -> Callable[..., Any] | Callable[[Callable[..., Any]], Callable[..., Any]]
Decorator to register a function as a tool.
Can be used with or without parameters:
# Without parameters
@provider.tool
def my_function(x: int) -> str:
return str(x)
# With parameters
@provider.tool(name="custom_name", description="Custom description")
def another_function(y: str) -> str:
return y.upper()
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
func
|
Callable[..., Any] | None
|
Function to register (when used without parentheses) |
None
|
name
|
str | None
|
Override for tool name |
None
|
description
|
str | None
|
Override for tool description |
None
|
enabled
|
bool
|
Whether tool is initially enabled |
True
|
requires_confirmation
|
bool
|
Whether execution needs confirmation |
False
|
metadata
|
dict[str, str] | None
|
Additional tool metadata |
None
|
**kwargs
|
Any
|
Additional arguments passed to Tool.from_callable |
{}
|
Source code in src/llmling_agent/resource_providers/static.py
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 | |