mirror of
https://github.com/agent0ai/agent-zero.git
synced 2026-07-09 17:08:29 +00:00
Add llama.cpp and vLLM local providers
Add llama.cpp / llama-server support: - Register llama.cpp chat and embedding providers through hosted_vllm defaults on host.docker.internal:8080. - Add onboarding metadata, a bundled icon, no-key provider metadata, model discovery coverage, setup docs, and tests. Add vLLM support: - Register vLLM chat and embedding providers through hosted_vllm defaults on host.docker.internal:8000. - Add onboarding metadata, a bundled icon, no-key provider metadata, model discovery coverage, setup docs, and tests. - Strip empty tools arrays from the Responses-to-chat fallback path so strict OpenAI-compatible servers accept local vLLM calls.
This commit is contained in:
parent
0450098117
commit
9bcef39028
18 changed files with 450 additions and 6 deletions
|
|
@ -459,6 +459,7 @@ class ChatCompletionsTransport:
|
|||
chat_kwargs = dict(kwargs)
|
||||
_drop_internal_transport_kwargs(chat_kwargs)
|
||||
if not _has_tools(chat_kwargs.get("tools")):
|
||||
chat_kwargs.pop("tools", None)
|
||||
chat_kwargs.pop("tool_choice", None)
|
||||
chat_kwargs.pop("parallel_tool_calls", None)
|
||||
if _is_openai_prompt_cache_provider(model, chat_kwargs):
|
||||
|
|
@ -1538,6 +1539,8 @@ def _is_responses_not_supported_error(exc: Exception) -> bool:
|
|||
"unsupportedparamserror",
|
||||
"does not support parameters",
|
||||
"no 'tools' defined while 'tool_choice' is specified",
|
||||
"tools` must not be an empty array",
|
||||
"tools must not be an empty array",
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
|||
45
helpers/litellm_transport.py.dox.md
Normal file
45
helpers/litellm_transport.py.dox.md
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
# litellm_transport.py DOX
|
||||
|
||||
## Purpose
|
||||
|
||||
- Own Agent Zero's LiteLLM transport adapter for Chat Completions and Responses API calls.
|
||||
- Normalize Agent Zero model-call kwargs into provider-safe LiteLLM requests.
|
||||
- Preserve canonical response metadata for history, provider-state continuation, and fallback decisions.
|
||||
|
||||
## Ownership
|
||||
|
||||
- `litellm_transport.py` owns the runtime implementation.
|
||||
- `litellm_transport.py.dox.md` owns durable notes about responsibilities, contracts, side effects, and verification for that implementation.
|
||||
- Classes:
|
||||
- `TransportMode`
|
||||
- `TransportRecovery`
|
||||
- `TransportPolicy`
|
||||
- `LiteLLMTransport`
|
||||
- `ChatCompletionsTransport`
|
||||
- `ResponsesTransport`
|
||||
- `ResponsesEventParser`
|
||||
- Top-level functions include transport cache reset, request normalization, parsing, prompt-cache preparation, and response/error classifiers.
|
||||
|
||||
## Runtime Contracts
|
||||
|
||||
- Keep provider selection and provider-specific defaults outside this helper; callers pass a resolved LiteLLM model name and kwargs.
|
||||
- Strip Agent Zero internal kwargs before sending requests to LiteLLM.
|
||||
- Do not send orphan tool controls when no tools are present; strict OpenAI-compatible servers can reject empty `tools` arrays.
|
||||
- Prefer Responses API when configured, but fallback to Chat Completions when the provider does not support Responses.
|
||||
- Preserve provider-state metadata when Responses API calls succeed, and fall back to local replay when provider state is unsupported.
|
||||
- Keep prompt-cache markers only for providers that accept them.
|
||||
|
||||
## Work Guidance
|
||||
|
||||
- Add provider-agnostic request cleanup here when multiple OpenAI-compatible providers can benefit.
|
||||
- Treat fallback behavior as a shared transport contract, not a provider registry.
|
||||
- Keep tool conversion symmetric between Chat Completions and Responses requests.
|
||||
|
||||
## Verification
|
||||
|
||||
- Run `pytest tests/test_stream_tool_early_stop.py tests/test_responses_architecture.py -q` after changing transport normalization or fallback behavior.
|
||||
- Run local-provider smoke checks when changing OpenAI-compatible request cleanup.
|
||||
|
||||
## Child DOX Index
|
||||
|
||||
No child DOX files.
|
||||
39
helpers/llm_result.py.dox.md
Normal file
39
helpers/llm_result.py.dox.md
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
# llm_result.py DOX
|
||||
|
||||
## Purpose
|
||||
|
||||
- Own canonical LLM result metadata shared by model transports, history, and tool-result processing.
|
||||
- Preserve Responses API output items, provider response IDs, reasoning text, usage, and capability metadata in a serializable form.
|
||||
|
||||
## Ownership
|
||||
|
||||
- `llm_result.py` owns the runtime implementation.
|
||||
- `llm_result.py.dox.md` owns durable notes about responsibilities, contracts, side effects, and verification for that implementation.
|
||||
- Classes:
|
||||
- `ResponseItem`
|
||||
- `ResponseFunctionCall`
|
||||
- `LLMResult`
|
||||
- Top-level functions include metadata conversion, function-call output item construction, object normalization, output-text extraction, reasoning extraction, and function-call argument parsing.
|
||||
|
||||
## Runtime Contracts
|
||||
|
||||
- `LLMResult.metadata()` stores data under `RESPONSE_METADATA_KEY` so history can round-trip provider state.
|
||||
- `from_response(...)` must preserve provider `response_id`, `previous_response_id`, raw output items, usage, and capability metadata.
|
||||
- `from_chat(...)` must produce an equivalent chat-completions result with `mode="chat_completions"` and `state="off"`.
|
||||
- Function-call output items must preserve `call_id` and optional acknowledged safety checks.
|
||||
- Argument parsing must tolerate JSON strings, dictionaries, and malformed values without throwing.
|
||||
|
||||
## Work Guidance
|
||||
|
||||
- Keep metadata backward-compatible with existing serialized chat history.
|
||||
- Treat unknown response item types as preserved built-in items unless they are local function calls, message text, or reasoning.
|
||||
- Avoid provider-specific assumptions in result parsing.
|
||||
|
||||
## Verification
|
||||
|
||||
- Run `pytest tests/test_responses_architecture.py -q` after changing result metadata behavior.
|
||||
- Run focused history/tool-processing tests when changing function-call serialization.
|
||||
|
||||
## Child DOX Index
|
||||
|
||||
No child DOX files.
|
||||
37
helpers/tunnel_origins.py.dox.md
Normal file
37
helpers/tunnel_origins.py.dox.md
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
# tunnel_origins.py DOX
|
||||
|
||||
## Purpose
|
||||
|
||||
- Own origin normalization for Remote Control tunnel URLs and CSRF/WebSocket same-origin checks.
|
||||
- Provide a small helper boundary between tunnel discovery and security enforcement.
|
||||
|
||||
## Ownership
|
||||
|
||||
- `tunnel_origins.py` owns the runtime implementation.
|
||||
- `tunnel_origins.py.dox.md` owns durable notes about responsibilities, contracts, side effects, and verification for that implementation.
|
||||
- Top-level functions:
|
||||
- `origin_from_url(value)`
|
||||
- `origin_key(value)`
|
||||
- `get_active_tunnel_origins()`
|
||||
|
||||
## Runtime Contracts
|
||||
|
||||
- Normalize URL and Origin header values to `scheme://host[:port]`, omitting default ports.
|
||||
- Return comparable origin keys with default ports restored for same-origin checks.
|
||||
- Treat invalid, missing, or malformed origins as `None`.
|
||||
- Discover active tunnel origins from `TunnelManager` and the Docker tunnel API without raising if either source is unavailable.
|
||||
- Keep tunnel service lookups short-timeout and local-only.
|
||||
|
||||
## Work Guidance
|
||||
|
||||
- Keep parsing based on `urllib.parse` rather than hand-rolled string checks.
|
||||
- Preserve defensive exception handling because tunnel services are optional and may not be running.
|
||||
- Coordinate security-sensitive changes with CSRF and WebSocket tests.
|
||||
|
||||
## Verification
|
||||
|
||||
- Run `pytest tests/test_csrf_tunnel_origins.py tests/test_ws_csrf.py -q` after changing tunnel origin behavior.
|
||||
|
||||
## Child DOX Index
|
||||
|
||||
No child DOX files.
|
||||
Loading…
Add table
Add a link
Reference in a new issue