ARTICLE DETAIL

建站实战干货

来自一线的建站与推广经验沉淀,每一条都经过真实交付验证。

ToolJet 集成 Anthropic 插件:用 Claude 在应用构建器中打造上下文感知的 AI 聊天机器人

2026/9/10 1:44:15 拓冰建站 浏览量
ToolJet 集成 Anthropic 插件:用 Claude 在应用构建器中打造上下文感知的 AI 聊天机器人 ToolJet 集成 Anthropic 插件用 Claude 在应用构建器中打造上下文感知的 AI 聊天机器人【免费下载链接】ToolJetOpen-source foundation of ToolJet AI - the enterprise app generation platform for internal tools, dashboards, business applications, workflows and AI agents. Build visually, from a prompt, or from Claude Code, Codex and Cursor over MCP 项目地址: https://gitcode.com/GitHub_Trending/to/ToolJet将 Anthropic 的 Claude 系列模型接入 ToolJet可以在你的内部工具、仪表盘和业务应用中直接创建交互式聊天机器人。这些机器人能够分析对话历史、结合预设的角色上下文生成贴合场景的回答适用于客户支持、虚拟助手、个性化对话等场景。本文将基于 ToolJet 开源仓库中的 Anthropic 市场插件Marketplace Plugin文档与源码完整讲解数据源连接、Chat 操作的参数配置、底层实现原理与响应结构帮助你快速落地一个可运行、可复用的 AI 对话能力。功能概览插件能做什么Anthropic 插件在 ToolJet 中的定位是一个type: ai类型的数据源见 manifest.json其核心价值在于交互式对话将用户的输入发送给 Claude 模型生成自然、连贯、上下文感知的回复多轮上下文维护可以携带过往对话记录让模型在后续回答中保持对话流的一致性实现动态、沉浸式的交互体验角色定制通过系统提示词System Prompt定义模型的角色与行为边界例如“你是一家 Fortune 500 公司的财务顾问”从而适配客服、答疑、个性化陪伴等具体业务。建立连接配置 API Key使用插件前需要先从 Anthropic Console 生成API Key然后在 ToolJet 中新建 Anthropic 数据源并填入密钥。配置界面的核心字段如下对应 manifest.json 中的定义字段类型说明API Keystring密码输入框必填用于调用 Anthropic Messages API 的身份凭证值得注意的是apiKey在 manifest 中被声明为加密字段tj:encrypted: [apiKey]并以password-v3控件渲染意味着密钥在存储和展示环节都会受到保护。在底层插件的连接逻辑位于 lib/index.tstestConnection和getConnection都会先校验apiKey是否存在缺失时抛出QueryError(Connection could not be established, API key is missing)然后通过官方 SDKanthropic-ai/sdk版本^0.32.1见 package.json创建客户端。连接测试会向 Messages API 发送一条最小请求max_tokens: 1的ping消息来验证密钥有效性成功后返回{ status: ok }。支持的操作Chat插件目前面向用户开放的操作是Chat对应 operations.json 中的下拉列表它实际包含两个取值Chatchat-v2当前推荐使用的操作默认值即chat-v2通过“历史记录 用户消息”的方式组织对话Chat (Deprecated)chat旧版操作通过直接传入消息数组的方式组织对话已标记为废弃。从 lib/index.ts 的源码可以看出两者最终都路由到getChatCompletion执行Chat与ChatV2分支共用同一个函数区别只体现在查询参数的组装方式上而源码中预留的 Vision 操作分支目前处于注释状态尚未开放。Chat 操作参数详解根据原文档与 operations.json 的 UI 定义Chat 操作包含以下参数。必填参数Model模型决定使用哪个 Claude 模型生成回复。原文档列出的可选模型为claude-3-5-sonnet-20241022claude-3-5-haiku-20241022claude-3-opus-20240229claude-3-sonnet-20240229claude-3-haiku-20240307而在当前仓库 operations.json 的模型下拉列表中选项已扩充并标注了生命周期状态模型状态claude-sonnet-4-5-20250929、claude-sonnet-4-20250514可用claude-opus-4-5-20251101、claude-opus-4-1-20250805、claude-opus-4-20250514可用claude-haiku-4-5可用claude-3-5-haiku-20241022Deprecated已弃用claude-3-5-sonnet-20241022Discontinued已停止claude-3-opus-20240229、claude-3-sonnet-20240229、claude-3-haiku-20240307Discontinued已停止也就是说原文档中的 5 个 Claude 3 系列模型在当前版本中已进入停用名单下拉列表的默认值仍为claude-3-5-sonnet-20241022但实际选用时建议优先使用列表中标注为可用的 Claude 4 系列新模型。Message消息作为用户与模型之间的输入交互。在旧版chat操作中这里需要传入一个 JSON 数组数组元素的role可选user或assistant。需要注意的是见 operations.json 中的 tooltip 提示数组中role为assistant的消息前后必须由role为user的消息包夹即首尾必须是用户消息。例如[ { role: user, content: Hello Claude! }, { role: assistant, content: Hello! How can I assist you today? }, { role: user, content: Give a report on stock performances of top 10 Fortune 500 companies } ]在推荐的chat-v2操作中该字段被拆分为Message History历史消息与User message用户消息历史消息记录此前用户与模型的对话可选用户消息则是当前轮次的提问必填源码在缺少时直接抛出Prompt is required for chat operation见 query_operations.ts。Max Size最大输出大小限制响应中使用的最大 token 数必填。界面的默认占位符为256。从源码实现看query_operations.ts该值会先做类型归一化字符串会被parseInt随后被钳制在12048之间若传入非法值NaN则回退为 256。可选参数System Prompt系统提示词定义模型评估消息、生成回复时的角色与上下文。例如You are a Financial advisor working in a Fortune 500 company该字符串会被原样传入 Anthropic SDK 的system参数见 query_operations.ts缺省时为空字符串。Temperature温度控制回复的随机性。原文档给出的取值范围为 01默认 1在源码中query_operations.ts该值同样会被归一化并钳制到[0, 1]若传入非法值则回退为 0.5。数值越低输出越确定、保守越高则越发散、富有创意。参数组装与请求下发getChatCompletionquery_operations.ts最终调用anthropicClient.messages.create()将上述参数映射为一次标准的 Anthropic Messages API 请求chat操作messages JSON.parse(message)chat-v2操作messages [...JSON.parse(history), { role: user, content: prompt }]即把历史记录与当前用户消息拼接为完整的消息数组model缺省时回退到claude-3-5-sonnet-20241022max_tokens与temperature经过上述钳制逻辑后传入。响应示例请求成功时接口返回的是 Anthropic 消息内容数组response.content数组中每个元素包含type与text字段。以下是关于“AI 在医疗保健中的益处”的完整响应示例[ { type: text, text: AI has numerous significant benefits in healthcare. Here are some key advantages:nn1. Diagnosis and Disease Detectionn- Faster and more accurate diagnosis through image analysis (X-rays, MRIs, CT scans)n- Early detection of diseases like cancern- Pattern recognition in patient symptoms and medical historynn2. Treatment Planningn- Personalized treatment recommendationsn- Drug interaction predictionsn- Treatment outcome forecastingn- Precision medicine based on patient datann3. Administrative Tasksn- Automated appointment schedulingn- Medical record managementn- Billing and insurance processingn- Reducing paperwork and administrative burdennn4. Patient Caren- Remote patient monitoringn- Virtual health assistantsn- Personalized care recommendationsn- Medication adherence trackingnn5. Research and Drug Developmentn- Accelerated drug discoveryn- Clinical trial matchingn- Analysis of medical research datan- Identification of new treatment approachesnn6. Preventive Caren- Risk prediction and assessmentn- Population health managementn- Lifestyle recommendationsn- Early intervention opportunitiesnn7. Cost Reductionn- Improved efficiencyn- Reduced medical errorsn- Better resource allocationn- Streamlined operationsnn8. Accessibilityn- 24/7 availability of basic healthcare informationn- Improved access to healthcare in remote areasn- Reduced wait timesn- Better distribution of medical expertisennThese benefits continue to expand as AI technology advances and becomes more integrated into healthcare systems. } ]在 ToolJet 查询编辑器中你可以将Run后的结果直接绑定到文本组件、聊天 UI 或表格组件上将{{queries.anthropic1.data}}这类引用接入应用逻辑。错误处理与可靠性设计插件在错误处理上做了分层设计lib/index.ts请求失败时优先解析 Anthropic API 返回的error.error.error.message作为错误信息并附带request_id、errorType错误类型与statusCodeHTTP 状态码等诊断字段便于在查询编辑器中进行排障连接测试失败时同样提取上述字段并抛出QueryError避免将 SDK 原始异常直接暴露给上层成功路径统一返回{ status: ok, data: result }符合 ToolJet 市场插件QueryService接口约定lib/index.ts。插件的工程结构速览如果你想深入了解或二次开发该插件可以按以下路径阅读源码文件作用lib/index.ts插件入口实现QueryService接口run执行查询、testConnection测试连接、getConnection创建客户端lib/query_operations.tsChat 请求组装与参数钳制逻辑lib/types.tsSourceOptions、QueryOptions类型与Operation枚举定义lib/manifest.json数据源配置项声明API Key 字段、加密声明lib/operations.json查询操作与全部参数的表单定义模型列表、字段必填性、占位符、tooltiptests/index.js插件测试占位当前为待实现状态此外package.json 显示插件通过vercel/ncc打包构建npm run build输出到dist/运行时依赖anthropic-ai/sdk ^0.32.1与tooljet-marketplace/common可随 ToolJet 市场Marketplace体系统一分发。快速上手小结在 Anthropic Console 生成 API Key在 ToolJet 中新建 Anthropic 数据源并填入密钥点击Test connection验证连通性新建查询选择数据源与Chat操作选用可用的 Claude 4 系列模型按需配置 System Prompt、Message History / User message、Temperature 与 Max Size运行查询将返回的文本内容绑定到应用组件即可获得一个支持多轮上下文、可定制角色行为的内置 AI 聊天能力。【免费下载链接】ToolJetOpen-source foundation of ToolJet AI - the enterprise app generation platform for internal tools, dashboards, business applications, workflows and AI agents. Build visually, from a prompt, or from Claude Code, Codex and Cursor over MCP 项目地址: https://gitcode.com/GitHub_Trending/to/ToolJet创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考