@truto/langchain-toolset 0.0.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -3
- package/dist/main.cjs +391 -1916
- package/dist/main.cjs.map +1 -1
- package/dist/module.js +392 -1913
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +1 -4
- package/dist/types.d.ts.map +1 -1
- package/package.json +3 -5
package/dist/types.d.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { DynamicStructuredTool } from "@langchain/core/tools";
|
|
2
|
-
export const isCustomMethod: (method: string) => boolean;
|
|
3
|
-
export const isIndividualMethod: (method: string) => boolean;
|
|
4
|
-
export const getRequiredProperties: (schema: Record<string, any>) => (string | null)[];
|
|
5
2
|
export const getPropertiesBySchema: (body: Record<string, any>, schema: Record<string, any>) => Pick<Record<string, any>, string>;
|
|
6
|
-
export const getToolName: (integrationLabel: string, resourceName: string, methodName: string) => string;
|
|
7
3
|
export default function getTools(integratedAccountId: string, config: {
|
|
4
|
+
methods?: string[];
|
|
8
5
|
truto: {
|
|
9
6
|
baseUrl?: string;
|
|
10
7
|
token: string;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";
|
|
1
|
+
{"mappings":";AAIA,OAAO,MAAM,8BACL,OAAO,MAAM,EAAE,GAAG,CAAC,UACjB,OAAO,MAAM,EAAE,GAAG,CAAC,sCAI5B,CAAA;AAED,wBAAsB,QAAQ,CAC5B,mBAAmB,EAAE,MAAM,EAC3B,MAAM,EAAE;IACN,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;IAClB,KAAK,EAAE;QACL,OAAO,CAAC,EAAE,MAAM,CAAA;QAChB,KAAK,EAAE,MAAM,CAAA;KACd,CAAA;CACF,GACA,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,sBAAsB,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAwGrE;AAED,eAAe,QAAQ,CAAA","sources":["src/src/index.ts","src/index.ts"],"sourcesContent":[null,"import { DynamicStructuredTool, tool } from '@langchain/core/tools'\nimport TrutoApi from '@truto/truto-ts-sdk'\nimport { each, keys, pick } from 'lodash-es'\n\nexport const getPropertiesBySchema = (\n body: Record<string, any>,\n schema: Record<string, any>\n) => {\n const keysToPick = keys(schema?.properties || {})\n return pick(body, keysToPick)\n}\n\nexport async function getTools(\n integratedAccountId: string,\n config: {\n methods?: string[]\n truto: {\n baseUrl?: string\n token: string\n }\n }\n): Promise<Record<string, DynamicStructuredTool<Record<string, any>>>> {\n const tools: Record<string, DynamicStructuredTool<Record<string, any>>> = {}\n\n const trutoApi = new TrutoApi({\n baseUrl: config.truto.baseUrl,\n token: config.truto.token,\n })\n\n const availableTools = await trutoApi.integratedAccount.tools(\n integratedAccountId,\n config?.methods\n )\n\n each(availableTools, availableTool => {\n const toolName = availableTool.name\n tools[toolName] = tool<Record<string, any>>(\n async config => {\n const resourceName = availableTool.resource\n const methodToCall = availableTool.method\n const query =\n getPropertiesBySchema(config, availableTool.query_schema) || {}\n const body =\n getPropertiesBySchema(config, availableTool.body_schema) || {}\n switch (methodToCall) {\n case 'list':\n return JSON.stringify(\n await trutoApi.proxyApi\n .list({\n integrated_account_id: integratedAccountId,\n resource: resourceName,\n ...query,\n })\n .next(),\n null,\n 2\n )\n case 'get':\n return JSON.stringify(\n await trutoApi.proxyApi.get(config?.id, {\n integrated_account_id: integratedAccountId,\n resource: resourceName,\n ...query,\n }),\n null,\n 2\n )\n case 'create':\n return JSON.stringify(\n await trutoApi.proxyApi.create(body, {\n integrated_account_id: integratedAccountId,\n resource: resourceName,\n ...query,\n }),\n null,\n 2\n )\n case 'update':\n return JSON.stringify(\n await trutoApi.proxyApi.update(config?.id, body, {\n integrated_account_id: integratedAccountId,\n resource: resourceName,\n ...query,\n }),\n null,\n 2\n )\n case 'delete':\n return JSON.stringify(\n await trutoApi.proxyApi.delete(config?.id, {\n integrated_account_id: integratedAccountId,\n resource: resourceName,\n ...query,\n }),\n null,\n 2\n )\n default:\n return JSON.stringify(\n await trutoApi.proxyApi.customMethod(methodToCall, body, {\n integrated_account_id: integratedAccountId,\n resource: resourceName,\n ...query,\n }),\n null,\n 2\n )\n }\n },\n {\n name: toolName,\n description: availableTool.description || '',\n schema: {\n type: 'object',\n properties: {\n ...(availableTool.query_schema?.properties || {}),\n ...(availableTool.body_schema?.properties || {}),\n },\n required: availableTool.required || [],\n },\n }\n )\n })\n\n return tools\n}\n\nexport default getTools\n"],"names":[],"version":3,"file":"types.d.ts.map"}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.0
|
|
7
|
+
"version": "0.1.0",
|
|
8
8
|
"description": "SuperAI toolset for TypeScript. Works in Langchain.js.",
|
|
9
9
|
"repository": "https://github.com/trutohq/truto-langchainjs-toolset.git",
|
|
10
10
|
"source": "src/index.ts",
|
|
@@ -46,7 +46,6 @@
|
|
|
46
46
|
"@types/jest": "29.4.0",
|
|
47
47
|
"@types/lodash-es": "4.17.7",
|
|
48
48
|
"@types/node": "18.14.6",
|
|
49
|
-
"@types/pluralize": "0.0.33",
|
|
50
49
|
"@typescript-eslint/eslint-plugin": "5.46.1",
|
|
51
50
|
"@typescript-eslint/parser": "5.46.1",
|
|
52
51
|
"@langchain/openai": "0.4.4",
|
|
@@ -59,10 +58,9 @@
|
|
|
59
58
|
"typescript": "4.9.5"
|
|
60
59
|
},
|
|
61
60
|
"dependencies": {
|
|
62
|
-
"@truto/truto-ts-sdk": "
|
|
61
|
+
"@truto/truto-ts-sdk": "2.0.2",
|
|
63
62
|
"@langchain/core": "0.3.42",
|
|
64
|
-
"lodash-es": "4.17.21"
|
|
65
|
-
"pluralize": "8.0.0"
|
|
63
|
+
"lodash-es": "4.17.21"
|
|
66
64
|
},
|
|
67
65
|
"scripts": {
|
|
68
66
|
"dev": "parcel watch",
|