thinking/ThinkingProtocol.java

ZhiWei · src/main/java/com/lifepilot/llm/thinking/ThinkingProtocol.java · java · MIT
ai

Interface defining protocol for handling provider-specific thinking/reasoning modes in LLM responses.

// Source: https://github.com/ntygod/ZhiWei | License: MIT | Copyright 2026 ntygod
// Provided via justclaw.it.com; keep this notice with the code.
package com.lifepilot.llm.thinking;

import com.fasterxml.jackson.databind.JsonNode;
import com.lifepilot.llm.history.AssistantMessageBuilder;
import com.lifepilot.llm.profile.ThinkingProtocolId;
import org.springframework.lang.Nullable;

import java.util.Map;

/**
 * 推理模式协议处理器。
 *
 * <p>每个实现承载一家 provider 的 thinking 协议差异,通过三个方法表达:
 * <ol>
 *   <li>{@link #applyToRequest(RequestBuilder, ThinkingMode)} — 把 mode 转换成厂商私有字段;</li>
 *   <li>{@link #extractReasoning(JsonNode)} — 从响应(同步或流式 chunk)提取 reasoning_content;</li>
 *   <li>{@link #injectHistoryReasoning(AssistantMessageBuilder, Map)} — 多轮回传时按协议注入 reasoning。</li>
 * </ol>
 *
 * @author zsg
 * @si

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key