1123Javayanglei/vscode-chat-proxy/proxy does not have a README file

    ProxyError

    pub(all) suberror ProxyError {
    ProxyError(String)
    }

    ensure_system_prefix

    fn ensure_system_prefix(root :
    Json
    ) -> Bool

    Ensure the first system message of a Chat Completions request body starts with the built-in required_prefix.

    Prefer ensure_system_prefix_with with the configured prompt; this wrapper keeps the historical API (and the historical default sentence) stable.

    ensure_system_prefix_with

    fn ensure_system_prefix_with(root :
    Json
    , prompt : String) -> Bool

    Ensure the first system message of a Chat Completions request body starts with prompt (typically @config.Config::system_prompt).

    • first system message already starts with it: unchanged;
    • otherwise the sentence is prepended to its content (plain string content, or the first text part of multimodal content);
    • no system message at all: one is inserted at the front of messages.
    • a blank prompt falls back to required_prefix.

    Returns true when the JSON was modified.

    handle_connection

    Handle one client connection: serve requests in a keep-alive loop, rewriting the Chat Completions system message on the way and reusing pooled upstream connections. SSE / chunked responses are streamed chunk-by-chunk. Every request is recorded in the flow store for the monitor UI.

    required_prefix

    let required_prefix : String

    The built-in required opening sentence of the system message.

    This is only the default: the actual sentence comes from the config (SYSTEM_PROMPT in .env / the environment, or --system-prompt), see @config.Config::system_prompt.

    rewrite_chat_body_bytes

    fn rewrite_chat_body_bytes(body : Bytes, prompt : String) -> Result[Bytes?, String]

    Rewrite a raw UTF-8 Chat Completions JSON body so its first system message opens with prompt. Uses a zero-DOM byte-level surgical splice fast path (5-20x faster on large LLM conversation bodies) and seamlessly falls back to full @json.parse + ensure_system_prefix_with for multimodal content, escaped prefixes, or invalid JSON.

    Returns Ok(Some(new_bytes)) when modified, Ok(None) when unchanged, or Err(msg) when the body is not valid JSON.