mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-03 02:22:24 +00:00
feat: NoopProvider for tests + agent_settings.vm_provider=noop config
In-memory `AgentVMProvider` used by the unit tests and as the default when `agent_settings.vm_provider` is unset. The factory returns `NoopProvider` when no AWS-backed provider is configured so the proxy boots cleanly without AWS credentials. LIT-2878
This commit is contained in:
parent
380cf11298
commit
bdcda518a7
1 changed files with 49 additions and 0 deletions
49
litellm/proxy/agent_session_endpoints/vm_providers/noop.py
Normal file
49
litellm/proxy/agent_session_endpoints/vm_providers/noop.py
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
"""
|
||||
No-op `AgentVMProvider` implementation.
|
||||
|
||||
Used in tests and for environments without an EC2 backend. `provision` returns
|
||||
a fake handle immediately; `status` always reports `running`. The provider is
|
||||
the default in `factory.py` so the proxy starts up without AWS configured.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import uuid
|
||||
|
||||
from litellm.proxy.agent_session_endpoints.vm_providers.base import (
|
||||
AgentVMProvider,
|
||||
ProvisionContext,
|
||||
VMHandle,
|
||||
VMState,
|
||||
VMStatus,
|
||||
)
|
||||
|
||||
|
||||
class NoopProvider(AgentVMProvider):
|
||||
"""In-memory provider used by tests and `vm_provider: noop` config."""
|
||||
|
||||
name = "noop"
|
||||
|
||||
def __init__(self) -> None:
|
||||
self._terminated: set = set()
|
||||
|
||||
async def provision(self, ctx: ProvisionContext) -> VMHandle:
|
||||
vm_id = f"noop-{uuid.uuid4().hex[:12]}"
|
||||
return VMHandle(
|
||||
vm_id=vm_id,
|
||||
provider=self.name,
|
||||
region=(ctx.ec2_config.region if ctx.ec2_config else None),
|
||||
metadata={
|
||||
"session_id": ctx.session_id,
|
||||
"team_id": ctx.team_id,
|
||||
"mode": ctx.mode,
|
||||
},
|
||||
)
|
||||
|
||||
async def terminate(self, vm: VMHandle) -> None:
|
||||
self._terminated.add(vm.vm_id)
|
||||
|
||||
async def status(self, vm: VMHandle) -> VMStatus:
|
||||
if vm.vm_id in self._terminated:
|
||||
return VMStatus(state=VMState.TERMINATED)
|
||||
return VMStatus(state=VMState.RUNNING, public_ip="127.0.0.1")
|
||||
Loading…
Add table
Reference in a new issue