@ 方程式应用程序/ 核心工具
零依赖双子座函数调用计划与能力范围工具注射用于边缘AI剂. 工作于Node.js,浏览器,以及React Introduct (Hermes).
医生 • 妇女 GitHub 图像 • 妇女 范围Lab • 妇女 维基解密 • 妇女 更改日志 • 妇女 问题
缩小边际AI(Expo/React Index)和云代理(Cloud Run)之间的差距的通用登记册.
概览
core-llm-tools 为双子座模型提供JSON函数声明(Tools)的共享,严格类型的寄存器. 通过脱钩 工具接口 (计划)从 工具执行 (执行代码),这个软件包允许客户端-侧切换代理和重后端云代理共享完全相同的能力,而无需将Node.js服务器的依赖性导入到浏览器或移动环境.
还引入了强壮的 基于能力的范围模型 (类似于OAuth 2.0),确保大语言模型只注入用户明确授权的工具.
特征
- 平台不可知论 ——零运行时间依赖关系. 纯类型脚本. 安全地为Node.js,浏览器,以及React Introduct Hermes引擎编译.
- 基于能力的安全 ——工具被锁定在特定瞄准镜后(例如,
calendar:read, (中文(简体) ),messages:send) (中文(简体) ). 注射器确保模型不能对未经授权的工具产生幻觉. - 严格打字 - 提供刚性接口(
AgentToolSchema, (中文(简体) ),AgentToolManifest),防止双子座API请求的畸形. - 统一边距/ 云层运行 ——使轻量级边缘模型(类似于双子座纳诺)能够使用重云跑后端使用的完全相同的策略来进行分解意图来执行.
- GraphRAG 工具计划 —— 说
graphTraverseManifest财务报告和审定财务报表ontologyGetManifest用于 GraphRAG 检索 API 的预建双子工具计划;见 GraphRAG 指南。 。 。 .
安装
npm install @equationalapplications/core-llm-tools
# or
pnpm add @equationalapplications/core-llm-tools
快速启动
1. 界定工具说明
工具的定义是通过将标准的双子座JSON schema包入一个需要的安全范围.
import type { AgentToolManifest } from '@equationalapplications/core-llm-tools';
export const getCalendarEventsManifest: AgentToolManifest = {
name: 'get_calendar_events',
scope: 'calendar:read', // Security scope required to use this tool
schema: {
name: 'get_calendar_events',
description: 'Fetch the user\'s schedule for a given date.',
parameters: {
type: 'object',
properties: {
date: { type: 'string' }
}
}
}
};
2. 注入授权工具
运行时使用 buildAuthorizedToolsArray 以用户的权限过滤工具库。 它会把双子座完全送回来 tools[] 数组:最多一个 functionDeclarations group 包含每个授权函数工具的 schema,每个授权内置工具外加一个条目(如Google Search grounding).
import { buildAuthorizedToolsArray, escalateToCloudManifest } from '@equationalapplications/core-llm-tools';
// 1. Gather all manifests known to your app
const allAppTools = [escalateToCloudManifest, getCalendarEventsManifest];
// 2. Fetch the user's authorized scopes from your DB (e.g., SQLite/Postgres)
const userGrantedScopes = ['calendar:read'];
// 3. The injector automatically includes 'core' tools and authorized scoped tools,
// collapsing all authorized function tools into a single functionDeclarations group
const tools = buildAuthorizedToolsArray(allAppTools, userGrantedScopes);
// => [{ functionDeclarations: [get_calendar_events, escalate_to_cloud] }]
// 4. Pass safely to Gemini
const response = await ai.models.generateContent({
model: 'gemini-flash-latest',
contents: userInput,
config: { tools }, // @google/genai reads tools only from config
});
3. 内建工具(轮廓)
这里"Grounding"指双子座的服务器-侧谷歌搜索工具. 这与
core-llm-wiki证据查证(WikiConfig.grounding以核实事实来源.
一些双子座能力,比如 Google 搜索定位, (中文(简体) ),
由 Google 执行内置工具, 而不是功能声明您的代码
执行。 兹以 kind: 'built_in' 和流经相同的
作为功能工具的能力范围模型,通过 buildAuthorizedToolsArray。 。 。 .
使用 AnyAgentToolManifest 当混合功能和内置显示时;
AgentToolManifest 仍然是现有呼叫者的仅函数类型:
import type { AnyAgentToolManifest } from '@equationalapplications/core-llm-tools';
import { buildAuthorizedToolsArray, googleSearchManifest, escalateToCloudManifest } from '@equationalapplications/core-llm-tools';
const allAppTools: AnyAgentToolManifest[] = [escalateToCloudManifest, googleSearchManifest];
const userGrantedScopes: string[] = [];
// Returns the full Gemini tools[] array: a functionDeclarations group (if any
// function tools are authorized) plus one entry per authorized built-in tool.
const tools = buildAuthorizedToolsArray(allAppTools, userGrantedScopes);
// => [{ functionDeclarations: [...] }, { googleSearch: {} }]
// The manifest is named `google_search`; the wire key is `googleSearch`,
// the only spelling @google/genai reads. The REST API accepts it too.
// The GeminiToolEntry type accepts both spellings, so call sites written
// against the pre-rename `google_search` shape keep compiling.
const response = await ai.models.generateContent({
model: 'gemini-flash-latest',
contents: userInput,
config: { tools }, // @google/genai reads tools only from config
});
说明: 当模型使用时
google_search双子座返回 agroundingMetadata对象 (搜索查询,来源引用等)对答复. 解析元数据是 caller's responsibility——这个软件包只处理请求方工具声明.
内存表
ontology_get (单位:千美元)ontologyGetManifest, (中文(简体) ), graph_traverse (单位:千美元)graphTraverseManifest),以及 instructions_get (单位:千美元)instructionsGetManifest) 仅是计划 memory:read 工具。 派他们去 WikiMemory.getOntologyManifest, (中文(简体) ), traverseGraph,以及 getInstructions。 。 。 . instructions_get 返回您的帐号 WikiConfig.prompts 超音速 保密 名字跟Synapse Tree的一样 <resource>_<verb> 公约》的执行情况 @equationalapplications/mcp-server 工具也会使用.
在8.0.0中被删除: wiki_* 工具名称
| 删除导出( 工具名) | 改为使用 |
|---|---|
wikiTraverseGraphManifest (单位:千美元)wiki_traverse_graph(中文(简体) ) | graphTraverseManifest (单位:千美元)graph_traverse(中文(简体) ) |
wikiGetOntologyManifest (单位:千美元)wiki_get_ontology(中文(简体) ) | ontologyGetManifest (单位:千美元)ontology_get(中文(简体) ) |
wikiGetInstructionsManifest (单位:千美元)wiki_get_instructions(中文(简体) ) | instructionsGetManifest (单位:千美元)instructions_get(中文(简体) ) |
LEGACY_TOOL_NAMES 财务报告和审定财务报表 canonicalToolName 被删除。 申报新名单,并按新姓名发出. 一个仍然告诉一个模型调用旧名的被存储的提示器必须更新,因为该模型不再有这个名字的工具.
有用资源与链接
- Google Gen AI: 函数调用教程 ——关于这个包中的JSON计划如何与双子座模型相互作用的官方文献.
- JSON Schema 规格 - 结构基础
AgentToolSchema.parameters。 。 。 . - OAuth 2.0 范围概念 - 以能力为基础的启发
AgentScope允许等级. - @google/adk (代理开发工具包) —— Cloud Run后端使用的服务器侧框架来包接和执行本包所定义的策略.
莫诺雷波生态系统
| 软件包 | 目的 |
|---|---|
| @ 方程式应用程序/ core-llm-wiki | 持续的零星记忆 |
| @ 方程式应用程序/ expo- llm- wiki | 世博会/反应原生器的持久性瞬间记忆 |
| @ 方程式应用/ react-llm-wiki | Web 的持续的零星记忆 |
| @equental applications/prisma-outbox (英语) | 同步 SQLite 发件箱事件到 Prisma |
| @ 方程式应用程序/ 核心工具 | 双子座工具计划和能力注射器 |
| @ 方程式应用程序/ core-okf | 零依赖开放知识格式 (OKF) v0.1 + v0.2 原始人——剖析并生成可互通的知识捆. |
| @equationalapplications/schema-org-llm-wiki (英语) | Cured schema.org 温剂肿瘤特征表 |
| @equental应用程序/schema-software-org | 软件组织执行本体学表——17个节点类型,40个边缘,热剂超集,只数据 |
| @ 公式应用程序/ mcp- server | MCP 服务器向编码代理显示 SynapseTree 内存工具 |
由方程式应用有限责任公司制造. https://equationalapplications.com/ (中文(简体) )