
【免费下载链接】rocketride-serverHigh-performance AI pipeline engine with a C core and 50 Python-extensible nodes. Build, debug, and scale LLM workflows with 13 model providers, 8 vector databases, and agent orchestration, all from your IDE. Includes VS Code extension, TypeScript/Python SDKs, and Docker deployment.项目地址https://gitcode.com/gh_mirrors/ro/rocketride-server点击查看免费下载llm_anthropic是 RocketRide 中负责连接 Anthropic Claude 系列模型的 LLM 节点既可作为独立节点在管道中直接完成问答也能以llm调用通道的形式被 Agent、向量数据库、数据库等节点复用。本文以 nodes/src/nodes/llm_anthropic/README.md 为核心结合节点源码、服务声明与 AI 公共库实现完整讲解它的定位、配置、模型 Profile、Extended thinking 机制、认证与保存时校验逻辑让你能在自己的管道中快速接入 Claude 并理解底层行为。节点定位作为 llm 调用通道融入 RocketRide 管道llm_anthropic是 RocketRide 的 LLM 类节点。根据节点服务声明 services.jsonclassType为[llm]capabilities为[invoke]即它提供 LLM 的invoke能力register为filter协议为llm_anthropic://路径为nodes.llm_anthropic节点实例类 IInstance.py 继承自ai.common.llm_base.LLMBase与其它 LLM 提供方节点共享同一套节点级基类。这意味着它有两种典型用法作为llminvoke 连接被 Agent、向量存储、数据库等需要 LLM 的节点调用在管道中通过 lanes 直接使用例如把聊天输入接进来、把生成结果接出去。此外服务声明中还包含一个可运行的测试用例test段以claude-opus-4-5Profile 为输入向questionslane 发送What is 22?期望answerslane 返回包含Mock LLM response的响应用于节点回归验证。技术底座langchain-anthropic anthropic SDK节点核心实现位于 anthropic.py技术栈为langchain-anthropic通过ChatAnthropic完成主推理调用anthropic官方 SDK在保存配置时直接发起探测请求做校验langchain-core / langchain与管道其它组件对接的基础依赖。关键构造逻辑anthropic.py#L52-L93model config.get(model) model_gate gate_model_name(str(model) if model is not None else ) apikey (config.get(apikey) or ).strip() if not apikey or not apikey.startswith(sk-ant): raise ValueError(Invalid Anthropic API key format, please check your API key.) self._llm ChatAnthropic( modelmodel, api_keyapikey, max_tokensself._modelOutputTokens, custom_get_token_ids_estimate_token_ids, )其中值得注意的几点配置中的modelOutputTokens被直接作为max_tokens传给模型见 anthropic.py#L85-L90预算用的 token 计数按约 4 个字符 ≈ 1 个 token估算_estimate_token_ids见 anthropic.py#L40-L42modelSource字段用于记录自定义模型定义的来源取值为manual或openrouterAPI key 在构造时读取不会由节点存储。三条典型接入路径直接问答chat → llm_anthropic → response_answers最基本的用法是chat → llm_anthropic → response_answers问题从聊天节点进入Claude 的答案流式返回给 answers 响应。仓库自带的 example.pipe 正是这个管道的完整 JSON 定义其核心结构为三个组件{ components: [ { id: chat_1, provider: chat, name: Chat, config: { mode: Source, type: chat } }, { id: llm_anthropic_1, provider: llm_anthropic, name: Anthropic, config: { profile: claude-sonnet-4-6, claude-sonnet-4-6: { apikey: ${ROCKETRIDE_ANTHROPIC_KEY} } }, input: [ { lane: questions, from: chat_1 } ] }, { id: response_answers_1, provider: response_answers, name: Return Answers, config: { laneName: answers }, input: [ { lane: answers, from: llm_anthropic_1 } ] } ] }从中可以看到两个重要的实操细节API key 通过${ROCKETRIDE_ANTHROPIC_KEY}环境变量注入避免把密钥直接写进管道文件节点配置文件中的profile与对应 profile 段如claude-sonnet-4-6并列存放其中保存 apikey 等该 profile 专属配置。作为 Agent 的推理引擎在webhook → agent_rocketride → response管道中把本节点接到 agent 的llm通道上Claude 就承担 Agent 的推理与工具调用职责。此时换 Profile 即可在成本与能力之间权衡无需改动管道拓扑——例如从claude-sonnet-4-6切到claude-haiku-4-5以降低延迟与成本或切到claude-opus-5提升复杂推理能力。为数据库节点生成 SQL在webhook → db_postgres → response管道中把本节点接到数据库节点的llm通道上Claude 负责把自然语言问题翻译成 SQL再由数据库节点校验并执行。这是「LLM 作为能力注入其它节点」的典型范式数据库节点本身不直接内置模型而是通过llm通道复用任意 LLM 提供方。输入输出 LanesLane inLane out说明questionsanswers直接发送问题收到生成的答案该 lanes 声明同时出现在 services.json 的lanes段中questions: [answers]是画布连线与运行时调度的依据。模型 Profiles 与令牌配额节点默认 Profile 为Claude Sonnet 4.6claude-sonnet-4-6。命名 Profile 的模型 ID 与令牌上限由 Profile 固定选择后无需也不能手动改模型只有customProfile 直接暴露model与modelTotalTokens供自由填写。主 Profile 表默认可见ProfileModel IDContext tokensOutput tokensClaude Sonnet 4.6(default)claude-sonnet-4-61,000,000128,000Anthropic: Claude Fable 5claude-fable-51,000,000128,000Anthropic: Claude Sonnet 5claude-sonnet-51,000,000128,000Anthropic: Claude Fable 5.1claude-fable-5-11,000,000128,000Claude Opus 5claude-opus-51,000,000128,000Anthropic: Claude Opus 4.8claude-opus-4-81,000,000128,000展开后的完整 Profile 列表共 17 个与 services.json 的preconfig.profiles一一对应ProfileModel IDContext tokensOutput tokenscustom用户指定200,000可编辑—Claude Opus 4.6claude-opus-4-61,000,000128,000Claude Haiku 4.5claude-haiku-4-5200,00064,000Claude Sonnet 4.5claude-sonnet-4-51,000,00064,000Claude Opus 4.5claude-opus-4-5200,00064,000Anthropic: Claude Opus 4.7claude-opus-4-71,000,000128,000Anthropic: Claude 3 Haikuclaude-3-haiku200,0004,096Anthropic: Claude Fable Latestclaude-fable-latest1,000,000128,000Anthropic Claude Haiku Latestclaude-haiku-latest200,00064,000Anthropic: Claude Opus 4claude-opus-4200,00032,000Anthropic: Claude Opus 4.1claude-opus-4-1200,00032,000Claude Opus 5 (Fast)claude-opus-5-fast1,000,000128,000Anthropic: Claude Opus 4.7 (Fast)claude-opus-4-7-fast1,000,000128,000Anthropic: Claude Opus 4.8 (Fast)claude-opus-4-8-fast1,000,000128,000Anthropic: Claude Opus Latestclaude-opus-latest1,000,000128,000Anthropic: Claude Sonnet 4claude-sonnet-41,000,00064,000Anthropic Claude Sonnet Latestclaude-sonnet-latest1,000,000128,000*-latestProfile 跟随 Anthropic 当前的模型别名会随 Anthropic 发布新版本而更新当可复现性重要时应固定使用具体版本号的 Profile而不是latest别名。另外services.json 中还为部分已下架模型标注了deprecated与迁移提示例如claude-opus-4-1建议改用claude-opus-5、claude-opus-5-fast等OpenRouter 已不再收录UI 会据此提示用户迁移避免选用失效模型。配置字段与 Schema大多数管道只需两步配置选一个 Profile 填 API key。节点配置的完整 Schema 如下由 README 的生成段给出与 services.json 的fields定义一致字段类型说明默认值anthropic.profilestringModelLLM 模型选择claude-sonnet-4-6extendedThinkingbooleanExtended thinking启用 Anthropic 扩展思考推理默认关闭仅对支持推理的模型、在交互式聊天路径生效falsemodelstringModelAnthropic 模型custom Profile 使用—modelTotalTokensnumberTokens总令牌数custom Profile 使用—命名 Profile 通过anthropic.profile的conditional表单段决定哪些字段可编辑例如claude-sonnet-4-6等推理类 Profile 暴露apikey、extendedThinking、modelSource而claude-3-haiku不支持扩展思考只暴露apikey与modelSourcecustom则暴露model、modelTotalTokens、apikey、modelSource。这与「命名 Profile 固定模型与配额、custom 完全开放」的规则一致。认证与密钥安全在apikey字段提供 Anthropic API key 即可。节点在启动时执行校验见 anthropic.py#L64-L69key 必须非空必须以sk-ant开头同时覆盖标准sk-ant-...与较新的sk-ant-api03-...两种格式校验失败时抛出Invalid Anthropic API key format, please check your API key.。key 只在构造时读取一次不会由节点存储。配合 example.pipe 中${ROCKETRIDE_ANTHROPIC_KEY}环境变量注入的写法可以做到密钥不落盘。Extended thinking 深度解析双开关机制extendedThinking开关默认关闭开启后请求模型的推理流。要真正激活 thinking需要两个开关同时为真模型自身的capabilities.reasoning标志由 OpenRouter 模型同步时打上见 services.json 中各 profile 的capabilities.reasoning本节点的extendedThinking开关。在 anthropic.py#L78-L83 中可以看到实现只有self._is_reasoning为真且配置打开了extendedThinking时才会调用build_anthropic_thinking_kwargs构造 thinking 参数并把_native_stream_provider设为anthropic。同时它只影响交互式流式路径——Agent /expectJson路径从不请求 thinking走普通 LangChain 客户端。按模型选择 thinking 参数路由前缀如openrouter/anthropic/在匹配前会被剥离gate_model_name见 llm_native_stream.py#L45-L57。随后 build_anthropic_thinking_kwargs 按模型分三类处理模型发送的 thinking 参数旧版 Claude 3 / 3.5 Haiku无。这些模型不支持扩展思考发送参数会返回 400。Haiku 4.5 不受此限制归入下一行处理旧版模型Claude 3.x除Claude 3 / 3.5 Haiku另加 4.0、4.1、4.5 含 Haiku 4.5 及其claude-haiku-latest别名、4.6、Mythos Previewthinking: {type: enabled, budget_tokens: N}外加interleaved-thinking-2025-05-14beta 头其中N为输出令牌上限的一半最小 2,048且始终小于max_tokens若输出窗口小到无法容纳有效预算则整体跳过其余所有 Claude 模型claude-opus-4-7、claude-opus-4-8及 Claude 5 全系——claude-sonnet-5、claude-opus-5、claude-fable-5、claude-mythos-5——以及任何未来模型thinking: {type: adaptive, display: summarized}自适应思考。Claude 4.7 会以 HTTP 400 拒绝旧的enabledbudget_tokens形态因此旧模型被做成显式 allowlist未知/未来模型默认走 adaptive两个值得注意的实现细节整 ID 匹配而非开放前缀匹配前会剥离-YYYYMMDD日期后缀与-fast部署后缀_anthropic_base_model_id见 llm_native_stream.py#L96-L113且 legacy 列表按完整模型 ID 精确匹配——这样未来的claude-sonnet-4-50不会被误判成claude-sonnet-4-5旧版 Claude 3.x 判定以claude-3-整段前缀匹配避免把假设中的claude-30-...误伤。原生流式路径当 thinking 真正启用时响应通过 Anthropic Messages API 的原生流式处理器ai.common.llm_native_streamprovideranthropic传输这样LangChain 会丢弃的 thinking delta 得以保留并被转发到thinkingSSE lane不支持推理的模型仍走默认的 LangChain 流式路径。原生处理器会过滤出 Messages API 允许的字段集合model、messages、max_tokens、thinking、betas等见 llm_native_stream.py#L148-L170并在存在betas时通过client.beta.messages.create发起请求。保存时验证Save-time validation在节点配置保存、首次执行管道之前会先跑一遍轻量校验实现于 IGlobal.py 的validateConfig检查modelTotalTokenscustom Profile大于 0否则给出警告Token limit must be greater than 0使用配置的 key 向配置的模型发送一次最小探测请求max_tokens: 1消息内容Hi。任何失败坏 key、未知模型、限流、网络错误都会以单行、简洁的警告形式呈现Error status: type - message优先从 API 的结构化错误负载中提取网络或 SDK 错误若无结构化负载则回退到原始异常消息并折叠为单行。_format_error会把status、type、message拼装并压缩多余空白见 IGlobal.py#L205-L232。这意味着你在保存配置时就能发现密钥或模型问题而不是等到管道运行才报错。依赖清单节点运行依赖见 requirements.txtlangchain-anthropicanthropiclangchain-corelangchain源码导读anthropic.pyChat类实现负责 API key 校验、ChatAnthropic构造、extended thinking 参数装配与原生流式路径选择IGlobal.py全局生命周期加载依赖、创建 Chat 实例、清理与保存时验证IInstance.py实例类继承LLMBaseservices.json节点注册信息、全部 Profile 定义、字段 Schema、lanes 与测试用例example.pipe可直接导入画布的最小示例管道llm_native_stream.pythinking 参数按模型分发与 Anthropic 原生流式处理的公共实现。整体来看llm_anthropic的设计遵循「配置极简、能力注入」的思路对大多数管道只需选 Profile、填 key对需要精细控制的场景通过customProfile 与extendedThinking开关获得模型与推理行为的完整控制权同时保存时验证和原生 thinking 流式传输保证了配置可及时发现错误、推理过程不丢失。赞分享【免费下载链接】rocketride-serverHigh-performance AI pipeline engine with a C core and 50 Python-extensible nodes. Build, debug, and scale LLM workflows with 13 model providers, 8 vector databases, and agent orchestration, all from your IDE. Includes VS Code extension, TypeScript/Python SDKs, and Docker deployment.项目地址https://gitcode.com/gh_mirrors/ro/rocketride-server点击查看免费下载相关推荐RocketRide llm_bedrock 节点实战在 AI Pipeline 中接入 Amazon Bedrock 模型RocketRide llm_bedrock 节点实战在 AI Pipeline 中接入 Amazon Bedrock 模型 本篇技术指南以 RocketRiRocketRide 的 llm_gemini 节点在 AI Pipeline 中接入 Google Gemini 模型RocketRide 的 llm_gemini 节点在 AI Pipeline 中接入 Google Gemini 模型 RocketRide 是一个以 CRocketRide 的 llm_deepseek 节点在管道中接入 DeepSeek 云端、Ollama 本地与 OpenRouter 模型RocketRide 的 llm_deepseek 节点在管道中接入 DeepSeek 云端、Ollama 本地与 OpenRouter 模型 llm_dee创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考